congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
DatasetUrl
Code IndexAdd Tabnine to your IDE (free)

How to use
DatasetUrl
in
ucar.nc2.dataset

Best Java code snippets using ucar.nc2.dataset.DatasetUrl (Showing top 20 results out of 315)

origin: Unidata/thredds

List<String> allprotocols = DatasetUrl.getProtocols(location);
 svctype = searchFragment(fragment);
 svctype = decodeLeadProtocol(leadprotocol);
 svctype = searchPath(trueurl);
  svctype = decodePathExtension(trueurl); // look at the path extension
  if(svctype == null && checkIfNcml(new File(location))) {
   svctype = ServiceType.NCML;
  svctype = disambiguateHttp(trueurl);
   if (checkIfRemoteNcml(trueurl)) {
    svctype = ServiceType.NCML;
return new DatasetUrl(svctype, trueurl);
origin: Unidata/thredds

/**
 * Factory method for opening a NetcdfFile through the netCDF API.
 *
 * @param location   location of dataset.
 * @param cancelTask use to allow task to be cancelled; may be null.
 * @return NetcdfFile object
 * @throws java.io.IOException on read error
 */
public static NetcdfFile openFile(String location, ucar.nc2.util.CancelTask cancelTask) throws IOException {
 DatasetUrl durl = DatasetUrl.findDatasetUrl(location);
 return openOrAcquireFile(null, null, null, durl, -1, cancelTask, null);
}
origin: Unidata/thredds

ServiceType result = checkIfCdmr(location);
if (result != null) return result;
checkCdmr = true;
ServiceType result = checkIfDods(location);
if (result != null) return result;
checkDap2 = true;
ServiceType result = checkIfDap4(location);
if (result != null) return result;
checkDap4 = true;
ServiceType result = checkIfDods(location);
if (result != null)
 return result;
ServiceType result = checkIfDap4(location);
if (result != null)
 return result;
ServiceType result = checkIfCdmr(location);
if (result != null)
 return result;
origin: Unidata/thredds

static private boolean checkIfRemoteNcml(String location) throws IOException {
 if (decodePathExtension(location)==ServiceType.NCML) {
  // just because location ends with ncml does not mean it's ncml
  // if the ncml file is being served up via http by a remote server,
  // we should be able to read the first bit of it and see if it even
  // looks like an ncml file.
  try (HTTPMethod method = HTTPFactory.Get(location)) {
   method.setRange(0, NUM_BYTES_TO_DETERMINE_NCML);
   method.setRequestHeader("accept-encoding", "identity");
   int statusCode = method.execute();
   if (statusCode >= 300) {
    if (statusCode == 401) {
     throw new IOException("Unauthorized to open dataset " + location);
    } else if (statusCode == 406) {
     String msg = location + " - this server does not support returning content without any encoding.";
     msg = msg + " Please download the file locally. Return status=" + statusCode;
     throw new IOException(msg);
    } else {
     throw new IOException(location + " is not a valid URL, return status=" + statusCode);
    }
   }
   return checkIfNcml(method.getResponseAsString());
  }
 }
 return false;
}
origin: Unidata/thredds

public TestDatasetWrapP(String filename) {
 durl = new DatasetUrl(null, filename);
}
origin: Unidata/thredds

protected void protocheck(String path, String expected) {
 if (expected == null)
  expected = "";
 List<String> protocols = DatasetUrl.getProtocols(path);
 StringBuilder buf = new StringBuilder();
 for (String s : protocols) {
  buf.append(s);
  buf.append(":");
 }
 String result = buf.toString();
 boolean ok = expected.equals(result);
 if (show || !ok) System.out.printf(" path=%s; result=%s; pass=%s\n", path, result, ok);
 Assert.assertEquals(path, expected, result);
}
origin: Unidata/thredds

static private boolean checkIfNcml(File file) throws IOException {
 if (!file.exists()) {
  return false;
 }
 try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(file), NUM_BYTES_TO_DETERMINE_NCML)) {
  byte[] bytes = new byte[NUM_BYTES_TO_DETERMINE_NCML];
  int bytesRead = in.read(bytes);
  if (bytesRead <= 0) {
   return false;
  } else {
   return checkIfNcml(new String(bytes, 0, bytesRead));
  }
 }
}
origin: Unidata/thredds

public GribCollectionImmutable getGribCollection() throws IOException {
 String path = getIndexFilenameInCache();
 if (path == null) {
  if (Grib.debugIndexOnly) {  // we are running in debug mode where we only have the indices, not the data files
   // tricky: substitute the current root
   File orgParentDir = new File(directory);
   File currentFile = new File(PartitionCollectionMutable.this.indexFilename);
   File currentParent = currentFile.getParentFile();
   File currentParentWithDir = new File(currentParent, orgParentDir.getName());
   File nestedIndex = isPartitionOfPartitions ? new File(currentParentWithDir, filename) : new File(currentParent, filename); // JMJ
   path = nestedIndex.getPath();
  } else {
   throw new FileNotFoundException("No index filename for partition= "+this.toString());
  }
 }
 // LOOK not cached
 return (GribCollectionImmutable) PartitionCollectionImmutable.partitionCollectionFactory.open(new DatasetUrl(null, path), -1, null, this);
}
origin: Unidata/thredds

protected boolean protocheck(String path, String expected)
{
  if(expected == null)
    expected = "";
  List<String> protocols = DatasetUrl.getProtocols(path);
  StringBuilder buf = new StringBuilder();
  for(String s : protocols) {
    buf.append(s);
    buf.append(":");
  }
  String result = buf.toString();
  boolean ok = expected.equals(result);
  System.err.printf("path=|%s| result=|%s| pass=%s\n",
      path, result, (ok ? "true" : "false"));
  System.err.flush();
  return ok;
}
origin: Unidata/thredds

public TestNcmlWriteAndCompareShared(String location, boolean compareData) throws IOException {
 this.durl = DatasetUrl.findDatasetUrl(location);
 this.compareData = compareData;
}
origin: Unidata/thredds

static public GribCollectionImmutable acquireGribCollection(FileFactory factory, Object hashKey, String location, int buffer_size, CancelTask cancelTask, Object spiObject) throws IOException {
 FileCacheable result;
 DatasetUrl durl = new DatasetUrl(null, location);
 if (gribCollectionCache != null) {
  // FileFactory factory, Object hashKey, String location, int buffer_size, CancelTask cancelTask, Object spiObject
  result = GribCdmIndex.gribCollectionCache.acquire(factory, hashKey, durl, buffer_size, cancelTask, spiObject);
 } else {
  // String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object iospMessage
  result = factory.open(durl, buffer_size, cancelTask, spiObject);
 }
 return (GribCollectionImmutable) result;
}
origin: Unidata/thredds

/**
 * Factory method for opening a dataset through the netCDF API, and identifying its coordinate variables.
 *
 * @param location    location of file
 * @param enhance     if true, use defaultEnhanceMode, else no enhancements
 * @param buffer_size RandomAccessFile buffer size, if <= 0, use default size
 * @param cancelTask  allow task to be cancelled; may be null.
 * @param spiObject   sent to iosp.setSpecial() if not null
 * @return NetcdfDataset object
 * @throws java.io.IOException on read error
 */
static public NetcdfDataset openDataset(String location, boolean enhance, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException {
 DatasetUrl durl = DatasetUrl.findDatasetUrl(location);
 return openDataset(durl, enhance ? defaultEnhanceMode : null, buffer_size, cancelTask, spiObject);
}
origin: Unidata/thredds

static public RandomAccessFile acquire(String location) throws IOException {
 if (cache == null)
  return new RandomAccessFile(location, "r");
 else
  return (RandomAccessFile) cache.acquire(factory, new DatasetUrl(null, location));
}
origin: Unidata/thredds

/**
 * Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems
 * and turn into a DtCoverageDataset.
 *
 * @param location netcdf dataset to open, using NetcdfDataset.acquireDataset().
 * @return GridDataset
 * @throws java.io.IOException on read error
 * @see ucar.nc2.dataset.NetcdfDataset#acquireDataset
 */
static public DtCoverageDataset open(String location) throws java.io.IOException {
 DatasetUrl durl = DatasetUrl.findDatasetUrl(location);
 return open(durl, NetcdfDataset.getDefaultEnhanceMode());
}
origin: Unidata/thredds

static public RandomAccessFile acquire(String location, int buffer_size) throws IOException {
 if (cache == null)
  return new RandomAccessFile(location, "r", buffer_size);
 else
  return (RandomAccessFile) cache.acquire(factory, location, new DatasetUrl(null, location), buffer_size, null, null);
}
origin: Unidata/thredds

/**
 * Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems
 * and turn into a GridDataset.
 *
 * @param location netcdf dataset to open, using NetcdfDataset.acquireDataset().
 * @param enhanceMode open netcdf dataset with this enhanceMode
 * @return GridDataset
 * @throws java.io.IOException on read error
 * @see ucar.nc2.dataset.NetcdfDataset#acquireDataset
 */
static public GridDataset open(String location, Set<NetcdfDataset.Enhance> enhanceMode) throws java.io.IOException {
 NetcdfDataset ds = ucar.nc2.dataset.NetcdfDataset.acquireDataset(null, DatasetUrl.findDatasetUrl(location), enhanceMode, -1, null, null);
 return new GridDataset(ds, null);
}
origin: Unidata/thredds

/**
 * Open a file, keep track of open files
 * @param location open this location
 * @param openFiles keep track of open files
 * @return file or null if not found
 */
private NetcdfDataset open(String location, Map<String, NetcdfDataset> openFiles)  throws IOException {
 NetcdfDataset ncd;
 if (openFiles != null) {
  ncd = openFiles.get(location);
  if (ncd != null) return ncd;
 }
 if (config.innerNcml == null) {
  ncd = NetcdfDataset.acquireDataset(new DatasetUrl(null, location), true, null);  // default enhance
 } else {
  NetcdfFile nc = NetcdfDataset.acquireFile(new DatasetUrl(null, location), null);
  ncd = NcMLReader.mergeNcML(nc, config.innerNcml); // create new dataset
  ncd.enhance(); // now that the ncml is added, enhance "in place", ie modify the NetcdfDataset
 }
 if (openFiles != null && ncd != null) {
  openFiles.put(location, ncd);
 }
 return ncd;
}
origin: Unidata/thredds

/**
 * Open a dataset as a TypedDataset.
 *
 * @param datatype open this kind of Typed Dataset; may be null, which means search all factories.
 *   If datatype is not null, only return correct TypedDataset (eg PointObsDataset for DataType.POINT).
 * @param location URL or file location of the dataset
 * @param task user may cancel
 * @param errlog place errors here, may not be null
 * @return a subclass of TypedDataset
 * @throws java.io.IOException on io error
 */
static public TypedDataset open( FeatureType datatype, String location, ucar.nc2.util.CancelTask task, StringBuilder errlog) throws IOException {
 DatasetUrl durl = DatasetUrl.findDatasetUrl(location);
 NetcdfDataset ncd = NetcdfDataset.acquireDataset(durl, true, task);
 return open( datatype, ncd, task, errlog);
}
origin: Unidata/thredds

static private NetcdfFile acquireDODS(FileCache cache, FileFactory factory, Object hashKey,
                   String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException {
 if (cache == null) {
  return openDodsByReflection(location, cancelTask);
 }
 if (factory == null) factory = new DodsFactory();
 return (NetcdfFile) cache.acquire(factory, hashKey, new DatasetUrl(ServiceType.OPENDAP, location), buffer_size, cancelTask, spiObject);
}
origin: Unidata/thredds

public NetcdfFile acquireFile(CancelTask cancelTask) throws IOException {
 if (debugOpenFile) System.out.println(" try to acquire " + cacheLocation);
 long start = System.currentTimeMillis();
 if (durl == null)
  durl = DatasetUrl.findDatasetUrl(cacheLocation); // cache the ServiceType so we dont have to keep figuring it out
 NetcdfFile ncfile = NetcdfDataset.acquireFile(reader, null, durl, -1, cancelTask, spiObject);
 // must merge NcML before enhancing
 if (mergeNcml != null)
  ncfile = NcMLReader.mergeNcML(ncfile, mergeNcml); // create new dataset
 if (enhance == null || enhance.isEmpty()) {
  if (debugOpenFile) System.out.println(" acquire (no enhance) " + cacheLocation + " took " + (System.currentTimeMillis() - start));
  return ncfile;
 }
 // must enhance
 NetcdfDataset ds;
 if (ncfile instanceof NetcdfDataset) {
  ds = (NetcdfDataset) ncfile;
  ds.enhance(enhance); // enhance "in place", ie modify the NetcdfDataset
 } else {
  ds = new NetcdfDataset(ncfile, enhance); // enhance when wrapping
 }
 if (debugOpenFile) System.out.println(" acquire (enhance) " + cacheLocation + " took " + (System.currentTimeMillis() - start));
 return ds;
}
ucar.nc2.datasetDatasetUrl

Javadoc

Detection of the protocol from a location string. Split out from NetcdfDataset. LOOK should be refactored

Most used methods

  • <init>
  • findDatasetUrl
  • getProtocols
    Return the set of leading protocols for a url; may be more than one. Watch out for Windows paths sta
  • checkIfCdmr
  • checkIfDap4
  • checkIfDods
  • checkIfNcml
  • checkIfRemoteNcml
  • decodeLeadProtocol
  • decodePathExtension
    Check path extension; assumes no query or fragment
  • disambiguateHttp
    If the URL alone is not sufficient to disambiguate the location, then this method will attempt to do
  • hashCode
  • disambiguateHttp,
  • hashCode,
  • parseFragment,
  • searchFragment,
  • searchPath,
  • validateprotocol

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getResourceAsStream (ClassLoader)
  • requestLocationUpdates (LocationManager)
  • compareTo (BigDecimal)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Permission (java.security)
    Legacy security code; do not use.
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Top 17 Plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now