1 48 49 package org.exolab.jms.message; 50 51 import java.io.Externalizable ; 52 import java.io.IOException ; 53 import java.io.ObjectInput ; 54 import java.io.ObjectOutput ; 55 56 import javax.jms.JMSException ; 57 58 59 65 public class Priority implements Externalizable { 66 67 static final long serialVersionUID = 1; 69 70 private int priority_ = 0; 71 72 public Priority() { 73 74 } 75 76 public Priority(int priority) throws JMSException { 77 if (priority >= 0 && priority < 10) { 78 priority_ = priority; 79 } else { 80 throw new JMSException ("Invalid priority"); 81 } 82 } 83 84 85 public void writeExternal(ObjectOutput out) throws IOException { 87 out.writeLong(serialVersionUID); 88 out.writeInt(priority_); 89 } 90 91 92 public void readExternal(ObjectInput in) 94 throws IOException , ClassNotFoundException { 95 long version = in.readLong(); 96 if (version == serialVersionUID) { 97 priority_ = in.readInt(); 98 } else { 99 throw new IOException ("Incorrect version enountered: " + 100 version + " This version = " + 101 serialVersionUID); 102 } 103 } 104 105 106 public int getPriority() { 107 return priority_; 108 } 109 110 public boolean isExpedited() { 112 return (priority_ >= 5 ? true : false); 113 } 114 115 public boolean isGreater(Priority toCompare) { 117 return (priority_ > toCompare.priority_); 118 } 119 120 public boolean isEqual(Priority toCompare) { 122 return (priority_ == toCompare.priority_); 123 } 124 } 125 126 | Popular Tags |