1 25 26 package org.apache.jasper.xmlparser; 27 28 52 public class XMLString { 53 54 58 59 public char[] ch; 60 61 62 public int offset; 63 64 65 public int length; 66 67 71 72 public XMLString() { 73 } 75 83 public XMLString(char[] ch, int offset, int length) { 84 setValues(ch, offset, length); 85 } 87 96 public XMLString(XMLString string) { 97 setValues(string); 98 } 100 104 112 public void setValues(char[] ch, int offset, int length) { 113 this.ch = ch; 114 this.offset = offset; 115 this.length = length; 116 } 118 127 public void setValues(XMLString s) { 128 setValues(s.ch, s.offset, s.length); 129 } 131 132 public void clear() { 133 this.ch = null; 134 this.offset = 0; 135 this.length = -1; 136 } 138 146 public boolean equals(char[] ch, int offset, int length) { 147 if (ch == null) { 148 return false; 149 } 150 if (this.length != length) { 151 return false; 152 } 153 154 for (int i=0; i<length; i++) { 155 if (this.ch[this.offset+i] != ch[offset+i] ) { 156 return false; 157 } 158 } 159 return true; 160 } 162 168 public boolean equals(String s) { 169 if (s == null) { 170 return false; 171 } 172 if ( length != s.length() ) { 173 return false; 174 } 175 176 for (int i=0; i<length; i++) { 180 if (ch[offset+i] != s.charAt(i)) { 181 return false; 182 } 183 } 184 185 return true; 186 } 188 192 193 public String toString() { 194 return length > 0 ? new String (ch, offset, length) : ""; 195 } 197 } | Popular Tags |