1 7 package com.sun.corba.se.impl.encoding; 8 9 17 public final class OSFCodeSetRegistry 18 { 19 public static final int ISO_8859_1_VALUE = 0x00010001; 24 public static final int UTF_16_VALUE = 0x00010109; 25 public static final int UTF_8_VALUE = 0x05010001; 26 public static final int UCS_2_VALUE = 0x00010100; 27 public static final int ISO_646_VALUE = 0x00010020; 28 29 private OSFCodeSetRegistry() {} 30 31 36 public final static class Entry 37 { 38 private String javaName; 39 private int encodingNum; 40 private boolean isFixedWidth; 41 private int maxBytesPerChar; 42 43 private Entry(String javaName, 44 int encodingNum, 45 boolean isFixedWidth, 46 int maxBytesPerChar) { 47 this.javaName = javaName; 48 this.encodingNum = encodingNum; 49 this.isFixedWidth = isFixedWidth; 50 this.maxBytesPerChar = maxBytesPerChar; 51 } 52 53 58 public String getName() { 59 return javaName; 60 } 61 62 65 public int getNumber() { 66 return encodingNum; 67 } 68 69 74 public boolean isFixedWidth() { 75 return isFixedWidth; 76 } 77 78 public int getMaxBytesPerChar() { 79 return maxBytesPerChar; 80 } 81 82 86 public boolean equals(Object obj) { 87 if (this == obj) 88 return true; 89 90 if (!(obj instanceof OSFCodeSetRegistry.Entry)) 91 return false; 92 93 OSFCodeSetRegistry.Entry other 94 = (OSFCodeSetRegistry.Entry)obj; 95 96 return (javaName.equals(other.javaName) && 97 encodingNum == other.encodingNum && 98 isFixedWidth == other.isFixedWidth && 99 maxBytesPerChar == other.maxBytesPerChar); 100 } 101 102 105 public int hashCode() { 106 return encodingNum; 107 } 108 } 109 110 114 public static final Entry ISO_8859_1 115 = new Entry("ISO-8859-1", 116 ISO_8859_1_VALUE, 117 true, 118 1); 119 120 127 static final Entry UTF_16BE 128 = new Entry("UTF-16BE", 129 -1, 130 true, 131 2); 132 133 static final Entry UTF_16LE 134 = new Entry("UTF-16LE", 135 -2, 136 true, 137 2); 138 139 146 public static final Entry UTF_16 147 = new Entry("UTF-16", 148 UTF_16_VALUE, 149 true, 150 4); 151 152 157 public static final Entry UTF_8 158 = new Entry("UTF-8", 159 UTF_8_VALUE, 160 false, 161 6); 162 163 174 public static final Entry UCS_2 175 = new Entry("UCS-2", 176 UCS_2_VALUE, 177 true, 178 2); 179 180 186 public static final Entry ISO_646 187 = new Entry("US-ASCII", 188 ISO_646_VALUE, 189 true, 190 1); 191 192 196 public static Entry lookupEntry(int encodingValue) { 197 switch(encodingValue) { 198 case ISO_8859_1_VALUE: 199 return OSFCodeSetRegistry.ISO_8859_1; 200 case UTF_16_VALUE: 201 return OSFCodeSetRegistry.UTF_16; 202 case UTF_8_VALUE: 203 return OSFCodeSetRegistry.UTF_8; 204 case ISO_646_VALUE: 205 return OSFCodeSetRegistry.ISO_646; 206 case UCS_2_VALUE: 207 return OSFCodeSetRegistry.UCS_2; 208 default: 209 return null; 210 } 211 } 212 } 213 | Popular Tags |