1 57 58 package com.sun.org.apache.xerces.internal.xni; 59 60 84 public class XMLString { 85 86 90 91 public char[] ch; 92 93 94 public int offset; 95 96 97 public int length; 98 99 103 104 public XMLString() { 105 } 107 115 public XMLString(char[] ch, int offset, int length) { 116 setValues(ch, offset, length); 117 } 119 128 public XMLString(XMLString string) { 129 setValues(string); 130 } 132 136 144 public void setValues(char[] ch, int offset, int length) { 145 this.ch = ch; 146 this.offset = offset; 147 this.length = length; 148 } 150 159 public void setValues(XMLString s) { 160 setValues(s.ch, s.offset, s.length); 161 } 163 164 public void clear() { 165 this.ch = null; 166 this.offset = 0; 167 this.length = -1; 168 } 170 178 public boolean equals(char[] ch, int offset, int length) { 179 if (ch == null) { 180 return false; 181 } 182 if (this.length != length) { 183 return false; 184 } 185 186 for (int i=0; i<length; i++) { 187 if (this.ch[this.offset+i] != ch[offset+i] ) { 188 return false; 189 } 190 } 191 return true; 192 } 194 200 public boolean equals(String s) { 201 if (s == null) { 202 return false; 203 } 204 if ( length != s.length() ) { 205 return false; 206 } 207 208 for (int i=0; i<length; i++) { 212 if (ch[offset+i] != s.charAt(i)) { 213 return false; 214 } 215 } 216 217 return true; 218 } 220 224 225 public String toString() { 226 return length > 0 ? new String (ch, offset, length) : ""; 227 } 229 } | Popular Tags |