001: /*
002: * Copyright (c) 2004 JETA Software, Inc. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without modification,
005: * are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of JETA Software nor the names of its contributors may
015: * be used to endorse or promote products derived from this software without
016: * specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
021: * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
022: * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
023: * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
024: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
025: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
026: * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: */
029:
030: package com.jeta.forms.store.memento;
031:
032: import java.io.Externalizable;
033: import java.io.IOException;
034:
035: /**
036: * This class is used to provide a version stamp to a forms file. This is not
037: * the version of the forms designer product. Rather, this allows the runtime to
038: * check the form file version. If this is an older runtime that is trying to
039: * load a file stored with a more recent, incompatible runtime, an error message
040: * can be displayed to the user.
041: *
042: * Incompatible changes should be marked by an increase in the major version
043: * number. Changes to the minor and sub versions should be reserved for bug
044: * fixes or changes that can be loaded and safely ignored by older runtimes.
045: *
046: * @deprecated. Use FormsVersion2
047: * @author Jeff Tassin
048: */
049: public class FormsVersion implements Externalizable, Comparable {
050: /**
051: * The version of this class.
052: */
053: public static final int VERSION = 1;
054:
055: /**
056: * The version of the forms runtime file. Update these values when the forms
057: * runtime is changed.
058: */
059: private int m_major = 1;
060: private int m_minor = 3;
061: private int m_sub = 0;
062:
063: /**
064: * Comparable implementation
065: */
066: public int compareTo(Object o) {
067: if (o instanceof FormsVersion) {
068: FormsVersion version = (FormsVersion) o;
069: if (m_major > version.m_major)
070: return 1;
071: else if (m_major < version.m_major)
072: return -1;
073: else {
074: /** major versions are the same, check minor */
075: if (m_minor > version.m_minor)
076: return 1;
077: else if (m_minor < version.m_minor)
078: return -1;
079: else {
080: /** major and minor versions are the same, check sub */
081: if (m_sub > version.m_sub)
082: return 1;
083: else if (m_sub < version.m_sub)
084: return -1;
085: else
086: return 0; // versions are equal
087: }
088: }
089: } else {
090: return -1;
091: }
092:
093: }
094:
095: /**
096: * Externalizable Implementation
097: */
098: public void readExternal(java.io.ObjectInput in)
099: throws ClassNotFoundException, IOException {
100: int classversion = in.readInt();
101: m_major = in.readInt();
102: m_minor = in.readInt();
103: m_sub = in.readInt();
104: }
105:
106: /**
107: * Externalizable Implementation
108: */
109: public void writeExternal(java.io.ObjectOutput out)
110: throws IOException {
111: out.writeInt(VERSION);
112: out.writeInt(m_major);
113: out.writeInt(m_minor);
114: out.writeInt(m_sub);
115: }
116:
117: public String toString() {
118: return m_major + "." + m_minor + "." + m_sub;
119: }
120: }
|