KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jass > as > ActivityIdImpl


1 /**
2  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3  -
4  - JASS: Java Advanced tranSaction Support
5  -
6  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7  -
8  - This module was originally developed by
9  -
10  - LSD (Distributed Systems Lab, http://lsd.ls.fi.upm.es/lsd/lsd.htm)
11  - at Universidad Politecnica de Madrid (UPM) as an ObjectWeb Consortium
12  - (http://www.objectweb.org) project.
13  -
14  - This project has been partially funded by the European Commission under
15  - the IST programme of V FP grant IST-2001-37126 and by the Spanish
16  - Ministry of Science & Technology (MCyT) grants TIC2002-10376-E and
17  - TIC2001-1586-C03-02
18  -
19  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
20  - The original code and portions created by LSD are
21  - Copyright (c) 2004 LSD (UPM)
22  - All rights reserved.
23  -
24  - Redistribution and use in source and binary forms, with or without
25  - modification, are permitted provided that the following conditions are met:
26  -
27  - -Redistributions of source code must retain the above copyright notice, this
28  - list of conditions and the following disclaimer.
29  -
30  - -Redistributions in binary form must reproduce the above copyright notice,
31  - this list of conditions and the following disclaimer in the documentation
32  - and/or other materials provided with the distribution.
33  -
34  - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
35  - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36  - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37  - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
38  - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
39  - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
40  - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
41  - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
42  - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
43  - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44  - POSSIBILITY OF SUCH DAMAGE.
45  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46  -
47  - Author: Francisco Perez Sorrosal (frperezs)
48  -
49  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50 */

51
52 package org.objectweb.jass.as;
53
54 import javax.activity.GlobalId JavaDoc;
55
56 /**
57  * Activity identifier representation.
58  * @author fran
59  * Date: Feb 16, 2004
60  * org.objectweb.jass.asActivityIdImpl.java
61  */

62 public class ActivityIdImpl implements GlobalId JavaDoc, java.io.Serializable JavaDoc {
63
64     // Unique Activity Id
65
private byte[] id = null;
66
67     // Constructors -----------------------------------------------------------
68

69     /**
70      * Constructor
71      * @param globalId
72      */

73     public ActivityIdImpl(byte[] globalId) {
74         this.id = globalId;
75     }
76
77     // Implements GlobalId ----------------------------------------------------
78

79     /**
80      * Returns a printable String that identifies the Activity. This is used
81      * for debug and servicability purposes.
82      * @return A printable String that identifies the Activity.
83      */

84     public byte[] toBytes() {
85         return id;
86     }
87
88     /**
89      * Compare for equality. Instances are considered equal if they are both
90      * instances of ActivityIdImpl, and if they have the same global activity id
91      * @return true or false
92      */

93     public boolean equals(Object JavaDoc obj) {
94         if (obj == this)
95             return true;
96         if (obj instanceof ActivityIdImpl) {
97             ActivityIdImpl other = (ActivityIdImpl) obj;
98
99             if (id.length != other.id.length)
100                 return false;
101
102             for (int i = 0; i < id.length; ++i)
103                 if (id[i] != other.id[i])
104                     return false;
105
106             return true;
107         }
108         return false;
109     }
110
111     /**
112      * Returns a byte array representation of the GlobalId. This is exactly
113      * equivalent to the buffer value of the org.omg.CosActivity.GlobalId which
114      * is defined in the OMG Activity service specification as a sequence of
115      * octets.
116      * @return a byte array that uniquely identifies the Activity across the
117      * namespace.
118      */

119     public java.lang.String JavaDoc print() {
120         if (id == null)
121             return "[NULL ActivityId]";
122         // The http:// prefix is added to satisfy URI requirements (WSCAF)
123
String JavaDoc s = "http://" + new String JavaDoc(id);
124
125         return s;
126     }
127 }
128
Popular Tags