1 23 package org.enhydra.xml.io; 24 25 31 class CharacterSet { 32 33 private final String fName; 34 35 36 private final int fCharSize; 37 38 39 private final int fMaxCharValue; 40 41 42 private final String fMimePreferred; 43 44 45 private final String [] fAliases; 46 47 48 public CharacterSet(String name, 49 int charSize, 50 String mimePreferred, 51 String [] aliases) { 52 fName = name; 53 fCharSize = charSize; 54 fMimePreferred = mimePreferred; 55 fAliases = aliases; 56 57 int maxCharValue; 59 if (charSize == 7) { 60 maxCharValue = 0x7e; 61 } else if (charSize == 8) { 62 maxCharValue = 0xFF; 63 } else { 64 maxCharValue = 0xFFFF; 65 } 66 fMaxCharValue = maxCharValue; 67 } 68 69 70 public final String getName() { 71 return fName; 72 } 73 74 75 public final int getCharSize() { 76 return fCharSize; 77 } 78 79 80 public final int getMaxCharValue() { 81 return fMaxCharValue; 82 } 83 84 85 public final String getMIMEPreferred() { 86 return fMimePreferred; 87 } 88 89 90 public final String [] getAliases() { 91 return fAliases; 92 } 93 94 101 public boolean isValid(char ch) { 102 return (ch <= fMaxCharValue); 103 } 104 105 114 public boolean sameValidCharRange(CharacterSet otherSet) { 115 return isCompatible(otherSet); 116 } 117 118 126 public boolean isCompatible(CharacterSet otherSet) { 127 return (otherSet.getMaxCharValue() == fMaxCharValue); 128 } 129 130 131 public String toString() { 132 StringBuffer buf = new StringBuffer (256); buf.append(fName); 134 buf.append(": "); 135 buf.append(fCharSize); 136 buf.append(' '); 137 buf.append(fMimePreferred); 138 for (int i = 1; i < fAliases.length; i++) { 139 buf.append(' '); 140 buf.append(fAliases[i]); 141 } 142 return buf.toString(); 143 } 144 } 145 146 | Popular Tags |