1 16 17 package org.apache.xerces.xni; 18 19 43 public class XMLString { 44 45 49 50 public char[] ch; 51 52 53 public int offset; 54 55 56 public int length; 57 58 62 63 public XMLString() { 64 } 66 74 public XMLString(char[] ch, int offset, int length) { 75 setValues(ch, offset, length); 76 } 78 87 public XMLString(XMLString string) { 88 setValues(string); 89 } 91 95 103 public void setValues(char[] ch, int offset, int length) { 104 this.ch = ch; 105 this.offset = offset; 106 this.length = length; 107 } 109 118 public void setValues(XMLString s) { 119 setValues(s.ch, s.offset, s.length); 120 } 122 123 public void clear() { 124 this.ch = null; 125 this.offset = 0; 126 this.length = -1; 127 } 129 137 public boolean equals(char[] ch, int offset, int length) { 138 if (ch == null) { 139 return false; 140 } 141 if (this.length != length) { 142 return false; 143 } 144 145 for (int i=0; i<length; i++) { 146 if (this.ch[this.offset+i] != ch[offset+i] ) { 147 return false; 148 } 149 } 150 return true; 151 } 153 159 public boolean equals(String s) { 160 if (s == null) { 161 return false; 162 } 163 if ( length != s.length() ) { 164 return false; 165 } 166 167 for (int i=0; i<length; i++) { 171 if (ch[offset+i] != s.charAt(i)) { 172 return false; 173 } 174 } 175 176 return true; 177 } 179 183 184 public String toString() { 185 return length > 0 ? new String (ch, offset, length) : ""; 186 } 188 } | Popular Tags |