static public void writeNcML ( NetcdfFile ncfile , Writer writer , WantValues showValues , String url ) throws IOException { Preconditions . checkNotNull ( ncfile ) ; Preconditions . checkNotNull ( writer ) ; Preconditions . checkNotNull ( showValues ) ; Predicate < Variable > writeVarsPred ; switch ( showValues ) { case none : writeVarsPred = NcMLWriter . writeNoVariablesPredicate ; break ; case coordsOnly : writeVarsPred = NcMLWriter . writeCoordinateVariablesPredicate ; break ; case all : writeVarsPred = NcMLWriter . writeAllVariablesPredicate ; break ; default : String message = String . format ( "CAN'T HAPPEN: showValues (%s) != null and checked all possible enum values." , showValues ) ; throw new AssertionError ( message ) ; } NcMLWriter ncmlWriter = new NcMLWriter ( ) ; ncmlWriter . setWriteVariablesPredicate ( writeVarsPred ) ; Element netcdfElement = ncmlWriter . makeNetcdfElement ( ncfile , url ) ; ncmlWriter . writeToWriter ( netcdfElement , writer ) ; }
Write the NcML representation for a file . Note that ucar . nc2 . dataset . NcMLWriter has a JDOM implementation for complete NcML . This method implements only the core NcML for plain ole netcdf files .