Index: src/test/java/quickfix/DefaultMessageFactoryTest.java
===================================================================
--- src/test/java/quickfix/DefaultMessageFactoryTest.java (revision 0)
+++ src/test/java/quickfix/DefaultMessageFactoryTest.java (revision 0)
@@ -0,0 +1,48 @@
+package quickfix;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import quickfix.field.MsgType;
+import quickfix.field.LinesOfText;
+import quickfix.util.ExpectedTestFailure;
+
+/**
+ * Verifies the behaviour of the {@link DefaultMessageFactory} class
+ * @author toli
+ * @version $Id$
+ */
+
+public class DefaultMessageFactoryTest extends TestCase {
+ public DefaultMessageFactoryTest(String inName) {
+ super(inName);
+ }
+
+ public static Test suite() {
+ return new TestSuite(DefaultMessageFactoryTest.class);
+ }
+
+ public void testMessageCreate() throws Exception {
+ DefaultMessageFactory factory = new DefaultMessageFactory();
+ assertEquals(quickfix.fix40.Advertisement.class, factory.create("FIX.4.0", MsgType.ADVERTISEMENT).getClass());
+ assertEquals(quickfix.fix41.Advertisement.class, factory.create("FIX.4.1", MsgType.ADVERTISEMENT).getClass());
+ assertEquals(quickfix.fix42.Advertisement.class, factory.create("FIX.4.2", MsgType.ADVERTISEMENT).getClass());
+ assertEquals(quickfix.fix43.Advertisement.class, factory.create("FIX.4.3", MsgType.ADVERTISEMENT).getClass());
+ assertEquals(quickfix.fix44.Advertisement.class, factory.create("FIX.4.4", MsgType.ADVERTISEMENT).getClass());
+ assertEquals(quickfix.Message.class, factory.create("unknown", MsgType.ADVERTISEMENT).getClass());
+ }
+ public void testGroupCreate() throws Exception {
+ final DefaultMessageFactory factory = new DefaultMessageFactory();
+ new ExpectedTestFailure(IllegalArgumentException.class, "unknown") {
+ protected void execute() throws Throwable {
+ factory.create("unknown", MsgType.NEWS, LinesOfText.FIELD);
+ }
+ }.run();
+
+ assertEquals(quickfix.fix40.News.LinesOfText.class, factory.create("FIX.4.0", MsgType.NEWS, LinesOfText.FIELD).getClass());
+ assertEquals(quickfix.fix41.News.LinesOfText.class, factory.create("FIX.4.1", MsgType.NEWS, LinesOfText.FIELD).getClass());
+ assertEquals(quickfix.fix42.News.LinesOfText.class, factory.create("FIX.4.2", MsgType.NEWS, LinesOfText.FIELD).getClass());
+ assertEquals(quickfix.fix43.News.LinesOfText.class, factory.create("FIX.4.3", MsgType.NEWS, LinesOfText.FIELD).getClass());
+ assertEquals(quickfix.fix44.News.LinesOfText.class, factory.create("FIX.4.4", MsgType.NEWS, LinesOfText.FIELD).getClass());
+ }
+}
Index: src/main/java/quickfix/codegen/MessageFactory.xsl
===================================================================
--- src/main/java/quickfix/codegen/MessageFactory.xsl (revision 601)
+++ src/main/java/quickfix/codegen/MessageFactory.xsl (working copy)
@@ -23,11 +23,12 @@
- /* -*- C++ -*- */
+ /* -*- Generated Java -*- */
package quickfix.fix;
import quickfix.Message;
+import quickfix.Group;
public class MessageFactory implements quickfix.MessageFactory
{
@@ -35,16 +36,41 @@
return new quickfix.fix.Message();
}
+
+ public Group create(String beginString, String msgType, int correspondingFieldID) {
+
+ return null;
+ }
}
-
+
+
+
+ if("".equals(msgType)) {
+ return new quickfix.fix.();
+ }
+
+
+
+
+ if("".equals(msgType)) {
+ switch(correspondingFieldID) {
+
+
+
+ }
+ }
+
+
+
+
+ case quickfix.field..FIELD:
+ return new quickfix.fix();
+
+
+
+
+
+
-
-
- if("".equals(msgType)) {
- return new quickfix.fix.();
- }
-
-
-
Index: src/main/java/quickfix/DefaultMessageFactory.java
===================================================================
--- src/main/java/quickfix/DefaultMessageFactory.java (revision 601)
+++ src/main/java/quickfix/DefaultMessageFactory.java (working copy)
@@ -54,4 +54,23 @@
}
return new Message();
}
+
+ public Group create(String beginString, String msgType, int correspondingFieldID) {
+ if("FIX.4.0".equals(beginString)) {
+ return fix40Factory.create(beginString, msgType, correspondingFieldID);
+ }
+ if("FIX.4.1".equals(beginString)) {
+ return fix41Factory.create(beginString, msgType, correspondingFieldID);
+ }
+ if("FIX.4.2".equals(beginString)) {
+ return fix42Factory.create(beginString, msgType, correspondingFieldID);
+ }
+ if("FIX.4.3".equals(beginString)) {
+ return fix43Factory.create(beginString, msgType, correspondingFieldID);
+ }
+ if("FIX.4.4".equals(beginString)) {
+ return fix44Factory.create(beginString, msgType, correspondingFieldID);
+ }
+ throw new IllegalArgumentException("Unsupported FIX version: "+beginString);
+ }
}
Index: src/main/java/quickfix/MessageFactory.java
===================================================================
--- src/main/java/quickfix/MessageFactory.java (revision 601)
+++ src/main/java/quickfix/MessageFactory.java (working copy)
@@ -36,4 +36,20 @@
* @return a message instance
*/
Message create(String beginString, String msgType);
+
+ /**
+ * Creates a group for the specified parent message type and
+ * for the fields with the corresponding field ID
+ *
+ * Example: to create a {@link quickfix.fix42.MarketDataRequest.NoMDEntryTypes}
+ * you need to call
+ * create({@link quickfix.field.MsgType#MARKET_DATA_REQUEST, {@link quickfix.field.NoMDEntries#FIELD})
+ *
+ * @param beginString
+ * the FIX version (for example, "FIX.4.2")
+ * @param msgType Message type of the enclosing message
+ * @param correspondingFieldID the fieldID of the field in the group
+ * @return group
+ */
+ public Group create(String beginString, String msgType, int correspondingFieldID);
}
\ No newline at end of file