From: <ope...@li...> - 2008-01-11 16:07:30
|
Revision: 115 http://openfast.svn.sourceforge.net/openfast/?rev=115&view=rev Author: jacob_northey Date: 2008-01-11 08:07:21 -0800 (Fri, 11 Jan 2008) Log Message: ----------- [maven-release-plugin] copy for tag openfast-0.9.5b Added Paths: ----------- tags/openfast-0.9.5b/ tags/openfast-0.9.5b/etc/ tags/openfast-0.9.5b/license.txt tags/openfast-0.9.5b/pom.xml tags/openfast-0.9.5b/src/ tags/openfast-0.9.5b/src/main/java/org/openfast/MessageBlockReader.java tags/openfast-0.9.5b/src/main/java/org/openfast/MessageInputStream.java tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/IncrementIntegerOperatorCodec.java tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/TailOperatorCodec.java tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/AsciiString.java tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java tags/openfast-0.9.5b/src/main/java/org/openfast/util/RecordingInputStream.java tags/openfast-0.9.5b/src/site/ tags/openfast-0.9.5b/src/site/resources/css/site.css tags/openfast-0.9.5b/src/test/java/org/openfast/TemplateTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/scenario/CmeTemplateTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/submitted/ComposedDecimalNullPointerTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/submitted/IncrementOperatorTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/submitted/OpraFeedTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/submitted/OptionalInitialValueTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/submitted/StringNullTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/template/loader/XMLMessageTemplateLoaderTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/template/operator/TailOperatorCodecTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/template/type/codec/AsciiStringTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/test/OpenFastTestCase.java tags/openfast-0.9.5b/src/test/resources/CME/ tags/openfast-0.9.5b/src/test/resources/FPL/ tags/openfast-0.9.5b/src/test/resources/FPL/FASTTestTemplate.xml tags/openfast-0.9.5b/src/test/resources/FPL/data.xml tags/openfast-0.9.5b/src/test/resources/FPL/messages.fast tags/openfast-0.9.5b/src/test/resources/OPRA/ tags/openfast-0.9.5b/src/test/resources/components.xml tags/openfast-0.9.5b/src/test/resources/preTrade.xml tags/openfast-0.9.5b/src/test/resources/session.xml tags/openfast-0.9.5b/src/test/resources/template.xml Removed Paths: ------------- tags/openfast-0.9.5b/etc/ tags/openfast-0.9.5b/etc/tagVersion.bat tags/openfast-0.9.5b/etc/tagVersion.sh tags/openfast-0.9.5b/license.txt tags/openfast-0.9.5b/pom.xml tags/openfast-0.9.5b/src/ tags/openfast-0.9.5b/src/main/java/org/openfast/MessageInputStream.java tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/IncrementIntegerOperatorCodec.java tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/TailOperatorCodec.java tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/AsciiString.java tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java tags/openfast-0.9.5b/src/main/java/org/openfast/util/RecordingInputStream.java tags/openfast-0.9.5b/src/site/resources/css/site.css tags/openfast-0.9.5b/src/test/java/org/openfast/TemplateTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/components.xml tags/openfast-0.9.5b/src/test/java/org/openfast/preTrade.xml tags/openfast-0.9.5b/src/test/java/org/openfast/scenario/1.fast tags/openfast-0.9.5b/src/test/java/org/openfast/scenario/CmeTemplateTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/scenario/templates.xml tags/openfast-0.9.5b/src/test/java/org/openfast/session.xml tags/openfast-0.9.5b/src/test/java/org/openfast/submitted/ComposedDecimalNullPointerTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/submitted/FASTTestTemplate.xml tags/openfast-0.9.5b/src/test/java/org/openfast/submitted/OptionalInitialValueTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/submitted/messages.fast tags/openfast-0.9.5b/src/test/java/org/openfast/template/loader/XMLMessageTemplateLoaderTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/template/loader/mdIncrementalRefreshTemplate.xml tags/openfast-0.9.5b/src/test/java/org/openfast/template/operator/TailOperatorCodecTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/template/type/codec/AsciiStringTest.java tags/openfast-0.9.5b/src/test/java/org/openfast/template.xml tags/openfast-0.9.5b/src/test/java/org/openfast/test/OpenFastTestCase.java Copied: tags/openfast-0.9.5b (from rev 101, trunk) Copied: tags/openfast-0.9.5b/etc (from rev 99, trunk/etc) Deleted: tags/openfast-0.9.5b/etc/tagVersion.bat =================================================================== --- trunk/etc/tagVersion.bat 2007-12-06 17:11:51 UTC (rev 99) +++ tags/openfast-0.9.5b/etc/tagVersion.bat 2008-01-11 16:07:21 UTC (rev 115) @@ -1,4 +0,0 @@ -@echo off -svn propset major.version %1 . -svn propset minor.version %2 . -echo "Set version to %1.%2" \ No newline at end of file Deleted: tags/openfast-0.9.5b/etc/tagVersion.sh =================================================================== --- trunk/etc/tagVersion.sh 2007-12-06 17:11:51 UTC (rev 99) +++ tags/openfast-0.9.5b/etc/tagVersion.sh 2008-01-11 16:07:21 UTC (rev 115) @@ -1,4 +0,0 @@ -#!/bin/sh -svn propset major.version $1 . -svn propset minor.version $2 . -echo Set version to $1.$2 \ No newline at end of file Deleted: tags/openfast-0.9.5b/license.txt =================================================================== --- trunk/license.txt 2007-12-06 19:43:37 UTC (rev 101) +++ tags/openfast-0.9.5b/license.txt 2008-01-11 16:07:21 UTC (rev 115) @@ -1,18 +0,0 @@ -The contents of this file are subject to the Mozilla Public License -Version 1.1 (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.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is OpenFAST. - -The Initial Developer of the Original Code is The LaSalle Technology -Group, LLC. Portions created by The LaSalle Technology Group, LLC -are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. - -Contributor(s): Jacob Northey <ja...@la...> - Craig Otis <co...@la...> \ No newline at end of file Copied: tags/openfast-0.9.5b/license.txt (from rev 99, trunk/license.txt) =================================================================== --- tags/openfast-0.9.5b/license.txt (rev 0) +++ tags/openfast-0.9.5b/license.txt 2008-01-11 16:07:21 UTC (rev 115) @@ -0,0 +1,18 @@ +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> \ No newline at end of file Deleted: tags/openfast-0.9.5b/pom.xml =================================================================== --- trunk/pom.xml 2007-12-06 19:43:37 UTC (rev 101) +++ tags/openfast-0.9.5b/pom.xml 2008-01-11 16:07:21 UTC (rev 115) @@ -1,148 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.openfast</groupId> - <artifactId>openfast</artifactId> - <packaging>jar</packaging> - <version>0.9.5-SNAPSHOT</version> - - <organization> - <name>The LaSalle Technology Group, LLC</name> - <url>http://www.lasalletech.com</url> - </organization> - - <name>OpenFAST</name> - - <description>OpenFAST is a 100% Java implementation of the FAST Protocol.</description> - - <licenses> - <license> - <name>Mozilla Public License Version 1.1</name> - <url>http://www.mozilla.org/MPL/MPL-1.1.html</url> - <distribution>repo</distribution> - </license> - </licenses> - - <url>http://www.openfast.org</url> - <inceptionYear>2006</inceptionYear> - - <issueManagement> - <system>sourceforge</system> - <url>http://sourceforge.net/tracker/?group_id=198357</url> - </issueManagement> - - <scm> - <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</connection> - <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk/</developerConnection> - <url>http://openfast.svn.sourceforge.net/viewvc/openfast/trunk</url> - </scm> - - <mailingLists> - <mailingList> - <name>OpenFAST Users Mailing List</name> - <subscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-user</subscribe> - <unsubscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-user</unsubscribe> - <archive>https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-user</archive> - <post>ope...@li...</post> - </mailingList> - <mailingList> - <name>OpenFAST Commits Mailing List</name> - <subscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-commit</subscribe> - <unsubscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-commit</unsubscribe> - <archive>https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-commit</archive> - <post>ope...@li...</post> - </mailingList> - <mailingList> - <name>OpenFAST Announcements Mailing List</name> - <subscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-announce</subscribe> - <unsubscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-announce</unsubscribe> - <archive>https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-announce</archive> - <post>ope...@li...</post> - </mailingList> - </mailingLists> - - <build> - <resources> - <resource> - <directory>src/main/resources</directory> - </resource> - <resource> - <directory>src/test/resources</directory> - </resource> - </resources> - <extensions> - <extension> - <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-ssh</artifactId> - <version>1.0-beta-2</version> - </extension> - </extensions> - - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.4</source> - <target>1.4</target> - </configuration> - </plugin> - <plugin> - <artifactId>maven-release-plugin</artifactId> - <configuration> - <tagBase>https://openfast.svn.sourceforge.net/svnroot/openfast/tags</tagBase> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <executions> - <execution> - <id>javadoc</id> - <phase>process-classes</phase> - <goals> - <goal>javadoc</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptors> - <descriptor>src/assembly/source.xml</descriptor> - </descriptors> - </configuration> - <executions> - <execution> - <id>make-assembly</id> - <phase>package</phase> - <goals> - <goal>attached</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.2</version> - </dependency> - </dependencies> - - <distributionManagement> - <repository> - <id>sourceforge.net</id> - <name>Sourceforge.net Repository</name> - <url>scp://shell.sourceforge.net/home/groups/o/op/openfast/maven/release</url> - </repository> - <snapshotRepository> - <id>sourceforge.net</id> - <name>Sourceforge.net Snapshot Repository</name> - <url>scp://shell.sourceforge.net/home/groups/o/op/openfast/maven/snapshot</url> - </snapshotRepository> - </distributionManagement> -</project> \ No newline at end of file Copied: tags/openfast-0.9.5b/pom.xml (from rev 114, trunk/pom.xml) =================================================================== --- tags/openfast-0.9.5b/pom.xml (rev 0) +++ tags/openfast-0.9.5b/pom.xml 2008-01-11 16:07:21 UTC (rev 115) @@ -0,0 +1,188 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openfast</groupId> + <artifactId>openfast</artifactId> + <packaging>jar</packaging> + <version>0.9.5</version> + + <organization> + <name>The LaSalle Technology Group, LLC</name> + <url>http://www.lasalletech.com</url> + </organization> + + <name>OpenFAST</name> + + <description>OpenFAST is a 100% Java implementation of the FAST Protocol.</description> + + <developers> + <developer> + <name>Jacob Northey</name> + <organization>Lasalletech</organization> + <organizationUrl>http://www.lasalletech.com/</organizationUrl> + <roles> + <role>architect</role> + <role>developer</role> + </roles> + <timezone>-5</timezone> + </developer> + <developer> + <name>Craig Otis</name> + <organization>Lasalletech</organization> + <organizationUrl>http://www.lasalletech.com/</organizationUrl> + <roles> + <role>developer</role> + </roles> + <timezone>-5</timezone> + </developer> + </developers> + + <contributors> + <contributor> + <name>Stefan Schwendiman</name> + <organization>Swiss Exchange</organization> + <organizationUrl>http://www.swx.com</organizationUrl> + <roles> + <role>tester</role> + </roles> + <timezone>+1</timezone> + </contributor> + </contributors> + + <licenses> + <license> + <name>Mozilla Public License Version 1.1</name> + <url>http://www.mozilla.org/MPL/MPL-1.1.html</url> + <distribution>repo</distribution> + </license> + </licenses> + + <url>http://www.openfast.org</url> + <inceptionYear>2006</inceptionYear> + + <issueManagement> + <system>sourceforge</system> + <url>http://sourceforge.net/tracker/?group_id=198357</url> + </issueManagement> + + <scm> + <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-0.9.5b</connection> + <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-0.9.5b</developerConnection> + <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-0.9.5b</url> + </scm> + + <mailingLists> + <mailingList> + <name>OpenFAST Users Mailing List</name> + <subscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-user</subscribe> + <unsubscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-user</unsubscribe> + <archive>https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-user</archive> + <post>ope...@li...</post> + </mailingList> + <mailingList> + <name>OpenFAST Commits Mailing List</name> + <subscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-commit</subscribe> + <unsubscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-commit</unsubscribe> + <archive>https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-commit</archive> + <post>ope...@li...</post> + </mailingList> + <mailingList> + <name>OpenFAST Announcements Mailing List</name> + <subscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-announce</subscribe> + <unsubscribe>http://lists.sourceforge.net/mailman/listinfo/openfast-announce</unsubscribe> + <archive>https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-announce</archive> + <post>ope...@li...</post> + </mailingList> + </mailingLists> + + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + </resource> + <resource> + <directory>src/test/resources</directory> + </resource> + </resources> + <extensions> + <extension> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-ssh</artifactId> + <version>1.0-beta-2</version> + </extension> + </extensions> + + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.4</source> + <target>1.4</target> + </configuration> + </plugin> + <plugin> + <artifactId>maven-release-plugin</artifactId> + <configuration> + <tagBase>https://openfast.svn.sourceforge.net/svnroot/openfast/tags</tagBase> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <executions> + <execution> + <id>javadoc</id> + <phase>process-classes</phase> + <goals> + <goal>javadoc</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptors> + <descriptor>src/assembly/source.xml</descriptor> + </descriptors> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals> + <goal>attached</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.2</version> + <scope>test</scope> + </dependency> + </dependencies> + + <distributionManagement> + <repository> + <id>sourceforge.net</id> + <name>Sourceforge.net Repository</name> + <url>scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release</url> + </repository> + <snapshotRepository> + <id>sourceforge.net</id> + <name>Sourceforge.net Snapshot Repository</name> + <url>scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot</url> + </snapshotRepository> + <site> + <id>sourceforge.net</id> + <name>Sourceforge.net OpenFAST Web Site</name> + <url>scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/</url> + </site> + </distributionManagement> +</project> \ No newline at end of file Copied: tags/openfast-0.9.5b/src (from rev 99, trunk/src) Copied: tags/openfast-0.9.5b/src/main/java/org/openfast/MessageBlockReader.java (from rev 101, trunk/src/main/java/org/openfast/MessageBlockReader.java) =================================================================== --- tags/openfast-0.9.5b/src/main/java/org/openfast/MessageBlockReader.java (rev 0) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/MessageBlockReader.java 2008-01-11 16:07:21 UTC (rev 115) @@ -0,0 +1,18 @@ +package org.openfast; + +import java.io.InputStream; + +public interface MessageBlockReader { + + MessageBlockReader NULL = new MessageBlockReader(){ + public boolean readBlock(InputStream in) { + return true; + } + + public void messageRead(InputStream in, Message message) { + }}; + + boolean readBlock(InputStream in); + void messageRead(InputStream in, Message message); + +} Deleted: tags/openfast-0.9.5b/src/main/java/org/openfast/MessageInputStream.java =================================================================== --- trunk/src/main/java/org/openfast/MessageInputStream.java 2007-12-06 17:11:51 UTC (rev 99) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/MessageInputStream.java 2008-01-11 16:07:21 UTC (rev 115) @@ -1,133 +0,0 @@ -/* -The contents of this file are subject to the Mozilla Public License -Version 1.1 (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.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is OpenFAST. - -The Initial Developer of the Original Code is The LaSalle Technology -Group, LLC. Portions created by The LaSalle Technology Group, LLC -are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. - -Contributor(s): Jacob Northey <ja...@la...> - Craig Otis <co...@la...> -*/ - - -package org.openfast; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.openfast.codec.FastDecoder; -import org.openfast.template.MessageTemplate; -import org.openfast.template.TemplateRegisteredListener; -import org.openfast.template.TemplateRegistry; - - -public class MessageInputStream implements MessageStream { - private InputStream in; - private FastDecoder decoder; - private Context context; - private Map templateHandlers = Collections.EMPTY_MAP; - private List handlers = Collections.EMPTY_LIST; - - public MessageInputStream(InputStream inputStream) { - this(inputStream, new Context()); - } - - public MessageInputStream(InputStream inputStream, Context context) { - this.in = inputStream; - this.context = context; - this.decoder = new FastDecoder(context, in); - } - - /** - * @throws java.io.EOFException - * @return the next message in the stream - */ - public Message readMessage() { - if (context.isTraceEnabled()) - context.startTrace(); - - Message message = decoder.readMessage(); - - if (message == null) { - return null; - } - if (!handlers.isEmpty()) { - for (int i=0; i<handlers.size(); i++) { - ((MessageHandler) handlers.get(i)).handleMessage(message, context, decoder); - } - } - if (templateHandlers.containsKey(message.getTemplate())) { - MessageHandler handler = (MessageHandler) templateHandlers.get(message.getTemplate()); - handler.handleMessage(message, context, decoder); - - return readMessage(); - } - - return message; - } - - public void registerTemplate(int templateId, MessageTemplate template) { - context.registerTemplate(templateId, template); - } - - public void close() { - try { - in.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public InputStream getUnderlyingStream() { - return in; - } - - public void addMessageHandler(MessageTemplate template, MessageHandler handler) { - if (templateHandlers == Collections.EMPTY_MAP) { - templateHandlers = new HashMap(); - } - - templateHandlers.put(template, handler); - } - - public void addMessageHandler(MessageHandler handler) { - if (handlers == Collections.EMPTY_LIST) { - handlers = new ArrayList(4); - } - handlers.add(handler); - } - - public void setTemplateRegistry(TemplateRegistry registry) { - context.setTemplateRegistry(registry); - } - - public TemplateRegistry getTemplateRegistry() { - return context.getTemplateRegistry(); - } - - public void addTemplateRegisteredListener(TemplateRegisteredListener templateRegisteredListener) { - } - - public void reset() { - decoder.reset(); - } - - public Context getContext() { - return context; - } -} Copied: tags/openfast-0.9.5b/src/main/java/org/openfast/MessageInputStream.java (from rev 101, trunk/src/main/java/org/openfast/MessageInputStream.java) =================================================================== --- tags/openfast-0.9.5b/src/main/java/org/openfast/MessageInputStream.java (rev 0) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/MessageInputStream.java 2008-01-11 16:07:21 UTC (rev 115) @@ -0,0 +1,145 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> +*/ + + +package org.openfast; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.openfast.codec.FastDecoder; +import org.openfast.template.MessageTemplate; +import org.openfast.template.TemplateRegisteredListener; +import org.openfast.template.TemplateRegistry; + + +public class MessageInputStream implements MessageStream { + private InputStream in; + private FastDecoder decoder; + private Context context; + private Map templateHandlers = Collections.EMPTY_MAP; + private List handlers = Collections.EMPTY_LIST; + private MessageBlockReader blockReader = MessageBlockReader.NULL; + + public MessageInputStream(InputStream inputStream) { + this(inputStream, new Context()); + } + + public MessageInputStream(InputStream inputStream, Context context) { + this.in = inputStream; + this.context = context; + this.decoder = new FastDecoder(context, in); + } + + /** + * @throws java.io.EOFException + * @return the next message in the stream + */ + public Message readMessage() { + if (context.isTraceEnabled()) + context.startTrace(); + + boolean keepReading = blockReader.readBlock(in); + + if (!keepReading) return null; + + Message message = decoder.readMessage(); + + if (message == null) { + return null; + } + + blockReader.messageRead(in, message); + + if (!handlers.isEmpty()) { + for (int i=0; i<handlers.size(); i++) { + ((MessageHandler) handlers.get(i)).handleMessage(message, context, decoder); + } + } + if (templateHandlers.containsKey(message.getTemplate())) { + MessageHandler handler = (MessageHandler) templateHandlers.get(message.getTemplate()); + handler.handleMessage(message, context, decoder); + + return readMessage(); + } + + return message; + } + + public void registerTemplate(int templateId, MessageTemplate template) { + context.registerTemplate(templateId, template); + } + + public void close() { + try { + in.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public InputStream getUnderlyingStream() { + return in; + } + + public void addMessageHandler(MessageTemplate template, MessageHandler handler) { + if (templateHandlers == Collections.EMPTY_MAP) { + templateHandlers = new HashMap(); + } + + templateHandlers.put(template, handler); + } + + public void addMessageHandler(MessageHandler handler) { + if (handlers == Collections.EMPTY_LIST) { + handlers = new ArrayList(4); + } + handlers.add(handler); + } + + public void setTemplateRegistry(TemplateRegistry registry) { + context.setTemplateRegistry(registry); + } + + public TemplateRegistry getTemplateRegistry() { + return context.getTemplateRegistry(); + } + + public void addTemplateRegisteredListener(TemplateRegisteredListener templateRegisteredListener) { + } + + public void reset() { + decoder.reset(); + } + + public Context getContext() { + return context; + } + + public void setBlockReader(MessageBlockReader messageBlockReader) { + this.blockReader = messageBlockReader; + } +} Deleted: tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/IncrementIntegerOperatorCodec.java =================================================================== --- trunk/src/main/java/org/openfast/template/operator/IncrementIntegerOperatorCodec.java 2007-12-06 17:11:51 UTC (rev 99) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/IncrementIntegerOperatorCodec.java 2008-01-11 16:07:21 UTC (rev 115) @@ -1,74 +0,0 @@ -/** - * - */ -package org.openfast.template.operator; - -import org.openfast.NumericValue; -import org.openfast.ScalarValue; -import org.openfast.template.Scalar; -import org.openfast.template.type.Type; - -final class IncrementIntegerOperatorCodec extends OperatorCodec { - private static final long serialVersionUID = 1L; - - IncrementIntegerOperatorCodec(Operator operator, Type[] types) { - super(operator, types); - } - - public ScalarValue getValueToEncode(ScalarValue value, ScalarValue priorValue, Scalar field) { - if (priorValue == null) { - return value; - } - - if (value == null) { - if (field.isOptional()) { - if (priorValue == ScalarValue.UNDEFINED) { - return null; - } - - return ScalarValue.NULL; - } else { - throw new IllegalArgumentException(); - } - } - - if (priorValue.isUndefined()) { - if (value.equals(field.getDefaultValue())) { - return null; - } else { - return value; - } - } - - if (!value.equals(((NumericValue) priorValue).increment())) { - return value; - } - - return null; - } - - public ScalarValue decodeValue(ScalarValue newValue, ScalarValue previousValue, Scalar field) { - return newValue; - } - - public ScalarValue decodeEmptyValue(ScalarValue previousValue, Scalar field) { - if (previousValue == null) return null; - if (previousValue.isUndefined()) { - if (field.getDefaultValue().isUndefined()) { - if (field.isOptional()) { - return null; - } else { - throw new IllegalStateException("Field with operator increment must send a value if no previous value existed."); - } - } else { - return field.getDefaultValue(); - } - } - - return ((NumericValue) previousValue).increment(); - } - - public boolean equals(Object obj) { - return obj != null && obj.getClass() == getClass(); - } -} \ No newline at end of file Copied: tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/IncrementIntegerOperatorCodec.java (from rev 103, trunk/src/main/java/org/openfast/template/operator/IncrementIntegerOperatorCodec.java) =================================================================== --- tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/IncrementIntegerOperatorCodec.java (rev 0) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/IncrementIntegerOperatorCodec.java 2008-01-11 16:07:21 UTC (rev 115) @@ -0,0 +1,73 @@ +/** + * + */ +package org.openfast.template.operator; + +import org.openfast.NumericValue; +import org.openfast.ScalarValue; +import org.openfast.template.Scalar; +import org.openfast.template.type.Type; + +final class IncrementIntegerOperatorCodec extends OperatorCodec { + private static final long serialVersionUID = 1L; + + IncrementIntegerOperatorCodec(Operator operator, Type[] types) { + super(operator, types); + } + + public ScalarValue getValueToEncode(ScalarValue value, ScalarValue priorValue, Scalar field) { + if (priorValue == null) { + return value; + } + + if (value == null) { + if (field.isOptional()) { + if (priorValue == ScalarValue.UNDEFINED && field.getDefaultValue().isUndefined()) { + return null; + } + return ScalarValue.NULL; + } else { + throw new IllegalArgumentException(); + } + } + + if (priorValue.isUndefined()) { + if (value.equals(field.getDefaultValue())) { + return null; + } else { + return value; + } + } + + if (!value.equals(((NumericValue) priorValue).increment())) { + return value; + } + + return null; + } + + public ScalarValue decodeValue(ScalarValue newValue, ScalarValue previousValue, Scalar field) { + return newValue; + } + + public ScalarValue decodeEmptyValue(ScalarValue previousValue, Scalar field) { + if (previousValue == null) return null; + if (previousValue.isUndefined()) { + if (field.getDefaultValue().isUndefined()) { + if (field.isOptional()) { + return null; + } else { + throw new IllegalStateException("Field with operator increment must send a value if no previous value existed."); + } + } else { + return field.getDefaultValue(); + } + } + + return ((NumericValue) previousValue).increment(); + } + + public boolean equals(Object obj) { + return obj != null && obj.getClass() == getClass(); + } +} \ No newline at end of file Deleted: tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/TailOperatorCodec.java =================================================================== --- trunk/src/main/java/org/openfast/template/operator/TailOperatorCodec.java 2007-12-06 17:11:51 UTC (rev 99) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/TailOperatorCodec.java 2008-01-11 16:07:21 UTC (rev 115) @@ -1,91 +0,0 @@ -/** - * - */ -package org.openfast.template.operator; - -import org.openfast.Global; -import org.openfast.ScalarValue; -import org.openfast.StringValue; -import org.openfast.error.FastConstants; -import org.openfast.template.Scalar; -import org.openfast.template.type.Type; - -final class TailOperatorCodec extends OperatorCodec { - private static final long serialVersionUID = 1L; - - TailOperatorCodec(Operator operator, Type[] types) { - super(operator, types); - } - - public ScalarValue getValueToEncode(ScalarValue value, ScalarValue priorValue, Scalar field) { - if (value == null) { - return ScalarValue.NULL; - } - - if (priorValue == null) { - return value; - } - - if (priorValue.isUndefined()) { - priorValue = field.getBaseValue(); - } - - int index = 0; - - byte[] val = value.getBytes(); - byte[] prior = priorValue.getBytes(); - - if (val.length > prior.length) - return value; - - while (index < val.length && val[index] == prior[index]) - index++; - if (val.length == index) - return null; - return (ScalarValue) field.createValue(new String(val, index, val.length-index)); - } - - public ScalarValue decodeValue(ScalarValue newValue, - ScalarValue previousValue, Scalar field) { - StringValue base; - - if ((previousValue == null) && !field.isOptional()) { - Global.handleError(FastConstants.D6_MNDTRY_FIELD_NOT_PRESENT, - ""); - - return null; - } else if ((previousValue == null) || - previousValue.isUndefined()) { - base = (StringValue) field.getBaseValue(); - } else { - base = (StringValue) previousValue; - } - - if ((newValue == null) || newValue.isNull()) { - if (field.isOptional()) { - return null; - } else { - throw new IllegalArgumentException(""); - } - } - - String delta = ((StringValue) newValue).value; - int length = Math.max(base.value.length() - delta.length(), 0); - String root = base.value.substring(0, length); - - return new StringValue(root + delta); - } - - public ScalarValue decodeEmptyValue(ScalarValue previousValue, - Scalar field) { - if (previousValue.isUndefined()) { - return field.getBaseValue(); - } - - return previousValue; - } - - public boolean equals(Object obj) { - return obj != null && obj.getClass() == getClass(); - } -} \ No newline at end of file Copied: tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/TailOperatorCodec.java (from rev 110, trunk/src/main/java/org/openfast/template/operator/TailOperatorCodec.java) =================================================================== --- tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/TailOperatorCodec.java (rev 0) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/template/operator/TailOperatorCodec.java 2008-01-11 16:07:21 UTC (rev 115) @@ -0,0 +1,93 @@ +/** + * + */ +package org.openfast.template.operator; + +import org.openfast.Global; +import org.openfast.ScalarValue; +import org.openfast.StringValue; +import org.openfast.error.FastConstants; +import org.openfast.template.Scalar; +import org.openfast.template.type.Type; + +final class TailOperatorCodec extends OperatorCodec { + private static final long serialVersionUID = 1L; + + TailOperatorCodec(Operator operator, Type[] types) { + super(operator, types); + } + + public ScalarValue getValueToEncode(ScalarValue value, ScalarValue priorValue, Scalar field) { + if (value == null) { + if (priorValue == null) + return null; + if (priorValue.isUndefined() && field.getDefaultValue().isUndefined()) + return null; + return ScalarValue.NULL; + } + + if (priorValue == null) { + return value; + } + + if (priorValue.isUndefined()) { + priorValue = field.getBaseValue(); + } + + int index = 0; + + byte[] val = value.getBytes(); + byte[] prior = priorValue.getBytes(); + + if (val.length > prior.length) + return value; + if (val.length < prior.length) + Global.handleError(FastConstants.D3_CANT_ENCODE_VALUE, "The value " + val + " cannot be encoded by a tail operator with previous value " + priorValue); + + while (index < val.length && val[index] == prior[index]) + index++; + if (val.length == index) + return null; + return (ScalarValue) field.createValue(new String(val, index, val.length-index)); + } + + public ScalarValue decodeValue(ScalarValue newValue, ScalarValue previousValue, Scalar field) { + StringValue base; + + if ((previousValue == null) && !field.isOptional()) { + Global.handleError(FastConstants.D6_MNDTRY_FIELD_NOT_PRESENT, ""); + return null; + } else if ((previousValue == null) || previousValue.isUndefined()) { + base = (StringValue) field.getBaseValue(); + } else { + base = (StringValue) previousValue; + } + + if ((newValue == null) || newValue.isNull()) { + if (field.isOptional()) { + return null; + } else { + throw new IllegalArgumentException(""); + } + } + + String delta = ((StringValue) newValue).value; + int length = Math.max(base.value.length() - delta.length(), 0); + String root = base.value.substring(0, length); + + return new StringValue(root + delta); + } + + public ScalarValue decodeEmptyValue(ScalarValue previousValue, Scalar field) { + ScalarValue value = previousValue; + if (value != null && value.isUndefined()) + value = (field.getDefaultValue().isUndefined()) ? null : field.getDefaultValue(); + if (value == null && !field.isOptional()) + Global.handleError(FastConstants.D6_MNDTRY_FIELD_NOT_PRESENT, "The field " + field + " was not present."); + return value; + } + + public boolean equals(Object obj) { + return obj != null && obj.getClass() == getClass(); + } +} \ No newline at end of file Deleted: tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/AsciiString.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/AsciiString.java 2007-12-06 17:11:51 UTC (rev 99) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/AsciiString.java 2008-01-11 16:07:21 UTC (rev 115) @@ -1,103 +0,0 @@ -/* -The contents of this file are subject to the Mozilla Public License -Version 1.1 (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.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is OpenFAST. - -The Initial Developer of the Original Code is The LaSalle Technology -Group, LLC. Portions created by The LaSalle Technology Group, LLC -are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. - -Contributor(s): Jacob Northey <ja...@la...> - Craig Otis <co...@la...> -*/ - - -/** - * - */ -package org.openfast.template.type.codec; - -import org.openfast.ByteUtil; -import org.openfast.Global; -import org.openfast.ScalarValue; -import org.openfast.StringValue; -import org.openfast.error.FastConstants; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - - -final class AsciiString extends TypeCodec { - private static final long serialVersionUID = 1L; - - AsciiString() { } - - /** - * Takes a ScalarValue object, and converts it to a byte array - * @param value The ScalarValue to be encoded - * @return Returns a byte array of the passed object - */ - public byte[] encodeValue(ScalarValue value) { - if ((value == null) || value.isNull()) { - throw new IllegalStateException("Only nullable strings can represent null values."); - } - - String string = value.toString(); - - if ((string != null) && (string.length() == 0)) { - return TypeCodec.NULL_VALUE_ENCODING; - } - - return string.getBytes(); - } - - /** - * Reads in a stream of data and stores it to a StringValue object - * @param in The InputStream to be decoded - * @return Returns a new StringValue object with the data stream as a String - */ - public ScalarValue decode(InputStream in) { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - int byt; - - try { - do { - byt = in.read(); - buffer.write(byt); - } while ((byt & 0x80) == 0); - } catch (IOException e) { - throw new RuntimeException(e); - } - - byte[] bytes = buffer.toByteArray(); - bytes[bytes.length - 1] &= 0x7f; - - if (bytes[0] == 0) { - if (!ByteUtil.isEmpty(bytes)) - Global.handleError(FastConstants.R9_STRING_OVERLONG, null); - return new StringValue(""); - } - - return new StringValue(new String(bytes)); - } - - /** - * @return Returns a new StringValue object with the passed value - */ - public ScalarValue fromString(String value) { - return new StringValue(value); - } - - public boolean equals(Object obj) { - return obj != null && obj.getClass() == getClass(); - } -} Copied: tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/AsciiString.java (from rev 105, trunk/src/main/java/org/openfast/template/type/codec/AsciiString.java) =================================================================== --- tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/AsciiString.java (rev 0) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/AsciiString.java 2008-01-11 16:07:21 UTC (rev 115) @@ -0,0 +1,109 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> +*/ + + +/** + * + */ +package org.openfast.template.type.codec; + +import org.openfast.ByteUtil; +import org.openfast.Global; +import org.openfast.ScalarValue; +import org.openfast.StringValue; +import org.openfast.error.FastConstants; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + + +final class AsciiString extends TypeCodec { + private static final long serialVersionUID = 1L; + private static final String ZERO_TERMINATOR = "\u0000"; + private static final byte[] ZERO_PREAMBLE = new byte[] { 0, 0 }; + + AsciiString() { } + + /** + * Takes a ScalarValue object, and converts it to a byte array + * @param value The ScalarValue to be encoded + * @return Returns a byte array of the passed object + */ + public byte[] encodeValue(ScalarValue value) { + if ((value == null) || value.isNull()) { + throw new IllegalStateException("Only nullable strings can represent null values."); + } + + String string = value.toString(); + + if ((string != null) && (string.length() == 0)) { + return TypeCodec.NULL_VALUE_ENCODING; + } + if (string.startsWith(ZERO_TERMINATOR)) { + return ZERO_PREAMBLE; + } + return string.getBytes(); + } + + /** + * Reads in a stream of data and stores it to a StringValue object + * @param in The InputStream to be decoded + * @return Returns a new StringValue object with the data stream as a String + */ + public ScalarValue decode(InputStream in) { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + int byt; + + try { + do { + byt = in.read(); + buffer.write(byt); + } while ((byt & 0x80) == 0); + } catch (IOException e) { + throw new RuntimeException(e); + } + + byte[] bytes = buffer.toByteArray(); + bytes[bytes.length - 1] &= 0x7f; + + if (bytes[0] == 0) { + if (!ByteUtil.isEmpty(bytes)) + Global.handleError(FastConstants.R9_STRING_OVERLONG, null); + if (bytes.length > 1 && bytes[1] == 0) + return new StringValue("\u0000"); + return new StringValue(""); + } + + return new StringValue(new String(bytes)); + } + + /** + * @return Returns a new StringValue object with the passed value + */ + public ScalarValue fromString(String value) { + return new StringValue(value); + } + + public boolean equals(Object obj) { + return obj != null && obj.getClass() == getClass(); + } +} Deleted: tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java 2007-12-06 17:11:51 UTC (rev 99) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java 2008-01-11 16:07:21 UTC (rev 115) @@ -1,126 +0,0 @@ -/* -The contents of this file are subject to the Mozilla Public License -Version 1.1 (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.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is OpenFAST. - -The Initial Developer of the Original Code is The LaSalle Technology -Group, LLC. Portions created by The LaSalle Technology Group, LLC -are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. - -Contributor(s): Jacob Northey <ja...@la...> - Craig Otis <co...@la...> -*/ - - -/** - * - */ -package org.openfast.template.type.codec; - -import org.openfast.ByteUtil; -import org.openfast.Global; -import org.openfast.ScalarValue; -import org.openfast.StringValue; -import org.openfast.error.FastConstants; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - - -final class NullableAsciiString extends TypeCodec { - private static final long serialVersionUID = 1L; - private static final byte[] NULLABLE_EMPTY_STRING = new byte[] { 0x00, 0x00 }; - - NullableAsciiString() { } - - /** - * Takes a ScalarValue object, and converts it to a byte array - * @param value The ScalarValue to be encoded - * @return Returns a byte array of the passed object - */ - public byte[] encodeValue(ScalarValue value) { - if (value.isNull()) { - return TypeCodec.NULL_VALUE_ENCODING; - } - - String string = ((StringValue) value).value; - - if ((string != null) && (string.length() == 0)) { - return NULLABLE_EMPTY_STRING; - } - - return string.getBytes(); - } - - /** - * Reads in a stream of data and stores it to a StringValue object - * @param in The InputStream to be decoded - * @return Returns a new StringValue object with the data stream as a String - */ - public ScalarValue decode(InputStream in) { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - int byt; - - try { - do { - byt = in.read(); - buffer.write(byt); - } while ((byt & 0x80) == 0); - } catch (IOException e) { - throw new RuntimeException(e); - } - - byte[] bytes = buffer.toByteArray(); - bytes[bytes.length - 1] &= 0x7f; - - if (bytes[0] == 0) { - if (!ByteUtil.isEmpty(bytes)) - Global.handleError(FastConstants.R9_STRING_OVERLONG, null); - if ((bytes.length == 1)) { - return null; - } else { - return new StringValue(""); - } - } - - return new StringValue(new String(bytes)); - } - - /** - * Creates a new StringValue object - * @param value The string to be value of the new object - * @return Returns a new StringValue object with the passed string as its - * parameter - */ - public ScalarValue fromString(String value) { - return new StringValue(value); - } - - /** - * - * @return Returns an empty StringValue object - */ - public ScalarValue getDefaultValue() { - return new StringValue(""); - } - - /** - * @return Returns true - */ - public boolean isNullable() { - return true; - } - - public boolean equals(Object obj) { - return obj != null && obj.getClass() == getClass(); - } -} Copied: tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java (from rev 105, trunk/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java) =================================================================== --- tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java (rev 0) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java 2008-01-11 16:07:21 UTC (rev 115) @@ -0,0 +1,131 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> +*/ + + +/** + * + */ +package org.openfast.template.type.codec; + +import org.openfast.ByteUtil; +import org.openfast.Global; +import org.openfast.ScalarValue; +import org.openfast.StringValue; +import org.openfast.error.FastConstants; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + + +final class NullableAsciiString extends TypeCodec { + private static final long serialVersionUID = 1L; + private static final byte[] NULLABLE_EMPTY_STRING = new byte[] { 0x00, 0x00 }; + private static final byte[] ZERO_ENCODING = new byte[] { 0x00, 0x00, 0x00 }; + + NullableAsciiString() { } + + /** + * Takes a ScalarValue object, and converts it to a byte array + * @param value The ScalarValue to be encoded + * @return Returns a byte array of the passed object + */ + public byte[] encodeValue(ScalarValue value) { + if (value.isNull()) { + return TypeCodec.NULL_VALUE_ENCODING; + } + + String string = ((StringValue) value).value; + + if ((string != null) && (string.length() == 0)) { + return NULLABLE_EMPTY_STRING; + } + + if (string.startsWith("\u0000")) + return ZERO_ENCODING; + return string.getBytes(); + } + + /** + * Reads in a stream of data and stores it to a StringValue object + * @param in The InputStream to be decoded + * @return Returns a new StringValue object with the data stream as a String + */ + public ScalarValue decode(InputStream in) { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + int byt; + + try { + do { + byt = in.read(); + buffer.write(byt); + } while ((byt & 0x80) == 0); + } catch (IOException e) { + throw new RuntimeException(e); + } + + byte[] bytes = buffer.toByteArray(); + bytes[bytes.length - 1] &= 0x7f; + + if (bytes[0] == 0) { + if (!ByteUtil.isEmpty(bytes)) + Global.handleError(FastConstants.R9_STRING_OVERLONG, null); + if ((bytes.length == 1)) { + return null; + } else if (bytes.length == 2 && bytes[1] == 0){ + return new StringValue(""); + } else if (bytes.length == 3 && bytes[2] == 0) { + return new StringValue("\u0000"); + } + } + + return new StringValue(new String(bytes)); + } + + /** + * Creates a new StringValue object + * @param value The string to be value of the new object + * @return Returns a new StringValue object with the passed string as its + * parameter + */ + public ScalarValue fromString(String value) { + return new StringValue(value); + } + + /** + * + * @return Returns an empty StringValue object + */ + public ScalarValue getDefaultValue() { + return new StringValue(""); + } + + /** + * @return Returns true + */ + public boolean isNullable() { + return true; + } + + public boolean equals(Object obj) { + return obj != null && obj.getClass() == getClass(); + } +} Deleted: tags/openfast-0.9.5b/src/main/java/org/openfast/util/RecordingInputStream.java =================================================================== --- trunk/src/main/java/org/openfast/util/RecordingInputStream.java 2007-12-06 17:11:51 UTC (rev 99) +++ tags/openfast-0.9.5b/src/main/java/org/openfast/util/RecordingInputStream.java 2008-01-11 16:07:21 UTC (rev 115) @@ -1,62 +0,0 @@ -/* -The contents of this file are subject to the Mozilla Public License -Version 1.1 (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.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is OpenFAST. - -The Initial Developer of the Original Code is The LaSalle Technology -Group, LLC. Portions created by The LaSalle Technology Group, LLC -are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. - -Contributor(s): Jacob Northey <ja...@la...> - Craig Otis <co...@la...> -*/ - - -package org.openfast.util; - -import org.openfast.ByteUtil; - -import java.io.IOException; -import java.io.InputStream; - - -public class RecordingInputStream extends InputStream { - private byte[] buffer = new byte[1024]; - private int index = 0; - private InputStream in; - - public RecordingInputStream(InputStream inputStream) { - this.in = inputStream; - } - - - public int read() throws IOException { - int read = in.read(); - buffer[index++] = (byte) read; - - return read; - } - - public String toString() { - return ByteUtil.convertByteArrayToBitString(buffer, index); - } - - public byte[] getBuffer() { - byte[] b = new byte[index]; - System.arraycopy(buffer, 0, b, 0, index); - - return b; - } - - public void clear() { - index = 0; - } -} Copied: tags/openfast-0.9.5b/src/main/java/org/openfast/util/RecordingInputStream.java (from rev 104, trunk/src/main/java/org/openfast/util/RecordingInputStream.java) =========================... [truncated message content] |