home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / ccs_util.jar / com / commerceone / util / identity / StringIdentity.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-12-09  |  1.4 KB  |  41 lines

  1. package com.commerceone.util.identity;
  2.  
  3. public class StringIdentity implements Identity {
  4.    private final String m_identity;
  5.  
  6.    public String toString() {
  7.       return this.m_identity;
  8.    }
  9.  
  10.    public int hashCode() {
  11.       return this.m_identity.hashCode();
  12.    }
  13.  
  14.    public StringIdentity(String identity) {
  15.       this.m_identity = identity;
  16.    }
  17.  
  18.    public boolean equals(Object obj) {
  19.       return !(obj instanceof StringIdentity) ? false : this.m_identity.equals(obj.toString());
  20.    }
  21.  
  22.    public byte[] toBytes() {
  23.       byte[] bytes = new byte[this.m_identity.length() * 2];
  24.  
  25.       for(int i = 0; i < this.m_identity.length(); ++i) {
  26.          byte lowbyte = (byte)(this.m_identity.charAt(i) & 255);
  27.          int highbyteI = this.m_identity.charAt(i) & 255;
  28.          highbyteI <<= 8;
  29.          byte highbyte = (byte)highbyteI;
  30.          bytes[i * 2] = lowbyte;
  31.          bytes[i * 2 + 1] = highbyte;
  32.       }
  33.  
  34.       return bytes;
  35.    }
  36.  
  37.    public int formatHint() {
  38.       return 0;
  39.    }
  40. }
  41.