svnno****@sourc*****
svnno****@sourc*****
2008年 12月 18日 (木) 20:22:42 JST
Revision: 2277 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2277 Author: daisuke_m Date: 2008-12-18 20:22:42 +0900 (Thu, 18 Dec 2008) Log Message: ----------- [SER-7] StAXシリアライザ実装中。 テストでStackOverflowとか起こしてるけどww Modified Paths: -------------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialQueue.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialStack.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/JiemamyCommand.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/JiemamyModelAcceptor.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/CloseCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/EmptyElementCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/NullCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/OpenCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/end/DialectEndCommand.java 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/end/RootModelEndCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/DialectStartCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/RootModelStartCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/StartElementCommand.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.serializer/src/test/java/org/jiemamy/internal/serializer/stax/StaxTest.java Added Paths: ----------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/Resolvable.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/ResolvableQueue.java artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandBase.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/XmlNodes.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ 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/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/internal/serializer/stax/command/factory/RootModelCommandFactory.java artemis/trunk/org.jiemamy.serializer/src/test/resources/minimal.jiemamy-core.xml Removed Paths: ------------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialQueueImpl.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialStackImpl.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyXmlConstants.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/AbstractJiemamyCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/ContentsCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/DividableCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/dividable/ -------------- next part -------------- Copied: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java (from rev 2276, artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialStackImpl.java) =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,84 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/16 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +import java.util.Iterator; + +import org.apache.commons.collections15.ArrayStack; + +/** + * TODO for dmiyamoto + * @param <E> + * @author dmiyamoto + */ +public class ArrayEssentialStack<E> implements EssentialStack<E> { + + private ArrayStack<E> stack = new ArrayStack<E>(); + + + /** + * {@inheritDoc} + */ + public void clear() { + stack.clear(); + } + + /** + * {@inheritDoc} + */ + public Iterator<E> iterator() { + return stack.iterator(); + } + + /** + * {@inheritDoc} + */ + public E peek() { + return stack.peek(); + } + + /** + * {@inheritDoc} + */ + public E peek(int n) { + return stack.peek(n); + } + + /** + * {@inheritDoc} + */ + public E pop() { + return stack.pop(); + } + + /** + * {@inheritDoc} + */ + public void push(E element) { + stack.push(element); + } + + /** + * {@inheritDoc} + */ + public int size() { + return stack.size(); + } + +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/ArrayEssentialStack.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialQueue.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialQueue.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialQueue.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -27,12 +27,18 @@ * @param <E> * @author daisuke */ -public interface EssentialQueue<E> { +public interface EssentialQueue<E> extends Iterable<E> { + void clear(); + E dequeue(); void enqueue(E element); + void enqueue(EssentialQueue<E> queue); + + boolean isEmpty(); + E peek(); int size(); Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialQueueImpl.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialQueueImpl.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialQueueImpl.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -1,72 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/16 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils; - -import java.util.LinkedList; - -/** - * TODO for daisuke - * @author daisuke - */ -/** - * TODO for daisuke - * @author daisuke - */ -public class EssentialQueueImpl<E> implements EssentialQueue<E> { - - private LinkedList<E> linkedList = new LinkedList<E>(); - - - /** - * {@inheritDoc} - */ - public E dequeue() { - return linkedList.poll(); - } - - /** - * {@inheritDoc} - */ - public void enqueue(E element) { - linkedList.offer(element); - } - - /** - * {@inheritDoc} - */ - public E peek() { - return linkedList.peek(); - } - - /** - * {@inheritDoc} - */ - public int size() { - return linkedList.size(); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return linkedList.toString(); - } - -} Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialStack.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialStack.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialStack.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -27,10 +27,14 @@ * @param <E> * @author daisuke */ -public interface EssentialStack<E> { +public interface EssentialStack<E> extends Iterable<E> { + void clear(); + E peek(); + E peek(int n); + E pop(); void push(E element); Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialStackImpl.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialStackImpl.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialStackImpl.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -1,60 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/16 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils; - -import org.apache.commons.collections15.ArrayStack; - -/** - * TODO for dmiyamoto - * @author dmiyamoto - */ -public class EssentialStackImpl<E> implements EssentialStack<E> { - - private ArrayStack<E> stack = new ArrayStack<E>(); - - - /** - * {@inheritDoc} - */ - public E peek() { - return stack.peek(); - } - - /** - * {@inheritDoc} - */ - public E pop() { - return stack.pop(); - } - - /** - * {@inheritDoc} - */ - public void push(E element) { - stack.push(element); - } - - /** - * {@inheritDoc} - */ - public int size() { - return stack.size(); - } - -} Copied: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java (from rev 2276, artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/EssentialQueueImpl.java) =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,106 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/16 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.NoSuchElementException; + +/** + * TODO for daisuke + * @param <E> + * @author daisuke + */ +public class LinkedEssentialQueue<E> implements EssentialQueue<E> { + + private LinkedList<E> linkedList = new LinkedList<E>(); + + + /** + * {@inheritDoc} + */ + public void clear() { + linkedList.clear(); + } + + /** + * {@inheritDoc} + */ + public E dequeue() { + return linkedList.poll(); + } + + /** + * {@inheritDoc} + */ + public void enqueue(E element) { + linkedList.offer(element); + } + + /** + * {@inheritDoc} + */ + public void enqueue(EssentialQueue<E> queue) { + try { + while (true) { + E element = queue.dequeue(); + enqueue(element); + } + } catch (NoSuchElementException e) { + + } + } + + /** + * {@inheritDoc} + */ + public boolean isEmpty() { + return linkedList.isEmpty(); + } + + /** + * {@inheritDoc} + */ + public Iterator<E> iterator() { + return linkedList.iterator(); + } + + /** + * {@inheritDoc} + */ + public E peek() { + return linkedList.peek(); + } + + /** + * {@inheritDoc} + */ + public int size() { + return linkedList.size(); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return linkedList.toString(); + } + +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/LinkedEssentialQueue.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/Resolvable.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/Resolvable.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/Resolvable.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,34 @@ +/* + * 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.utils; + +/** + * TODO for daisuke + * @param <T> + * @author daisuke + */ +public interface Resolvable<T> { + + /** + * TODO for daisuke + * @return + */ + EssentialQueue<T> resolve(); + +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/Resolvable.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/ResolvableQueue.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/ResolvableQueue.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/ResolvableQueue.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,165 @@ +/* + * 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.utils; + +import java.util.Iterator; +import java.util.NoSuchElementException; + +/** + * TODO for daisuke + * @param <E> + * @author daisuke + */ +public class ResolvableQueue<E> implements EssentialQueue<E> { + + private EssentialStack<ResolvableQueue<Object>> stack = new ArrayEssentialStack<ResolvableQueue<Object>>(); + + + /** + * {@inheritDoc} + */ + public void clear() { + stack.clear(); + } + + /** + * {@inheritDoc} + */ + public E dequeue() { + resolve(); + return (E) stack.peek().dequeue(); + } + + /** + * {@inheritDoc} + */ + public void enqueue(E element) { + if (stack.size() == 0) { + stack.push(new ResolvableQueue<Object>()); + } + stack.peek(0).enqueue(element); + } + + /** + * {@inheritDoc} + */ + public void enqueue(EssentialQueue<E> queue) { + if (queue instanceof ResolvableQueue) { + ResolvableQueue<E> resQueue = (ResolvableQueue<E>) queue; + try { + while (true) { + Object element = resQueue.unresolveDequeue(); + if (element instanceof Resolvable) { + Resolvable<E> resolvable = (Resolvable<E>) element; + enqueue(resolvable); + } else { + enqueue((E) element); + } + } + } catch (NoSuchElementException e) { + // ignore + } + } + + } + + /** + * TODO for daisuke + * @param resolvableElement + */ + public void enqueue(Resolvable<E> resolvableElement) { + if (stack.size() == 0) { + stack.push(new ResolvableQueue<Object>()); + } + stack.peek(0).enqueue(resolvableElement); + } + + /** + * {@inheritDoc} + */ + public boolean isEmpty() { + if (stack.size() == 0) { + return true; + } + for (EssentialQueue<Object> queue : stack) { + if (queue.size() != 0) { + return false; + } + } + return true; + } + + /** + * {@inheritDoc} + */ + public Iterator<E> iterator() { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + public E peek() { + resolve(); + return (E) stack.peek().peek(); + } + + /** + * {@inheritDoc} + */ + public int size() { + throw new UnsupportedOperationException(); + } + + /** + * TODO for daisuke + * @return + */ + public Object unresolveDequeue() { + if (stack.peek().size() == 0) { + stack.pop(); + } + return stack.peek().dequeue(); + } + + private void resolve() { + boolean loop = true; + while (loop) { + Object element = stack.peek().peek(); + if (element instanceof Resolvable) { + stack.peek().dequeue(); + if (stack.peek().size() != 0) { + stack.push(new ResolvableQueue<Object>()); + } + + // enqueueされるResolvableは、必ず <E> である + Resolvable<E> resolvable = (Resolvable<E>) element; + stack.peek().enqueue(resolvable.resolve()); + } else { + loop = false; + } + + if (stack.peek().size() == 0) { + stack.pop(); + } + } + assert stack.peek().peek() instanceof Resolvable<?> == false; + } + +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/utils/ResolvableQueue.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,148 @@ +/* + * 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.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * TODO for daisuke + * @author daisuke + */ +public class ResolvableQueueTest { + + private ResolvableQueue<TestElement> queue; + + + /** + * setup + * @throws Exception + */ + @Before + public void setUp() throws Exception { + queue = new ResolvableQueue<TestElement>(); + } + + /** + * teardown + * @throws Exception + */ + @After + public void tearDown() throws Exception { + queue = null; + } + + @Test + public void test01_キューとして機能する() throws Exception { + queue.enqueue(new TestElement('a')); + queue.enqueue(new TestElement('b')); + queue.enqueue(new TestElement('c')); + + assertThat(queue.dequeue().ch, is('a')); + assertThat(queue.dequeue().ch, is('b')); + assertThat(queue.dequeue().ch, is('c')); + } + + @Test + public void test02_可分割キューとして機能する() throws Exception { + queue.enqueue(new TestElement('a')); + queue.enqueue(new ResolvableTestElement("xyz")); + queue.enqueue(new TestElement('c')); + + assertThat(queue.dequeue().ch, is('a')); + assertThat(queue.dequeue().ch, is('x')); + assertThat(queue.dequeue().ch, is('y')); + assertThat(queue.dequeue().ch, is('z')); + assertThat(queue.dequeue().ch, is('c')); + } + + @Test + public void test03_複数段可分割キューとして機能する() throws Exception { + queue.enqueue(new TestElement('a')); + queue.enqueue(new ResolvableTestElement2("opq", "xyz")); + queue.enqueue(new TestElement('c')); + + assertThat(queue.dequeue().ch, is('a')); + assertThat(queue.dequeue().ch, is('o')); + assertThat(queue.dequeue().ch, is('p')); + assertThat(queue.dequeue().ch, is('q')); + assertThat(queue.dequeue().ch, is('x')); + assertThat(queue.dequeue().ch, is('y')); + assertThat(queue.dequeue().ch, is('z')); + assertThat(queue.dequeue().ch, is('c')); + } + + + private static class ResolvableTestElement implements Resolvable<TestElement> { + + String str; + + + ResolvableTestElement(String str) { + this.str = str; + } + + /** + * {@inheritDoc} + */ + public EssentialQueue<TestElement> resolve() { + EssentialQueue<TestElement> queue = new LinkedEssentialQueue<TestElement>(); + char[] array = str.toCharArray(); + for (char c : array) { + queue.enqueue(new TestElement(c)); + } + return queue; + } + } + + private static class ResolvableTestElement2 implements Resolvable<TestElement> { + + String[] str; + + + ResolvableTestElement2(String... str) { + this.str = str; + } + + /** + * {@inheritDoc} + */ + public EssentialQueue<TestElement> resolve() { + ResolvableQueue<TestElement> queue = new ResolvableQueue<TestElement>(); + for (String s : str) { + queue.enqueue(new ResolvableTestElement(s)); + } + return queue; + } + } + + private static class TestElement { + + char ch; + + + TestElement(char c) { + ch = c; + } + } +} Property changes on: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain 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-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/CommandContext.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -18,22 +18,20 @@ */ package org.jiemamy.internal.serializer.stax; -import javax.xml.namespace.QName; - import org.jiemamy.internal.serializer.stax.command.CloseCommand; 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.EssentialStack; -import org.jiemamy.utils.EssentialStackImpl; +import org.jiemamy.utils.ArrayEssentialStack; /** - * TODO for dmiyamoto - * @author dmiyamoto + * TODO for daisuke + * @author daisuke */ public class CommandContext { - private EssentialStack<JiemamyCommand> stack = new EssentialStackImpl<JiemamyCommand>(); + private EssentialStack<JiemamyCommand> stack = new ArrayEssentialStack<JiemamyCommand>(); private Object content; @@ -53,13 +51,13 @@ } } - public void end(EndElementCommand command, QName endQName) { + public void end(EndElementCommand command) { JiemamyCommand pop = stack.pop(); if (pop instanceof StartElementCommand == false) { throw new IllegalStateException(); } StartElementCommand start = (StartElementCommand) pop; - if (start.getQName().equals(endQName) == false) { + if (start.getQName().equals(command.getQName()) == false) { throw new IllegalStateException(); } } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -18,6 +18,7 @@ */ package org.jiemamy.internal.serializer.stax; +import javax.xml.stream.XMLEventFactory; import javax.xml.stream.XMLEventWriter; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; @@ -28,13 +29,17 @@ * Jiemamyのモデル操作をあらわすコマンドオブジェクト。 * @author daisuke */ -public interface JiemamyCommand { +public interface JiemamyCommand extends JiemamyCommandBase { + /** TODO for daisuke */ + XMLEventFactory EVENT_FACTORY = XMLEventFactory.newInstance(); + + /** * コマンドを{@link RootModel}に適用する。 * @param rootModel 書き出し対象のRootModel * @param ctx - * @return + * @return コマンドを反映した{@link RootModel} */ RootModel applyTo(RootModel rootModel, CommandContext ctx); Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandBase.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandBase.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandBase.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,28 @@ +/* + * 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; + + +/** + * TODO for daisuke + * @author daisuke + */ +public interface JiemamyCommandBase { + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandBase.java ___________________________________________________________________ Name: svn:mime-type + text/plain 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-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -20,20 +20,17 @@ import java.util.Collection; import java.util.NoSuchElementException; -import java.util.Stack; import org.apache.commons.lang.Validate; import org.jiemamy.internal.serializer.stax.command.CloseCommand; -import org.jiemamy.internal.serializer.stax.command.ContentsCommand; -import org.jiemamy.internal.serializer.stax.command.DividableCommand; import org.jiemamy.internal.serializer.stax.command.OpenCommand; -import org.jiemamy.internal.serializer.stax.command.dividable.RootModelCommand; 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.model.RootModel; -import org.jiemamy.utils.EssentialQueue; -import org.jiemamy.utils.EssentialQueueImpl; +import org.jiemamy.utils.ResolvableQueue; /** * {@link RootModel}の内容を{@link JiemamyCommand}として読み出す、Reader実装。 @@ -44,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 ContentsCommand} of dialect</li></ul> + * <ul><li>{@link DialectCommandFactory}</li></ul> * <li>{@link EndElementCommand} of {@link String} (dialect)</li> * <li>...</li> * <li>{@link StartElementCommand} of {@link Collection} (domains)</li> @@ -73,7 +70,7 @@ private RootModel rootModel; - private Stack<EssentialQueue<JiemamyCommand>> stack = new Stack<EssentialQueue<JiemamyCommand>>(); + private ResolvableQueue<JiemamyCommand> queue = new ResolvableQueue<JiemamyCommand>(); private boolean closed; @@ -103,7 +100,7 @@ */ public boolean hasNext() { checkClosed(); - return stack.isEmpty() == false; + return queue.isEmpty() == false; } /** @@ -113,23 +110,7 @@ checkClosed(); checkNext(); - JiemamyCommand command; - if (stack.peek().peek() instanceof DividableCommand) { - DividableCommand dividable = (DividableCommand) stack.peek().dequeue(); - if (stack.peek().size() == 0) { - stack.pop(); - } - - stack.push(dividable.divide()); - command = nextCommand(); // recursion - } else { - command = stack.peek().dequeue(); - if (stack.peek().size() == 0) { - stack.pop(); - } - } - - return command; + return queue.dequeue(); } /** @@ -139,12 +120,10 @@ */ public void reset() { checkClosed(); - stack.clear(); - EssentialQueue<JiemamyCommand> queue = new EssentialQueueImpl<JiemamyCommand>(); + queue.clear(); queue.enqueue(new OpenCommand()); - queue.enqueue(new RootModelCommand(rootModel)); + queue.enqueue(new RootModelCommandFactory(rootModel)); queue.enqueue(new CloseCommand()); - stack.push(queue); } private void checkClosed() { Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyModelAcceptor.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyModelAcceptor.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyModelAcceptor.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -26,6 +26,7 @@ /** * TODO for daisuke + * @param <T> * @param model * @param eventVisitor */ Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyXmlConstants.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyXmlConstants.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyXmlConstants.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -1,40 +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.internal.serializer.stax; - -import javax.xml.namespace.QName; - -import org.jiemamy.serializer.Namespaces; - -/** - * TODO for daisuke - * @author daisuke - */ -public final class JiemamyXmlConstants { - - public static final QName ROOT_MODEL = new QName(Namespaces.CORE, "rootModel"); - - public static final QName DIALECT = new QName(Namespaces.CORE, "dialect"); - - public static final QName ID = new QName("id"); - - - private JiemamyXmlConstants() { - } -} 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-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -20,10 +20,12 @@ import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.XMLEvent; import org.apache.commons.lang.Validate; -import org.jiemamy.internal.serializer.stax.command.AbstractJiemamyCommand; +import org.jiemamy.internal.serializer.stax.command.factory.CommandFactoryRule; +import org.jiemamy.internal.serializer.stax.command.factory.CoreCommandFactoryRule; /** * {@link XMLEventReader}を{@link JiemamyCommandInputStream}として扱うアダプタ。 @@ -33,6 +35,10 @@ private XMLEventReader xmlEventReader; + private CommandFactoryRule rule = new CoreCommandFactoryRule(); + + private CommandContext ctx = new CommandContext(); + /** * コンストラクタ。 @@ -69,7 +75,8 @@ */ public JiemamyCommand nextCommand() throws JiemamyCommandException { try { - return AbstractJiemamyCommand.newInstance(xmlEventReader.nextEvent()); + XMLEvent xmlEvent = xmlEventReader.nextEvent(); + return rule.getCommand(xmlEvent, ctx); } catch (XMLStreamException e) { throw new JiemamyCommandException(e); } Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/XmlNodes.java (from rev 2276, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyXmlConstants.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/XmlNodes.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/XmlNodes.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,111 @@ +/* + * 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 + */ +//public final class XmlNodes { +// +// // -------- Elements +// +// public static final QName ROOT_MODEL = new QName(Namespaces.CORE, "rootModel"); +// +// public static final QName DIALECT = new QName(Namespaces.CORE, "dialect"); +// +// public static final QName SCHEMA_NAME = new QName(Namespaces.CORE, "schemaName"); +// +// public static final QName BEGIN_SCRIPT = new QName(Namespaces.CORE, "beginScript"); +// +// public static final QName END_SCRIPT = new QName(Namespaces.CORE, "endScript"); +// +// public static final QName DESCRIPTION = new QName(Namespaces.CORE, "description"); +// +// public static final QName DOMAINS = new QName(Namespaces.CORE, "domains"); +// +// public static final QName DOMAIN = new QName(Namespaces.CORE, "domain"); +// +// public static final QName NAME = new QName(Namespaces.CORE, "name"); +// +// public static final QName LOGICAL_NAME = new QName(Namespaces.CORE, "logicalName"); +// +// public static final QName DATATYPE_DESC = new QName(Namespaces.CORE, "dataTypeDescriptor"); +// +// public static final QName DEFAULT_VALUE = new QName(Namespaces.CORE, "defaultValue"); +// +// public static final QName CONSTRAINTS = new QName(Namespaces.CORE, "constraints"); +// +// public static final QName CONSTRAINT = new QName(Namespaces.CORE, "constraint"); +// +// public static final QName SIMPLE_INDEX = new QName(Namespaces.CORE, "simpleIndex"); +// +// public static final QName FREE_STRING = new QName(Namespaces.CORE, "freeString"); +// +// public static final QName OPTIONS = new QName(Namespaces.CORE, "options"); +// +// public static final QName NODES = new QName(Namespaces.CORE, "nodes"); +// +// public static final QName TABLE = new QName(Namespaces.CORE, "table"); +// +// public static final QName SOURCE_CONNECTIONS = new QName(Namespaces.CORE, "sourceConnections"); +// +// public static final QName TARGET_CONNECTIONS = new QName(Namespaces.CORE, "targetConnections"); +// +// public static final QName COLUMNS = new QName(Namespaces.CORE, "columns"); +// +// public static final QName REPRESENTATION = new QName(Namespaces.CORE, "representation"); +// +// public static final QName CONNECTIONS = new QName(Namespaces.CORE, "connections"); +// +// public static final QName SOURCE = new QName(Namespaces.CORE, "source"); +// +// public static final QName TARGET = new QName(Namespaces.CORE, "target"); +// +// public static final QName FOREIGN_KEY = new QName(Namespaces.CORE, "foreignKey"); +// +// public static final QName MAPPINGS = new QName(Namespaces.CORE, "mappings"); +// +// public static final QName MAPPING = new QName(Namespaces.CORE, "mapping"); +// +// public static final QName CONSTRAINT_COLUMN = new QName(Namespaces.CORE, "constraintColumn"); +// +// public static final QName REFERENCE_COLUMN = new QName(Namespaces.CORE, "referenceColumn"); +// +// public static final QName ON_DELETE = new QName(Namespaces.CORE, "onDelete"); +// +// public static final QName ON_UPDATE = new QName(Namespaces.CORE, "onUpdate"); +// +// public static final QName DEFERRABLE = new QName(Namespaces.CORE, "deferrable"); +// +// public static final QName INITIALLY_CHECK_TIME = new QName(Namespaces.CORE, "initiallyCheckTime"); +// +// public static final QName INSERT_DATA_SET = new QName(Namespaces.CORE, "insertDataSetModels"); +// +// public static final QName DATA_SET = new QName(Namespaces.CORE, "dataSet"); +// +// // -------- Attributes +// +// public static final QName ID = new QName("id"); +// +// +// private XmlNodes() { +// } +//} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/XmlNodes.java ___________________________________________________________________ Name: svn:mime-type + text/plain Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/AbstractJiemamyCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/AbstractJiemamyCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/AbstractJiemamyCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -1,79 +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.internal.serializer.stax.command; - -import javax.xml.stream.XMLEventFactory; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.events.XMLEvent; - -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -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.StaxUtil; - -/** - * TODO for daisuke - * @author daisuke - */ -public abstract class AbstractJiemamyCommand implements JiemamyCommand { - - protected static final XMLEventFactory EVENT_FACTORY = XMLEventFactory.newInstance(); - - private static Logger logger = LoggerFactory.getLogger(AbstractJiemamyCommand.class); - - - /** - * TODO for daisuke - * @param xmlEvent - * @return - */ - public static JiemamyCommand newInstance(XMLEvent xmlEvent) { - logger.info("Type: " + StaxUtil.toEventTypeEnum(xmlEvent.getEventType()).toString()); - - switch (xmlEvent.getEventType()) { - case XMLStreamConstants.START_DOCUMENT: - return new OpenCommand(); - - case XMLStreamConstants.END_DOCUMENT: - return new CloseCommand(); - - case XMLStreamConstants.START_ELEMENT: - // FIXME StartElementCommandはabstractであるり、適切なサブクラスを返すべき。 - return new StartElementCommand(xmlEvent.asStartElement()); - - case XMLStreamConstants.END_ELEMENT: - // FIXME EndElementCommandはabstractであるり、適切なサブクラスを返すべき。 - return new EndElementCommand(xmlEvent.asEndElement()); - - case XMLStreamConstants.CHARACTERS: - String text = xmlEvent.asCharacters().getData(); - return StringUtils.isBlank(text) ? new NullCommand() : new ContentsCommand(text); - - default: - return new NullCommand(); - } - } - - void dummyToSuppressFindBugs() { - } -} Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/CloseCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/CloseCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/CloseCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -22,13 +22,14 @@ 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 CloseCommand extends AbstractJiemamyCommand { +public class CloseCommand implements JiemamyCommand { /** * {@inheritDoc} Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/ContentsCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/ContentsCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/ContentsCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -1,67 +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.internal.serializer.stax.command; - -import javax.xml.stream.XMLEventWriter; -import javax.xml.stream.XMLStreamException; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; - -import org.jiemamy.internal.serializer.stax.CommandContext; -import org.jiemamy.model.RootModel; - -/** - * TODO for daisuke - * @author daisuke - */ -public class ContentsCommand extends AbstractJiemamyCommand { - - private String text; - - - /** - * コンストラクタ。 - * @param text - * @category instance creation - */ - public ContentsCommand(String text) { - Validate.notNull(text); - this.text = text; - } - - /** - * {@inheritDoc} - */ - public RootModel applyTo(RootModel rootModel, CommandContext ctx) { - if (StringUtils.isBlank(text)) { - return rootModel; - } - // TODO Auto-generated method stub - return rootModel; - } - - /** - * {@inheritDoc} - */ - public void applyTo(XMLEventWriter xmlWriter) throws XMLStreamException { - xmlWriter.add(EVENT_FACTORY.createCharacters(text)); - } - -} Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/DividableCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/DividableCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/DividableCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -1,69 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/16 - * - * 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 org.apache.commons.lang.NotImplementedException; - -import org.jiemamy.internal.serializer.stax.CommandContext; -import org.jiemamy.internal.serializer.stax.JiemamyCommand; -import org.jiemamy.internal.serializer.stax.command.dividable.TableModelCommand; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.node.TableModel; -import org.jiemamy.utils.EssentialQueue; - -/** - * TODO for daisuke - * @author daisuke - */ -public abstract class DividableCommand implements JiemamyCommand { - - /** - * TODO for daisuke - * @param element - * @return - */ - public static DividableCommand newInstance(Object element) { - if (element instanceof TableModel) { - return new TableModelCommand((TableModel) element); - } else { - // FIXME - throw new NotImplementedException(); - } - } - - /** - * {@inheritDoc} - */ - public RootModel applyTo(RootModel rootModel, CommandContext ctx) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void applyTo(XMLEventWriter xmlWriter) throws XMLStreamException { - throw new UnsupportedOperationException(); - } - - public abstract EssentialQueue<JiemamyCommand> divide(); - -} Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/EmptyElementCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/EmptyElementCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/EmptyElementCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -23,13 +23,14 @@ 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 EmptyElementCommand extends AbstractJiemamyCommand { +public class EmptyElementCommand implements JiemamyCommand { private QName qName; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/NullCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/NullCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/NullCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -21,13 +21,14 @@ import javax.xml.stream.XMLEventWriter; 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 NullCommand extends AbstractJiemamyCommand { +public class NullCommand implements JiemamyCommand { /** * {@inheritDoc} Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/OpenCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/OpenCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/OpenCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -24,13 +24,14 @@ import org.apache.commons.lang.CharEncoding; 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 OpenCommand extends AbstractJiemamyCommand { +public class OpenCommand implements JiemamyCommand { /** * {@inheritDoc} Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/end/DialectEndCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/end/DialectEndCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/end/DialectEndCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -18,8 +18,9 @@ */ package org.jiemamy.internal.serializer.stax.command.end; +import javax.xml.namespace.QName; + import org.jiemamy.internal.serializer.stax.CommandContext; -import org.jiemamy.internal.serializer.stax.JiemamyXmlConstants; import org.jiemamy.model.RootModel; /** @@ -30,10 +31,11 @@ /** * コンストラクタ。 + * @param qName * @category instance creation */ - public DialectEndCommand() { - super(JiemamyXmlConstants.DIALECT); + public DialectEndCommand(QName qName) { + super(qName); } /** Modified: 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/end/EndElementCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/end/EndElementCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -24,14 +24,14 @@ import javax.xml.stream.events.EndElement; import org.jiemamy.internal.serializer.stax.CommandContext; -import org.jiemamy.internal.serializer.stax.command.AbstractJiemamyCommand; +import org.jiemamy.internal.serializer.stax.JiemamyCommand; import org.jiemamy.model.RootModel; /** * TODO for daisuke * @author daisuke */ -public class EndElementCommand extends AbstractJiemamyCommand { +public abstract class EndElementCommand implements JiemamyCommand { private QName qName; @@ -58,7 +58,7 @@ * {@inheritDoc} */ public RootModel applyTo(RootModel rootModel, CommandContext ctx) { - ctx.end(this, qName); + ctx.end(this); return rootModel; } @@ -69,4 +69,8 @@ xmlWriter.add(EVENT_FACTORY.createEndElement(qName, null)); } + public QName getQName() { + return qName; + } + } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/end/RootModelEndCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/end/RootModelEndCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/end/RootModelEndCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -18,20 +18,21 @@ */ package org.jiemamy.internal.serializer.stax.command.end; -import org.jiemamy.internal.serializer.stax.JiemamyXmlConstants; +import javax.xml.namespace.QName; /** - * TODO for dmiyamoto - * @author dmiyamoto + * TODO for daisuke + * @author daisuke */ public class RootModelEndCommand extends EndElementCommand { /** * コンストラクタ。 + * @param name * @category instance creation */ - public RootModelEndCommand() { - super(JiemamyXmlConstants.ROOT_MODEL); + public RootModelEndCommand(QName name) { + super(name); } } Added: 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 (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactory.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,54 @@ +/* + * 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(); + +} 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 Added: 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 (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactoryRule.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,139 @@ +/* + * 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); + } +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactoryRule.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CoreCommandFactoryRule.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,36 @@ +/* + * 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); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CoreCommandFactoryRule.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/DialectCommandFactory.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,122 @@ +/* + * 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)); + } + + } +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/DialectCommandFactory.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullCommandFactory.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,66 @@ +/* + * 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>(); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullCommandFactory.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullEndCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,39 @@ +/* + * 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 org.jiemamy.internal.serializer.stax.command.start.StartElementCommand; + +/** + * TODO for daisuke + * @author daisuke + */ +public class NullEndCommand extends StartElementCommand { + + /** + * コンストラクタ。 + * @category instance creation + */ + public NullEndCommand() { + super((QName) null); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullEndCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullStartCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,39 @@ +/* + * 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 org.jiemamy.internal.serializer.stax.command.end.EndElementCommand; + +/** + * TODO for daisuke + * @author daisuke + */ +public class NullStartCommand extends EndElementCommand { + + /** + * コンストラクタ。 + * @category instance creation + */ + public NullStartCommand() { + super((QName) null); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullStartCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/RootModelCommandFactory.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,126 @@ +/* + * 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(); + } + } +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/RootModelCommandFactory.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/DialectStartCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/DialectStartCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/DialectStartCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -18,11 +18,11 @@ */ package org.jiemamy.internal.serializer.stax.command.start; -import org.jiemamy.internal.serializer.stax.JiemamyXmlConstants; +import javax.xml.namespace.QName; /** - * TODO for dmiyamoto - * @author dmiyamoto + * TODO for daisuke + * @author daisuke */ public class DialectStartCommand extends StartElementCommand { @@ -30,8 +30,8 @@ * コンストラクタ。 * @category instance creation */ - public DialectStartCommand() { - super(JiemamyXmlConstants.DIALECT); + public DialectStartCommand(QName qName) { + super(qName); } } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/RootModelStartCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/RootModelStartCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/RootModelStartCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -22,6 +22,7 @@ import java.util.List; 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; @@ -30,14 +31,13 @@ import org.apache.commons.lang.ObjectUtils; import org.jiemamy.internal.serializer.stax.CommandContext; -import org.jiemamy.internal.serializer.stax.JiemamyXmlConstants; import org.jiemamy.model.Jiemamy; import org.jiemamy.model.RootModel; import org.jiemamy.serializer.Namespaces; /** - * TODO for dmiyamoto - * @author dmiyamoto + * TODO for daisuke + * @author daisuke */ public class RootModelStartCommand extends StartElementCommand { @@ -53,11 +53,12 @@ /** * コンストラクタ。 + * @param name * @param id * @category instance creation */ - public RootModelStartCommand(UUID id) { - super(JiemamyXmlConstants.ROOT_MODEL); + public RootModelStartCommand(QName name, UUID id) { + super(name); this.id = id; } @@ -75,7 +76,7 @@ @Override public void applyTo(XMLEventWriter xmlWriter) throws XMLStreamException { List<Attribute> attrs = new ArrayList<Attribute>(); - attrs.add(EVENT_FACTORY.createAttribute(JiemamyXmlConstants.ID, id.toString())); + attrs.add(EVENT_FACTORY.createAttribute(new QName("id"), id.toString())); xmlWriter.add(EVENT_FACTORY.createStartElement(qName, attrs.iterator(), NAMESPACES.iterator())); } Modified: 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/start/StartElementCommand.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/StartElementCommand.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -26,14 +26,14 @@ import org.apache.commons.lang.Validate; import org.jiemamy.internal.serializer.stax.CommandContext; -import org.jiemamy.internal.serializer.stax.command.AbstractJiemamyCommand; +import org.jiemamy.internal.serializer.stax.JiemamyCommand; import org.jiemamy.model.RootModel; /** * TODO for daisuke * @author daisuke */ -public class StartElementCommand extends AbstractJiemamyCommand { +public abstract class StartElementCommand implements JiemamyCommand { QName qName; 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-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -11,6 +11,7 @@ import javax.xml.stream.XMLInputFactory; import javax.xml.stream.events.XMLEvent; +import org.apache.commons.lang.ClassUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -19,11 +20,13 @@ import org.slf4j.LoggerFactory; import org.jiemamy.internal.serializer.stax.command.CloseCommand; -import org.jiemamy.internal.serializer.stax.command.ContentsCommand; -import org.jiemamy.internal.serializer.stax.command.EmptyElementCommand; +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.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.model.Artemis; import org.jiemamy.model.Jiemamy; import org.jiemamy.model.RootModel; @@ -64,17 +67,27 @@ RootModel rootModel = Jiemamy.newRootModel(); JiemamyCommandInputStream stream = new JiemamyCommandInputStreamImpl(rootModel); - List<Class<? extends JiemamyCommand>> expectedClasses = CollectionsUtil.newArrayList(); + List<Class<?>> expectedClasses = CollectionsUtil.newArrayList(); { expectedClasses.add(OpenCommand.class); - expectedClasses.add(StartElementCommand.class); - expectedClasses.add(EmptyElementCommand.class); - expectedClasses.add(EndElementCommand.class); + expectedClasses.add(RootModelStartCommand.class); + expectedClasses.add(DialectStartCommand.class); + expectedClasses.add(DialectCommandFactory.class); + expectedClasses.add(DialectEndCommand.class); + expectedClasses.add(RootModelEndCommand.class); expectedClasses.add(CloseCommand.class); } - check(stream, expectedClasses); + List<JiemamyCommand> actual = check(stream); + int index = 0; + for (Class<?> expectedClass : expectedClasses) { + logger.info("expected" + index + " is " + expectedClass); + logger.info("actual " + index + " is " + actual.get(index).getClass()); + assertThat("error index=" + index, actual.get(index), instanceOf(expectedClass)); + index++; + } + stream.close(); } @@ -84,7 +97,7 @@ */ @Test public void test02_fromXmlModel() throws Exception { - InputStream in = JiemamyCommandInputStreamTest.class.getResourceAsStream("/minimal.xml"); + InputStream in = JiemamyCommandInputStreamTest.class.getResourceAsStream("/minimal.jiemamy-core.xml"); XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true); @@ -103,49 +116,54 @@ List<Class<? extends JiemamyCommand>> expectedClasses = CollectionsUtil.newArrayList(); { - // <?xml version="1.0" encoding="utf-8" ?> + // <?xml version='1.0' encoding='UTF-8'?> expectedClasses.add(OpenCommand.class); - // <foo xmlns:prefix="uri_prifix" xmlns="uri_anon"> - expectedClasses.add(StartElementCommand.class); + // <rootModel xmlns="http://jiemamy.org/xml/ns/core" id="ffffffff-ffff-ffff-ffff-ffffffffffff"> + expectedClasses.add(RootModelStartCommand.class); - // <bar prefix:localName="piyo"> - expectedClasses.add(StartElementCommand.class); + // <dialect> + expectedClasses.add(DialectStartCommand.class); - // value - expectedClasses.add(ContentsCommand.class); + expectedClasses.add(NullCommand.class); - // </bar> - expectedClasses.add(EndElementCommand.class); + // com.example.HogeDialect +// expectedClasses.add(DialectCommandFactory.class); - // <bar /> - expectedClasses.add(StartElementCommand.class); - expectedClasses.add(EndElementCommand.class); + // </dialect> + expectedClasses.add(DialectEndCommand.class); - // </foo> - expectedClasses.add(EndElementCommand.class); + // </rootModel> + expectedClasses.add(RootModelEndCommand.class); expectedClasses.add(CloseCommand.class); } - check(stream, expectedClasses); + List<JiemamyCommand> actual = check(stream); + int index = 0; + for (Class<? extends JiemamyCommand> expectedClass : expectedClasses) { + logger.info("expected" + index + " is " + expectedClass); + logger.info("actual " + index + " is " + actual.get(index).getClass()); + assertThat("error index=" + index, actual.get(index), instanceOf(expectedClass)); + index++; + } + stream.close(); } /** * TODO for daisuke * @param stream - * @param expectedClasses + * @return * @throws JiemamyCommandException */ - private void check(JiemamyCommandInputStream stream, List<Class<? extends JiemamyCommand>> expectedClasses) - throws JiemamyCommandException { - int index = 0; + private List<JiemamyCommand> check(JiemamyCommandInputStream stream) throws JiemamyCommandException { + List<JiemamyCommand> result = CollectionsUtil.newArrayList(); while (stream.hasNext()) { JiemamyCommand command = stream.nextCommand(); - logger.info(command.toString()); - assertThat("index=" + index, command, instanceOf(expectedClasses.get(index))); - index++; + logger.info(ClassUtils.getShortClassName(command, "null")); + result.add(command); } + return result; } } 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-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -26,6 +26,7 @@ import javanet.staxutils.IndentingXMLEventWriter; +import javax.xml.namespace.QName; import javax.xml.stream.XMLEventWriter; import javax.xml.stream.XMLOutputFactory; @@ -38,15 +39,16 @@ import org.slf4j.LoggerFactory; import org.jiemamy.internal.serializer.stax.command.CloseCommand; -import org.jiemamy.internal.serializer.stax.command.ContentsCommand; 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.model.Artemis; import org.jiemamy.model.Jiemamy; import org.jiemamy.model.RootModel; +import org.jiemamy.serializer.Namespaces; import org.jiemamy.utils.UUIDUtil; /** @@ -123,11 +125,12 @@ */ private void writeTestDataTo(JiemamyCommandOutputStream stream) throws JiemamyCommandException { stream.write(new OpenCommand()); - stream.write(new RootModelStartCommand(UUIDUtil.valueOfOrRandom("ffffffff-ffff-ffff-ffff-ffffffffffff"))); - stream.write(new DialectStartCommand()); - stream.write(new ContentsCommand("com.example.HogeDialect")); - stream.write(new DialectEndCommand()); - stream.write(new RootModelEndCommand()); + 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 CloseCommand()); } } Modified: artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/StaxTest.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/StaxTest.java 2008-12-17 16:10:07 UTC (rev 2276) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/StaxTest.java 2008-12-18 11:22:42 UTC (rev 2277) @@ -23,6 +23,7 @@ import javanet.staxutils.IndentingXMLEventWriter; +import javax.xml.namespace.QName; import javax.xml.stream.XMLEventFactory; import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLEventWriter; @@ -99,7 +100,7 @@ if (event.isStartElement()) { StartElement startElement = event.asStartElement(); logger.info(StaxUtil.toEventTypeEnum(event.getEventType()) + ": " + startElement.getName().toString()); - Attribute id = startElement.getAttributeByName(JiemamyXmlConstants.ID); + Attribute id = startElement.getAttributeByName(new QName("id")); if (id != null) { logger.info("id=" + id.getValue()); } Added: artemis/trunk/org.jiemamy.serializer/src/test/resources/minimal.jiemamy-core.xml =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/test/resources/minimal.jiemamy-core.xml (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/test/resources/minimal.jiemamy-core.xml 2008-12-18 11:22:42 UTC (rev 2277) @@ -0,0 +1,4 @@ +<?xml version='1.0' encoding='UTF-8'?> +<rootModel xmlns="http://jiemamy.org/xml/ns/core" id="ffffffff-ffff-ffff-ffff-ffffffffffff"> + <dialect>com.example.HogeDialect</dialect> +</rootModel> Property changes on: artemis/trunk/org.jiemamy.serializer/src/test/resources/minimal.jiemamy-core.xml ___________________________________________________________________ Name: svn:mime-type + text/plain