KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jts > CosTransactions > LogRestartDescriptor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28
29 //----------------------------------------------------------------------------
30
//
31
// Module: LogRestartDescriptor.java
32
//
33
// Description: Log restart record.
34
//
35
// Product: com.sun.jts.CosTransactions
36
//
37
// Author: Simon Holdsworth
38
//
39
// Date: March, 1997
40
//
41
// Copyright (c): 1995-1997 IBM Corp.
42
//
43
// The source code for this program is not published or otherwise divested
44
// of its trade secrets, irrespective of what has been deposited with the
45
// U.S. Copyright Office.
46
//
47
// This software contains confidential and proprietary information of
48
// IBM Corp.
49
//----------------------------------------------------------------------------
50

51 package com.sun.jts.CosTransactions;
52
53 import java.io.*;
54
55 /**
56  * A class containing restart information.
57  *
58  * @version 0.01
59  *
60  * @author Simon Holdsworth, IBM Corporation
61  *
62  * @see LogHandle
63  */

64 class LogRestartDescriptor implements Serializable {
65     /**
66      *This constant holds the size of the LogRestartDecriptor object.
67      */

68     final static int SIZEOF = 12;
69
70     int restartValid = 0;
71     int restartDataLength = 0;
72     int timeStamp = 0;
73
74     /**
75      * Default LogRestartDescriptor constructor.
76      *
77      * @param
78      *
79      * @return
80      *
81      * @see
82      */

83     LogRestartDescriptor() {}
84
85     /**
86      * Constructs a LogRestartDescriptor from the given byte array.
87      *
88      * @param bytes The array of bytes from which the object is
89      * to be constructed.
90      * @param index The index in the array where copy is to start.
91      *
92      * @return
93      *
94      * @see
95      */

96     LogRestartDescriptor(byte[] bytes, int index) {
97         restartValid = (bytes[index++]&255) +
98                         ((bytes[index++]&255) << 8) +
99                         ((bytes[index++]&255) << 16) +
100                         ((bytes[index++]&255) << 24);
101
102         restartDataLength = (bytes[index++]&255) +
103                             ((bytes[index++]&255) << 8) +
104                             ((bytes[index++]&255) << 16) +
105                             ((bytes[index++]&255) << 24);
106
107         timeStamp = (bytes[index++]&255) +
108                     ((bytes[index++]&255) << 8) +
109                     ((bytes[index++]&255) << 16) +
110                     ((bytes[index++]&255) << 24);
111     }
112
113     /**
114      * Makes a byte representation of the LogRestartDescriptor.
115      *
116      * @param bytes The array of bytes into which the object is to be copied.
117      * @param index The index in the array where copy is to start.
118      *
119      * @return Number of bytes copied.
120      *
121      * @see
122      */

123     final int toBytes(byte[] bytes, int index) {
124         bytes[index++] = (byte) restartValid;
125         bytes[index++] = (byte)(restartValid >> 8);
126         bytes[index++] = (byte)(restartValid >> 16);
127         bytes[index++] = (byte)(restartValid >> 24);
128         bytes[index++] = (byte) restartDataLength;
129         bytes[index++] = (byte)(restartDataLength >> 8);
130         bytes[index++] = (byte)(restartDataLength >> 16);
131         bytes[index++] = (byte)(restartDataLength >> 24);
132         bytes[index++] = (byte) timeStamp;
133         bytes[index++] = (byte)(timeStamp >> 8);
134         bytes[index++] = (byte)(timeStamp >> 16);
135         bytes[index++] = (byte)(timeStamp >> 24);
136
137         return SIZEOF;
138     }
139
140     /**
141      * Determines whether the target object is equal to the parameter.
142      *
143      * @param other The other LogRestartDescriptor to be compared.
144      *
145      * @return Indicates whether the objects are equal.
146      *
147      * @see
148      */

149     final boolean equals(LogRestartDescriptor other) {
150         return (restartValid == other.restartValid &&
151                 restartDataLength == other.restartDataLength &&
152                 timeStamp == other.timeStamp);
153     }
154
155     /**
156      * This method is called to direct the object to format its state
157      * to a String.
158      *
159      * @param
160      *
161      * @return The formatted representation of the object.
162      *
163      * @see
164      */

165     public final String JavaDoc toString() {
166         return "LRD(valid="/*#Frozen*/ + restartValid +
167                ",len="/*#Frozen*/ + restartDataLength +
168                ",time="/*#Frozen*/ + timeStamp + ")"/*#Frozen*/;
169     }
170 }
171
Popular Tags