Package dap4.core.util
Class XURI
- java.lang.Object
-
- dap4.core.util.XURI
-
public class XURI extends Object
Provide an extended form of URI parser with the following features: 1. can parse the query and fragment parts. 2. supports multiple protocols 3. supports modification of the URI path. 4. supports url -> string as controlled by flags
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXURI.Parts
-
Field Summary
Fields Modifier and Type Field Description protected static Patterndrivelettertestprotected static Patternfiledrivelettertestprotected Map<String,String>fragfieldsprotected booleanisfileprotected List<String>nonleadschemesprotected Map<String,String>queryfieldsstatic EnumSet<XURI.Parts>URLALLstatic EnumSet<XURI.Parts>URLONLYstatic EnumSet<XURI.Parts>URLQUERY
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String[]allSchemes(String xu)Extract all schemes at front of a url.Stringassemble(EnumSet<XURI.Parts> parts)Reassemble the url using the specified partsstatic Stringcanonical(String s)Canonicalize a part of a URLprotected List<String>escapedsplit(String s, char sep, char escape)protected intfindunescaped(String s, int start, char sep, char escape, int len)Stringfixdriveletter(URI uri)Map<String,String>getFragFields()StringgetFragment()StringgetHost()StringgetPath()intgetPort()StringgetQuery()Map<String,String>getQueryFields()StringgetRealPath()Return a path that can be used to open a fileStringgetScheme()List<String>getSchemes()StringgetUserInfo()static booleanhasDriveLetter(String path)return true if this path appears to start with a windows drive letter including those hidden by leading '/'static StringhideDriveLetter(String path)Return a path with possible windows drive letter hidden by '/'.protected Map<String,String>insertAmpField(String key, String value, String query)voidinsertFragmentField(String key, String newval)Allow fragment fields to be insertedvoidinsertQueryField(String key, String newval)Allow queryfields to be insertedbooleanisFile()protected Map<String,String>parseAmpList(String s, char sep, char escape)protected voidparseFragment()protected voidparseQuery()protected voidrebuildQuery()Rebuild query from current queryfieldsprotected Map<String,String>removeAmpField(String key, String query)voidremoveQueryField(String key)Allow queryfields to be removedvoidsetFragment(String xfragment)voidsetHost(String xhost)voidsetPath(String xpath)voidsetPort(int xport)voidsetQuery(String xquery)voidsetScheme(String xscheme)voidsetUserInfo(String xuserinfo)StringtoString()static StringtruePath(String path)return repaired path; if this path appears to start with a windows drive letter hidden by leading '/', then the leading '/' is removed
-
-
-
Field Detail
-
drivelettertest
protected static final Pattern drivelettertest
-
filedrivelettertest
protected static final Pattern filedrivelettertest
-
URLONLY
public static final EnumSet<XURI.Parts> URLONLY
-
URLALL
public static final EnumSet<XURI.Parts> URLALL
-
URLQUERY
public static final EnumSet<XURI.Parts> URLQUERY
-
isfile
protected boolean isfile
-
-
Constructor Detail
-
XURI
public XURI(String xu) throws URISyntaxException
- Throws:
URISyntaxException
-
XURI
public XURI(URL xu) throws URISyntaxException
- Throws:
URISyntaxException
-
XURI
public XURI(URI xu) throws URISyntaxException
- Throws:
URISyntaxException
-
-
Method Detail
-
getUserInfo
public String getUserInfo()
-
getHost
public String getHost()
-
getPort
public int getPort()
-
getPath
public String getPath()
-
getRealPath
public String getRealPath()
Return a path that can be used to open a file- Returns:
-
getQuery
public String getQuery()
-
getFragment
public String getFragment()
-
getScheme
public String getScheme()
-
setScheme
public void setScheme(String xscheme)
-
setUserInfo
public void setUserInfo(String xuserinfo)
-
setHost
public void setHost(String xhost)
-
setPort
public void setPort(int xport)
-
setPath
public void setPath(String xpath)
-
setQuery
public void setQuery(String xquery)
-
setFragment
public void setFragment(String xfragment)
-
insertQueryField
public void insertQueryField(String key, String newval)
Allow queryfields to be inserted- Parameters:
key-newval-
-
insertFragmentField
public void insertFragmentField(String key, String newval)
Allow fragment fields to be inserted- Parameters:
key-newval-
-
removeQueryField
public void removeQueryField(String key)
Allow queryfields to be removed- Parameters:
key-
-
rebuildQuery
protected void rebuildQuery()
Rebuild query from current queryfields
-
isFile
public boolean isFile()
-
parseQuery
protected void parseQuery()
-
parseFragment
protected void parseFragment()
-
insertAmpField
protected Map<String,String> insertAmpField(String key, String value, String query)
-
findunescaped
protected int findunescaped(String s, int start, char sep, char escape, int len)
-
assemble
public String assemble(EnumSet<XURI.Parts> parts)
Reassemble the url using the specified parts- Parameters:
parts- to include- Returns:
- the assembled uri
-
fixdriveletter
public String fixdriveletter(URI uri) throws URISyntaxException
- Throws:
URISyntaxException
-
canonical
public static String canonical(String s)
Canonicalize a part of a URL- Parameters:
s- part of the url
-
hasDriveLetter
public static boolean hasDriveLetter(String path)
return true if this path appears to start with a windows drive letter including those hidden by leading '/'- Parameters:
path-- Returns:
- true, if path has drive letter
-
hideDriveLetter
public static String hideDriveLetter(String path)
Return a path with possible windows drive letter hidden by '/'. Repair => convert "x:/" to "/x:/" where x is a drive letter- Returns:
- repaired path
-
allSchemes
public static String[] allSchemes(String xu)
Extract all schemes at front of a url.- Returns:
- vector of schemes
-
-