svnno****@sourc*****
svnno****@sourc*****
2008年 11月 8日 (土) 17:37:57 JST
Revision: 2106 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=2106 Author: ykhr Date: 2008-11-08 17:37:57 +0900 (Sat, 08 Nov 2008) Log Message: ----------- Javadoc追加(実装はまだまだ) Modified Paths: -------------- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/DialectInstanceCreationStrategy.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/DefaultModelCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/EntityModelCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyHandler.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamySaxReader.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ModelInfo.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/RootCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElementCommand.java artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/sax/JiemamySaxReaderTest.java Added Paths: ----------- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/AbstractXmlElementCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElementStack.java -------------- next part -------------- Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/DialectInstanceCreationStrategy.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/DialectInstanceCreationStrategy.java 2008-11-06 23:38:41 UTC (rev 2105) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/DialectInstanceCreationStrategy.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -21,16 +21,17 @@ import org.jiemamy.spec.extension.dialect.Dialect; /** - * TODO for ykhr + * Dialectのインスタンスを生成するStrategy。 * @author ykhr */ public interface DialectInstanceCreationStrategy { /** - * TODO for ykhr - * @param fqcn - * @return - * @throws ClassNotFoundException + * Dialectのインスタンスを取得する。 + * + * @param fqcn フルクラス名 + * @return Dialectインスタンス + * @throws ClassNotFoundException クラスが見つからなかった場合 */ Dialect create(String fqcn) throws ClassNotFoundException; Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/AbstractXmlElementCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/AbstractXmlElementCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/AbstractXmlElementCommand.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -0,0 +1,54 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/07 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.serializer.sax; + +import org.xml.sax.Attributes; + +/** + * 空実装のXmlElementCommand。 + * @author ykhr + */ +public class AbstractXmlElementCommand implements XmlElementCommand { + + /** + * {@inheritDoc} + */ + public void end(ModelInfo model, XmlElement element, String text) { + } + + /** + * {@inheritDoc} + */ + public void endChild(XmlElement element, ModelInfo model, String text) { + } + + /** + * {@inheritDoc} + */ + public void start(XmlElement element, ModelInfo model, Attributes attributes) { + } + + /** + * {@inheritDoc} + */ + public XmlElementCommand startChild(XmlElement element, ModelInfo model, Attributes attributes) { + return null; + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/AbstractXmlElementCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/DefaultModelCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/DefaultModelCommand.java 2008-11-06 23:38:41 UTC (rev 2105) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/DefaultModelCommand.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -26,14 +26,15 @@ import org.jiemamy.spec.model.JiemamyModel; /** - * TODO for ykhr + * IDを持つJiemamyModelのXmlElementCommand。 * @author ykhr */ -public abstract class DefaultModelCommand implements XmlElementCommand { +abstract class DefaultModelCommand extends AbstractXmlElementCommand { /** * {@inheritDoc} */ + @Override public void start(XmlElement element, ModelInfo model, Attributes attributes) { String id = attributes.getValue("id"); if (id != null) { @@ -42,10 +43,20 @@ } } + /** + * 処理対象のJiemamyModel。 + * @param model Model情報 + * @return JiemamyModel + */ + protected abstract JiemamyModel getTargetModel(ModelInfo model); + + /** + * 処理対象のJiemamyModelAccessor。 + * @param model ModelInfo + * @return JiemamyModelAccessor + */ private JiemamyModelAccessor getTargetModelAccessor(ModelInfo model) { return (JiemamyModelAccessor) getTargetModel(model); } - protected abstract JiemamyModel getTargetModel(ModelInfo model); - } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/EntityModelCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/EntityModelCommand.java 2008-11-06 23:38:41 UTC (rev 2105) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/EntityModelCommand.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -21,14 +21,16 @@ import org.jiemamy.spec.model.node.AbstractEntityModel; /** - * TODO for ykhr + * AbstractEntityModel用XmlElementCommandクラス。 + * AbstractEntityModelが持つプロパティに値を設定する。 * @author ykhr */ -public abstract class EntityModelCommand extends DefaultModelCommand { +abstract class EntityModelCommand extends DefaultModelCommand { /** * {@inheritDoc} */ + @Override public void endChild(XmlElement element, ModelInfo model, String text) { String tagName = element.getName(); if (tagName.equals("name")) { @@ -44,6 +46,11 @@ } } + /** + * 処理対象のモデルを取得する。 + * @param model ModelInfo + * @return AbstractEntityModel + */ protected abstract AbstractEntityModel getTargetEntityModel(ModelInfo model); } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyHandler.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyHandler.java 2008-11-06 23:38:41 UTC (rev 2105) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamyHandler.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -29,176 +29,29 @@ import org.jiemamy.spec.model.RootModel; /** - * + * JiemamyXMLのSAX用DefaultHandler。 * @author ykhr */ class JiemamyHandler extends DefaultHandler { - private static class CommandInfo { - - private XmlElementCommand command; - - private XmlElementStack stackAtCommandStarted; - - - /** - * コンストラクタ。 - * @param command - * @param stackAtCommandStarted - * @category instance creation - */ - public CommandInfo(XmlElementCommand command, XmlElementStack stackAtCommandStarted) { - this.command = command; - this.stackAtCommandStarted = stackAtCommandStarted; - } - - /** - * TODO for ykhr - * @return the command - * @category accessing - */ - public XmlElementCommand getCommand() { - return command; - } - - /** - * TODO for ykhr - * @return the stackAtCommandStarted - * @category accessing - */ - public XmlElementStack getStackAtCommandStarted() { - return stackAtCommandStarted; - } - } + // TODO debug用 + private int depth = 0; - private static class FirstCommand implements XmlElementCommand { - - /** - * {@inheritDoc} - */ - public void end(ModelInfo model, XmlElement element, String text) { - // not called - } - - /** - * {@inheritDoc} - */ - public void endChild(XmlElement element, ModelInfo model, String text) { - // not called - } - - /** - * {@inheritDoc} - */ - public void start(XmlElement element, ModelInfo model, Attributes attributes) { - // not called - } - - /** - * {@inheritDoc} - */ - public XmlElementCommand startChild(XmlElement element, ModelInfo model, Attributes attributes) { - return new RootCommand(); - } - } - - /** - * TODO - * @author ykhr - */ - private static class XmlElementStack { - - private Stack<XmlElement> stack = new Stack<XmlElement>(); - - - /** - * TODO for ykhr - * @return - */ - public XmlElementStack copy() { - XmlElementStack newStack = new XmlElementStack(); - for (XmlElement element : stack) { - newStack.stack.push(new XmlElement(element.getUri(), element.getName())); - } - - return newStack; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (!(obj instanceof XmlElementStack)) { - return false; - } - - XmlElementStack xmlElementStack = (XmlElementStack) obj; - return stack.equals(xmlElementStack.stack); - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return stack.hashCode(); - } - - /** - * peek - * @return - */ - public XmlElement peek() { - return stack.peek(); - } - - /** - * pop - * @return - */ - public XmlElement pop() { - return stack.pop(); - } - - /** - * push - * @param element - */ - public void push(XmlElement element) { - stack.push(element); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - for (XmlElement element : stack) { - sb.append("/"); - sb.append(element.toString()); - } - - return sb.toString(); - } - - } - - + /** DialectInstanceCreationStrategy */ private DialectInstanceCreationStrategy dialectStrategy; + /** 読み込んでいるタグの構成 */ private XmlElementStack xmlElementStack = new XmlElementStack(); - private ModelInfo model; + /** モデル */ + private ModelInfo model = null; + /** コマンドのスタック */ private Stack<CommandInfo> commandStack = new Stack<CommandInfo>(); /** buffer */ private StringBuilder buffer = new StringBuilder(); - int depth = 0; - /** * コンストラクタ。 @@ -315,14 +168,15 @@ if (commandInfo.getStackAtCommandStarted().equals(xmlElementStack)) { command.end(model, element, buffer.toString()); commandStack.pop(); - System.out.println("*********************"); + System.out.println("***end command: " + command); } else { command.endChild(element, model, buffer.toString()); } + // TODO debug + depth--; printSpace(); System.out.println("end:" + xmlElementStack); - depth--; xmlElementStack.pop(); } @@ -343,7 +197,7 @@ JiemamyModelFactory.init(new S2FactoryStrategy("jiemamy-view.dicon")); RootModel rootModel = JiemamyModelFactory.createRoot().init(); model = new ModelInfo(rootModel, dialectStrategy); - commandStack.push(new CommandInfo(new FirstCommand(), xmlElementStack.copy())); + commandStack.push(new CommandInfo(new FirstCommand(), xmlElementStack.snapshot())); } /** @@ -358,9 +212,11 @@ XmlElementCommand nextCommand = command.startChild(element, model, attributes); if (nextCommand != null) { - commandStack.push(new CommandInfo(nextCommand, xmlElementStack.copy())); + commandStack.push(new CommandInfo(nextCommand, xmlElementStack.snapshot())); nextCommand.start(element, model, attributes); } + + // TODO debug printSpace(); System.out.println("start:" + xmlElementStack); depth++; @@ -405,11 +261,73 @@ } /** - * TODO for ykhr + * TODO debug */ private void printSpace() { for (int i = 0; i < depth; i++) { System.out.print(" "); } } + + + /** + * コマンド情報 + * @author ykhr + */ + private static class CommandInfo { + + /** コマンド */ + private XmlElementCommand command; + + /** このコマンドを開始した時点のタグの構成 */ + private XmlElementStack stackAtCommandStarted; + + + /** + * コンストラクタ。 + * @param command + * @param stackAtCommandStarted + * @category instance creation + */ + public CommandInfo(XmlElementCommand command, XmlElementStack stackAtCommandStarted) { + this.command = command; + this.stackAtCommandStarted = stackAtCommandStarted; + } + + /** + * コマンドを取得する。 + * @return the command + * @category accessing + */ + public XmlElementCommand getCommand() { + return command; + } + + /** + * コマンド開始時点のタグの構成を取得する。 + * @return the stackAtCommandStarted + * @category accessing + */ + public XmlElementStack getStackAtCommandStarted() { + return stackAtCommandStarted; + } + + } + + /** + * 最初のXmlElementCommandクラス。 + * @author ykhr + */ + private static class FirstCommand extends AbstractXmlElementCommand { + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo model, Attributes attributes) { + return new RootCommand(); + } + + } + } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamySaxReader.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamySaxReader.java 2008-11-06 23:38:41 UTC (rev 2105) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/JiemamySaxReader.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -38,6 +38,7 @@ */ public class JiemamySaxReader { + /** DialectInstanceCreationStrategy */ private DialectInstanceCreationStrategy strategy; @@ -59,10 +60,10 @@ } /** - * TODO for ykhr - * @param in - * @return - * @throws SerializationException + * デシリアライズする。 + * @param in 入力ストリーム + * @return RootModel + * @throws SerializationException 読み込みに失敗した場合 */ public RootModel deserialize(InputStream in) { try { Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ModelInfo.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ModelInfo.java 2008-11-06 23:38:41 UTC (rev 2105) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ModelInfo.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -24,27 +24,46 @@ import org.jiemamy.spec.model.node.TableModel; /** - * TODO for ykhr + * モデル情報。本クラスで、各Commandが必要な情報を持ちまわす。 * @author ykhr */ -public class ModelInfo { +class ModelInfo { + /** RootModel */ private RootModel rootModel; - private TableModel tableModel; + /** 現在読み込んでいるTableModel */ + private TableModel tableModel = null; - private ColumnModel columnModel; + /** 現在読み込んでいるColumnModel */ + private ColumnModel columnModel = null; + /** Dialect生成Strategy */ private DialectInstanceCreationStrategy dialectStrategy; + /** + * コンストラクタ。 + * @param rootModel + * @param strategy + * @category instance creation + */ public ModelInfo(RootModel rootModel, DialectInstanceCreationStrategy strategy) { this.rootModel = rootModel; dialectStrategy = strategy; } /** - * TODO for ykhr + * ColumnModelを取得する。 + * @return the columnModel + * @category accessing + */ + public ColumnModel getColumnModel() { + return columnModel; + } + + /** + * DialectInstanceCreationStrategyを取得する。 * @return the dialectStrategy * @category accessing */ @@ -53,7 +72,7 @@ } /** - * TODO for ykhr + * RootModelを取得する。 * @return the rootModel * @category accessing */ @@ -61,4 +80,13 @@ return rootModel; } + /** + * TableModelを取得する。 + * @return the tableModel + * @category accessing + */ + public TableModel getTableModel() { + return tableModel; + } + } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/RootCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/RootCommand.java 2008-11-06 23:38:41 UTC (rev 2105) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/RootCommand.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -25,18 +25,16 @@ import org.jiemamy.spec.model.JiemamyModel; import org.jiemamy.spec.model.RootModel; +/** + * RootレベルのCommandクラス。 + * @author ykhr + */ class RootCommand extends DefaultModelCommand { /** * {@inheritDoc} */ - public void end(ModelInfo model, XmlElement element, String text) { - // do nothing - } - - /** - * {@inheritDoc} - */ + @Override public void endChild(XmlElement element, ModelInfo model, String text) { String tagName = element.getName(); RootModel rootModel = model.getRootModel(); @@ -55,6 +53,7 @@ /** * {@inheritDoc} */ + @Override public XmlElementCommand startChild(XmlElement element, ModelInfo model, Attributes attributes) { String tagName = element.getName(); if (tagName.equals("domains")) { @@ -91,32 +90,7 @@ // TODO 仮実装Command - private static class NullCommand implements XmlElementCommand { - - /** - * {@inheritDoc} - */ - public void end(ModelInfo model, XmlElement element, String text) { - } - - /** - * {@inheritDoc} - */ - public void endChild(XmlElement element, ModelInfo model, String text) { - } - - /** - * {@inheritDoc} - */ - public void start(XmlElement element, ModelInfo model, Attributes attributes) { - } - - /** - * {@inheritDoc} - */ - public XmlElementCommand startChild(XmlElement element, ModelInfo model, Attributes attributes) { - return null; - } + private static class NullCommand extends AbstractXmlElementCommand { } } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElement.java 2008-11-06 23:38:41 UTC (rev 2105) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElement.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -1,15 +1,37 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/06 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ package org.jiemamy.serializer.sax; /** - * TODO for ykhr + * XMLのElement名を保持するクラス。 + * イミュータブル。 * @author ykhr */ class XmlElement { + /** URI */ private String uri; + /** Element名 */ private String name; + /** hashcode */ private int hashCode; @@ -39,7 +61,7 @@ } /** - * TODO for ykhr + * Element名を取得する。 * @return the name * @category accessing */ @@ -48,7 +70,7 @@ } /** - * TODO for ykhr + * URIを取得する。 * @return the uri * @category accessing */ @@ -69,6 +91,7 @@ */ @Override public String toString() { - return name; + return uri + ":" + name; } + } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElementCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElementCommand.java 2008-11-06 23:38:41 UTC (rev 2105) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElementCommand.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -20,10 +20,14 @@ import org.xml.sax.Attributes; +/** + * XMLの1要素に紐付くコマンド。 + * @author ykhr + */ interface XmlElementCommand { /** - * TODO for ykhr + * 終了処理。このコマンドに関連付いた要素の終了時に呼ばれる。 * @param model * @param element * @param text @@ -31,7 +35,7 @@ void end(ModelInfo model, XmlElement element, String text); /** - * TODO for ykhr + * 子要素の終了処理。配下の要素の終了時に呼ばれる。 * @param element * @param model * @param text @@ -39,7 +43,7 @@ void endChild(XmlElement element, ModelInfo model, String text); /** - * TODO for ykhr + * 開始処理。このコマンドに関連付いた要素の最初に呼ばれる。 * @param element * @param model * @param attributes @@ -47,11 +51,12 @@ void start(XmlElement element, ModelInfo model, Attributes attributes); /** - * TODO for ykhr + * 子要素の開始処理。配下の要素の開始時に呼ばれる。 * @param element * @param model * @param attributes - * @return + * @return XmlElementCommand */ XmlElementCommand startChild(XmlElement element, ModelInfo model, Attributes attributes); + } Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElementStack.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElementStack.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElementStack.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -0,0 +1,106 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/06 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.serializer.sax; + +import java.util.Stack; + +/** + * XMLの構成を保持するクラス。 + * @author ykhr + */ +class XmlElementStack { + + /** XMLの要素のスタック */ + private Stack<XmlElement> stack = new Stack<XmlElement>(); + + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof XmlElementStack)) { + return false; + } + + XmlElementStack xmlElementStack = (XmlElementStack) obj; + return stack.equals(xmlElementStack.stack); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return stack.hashCode(); + } + + /** + * peek + * @return スタックの先頭のXmlElement + */ + public XmlElement peek() { + return stack.peek(); + } + + /** + * pop + * @return スタックの先頭のXmlElement + */ + public XmlElement pop() { + return stack.pop(); + } + + /** + * スタックの先頭にXmlElementを追加する。 + * @param element 追加するXmlElement + */ + public void push(XmlElement element) { + stack.push(element); + } + + /** + * T現時点のスタックのコピーを作成する。 + * @return XmlElementStackのコピー + */ + public XmlElementStack snapshot() { + XmlElementStack newStack = new XmlElementStack(); + for (XmlElement element : stack) { + // 新しいインスタンスを作る必要はなさそうだけど・・・ + newStack.stack.push(new XmlElement(element.getUri(), element.getName())); + } + + return newStack; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + for (XmlElement element : stack) { + sb.append("/"); + sb.append(element.getName()); + } + + return sb.toString(); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/XmlElementStack.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/sax/JiemamySaxReaderTest.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/sax/JiemamySaxReaderTest.java 2008-11-06 23:38:41 UTC (rev 2105) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/sax/JiemamySaxReaderTest.java 2008-11-08 08:37:57 UTC (rev 2106) @@ -63,6 +63,7 @@ InputStream is = this.getClass().getClassLoader().getResourceAsStream("org/jiemamy/serializer/sax/test01.xml"); JiemamySaxReader reader = new JiemamySaxReader(new ReflectionDialectCreationStrategy()); RootModel rootModel = reader.deserialize(is); + System.out.println(rootModel); System.out.println("RootModel(Id):" + rootModel.getId()); System.out.println("RootModel(Dialect):" + rootModel.getDialect()); @@ -80,6 +81,7 @@ System.out.println(" Column:" + column.getId() + "," + column.getName()); } } + } @@ -96,8 +98,8 @@ new File("../org.jiemamy.dialect.mysql/target/classes").toURL() }); - return (Dialect) Class.forName("org.jiemamy.dialect.mysql.MySqlDialect", true, classLoader) - .newInstance(); + return Dialect.class.cast(Class.forName("org.jiemamy.dialect.mysql.MySqlDialect", true, classLoader) + .newInstance()); } catch (Exception e) { throw new RuntimeException(e); }