1 3 package org.jgroups.protocols; 4 5 6 import org.jgroups.Message; 7 8 import java.io.Serializable ; 9 10 11 12 18 public class TransportedVectorTime implements Serializable 19 { 20 23 int senderPosition; 24 25 28 int[] values; 29 30 33 private transient Message m; 34 35 38 public TransportedVectorTime() 39 { 40 } 41 42 48 public TransportedVectorTime(int senderIndex, int[] values) 49 { 50 this.values = values; 51 this.senderPosition = senderIndex; 52 } 53 54 58 public int getSenderIndex() 59 { 60 return senderPosition; 61 } 62 63 67 public int[] getValues() 68 { 69 return values; 70 } 71 72 76 public int size() 77 { 78 return values.length; 79 } 80 81 85 public void setAssociatedMessage(Message owner) 86 { 87 m = owner; 88 } 89 90 94 public Message getAssociatedMessage() 95 { 96 return m; 97 } 98 99 100 112 public boolean lessThanOrEqual(TransportedVectorTime other) 113 { 114 int[] b = other.getValues(); 115 int[] a = values; 116 for (int k = 0; k < a.length; k++) 117 { 118 119 if (a[k] <= b[k]) 120 continue; 121 else 122 return false; 123 } 124 return true; 125 } 126 127 137 public boolean equals(TransportedVectorTime other) 138 { 139 int a [] = getValues(); 140 int b [] = other.getValues(); 141 142 for (int i = 0; i < a.length; i++) 143 if (a[i] != b[i]) return false; 144 145 return true; 146 } 147 148 152 public String toString() 153 { 154 String classType = "TransportedVectorTime["; 155 int bufferLength = classType.length() + values.length * 2 + 1; 156 StringBuffer buf = new StringBuffer (bufferLength); 157 buf.append(classType); 158 for (int i = 0; i < values.length - 1; i++) 159 { 160 buf.append(values[i]).append(','); 161 } 162 buf.append(values[values.length - 1]); 163 buf.append(']'); 164 return buf.toString(); 165 } 166 } 167 | Popular Tags |