1 38 39 40 package com.sun.xml.fastinfoset.util; 41 42 public class CharArrayString extends CharArray { 43 protected String _s; 44 45 public CharArrayString(String s) { 46 this(s, true); 47 } 48 49 public CharArrayString(String s, boolean createArray) { 50 _s = s; 51 if (createArray) { 52 ch = _s.toCharArray(); 53 start = 0; 54 length = ch.length; 55 } 56 } 57 58 public String toString() { 59 return _s; 60 } 61 62 public int hashCode() { 63 return _s.hashCode(); 64 } 65 66 public boolean equals(Object obj) { 67 if (this == obj) { 68 return true; 69 } 70 if (obj instanceof CharArrayString) { 71 CharArrayString chas = (CharArrayString)obj; 72 return _s.equals(chas._s); 73 } else if (obj instanceof CharArray) { 74 CharArray cha = (CharArray)obj; 75 if (length == cha.length) { 76 int n = length; 77 int i = start; 78 int j = cha.start; 79 while (n-- != 0) { 80 if (ch[i++] != cha.ch[j++]) 81 return false; 82 } 83 return true; 84 } 85 } 86 return false; 87 } 88 89 } 90 | Popular Tags |