1 6 7 package org.htmlparser.util; 8 9 import java.io.Serializable ; 10 11 import org.htmlparser.util.sort.Ordered; 12 13 21 public class CharacterReference 22 implements 23 Serializable , 24 Cloneable , 25 Ordered 26 { 27 30 protected int mCharacter; 31 32 36 protected String mKernel; 37 38 43 public CharacterReference (String kernel, int character) 44 { 45 mKernel = kernel; 46 mCharacter = character; 47 if (null == mKernel) 48 mKernel = ""; 49 } 50 51 55 public String getKernel () 56 { 57 return (mKernel); 58 } 59 60 65 void setKernel (String kernel) 66 { 67 mKernel = kernel; 68 } 69 70 74 public int getCharacter () 75 { 76 return (mCharacter); 77 } 78 79 84 void setCharacter (int character) 85 { 86 mCharacter = character; 87 } 88 89 93 public String toString () 94 { 95 String hex; 96 StringBuffer ret; 97 98 ret = new StringBuffer (6 + 8 + 2); hex = Integer.toHexString (getCharacter ()); 100 ret.append ("\\u"); 101 for (int i = hex.length (); i < 4; i++) 102 ret.append ("0"); 103 ret.append (hex); 104 ret.append ("["); 105 ret.append (getKernel ()); 106 ret.append ("]"); 107 108 return (ret.toString ()); 109 } 110 111 115 119 public int compare (Object that) 120 { 121 CharacterReference r; 122 123 r = (CharacterReference)that; 124 125 return (getKernel ().compareTo (r.getKernel ())); 126 } 127 } 128 129 | Popular Tags |