1 8 package org.jboss.axis.attachments; 9 10 11 import org.jboss.axis.utils.Messages; 12 13 14 17 18 19 public final class DimeTypeNameFormat 20 { 21 private byte format = 0; 22 23 private DimeTypeNameFormat() 24 { 25 } 26 27 private DimeTypeNameFormat(byte f) 28 { 29 format = f; 30 } 31 32 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; 39 static final DimeTypeNameFormat NOCHANGE = 40 new DimeTypeNameFormat(NOCHANGE_VALUE); 41 42 public static final DimeTypeNameFormat MIME = 43 new DimeTypeNameFormat(MIME_VALUE); 44 45 public static final DimeTypeNameFormat URI = 46 new DimeTypeNameFormat(URI_VALUE); 47 48 public static final DimeTypeNameFormat UNKNOWN = 49 new DimeTypeNameFormat(UNKNOWN_VALUE); 50 51 static final DimeTypeNameFormat NODATA = 52 new DimeTypeNameFormat(NODATA_VALUE); 53 54 private static String [] toEnglish = {"NOCHANGE", "MIME", "URI", 55 "UNKNOWN", "NODATA"}; 56 private static DimeTypeNameFormat[] fromByte = {NOCHANGE, MIME, 57 URI, UNKNOWN, NODATA}; 58 59 public final String toString() 60 { 61 return toEnglish[format]; 62 } 63 64 public final byte toByte() 65 { 66 return format; 67 } 68 69 public final boolean equals(final Object x) 70 { 71 if (x == null) 72 { 73 return false; 74 } 75 if (!(x instanceof DimeTypeNameFormat)) 76 { 77 return false; 78 } 79 return ((DimeTypeNameFormat)x).format == this.format; 80 } 81 82 public static DimeTypeNameFormat parseByte(byte x) 83 { 84 if (x < 0 || x > fromByte.length) 85 { 86 throw new IllegalArgumentException (Messages.getMessage("attach.DimeStreamBadType", "" + x)); 87 } 88 return fromByte[x]; 89 } 90 91 public static DimeTypeNameFormat parseByte(Byte x) 92 { 93 return parseByte(x.byteValue()); 94 } 95 } 96 | Popular Tags |