Skip to content

Commit b47817f

Browse files
authored
Merge pull request #355 from JohnLCaron/openCleanup
Move NetcdfDataset.open to NetcdfDatasets.
2 parents 2b7b049 + 2347c03 commit b47817f

File tree

12 files changed

+48
-47
lines changed

12 files changed

+48
-47
lines changed

cdm-test/src/test/java/ucar/nc2/dt/grid/TestGridSubset.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import ucar.nc2.dataset.CoordinateAxis;
1616
import ucar.nc2.dataset.CoordinateAxis1D;
1717
import ucar.nc2.dataset.NetcdfDataset;
18+
import ucar.nc2.dataset.NetcdfDatasets;
1819
import ucar.nc2.dt.GridCoordSystem;
1920
import ucar.nc2.dt.GridDatatype;
2021
import ucar.nc2.grib.collection.Grib;
@@ -426,7 +427,7 @@ public void testBBSubsetVP2() throws Exception {
426427
@Test
427428
public void testSubsetCoordEdges() throws Exception {
428429
try (NetcdfDataset fooDataset =
429-
NetcdfDataset.openDataset(TestDir.cdmLocalFromTestDataDir + "ncml/subsetCoordEdges.ncml")) {
430+
NetcdfDatasets.openDataset(TestDir.cdmLocalFromTestDataDir + "ncml/subsetCoordEdges.ncml")) {
430431
logger.debug("Open {}", fooDataset.getLocation());
431432
CompareNetcdf2 compare = new CompareNetcdf2();
432433
boolean ok = true;

cdm-test/src/test/java/ucar/nc2/dt/grid/TestGridSubsetCoordinateSystem.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import ucar.nc2.dataset.CoordinateAxis;
1818
import ucar.nc2.dataset.CoordinateSystem;
1919
import ucar.nc2.dataset.NetcdfDataset;
20+
import ucar.nc2.dataset.NetcdfDatasets;
2021
import ucar.nc2.dataset.VariableDS;
2122
import ucar.nc2.dt.GridCoordSystem;
2223
import ucar.nc2.dt.GridDatatype;
@@ -111,7 +112,7 @@ public void testCoordinateSystemDomain() throws Exception {
111112
System.err.printf("%nOpen %s grid='%s'%n", filename, gridName);
112113
Grib.setDebugFlags(new DebugFlagsImpl("Grib/indexOnly"));
113114

114-
try (NetcdfDataset ncd = NetcdfDataset.openDataset(filename)) {
115+
try (NetcdfDataset ncd = NetcdfDatasets.openDataset(filename)) {
115116
Assert.assertNotNull(filename, ncd);
116117
VariableDS vds = (VariableDS) ncd.findVariable(gridName);
117118
Assert.assertNotNull(gridName, vds);

cdm-test/src/test/java/ucar/nc2/ft/coverage/TestCoverageClassificationP.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import ucar.nc2.constants.FeatureType;
1212
import ucar.nc2.dataset.CoordinateSystem;
1313
import ucar.nc2.dataset.NetcdfDataset;
14+
import ucar.nc2.dataset.NetcdfDatasets;
1415
import ucar.nc2.ft2.coverage.FeatureDatasetCoverage;
1516
import ucar.nc2.ft2.coverage.CoverageCollection;
1617
import ucar.nc2.ft2.coverage.CoverageDatasetFactory;
@@ -99,7 +100,7 @@ public void testAdapter() throws IOException {
99100
}
100101

101102
// check DtCoverageCS
102-
try (NetcdfDataset ds = NetcdfDataset.openDataset(endpoint)) {
103+
try (NetcdfDataset ds = NetcdfDatasets.openDataset(endpoint)) {
103104
Formatter errlog = new Formatter();
104105
DtCoverageCSBuilder builder = DtCoverageCSBuilder.classify(ds, errlog); // uses cs with largest # axes
105106
Assert.assertNotNull(errlog.toString(), builder);

cdm-test/src/test/java/ucar/nc2/ft/point/TestMiscPointFeature.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import ucar.nc2.VariableSimpleIF;
5151
import ucar.nc2.constants.FeatureType;
5252
import ucar.nc2.dataset.NetcdfDataset;
53+
import ucar.nc2.dataset.NetcdfDatasets;
5354
import ucar.nc2.ft.*;
5455
import ucar.nc2.time.CalendarDate;
5556
import ucar.nc2.time.CalendarDateRange;
@@ -303,12 +304,12 @@ public void testTryWith() throws IOException {
303304
@Test
304305
public void testTryWithWrap() throws IOException {
305306
String location = TestDir.cdmLocalFromTestDataDir + "testWrite.nc";
306-
NetcdfDataset ncd = NetcdfDataset.openDataset(location);
307-
Formatter errlog = new Formatter();
308-
try (FeatureDataset fdataset = FeatureDatasetFactoryManager.wrap(null, ncd, null, errlog)) {
309-
assert (fdataset == null);
307+
try (NetcdfDataset ncd = NetcdfDatasets.openDataset(location)) {
308+
Formatter errlog = new Formatter();
309+
try (FeatureDataset fdataset = FeatureDatasetFactoryManager.wrap(null, ncd, null, errlog)) {
310+
assert (fdataset == null);
311+
}
310312
}
311-
ncd.close();
312313
}
313314

314315
// This is a regression test for TDS-513: https://bugtracking.unidata.ucar.edu/browse/TDS-513

cdm-test/src/test/java/ucar/nc2/ft/point/standard/TestTableAnalyzer.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Formatter;
55
import org.junit.Test;
66
import org.junit.experimental.categories.Category;
7+
import ucar.nc2.NetcdfFile;
78
import ucar.nc2.dataset.NetcdfDataset;
89
import ucar.unidata.util.test.TestDir;
910
import ucar.unidata.util.test.category.NeedsCdmUnitTest;
@@ -14,10 +15,12 @@ public class TestTableAnalyzer {
1415
static void doit(String filename) throws IOException {
1516
filename = TestDir.cdmUnitTestDir + filename;
1617
System.out.println(filename);
17-
NetcdfDataset ncd = ucar.nc2.dataset.NetcdfDataset.openDataset(filename);
18-
TableAnalyzer csa = TableAnalyzer.factory(null, null, ncd);
19-
csa.getDetailInfo(new Formatter(System.out));
20-
System.out.println("%n-----------------");
18+
try (NetcdfDataset ncd = ucar.nc2.dataset.NetcdfDatasets.openDataset(filename, true, -1, null,
19+
NetcdfFile.IOSP_MESSAGE_ADD_RECORD_STRUCTURE)) {
20+
TableAnalyzer csa = TableAnalyzer.factory(null, null, ncd);
21+
csa.getDetailInfo(new Formatter(System.out));
22+
System.out.println("%n-----------------");
23+
}
2124
}
2225

2326
@Test

cdm-test/src/timing/java/ucar/nc2/TimeCdmRemote.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,13 @@ static Section makeSubset(Variable v) throws InvalidRangeException {
8080
return new Section(shape);
8181
}
8282

83-
8483
static void testRead(String filename, Stat stat, boolean readData) throws IOException, InvalidRangeException {
8584
long bytes = 0;
8685
long start = System.nanoTime();
8786
if (show)
8887
System.out.printf("%n------Reading filename %s (%s)%n", filename, stat.getName());
8988

90-
try (NetcdfFile ncfile = NetcdfDataset.openFile(filename, null)) {
89+
try (NetcdfFile ncfile = NetcdfDatasets.openFile(filename, null)) {
9190
if (readData)
9291
bytes = readAllData(ncfile);
9392
long end = System.nanoTime();

cdm/misc/src/test/java/ucar/nc2/TestDsmpCoverageClassification.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import ucar.nc2.constants.FeatureType;
1313
import ucar.nc2.dataset.CoordinateSystem;
1414
import ucar.nc2.dataset.NetcdfDataset;
15+
import ucar.nc2.dataset.NetcdfDatasets;
1516
import ucar.nc2.ft2.coverage.CoverageCollection;
1617
import ucar.nc2.ft2.coverage.CoverageDatasetFactory;
1718
import ucar.nc2.ft2.coverage.FeatureDatasetCoverage;
@@ -24,7 +25,6 @@
2425
/** Test Dsmp Coverage Classification */
2526
@Category(NeedsCdmUnitTest.class)
2627
public class TestDsmpCoverageClassification {
27-
2828
String endpoint = TestDir.cdmUnitTestDir + "formats/dmsp/F14200307192230.s.OIS";
2929
FeatureType expectType = FeatureType.SWATH;
3030
int domain = 2;
@@ -42,7 +42,7 @@ public void testAdapter() throws IOException {
4242
}
4343

4444
// check DtCoverageCS
45-
try (NetcdfDataset ds = NetcdfDataset.openDataset(endpoint)) {
45+
try (NetcdfDataset ds = NetcdfDatasets.openDataset(endpoint)) {
4646
Formatter errlog = new Formatter();
4747
DtCoverageCSBuilder builder = DtCoverageCSBuilder.classify(ds, errlog); // uses cs with largest # axes
4848
Assert.assertNotNull(errlog.toString(), builder);

cdm/radial/src/test/java/ucar/nc2/iosp/nexrad2/TestNexrad2.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import ucar.nc2.NetcdfFile;
1616
import ucar.nc2.Variable;
1717
import ucar.nc2.dataset.NetcdfDataset;
18+
import ucar.nc2.dataset.NetcdfDatasets;
1819
import ucar.nc2.dataset.VariableDS;
1920
import ucar.unidata.util.test.category.NeedsCdmUnitTest;
2021
import ucar.unidata.util.test.TestDir;
@@ -52,7 +53,7 @@ public int doAct(String filename) throws IOException {
5253
return 0;
5354
}
5455

55-
try (NetcdfFile ncfile = NetcdfDataset.openFile(filename, null)) {
56+
try (NetcdfFile ncfile = NetcdfDatasets.openFile(filename, null)) {
5657
return testRead(ncfile);
5758
}
5859
}
@@ -129,10 +130,8 @@ static public boolean testCoordSystem(NetcdfFile nexrad2) throws IOException {
129130

130131
@Test
131132
public void testCoordSys() throws IOException {
132-
// NetcdfDataset ncd = NetcdfDataset.openDataset(
133-
// "dods://localhost:8080/thredds/dodsC/testAll/Level2_KSOX_20051010_2322.ar2v", false, null);
134133
String filename = TestDir.cdmUnitTestDir + "formats/nexrad/level2/Level2_KYUX_20060527_2335.ar2v";
135-
try (NetcdfFile ncfile = NetcdfDataset.openFile(filename, null)) {
134+
try (NetcdfFile ncfile = NetcdfDatasets.openFile(filename, null)) {
136135
testCoordSystem(ncfile);
137136
}
138137
}
@@ -142,7 +141,7 @@ public void testBzipProblem() throws IOException, InvalidRangeException {
142141
// file where there was an error unzipping the file
143142
String filename =
144143
TestDir.cdmUnitTestDir + "formats/nexrad/level2/Level2_KFTG_20060818_1814.ar2v.uncompress.missingradials";
145-
try (NetcdfDataset ncd = NetcdfDataset.openDataset(filename)) {
144+
try (NetcdfDataset ncd = NetcdfDatasets.openDataset(filename)) {
146145

147146
VariableDS azi = (VariableDS) ncd.findVariable("azimuthR");
148147
assert azi != null;

cdm/radial/src/test/java/ucar/nc2/iosp/nexrad2/TestNexrad2HiResolution.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import ucar.nc2.NetcdfFile;
1515
import ucar.nc2.Variable;
1616
import ucar.nc2.dataset.NetcdfDataset;
17+
import ucar.nc2.dataset.NetcdfDatasets;
1718
import ucar.unidata.util.test.category.NeedsCdmUnitTest;
1819
import ucar.unidata.util.test.TestDir;
1920
import java.io.File;
@@ -51,15 +52,14 @@ public int doAct(String filename) throws IOException {
5152
return 0;
5253
}
5354

54-
try (NetcdfFile ncfile = NetcdfDataset.openFile(filename, null)) {
55+
try (NetcdfFile ncfile = NetcdfDatasets.openFile(filename, null)) {
5556
testRead(ncfile);
5657
testCoordSystem(ncfile);
5758
return 1;
5859
}
5960
}
6061
}
6162

62-
6363
private void testRead(NetcdfFile nexrad2) throws IOException {
6464
Dimension scanR = nexrad2.findDimension("scanR");
6565
assert null != scanR;

opendap/src/main/java/opendap/dap/HeaderInputStream.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
*
5050
* @author jehamby
5151
* @version $Revision: 15901 $
52-
* @see DConnect
5352
*/
5453
public class HeaderInputStream extends FilterInputStream {
5554
/**

0 commit comments

Comments
 (0)