/** Adds a parameter. * Setting a parameter to null removes it. */ public void addParameter(String key, String value){ if(value==null){ removeParameter(key); return; } if(query==null)query=new URLParameters(); query.add(key, value); }
private void pathStart(){ //1. If url is special and c is "\", syntax violation. if(url.isSpecial() && c=='\\') syntaxViolation(); //2. Set state to path state, and if neither c is "/", //nor url is special and c is "\", decrease pointer by one. state=PATH; //if(c!='/' && !(url.isSpecial() && c=='\\')) //Alex comments this line out pointer--; }
/** Deep clone. */ public URLParameters clone(){ String s=toString(); return new URLParameters(s); }
/** Sets a parameter. * Overwrites the parameter if it is already set. * Setting a parameter to null removes it. */ public void setParameter(String key, String value){ if(value==null)removeParameter(key); else parameter(key, value); } public URL parameter(String key, String value){
/** Deep clone. */ public URLSearchParams clone(){ String s=toString(); return new URLSearchParams(s); }
public URL parameter(String key, String value){ if(query==null && value==null)return this; if(query==null)query=new URLParameters(); query.set(key, value); return this; }
public void setSearch(String s){ if(null==s || 0==s.length()){ removeParameters(); return; } if(s.startsWith("?")) s=s.substring(1); query=new URLParameters(s); }
public URLSearchParams getSearchParams(){ if(query==null)return null; if(query instanceof URLSearchParams)return (URLSearchParams)query; query=new URLSearchParams(query); return (URLSearchParams)query; }
private void specialAuthorityIgnoreSlashes(){ //If c is neither "/" nor "\", set state to authority state, and decrease pointer by one. if(c!='/' && c!='\\'){ state=AUTHORITY; pointer--; } //Otherwise, syntax violation. else syntaxViolation(); }
/** A Windows drive letter is two code points, of which the first is an * ASCII alpha and the second is either ":" or "|".*/ private boolean isWindowsDriveLetter(char a, char b){ return isASCIIAlpha(a) && (b==':' || b=='|'); }
/** If non-standard port, returns server and post. */ public String getHost(){ if(host==null)return ""; if(isDefaultPort() || 0==port)return host; return host+":"+port; } public String host(){return getHost();}
public URLParameters parameters(){ if(query==null)query=new URLParameters(); return query; }
/** returns either a new URL or failure */ URL basic(String input, URL base, String encodingOverride){ return basic(input, base, encodingOverride, null, null); }
/** A Windows drive letter is two code points, of which the first is an * ASCII alpha and the second is either ":" or "|".*/ private boolean isWindowsDriveLetter(char a, char b){ return isASCIIAlpha(a) && (b==':' || b=='|'); }