1 16 17 20 21 package org.apache.axis.attachments; 22 23 24 import org.apache.axis.utils.Messages; 25 26 27 30 31 32 public final class DimeTypeNameFormat { 33 private byte format = 0; 34 private DimeTypeNameFormat() {} 35 private DimeTypeNameFormat(byte f) { 36 format = f; 37 } 38 static final byte NOCHANGE_VALUE = 0x00; static final byte MIME_VALUE = 0x01; static final byte URI_VALUE = 0x02; static final byte UNKNOWN_VALUE = 0x03; static final byte NODATA_VALUE = 0x04; 45 static final DimeTypeNameFormat NOCHANGE = 46 new DimeTypeNameFormat(NOCHANGE_VALUE); 47 48 public static final DimeTypeNameFormat MIME= 49 new DimeTypeNameFormat(MIME_VALUE); 50 51 public static final DimeTypeNameFormat URI= 52 new DimeTypeNameFormat(URI_VALUE); 53 54 public static final DimeTypeNameFormat UNKNOWN= 55 new DimeTypeNameFormat(UNKNOWN_VALUE); 56 57 static final DimeTypeNameFormat NODATA= 58 new DimeTypeNameFormat(NODATA_VALUE); 59 60 private static String [] toEnglish = {"NOCHANGE", "MIME", "URI", 61 "UNKNOWN", "NODATA"}; 62 private static DimeTypeNameFormat[] fromByte = {NOCHANGE, MIME, 63 URI, UNKNOWN, NODATA}; 64 65 public final String toString() { 66 return toEnglish[format]; 67 } 68 69 public final byte toByte() { 70 return format; 71 } 72 73 public int hashCode() { 74 return (int) format; 75 } 76 77 public final boolean equals(final Object x) { 78 if (x == null) { 79 return false; 80 } 81 if (!(x instanceof DimeTypeNameFormat)) { 82 return false; 83 } 84 return ((DimeTypeNameFormat) x).format == this.format; 85 } 86 87 public static DimeTypeNameFormat parseByte(byte x) { 88 if (x < 0 || x > fromByte.length) { 89 throw new IllegalArgumentException (Messages.getMessage( 90 "attach.DimeStreamBadType", "" + x)); 91 } 92 return fromByte[x]; 93 } 94 95 public static DimeTypeNameFormat parseByte(Byte x) { 96 return parseByte(x.byteValue()); 97 } 98 } 99 | Popular Tags |