org.autoplot.datasource.DataSetURI
Works with DataSourceRegistry to translate a URI into a DataSource. Also,
will provide completions.
DataSetURI( )
RECOGNIZE_FILE_EXTENSION_JSON
carefully inspect the file to see if there is a particular handler for it.
RECOGNIZE_FILE_EXTENSION_XML
carefully inspect the file to see if there is a particular handler for it.
abbreviateForHumanComsumption
abbreviateForHumanComsumption( String ssuri, int len ) → String
return a human-readable abbreviation of the URI, limiting to len characters.
Parameters
ssuri - a String
len - an int
Returns:
a string of length no more than len characters
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
blurTsbResolutionUri
blurTsbResolutionUri( String value ) → String
create the URI without the timerange.
Parameters
value - a uri. e.g. /tmp/foo$Y$m$d.dat?timerange=2014-001
Returns:
null or the value without the timerange, e.g. /tmp/foo$Y$m$d.dat
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
blurTsbUri
blurTsbUri( String value ) → String
create the URI without the timerange.
Parameters
value - a uri. e.g. /tmp/foo$Y$m$d.dat?timerange=2014-001
Returns:
null or the value without the timerange, e.g. /tmp/foo$Y$m$d.dat
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
checkLength
checkLength( java.io.File file ) → void
check that the file has length>0 and throw EmptyFileException if it does. This
code is the standard way this should be done.
Parameters
file - a File
Returns:
void (returns nothing)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
downloadResourceAsTempFile
downloadResourceAsTempFile( java.net.URL url, ProgressMonitor mon ) → File
This loads the URL to a local temporary file. If the temp file
is already downloaded and less than 10 seconds old, it will be used.
Parameters
url - the address to download.
mon - a progress monitor.
Returns:
a File in the FileSystemCache. The file will have question marks and ampersands removed.
See Also:
DataSetURI.downloadResourceAsTempFile.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
downloadResourceAsTempFile( java.net.URL url, int timeoutSeconds, ProgressMonitor mon ) → File
fromFile
fromFile( java.io.File file ) → String
canonical method for converting from File to human-readable string. This
simply tacks on "file://" to the filename. This was introduced so that there
is one canonical way to do this.
Parameters
file - a File
Returns:
a String
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
fromUri
fromUri( java.net.URI uri ) → String
canonical method for converting URI to human-readable string, containing
spaces and other illegal characters. Note pluses in the query part
are interpreted as spaces.
See also URISplit.uriDecode,etc.
Parameters
uri - an URI
Returns:
a String
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getCacheFilename
getCacheFilename( java.net.URI suri ) → File
provide standard logic for identifying the cache location for a file. The file
will not be downloaded, but clients can check to see if such resource has already been loaded.
There is one case where this might be slow, and that's when a zip file must be downloaded to get
the location. This returns null if the file is not from the cache (e.g. local file references).
Parameters
suri - the uri like http://autoplot.org/data/autoplot.dat
Returns:
the cache file, like /home/jbf/autoplot_data/fscache/http/autoplot.org/data/autoplot.dat, or null if the file is not
from the cache.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getCompletions
getCompletions( String surl, int carotpos, ProgressMonitor mon ) → List
this is never used in the application code. It must be left over from an earlier system.
This is used in Test005, some scripts, and IDL codes, so don't delete it!
Parameters
surl - a String
carotpos - an int
mon - a ProgressMonitor
Returns:
a java.util.List
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getDataSource
getDataSource( java.net.URI uri ) → DataSource
get the data source for the URI.
Parameters
uri - the URI.
Returns:
the data source from which the data set can be retrieved.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getDataSource( String suri ) → DataSource
getDataSourceFactory
getDataSourceFactory( java.net.URI uri, ProgressMonitor mon ) → DataSourceFactory
get the datasource factory for the URL. This has the rarely-used
logic that looks up MIME types for HTTP requests.
Parameters
uri - the URI of the data source.
mon - progress monitor
Returns:
the factory that produces the data source.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getDataSourceFormat
getDataSourceFormat( java.net.URI uri ) → DataSourceFormat
for now, just hide the URI stuff from clients, let's not mess with factories
Parameters
uri - the URI describing the output format and any arguments.
Returns:
the DataSourceFormat that formats a dataset to the format.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getDataSourceUri
getDataSourceUri( org.autoplot.datasource.DataSource ds ) → String
Prefix the URL with the datasource extension if necessary, so that
the URL would resolve to the dataSource. This is to support TimeSeriesBrowse,
and any time a resouce URL must be understood out of context.
TODO: note ds.getURI() should return the fully-qualified URI, so this is
no longer necessary.
Parameters
ds - the data source.
Returns:
the canonical URI.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getDiscoverableExtensions
getDiscoverableExtensions( ) → List
return a list of the extensions we were can immediately enter the editor,
so new users can plot things without knowing how to start a URI.
Since rev 10581, this uses introspection to call the reject method to support
compiling the applet.
Returns:
a java.util.List
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getExplicitExt
getExplicitExt( String surl ) → String
return the extension prefix of the URI, if specified.
Parameters
surl - a String
Returns:
null or an extension like "tsds"
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getExt
getExt( String surl ) → String
returns the explicit extension, or the file extension if found, or null.
The extension will not contain a period.
Inputs include:
- ac_h2_cris_20111221_v06.cdf → "cdf"
- /tmp/ac_h2_cris_20111221_v06.cdf → "cdf"
- /tmp/ac_h2_cris_20111221_v06 → null
Parameters
surl - a String
Returns:
the extension found, without the ".", or null if no period is found in the filename.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getFactoryCompletions
getFactoryCompletions( String surl1, int carotPos, ProgressMonitor mon ) → List
get the completions from the plug-in factory..
Parameters
surl1 - a String
carotPos - an int
mon - a ProgressMonitor
Returns:
a java.util.List
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getFile
getFile( java.net.URL url, ProgressMonitor mon ) → File
return a file reference for the url. This is initially to fix the problem
for Windows where new URL( "file://c:/myfile.dat" ).getPath() -> "/myfile.dat".
This will use a temporary local file in some cases, such as when the URL
has parameters, which prevent use with the FileSystem model.
TODO: why are there both getFile(url,mon) and getFile( suri, allowHtml, mon )???
Parameters
url - the URL of the file.
mon - progress monitor or null. If null then AlertProgressMonitor is used to show when the download time is not trivial.
Returns:
the File
See Also:
getFile(java.lang.String, boolean, org.das2.util.monitor.ProgressMonitor)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getFile( String suri, boolean allowHtml, ProgressMonitor mon ) → File
getFile( java.net.URI uri, ProgressMonitor mon ) → File
getFile( String uri, ProgressMonitor mon ) → File
getFile( String uri ) → File
getFileSystemAggCompletions
getFileSystemAggCompletions( String surl, int carotpos, ProgressMonitor mon ) → List
get completions within the filesystem that appear to form aggregations. Note this does not appear
to be used, having no Java references.
Parameters
surl - a String
carotpos - an int
mon - a ProgressMonitor
Returns:
a java.util.List
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getFileSystemCacheCompletions
getFileSystemCacheCompletions( String surl, int carotpos, boolean inclAgg, boolean inclFiles, String acceptPattern, ProgressMonitor mon ) → List
gets completions based on cached folders. This supports use when the
filesystem is offline, when parents are not web filesystems, and presents
used folders separately.
Parameters
surl - http://sarahandjeremy.net/
carotpos - the position of the carot. Presently everything after the carot is ignored.
inclAgg - include aggregations it sees. These are a guess.
inclFiles - include files as well as aggregations.
acceptPattern - if non-null, files and aggregations much match this.
mon - a ProgressMonitor
Returns:
possibly immutable list.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getFileSystemCompletions
getFileSystemCompletions( String surl, int carotpos, boolean inclAgg, boolean inclFiles, String acceptPattern, ProgressMonitor mon ) → List
get completions within the filesystem for the directory listing of files.
Parameters
surl - a String
carotpos - an int
inclAgg - include aggregations it sees. These are a guess.
inclFiles - include files as well as aggregations.
acceptPattern - if non-null, files and aggregations much match this.
mon - a ProgressMonitor
Returns:
a java.util.List
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getFileSystemCompletions( String surl, int carotpos, boolean inclAgg, java.util.List inclFiles, String acceptPattern, ProgressMonitor mon ) → List
getHostCompletions
getHostCompletions( String surl, int carotpos, ProgressMonitor mon ) → List
get completions for hosts, by looking in the user's cache area.
Parameters
surl - a String
carotpos - an int
mon - a ProgressMonitor
Returns:
possibly immutable list.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getHtmlFile
getHtmlFile( java.net.URL url, ProgressMonitor mon ) → File
get the file, allowing it to have "<html>" in the front. Normally this is not
allowed because of http://sourceforge.net/tracker/?func=detail&aid=3379717&group_id=199733&atid=970682
Parameters
url - an URL
mon - a ProgressMonitor
Returns:
a java.io.File
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getInputStream
getInputStream( java.net.URL url, ProgressMonitor mon ) → InputStream
get the InputStream from the path part of the URI. The stream must be closed by the client.
Parameters
url - URL like http://autoplot.org/data/autoplot.dat
mon - monitor that will monitor the stream as it is transmitted.
Returns:
the InputStream, which must be closed by the client. TODO: check usages...
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getInputStream( java.net.URI uri, ProgressMonitor mon ) → InputStream
getResourceURI
getResourceURI( java.net.URI uri ) → URI
returns the URI to be interpreted by the DataSource. This identifies
a file (or database) resource that can be passed to VFS.
Parameters
uri - an URI
Returns:
the URI for the datasource resource, or null if it is not valid.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getResourceURI( String surl ) → URI
getSortedDiscoverableExtentions
getSortedDiscoverableExtentions( ) → List
return the list of discoverable extentions, sorted by recent use.
Returns:
a java.util.List
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getTypesCompletions
getTypesCompletions( String surl, int carotpos, ProgressMonitor mon ) → List
return a list of completions showing discovery plugins, and the list of supported filesystem types.
Parameters
surl - a String
carotpos - an int
mon - a ProgressMonitor
Returns:
a java.util.List
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getURI
getURI( String surl ) → URI
canonical method for getting the Autoplot URI. If no protocol is specified, then file:// is
used. Note URIs may contain prefix like vap+bin:http://www.cdf.org/data.cdf. The
result will start with an Autoplot scheme like "vap:" or "vap+cdf:"
Note 20111117: "vap+cdaweb:" -> URI( "vap+cdaweb:file:///" that's why this works to toUri doesn't.
Parameters
surl - the string from the user that should be representable as a URI.
Returns:
the URI or null if it's clearly not a URI.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getURIValid
getURIValid( String surl ) → URI
get a URI from the string which is believed to be valid. This was introduced
because a number of codes called getURI without checking for null, which could be
returned when the URI could not be parsed ("This is not a uri"). Codes that
didn't check would produce a null pointer exception, and now they will produce
a more accurate error.
Parameters
surl - a String
Returns:
a java.net.URI
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getURL
getURL( String surl ) → URL
canonical method for getting the URL. These will always be web-downloadable
URLs.
Parameters
surl - the string from the user that should be representable as a URI.
Returns:
null or the URL if available.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
getWebURL
getWebURL( java.net.URI uri ) → URL
returns a downloadable URL from the Autoplot URI, perhaps popping off the
data source specifier. This assumes that the resource is a URL,
and getResourceURI().toURL() should be used to handle all cases.
Parameters
uri - An Autoplot URI.
Returns:
a URL that can be downloaded, or null if it is not found.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
init
init( ) → void
call this to trigger initialization
Returns:
void (returns nothing)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
isAggregating
isAggregating( String surl ) → boolean
check that the string uri is aggregating by looking for %Y's (etc) in the
file part of the URI. This also looks for:
- $y -- two digit year
- $(o -- orbit number
- $(periodic -- interval number
- $v -- version
Parameters
surl - a String
Returns:
a boolean
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
main
main( java.lang.String[] args ) → void
Parameters
args - a java.lang.String[]
Returns:
void (returns nothing)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
maybePlusToSpace
maybePlusToSpace( String ssheet ) → String
Legacy behavior was to convert pluses into spaces in URIs. This caused problems
distinguishing spaces from pluses, so we dropped this as the default behavior.
If data sources are to support legacy URIs, then they should use this routine
to mimic the behavior.
This checks if the URI already contains spaces, and will not convert if there
are already spaces.
Parameters
ssheet - a String
Returns:
a String
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
resetUriTsbTime
resetUriTsbTime( String value, DatumRange timeRange ) → String
return the URI with a new time.
Parameters
value - a String
timeRange - a DatumRange
Returns:
the URI with a new time.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
toUri
toUri( String suri ) → URI
canonical method for converting string from the wild into a URI-safe string.
This contains the code that converts a colloquial string URI into a
properly formed URI.
For example:
space is converted to "%20"
%Y is converted to $Y
This does not add file: or vap:. Pluses are only changed in the params part.
Parameters
suri - a String
Returns:
a java.net.URI
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
unaggregate
unaggregate( String resourceURI, DatumRange timerange ) → String
taken from unaggregate.jy in the servlet.
Parameters
resourceURI - resource URI like "file://tmp/data$Y$m$d.dat"
timerange - a timerange that will be covered by the span.
Returns:
the strings resolved.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]