public Field(String s) { String f[] = StringTools.parseString(s, FIELD_VALUE_SEPARATOR); if ((f.length > 0) && (f[0].length() > 0) && Character.isLetter(f[0].charAt(0))) { this.isHiRes = (f.length > 0) ? f[0].equalsIgnoreCase("H") : false; this.type = (f.length > 1) ? StringTools.parseInt(f[1], -1) : -1; } else { this.type = (f.length > 0) ? StringTools.parseInt(f[0], -1) : -1; this.isHiRes = (f.length > 1) ? f[1].equalsIgnoreCase("H") : false; } this.index = (f.length > 2) ? StringTools.parseInt(f[2], 0) : 0; this.length = (f.length > 3) ? StringTools.parseInt(f[3], 0) : 0; this.isValid = (f.length == 4) && (this.type >= 0) && (this.index >= 0) && (this.length > 0); }
/** ** Sets the URI from a string */ public void setURI(String uri) { int p = (uri != null) ? uri.indexOf("?") : -1; if (p >= 0) { this._setURI(uri.substring(0, p)); String a[] = StringTools.parseString(uri.substring(p + 1), "&"); for (int i = 0; i < a.length; i++) { String key = "", val = ""; int e = a[i].indexOf("="); if (e >= 0) { key = a[i].substring(0, e); val = a[i].substring(e + 1); } else { key = a[i]; val = ""; } this._addArg(key, val, false /*encode*/, false /*obfuscate*/); // assume already encoded } } else { this._setURI(uri); } }