Input:
assume theres only one in effect at a time [CODESPLIT] private void operate ( List < DataDescriptor > tree ) { if ( tree == null ) return ; boolean hasAssFields = false ; // boolean hasDpiFields = false;
 DataDescriptor . AssociatedField assField = null ; // 02 04 Y
 Iterator < DataDescriptor > iter = tree . iterator ( ) ; while ( iter . hasNext ( ) ) { DataDescriptor dd = iter . next ( ) ; if ( dd . f == 2 ) { if ( dd . x == 1 ) { changeWidth = ( dd . y == 0 ) ? null : dd ; iter . remove ( ) ; } else if ( dd . x == 2 ) { changeScale = ( dd . y == 0 ) ? null : dd ; iter . remove ( ) ; // throw new UnsupportedOperationException("2-2-Y (change scale)");
 } else if ( dd . x == 3 ) { changeRefval = ( dd . y == 255 ) ? null : dd ; iter . remove ( ) ; // throw new UnsupportedOperationException("2-3-Y (change reference values)");  // untested - no examples
 } else if ( dd . x == 4 ) { assField = ( dd . y == 0 ) ? null : new DataDescriptor . AssociatedField ( dd . y ) ; iter . remove ( ) ; hasAssFields = true ; } else if ( dd . x == 5 ) { // char data - this allows arbitrary string to be inserted
 dd . type = 1 ; // String
 dd . bitWidth = dd . y * 8 ; dd . name = "Note" ; } else if ( dd . x == 6 ) { // see L3-82 (3.1.6.5)
 // "Y bits of data are described by the immediately following descriptor". could they speak English?
 iter . remove ( ) ; if ( ( dd . y != 0 ) && iter . hasNext ( ) ) { // fnmoc using 2-6-0 as cancel (apparently)
 DataDescriptor next = iter . next ( ) ; next . bitWidth = dd . y ; } } else if ( dd . x == 7 ) { changeWtf = ( dd . y == 0 ) ? null : dd ; iter . remove ( ) ; } else if ( dd . x == 36 ) { if ( iter . hasNext ( ) ) { DataDescriptor dpi_dd = iter . next ( ) ; // this should be a replicated data present field
 dpi = new DataPresentIndicator ( tree , dpi_dd ) ; dd . dpi = dpi ; dpi_dd . dpi = dpi ; } } else if ( ( dd . x == 37 ) && ( dd . y == 255 ) ) { // cancel dpi
 dpi = null ; } else if ( ( dd . x == 24 ) && ( dd . y == 255 ) ) { dd . dpi = dpi ; } } else if ( dd . subKeys != null ) { operate ( dd . subKeys ) ; } else if ( dd . f == 0 ) { if ( dd . type != 3 ) { // numeric or string or enum, not compound
 if ( changeWidth != null ) dd . bitWidth += changeWidth . y - 128 ; if ( changeScale != null ) dd . scale += changeScale . y - 128 ; if ( changeRefval != null ) dd . refVal += changeRefval . y - 128 ; // LOOK wrong
 if ( changeWtf != null && dd . type == 0 ) { // see I.2 – BUFR Table C — 4
 // For Table B elements, which are not CCITT IA5 (character data), code tables, or flag tables:
 //  1. Add Y to the existing scale factor
 //  2. Multiply the existing reference value by 10 Y
 //  3. Calculate ((10 x Y) + 2) ÷  3, disregard any fractional remainder and add the result to the existing bit width.
 // HAHAHAHAHAHAHAHA
 int y = changeWtf . y ; dd . scale += y ; dd . refVal *= Math . pow ( 10 , y ) ; int wtf = ( ( 10 * y ) + 2 ) / 3 ; dd . bitWidth += wtf ; } } if ( ( dd . f == 0 ) && ( assField != null ) ) { assField . nfields ++ ; dd . assField = assField ; assField . dataFldName = dd . name ; } } } if ( hasAssFields ) addAssFields ( tree ) ; // if (hasDpiFields) addDpiFields(tree);
 }


Input:
///////////////// local time types [CODESPLIT] @ Override public Grib1ParamTime getParamTime ( Grib1SectionProductDefinition pds ) { int p1 = pds . getTimeValue1 ( ) ; // octet 19 int p2 = pds . getTimeValue2 ( ) ; // octet 20 int timeRangeIndicator = pds . getTimeRangeIndicator ( ) ; // octet 21 int n = pds . getNincluded ( ) ; int start ; int end ; int forecastTime = 0 ; boolean isInterval ; switch ( timeRangeIndicator ) { /*
      Monthly-diurnal (ds628.5/fcst_phy2m125_diurnal)
      Average over the days of the month.
      128: Average of N forecast products with a valid time ranging between reference time + P1 and reference time + P2;
        products have reference times at Intervals of 24 hours, beginning at the given reference time.
       */ case 128 : isInterval = true ; start = p1 ; end = p2 ; break ; /* 129: Temporal variance of N forecasts; each product has valid time ranging between reference time + P1 and reference time + P2;
         products have reference times at intervals of 24 hours, beginning at the given reference time;
         unit of measurement is square of that in Code Table 2 */ // LOOK /* 131: Temporal variance of N forecasts; valid time of the first product ranges between R + P1 and R + P2,
          where R is reference time given in octets 13 to 17, then subsequent products have valid time range at interval of P2 - P1;
          thus all N products cover continuous time span; products have reference times at intervals of P2 - P1, beginning at the given reference time;
          unit of measurement is square of that in Code Table 2 */ // LOOK case 129 : case 131 : isInterval = true ; start = p1 ; end = p2 ; break ; /* 130: Average of N forecast products; valid time of the first product ranges between R + P1 and R + P2, where R is reference time given in octets 13 to 17,
        then subsequent products have valid time range at interval of P2 - P1; thus all N products cover continuous time span; products have reference times at
        intervals of P2 - P1, beginning at the given reference time
       */ case 130 : isInterval = true ; start = p1 ; end = ( n > 0 ) ? p1 + n * ( p2 - p1 ) : p2 ; // prob n >= 1 break ; /* Temporal variance of N uninitialized analyses (P1 = 0) or instantaneous forecasts (P1 > 0);
          each product has valid time at the reference time + P1;
          products have reference times at intervals of P2, beginning at the given reference time;
          unit of measurement is square of that in Code Table 2 */ // LOOK case 132 : forecastTime = p1 ; start = p1 ; end = ( n > 0 ) ? p1 + ( n - 1 ) * p2 : p1 ; // LOOK ?? isInterval = ( n > 0 ) ; break ; default : return super . getParamTime ( pds ) ; } return new Grib1ParamTime ( this , timeRangeIndicator , isInterval , start , end , forecastTime ) ; }


Input: Get the dataset filename . [CODESPLIT] public String getDatasetFilename ( ) { String s = getEncodedName ( ) ; System . out . println ( s ) ; return ( s ) ; }


Input: Print the constrained <code > DDS< / code > on the given <code > PrintWriter< / code > . [CODESPLIT] public void printConstrained ( PrintWriter os ) { os . println ( "Dataset {" ) ; for ( Enumeration e = getVariables ( ) ; e . hasMoreElements ( ) ; ) { BaseType bt = ( BaseType ) e . nextElement ( ) ; // System.err.println("check: "+bt.getLongName()+" = "+((ServerMethods) bt).isProject()); ServerMethods sm = ( ServerMethods ) bt ; if ( sm . isProject ( ) ) { bt . printDecl ( os , "    " , true , true ) ; } } os . print ( "} " ) ; if ( getEncodedName ( ) != null ) os . print ( getEncodedName ( ) ) ; os . println ( ";" ) ; }


Input:
Is this a valid file? [CODESPLIT] public boolean isValidFile ( RandomAccessFile raf ) throws IOException { if ( ! super . isValidFile ( raf ) ) { return false ; } // TODO:  handle other types of surface files
 return gemreader . getFileSubType ( ) . equals ( GempakSurfaceFileReader . STANDARD ) || gemreader . getFileSubType ( ) . equals ( GempakSurfaceFileReader . SHIP ) ; }


Input: Get the CF feature type [CODESPLIT] public String getCFFeatureType ( ) { if ( gemreader . getFileSubType ( ) . equals ( GempakSurfaceFileReader . SHIP ) ) { return CF . FeatureType . point . toString ( ) ; } return CF . FeatureType . timeSeries . toString ( ) ; }


Input:
Read the data for the variable [CODESPLIT] public Array readData ( Variable v2 , Section section ) throws IOException , InvalidRangeException { if ( gemreader == null ) { return null ; } //System.out.println("looking for " + v2);
 //System.out.println("Section = " + section);
 //Trace.call1("GEMPAKSIOSP: readData");
 Array array = null ; if ( gemreader . getFileSubType ( ) . equals ( GempakSurfaceFileReader . SHIP ) ) { array = readShipData ( v2 , section ) ; } else if ( gemreader . getFileSubType ( ) . equals ( GempakSurfaceFileReader . STANDARD ) ) { array = readStandardData ( v2 , section ) ; } else { // climate data
 //array = readClimateData(v2, section);
 } //  long took = System.currentTimeMillis() - start;
 //  System.out.println("  read data took=" + took + " msec ");
 //Trace.call2("GEMPAKSIOSP: readData");
 return array ; }


Input:
Read in the data for the variable . In this case it should be a Structure . The section should be rank 2 ( station time ) . [CODESPLIT] private Array readStandardData ( Variable v2 , Section section ) throws IOException { Array array = null ; if ( v2 instanceof Structure ) { List < GempakParameter > params = gemreader . getParameters ( GempakSurfaceFileReader . SFDT ) ; Structure pdata = ( Structure ) v2 ; StructureMembers members = pdata . makeStructureMembers ( ) ; List < StructureMembers . Member > mbers = members . getMembers ( ) ; int i = 0 ; int numBytes = 0 ; int totalNumBytes = 0 ; for ( StructureMembers . Member member : mbers ) { member . setDataParam ( 4 * i ++ ) ; numBytes = member . getDataType ( ) . getSize ( ) ; totalNumBytes += numBytes ; } // one member is a byte
 members . setStructureSize ( totalNumBytes ) ; float [ ] missing = new float [ mbers . size ( ) ] ; int missnum = 0 ; for ( Variable v : pdata . getVariables ( ) ) { Attribute att = v . findAttribute ( "missing_value" ) ; missing [ missnum ++ ] = ( att == null ) ? GempakConstants . RMISSD : att . getNumericValue ( ) . floatValue ( ) ; } //int num = 0;
 Range stationRange = section . getRange ( 0 ) ; Range timeRange = section . getRange ( 1 ) ; int size = stationRange . length ( ) * timeRange . length ( ) ; // Create a ByteBuffer using a byte array
 byte [ ] bytes = new byte [ totalNumBytes * size ] ; ByteBuffer buf = ByteBuffer . wrap ( bytes ) ; array = new ArrayStructureBB ( members , new int [ ] { size } , buf , 0 ) ; for ( int stnIdx : stationRange ) { for ( int timeIdx : timeRange ) { GempakFileReader . RData vals = gemreader . DM_RDTR ( timeIdx + 1 , stnIdx + 1 , GempakSurfaceFileReader . SFDT ) ; if ( vals == null ) { int k = 0 ; for ( StructureMembers . Member member : mbers ) { if ( member . getDataType ( ) . equals ( DataType . FLOAT ) ) { buf . putFloat ( missing [ k ] ) ; } else { buf . put ( ( byte ) 1 ) ; } k ++ ; } } else { float [ ] reals = vals . data ; int var = 0 ; for ( GempakParameter param : params ) { if ( members . findMember ( param . getName ( ) ) != null ) { buf . putFloat ( reals [ var ] ) ; } var ++ ; } // always add the missing flag
 buf . put ( ( byte ) 0 ) ; } } } //Trace.call2("GEMPAKSIOSP: readStandardData");
 } return array ; }


Input:
Read in the data for the record variable . In this case it should be a Structure of record dimension . We can handle a subset of the variables in a structure . [CODESPLIT] private Array readShipData ( Variable v2 , Section section ) throws IOException { Array array = null ; if ( v2 instanceof Structure ) { List < GempakParameter > params = gemreader . getParameters ( GempakSurfaceFileReader . SFDT ) ; Structure pdata = ( Structure ) v2 ; StructureMembers members = pdata . makeStructureMembers ( ) ; List < StructureMembers . Member > mbers = members . getMembers ( ) ; int ssize = 0 ; //int stnVarNum = 0;
 List < String > stnKeyNames = gemreader . getStationKeyNames ( ) ; for ( StructureMembers . Member member : mbers ) { if ( stnKeyNames . contains ( member . getName ( ) ) ) { int varSize = getStnVarSize ( member . getName ( ) ) ; member . setDataParam ( ssize ) ; ssize += varSize ; } else if ( member . getName ( ) . equals ( TIME_VAR ) ) { member . setDataParam ( ssize ) ; ssize += 8 ; } else if ( member . getName ( ) . equals ( MISSING_VAR ) ) { member . setDataParam ( ssize ) ; ssize += 1 ; } else { member . setDataParam ( ssize ) ; ssize += 4 ; } } members . setStructureSize ( ssize ) ; // TODO:  figure out how to get the missing value for data
 //float[] missing = new float[mbers.size()];
 //int     missnum = 0;
 //for (Variable v : pdata.getVariables()) {
 //    Attribute att = v.findAttribute("missing_value");
 //    missing[missnum++] = (att == null)
 //                         ? GempakConstants.RMISSD
 //                         : att.getNumericValue().floatValue();
 //}
 Range recordRange = section . getRange ( 0 ) ; int size = recordRange . length ( ) ; // Create a ByteBuffer using a byte array
 byte [ ] bytes = new byte [ ssize * size ] ; ByteBuffer buf = ByteBuffer . wrap ( bytes ) ; array = new ArrayStructureBB ( members , new int [ ] { size } , buf , 0 ) ; List < GempakStation > stationList = gemreader . getStations ( ) ; List < Date > dateList = gemreader . getDates ( ) ; boolean needToReadData = ! pdata . isSubset ( ) ; if ( ! needToReadData ) { // subset, see if we need some param data
 for ( GempakParameter param : params ) { if ( members . findMember ( param . getName ( ) ) != null ) { needToReadData = true ; break ; } } } //boolean hasTime = (members.findMember(TIME_VAR) != null);
 // fill out the station information
 for ( int recIdx : recordRange ) { GempakStation stn = stationList . get ( recIdx ) ; for ( String varname : stnKeyNames ) { if ( members . findMember ( varname ) == null ) { continue ; } String temp = null ; switch ( varname ) { case GempakStation . STID : temp = StringUtil2 . padRight ( stn . getName ( ) , 8 ) ; break ; case GempakStation . STNM : buf . putInt ( stn . getSTNM ( ) ) ; break ; case GempakStation . SLAT : buf . putFloat ( ( float ) stn . getLatitude ( ) ) ; break ; case GempakStation . SLON : buf . putFloat ( ( float ) stn . getLongitude ( ) ) ; break ; case GempakStation . SELV : buf . putFloat ( ( float ) stn . getAltitude ( ) ) ; break ; case GempakStation . STAT : temp = StringUtil2 . padRight ( stn . getSTAT ( ) , 2 ) ; break ; case GempakStation . COUN : temp = StringUtil2 . padRight ( stn . getCOUN ( ) , 2 ) ; break ; case GempakStation . STD2 : temp = StringUtil2 . padRight ( stn . getSTD2 ( ) , 4 ) ; break ; case GempakStation . SPRI : buf . putInt ( stn . getSPRI ( ) ) ; break ; case GempakStation . SWFO : temp = StringUtil2 . padRight ( stn . getSWFO ( ) , 4 ) ; break ; case GempakStation . WFO2 : temp = StringUtil2 . padRight ( stn . getWFO2 ( ) , 4 ) ; break ; } if ( temp != null ) { buf . put ( temp . getBytes ( CDM . utf8Charset ) ) ; } } if ( members . findMember ( TIME_VAR ) != null ) { // put in the time
 Date time = dateList . get ( recIdx ) ; buf . putDouble ( time . getTime ( ) / 1000.d ) ; } if ( needToReadData ) { int column = stn . getIndex ( ) ; GempakFileReader . RData vals = gemreader . DM_RDTR ( 1 , column , GempakSurfaceFileReader . SFDT ) ; if ( vals == null ) { for ( GempakParameter param : params ) { if ( members . findMember ( param . getName ( ) ) != null ) { buf . putFloat ( GempakConstants . RMISSD ) ; } } buf . put ( ( byte ) 1 ) ; } else { float [ ] reals = vals . data ; int var = 0 ; for ( GempakParameter param : params ) { if ( members . findMember ( param . getName ( ) ) != null ) { buf . putFloat ( reals [ var ] ) ; } var ++ ; } buf . put ( ( byte ) 0 ) ; } } } //Trace.call2("GEMPAKSIOSP: readShipData");
 } return array ; }


Input: Build the netCDF file [CODESPLIT] protected void fillNCFile ( ) throws IOException { String fileType = gemreader . getFileSubType ( ) ; switch ( fileType ) { case GempakSurfaceFileReader . STANDARD : buildStandardFile ( ) ; break ; case GempakSurfaceFileReader . SHIP : buildShipFile ( ) ; break ; default : buildClimateFile ( ) ; break ; } }


Input:
Build a standard station structure [CODESPLIT] private void buildStandardFile ( ) { // Build station list
 List < GempakStation > stations = gemreader . getStations ( ) ; //Trace.msg("GEMPAKSIOSP: now have " + stations.size() + " stations");
 Dimension station = new Dimension ( "station" , stations . size ( ) , true ) ; ncfile . addDimension ( null , station ) ; ncfile . addDimension ( null , DIM_LEN8 ) ; ncfile . addDimension ( null , DIM_LEN4 ) ; ncfile . addDimension ( null , DIM_LEN2 ) ; List < Variable > stationVars = makeStationVars ( stations , station ) ; // loop through and add to ncfile
 for ( Variable stnVar : stationVars ) { ncfile . addVariable ( null , stnVar ) ; } // Build variable list (var(station,time))
 // time
 List < Date > timeList = gemreader . getDates ( ) ; int numTimes = timeList . size ( ) ; Dimension times = new Dimension ( TIME_VAR , numTimes , true ) ; ncfile . addDimension ( null , times ) ; Array varArray ; Variable timeVar = new Variable ( ncfile , null , null , TIME_VAR , DataType . DOUBLE , TIME_VAR ) ; timeVar . addAttribute ( new Attribute ( CDM . UNITS , "seconds since 1970-01-01 00:00:00" ) ) ; timeVar . addAttribute ( new Attribute ( "long_name" , TIME_VAR ) ) ; varArray = new ArrayDouble . D1 ( numTimes ) ; int i = 0 ; for ( Date date : timeList ) { ( ( ArrayDouble . D1 ) varArray ) . set ( i , date . getTime ( ) / 1000.d ) ; i ++ ; } timeVar . setCachedData ( varArray , false ) ; ncfile . addVariable ( null , timeVar ) ; List < Dimension > stationTime = new ArrayList <> ( ) ; stationTime . add ( station ) ; stationTime . add ( times ) ; // TODO: handle other parts
 Structure sfData = makeStructure ( GempakSurfaceFileReader . SFDT , stationTime , true ) ; if ( sfData == null ) { return ; } sfData . addAttribute ( new Attribute ( CF . COORDINATES , "time SLAT SLON SELV" ) ) ; ncfile . addVariable ( null , sfData ) ; ncfile . addAttribute ( null , new Attribute ( "CF:featureType" , CF . FeatureType . timeSeries . toString ( ) ) ) ; }


Input:
Build a ship station structure . Here the columns are the stations / reports and the rows ( 1 ) are the reports . [CODESPLIT] private void buildShipFile ( ) { // Build variable list (var(station,time))
 List < GempakStation > stations = gemreader . getStations ( ) ; int numObs = stations . size ( ) ; //Trace.msg("GEMPAKSIOSP: now have " + numObs + " stations");
 Dimension record = new Dimension ( "record" , numObs , true , ( numObs == 0 ) , false ) ; ncfile . addDimension ( null , record ) ; List < Dimension > records = new ArrayList <> ( 1 ) ; records . add ( record ) ; // time
 Variable timeVar = new Variable ( ncfile , null , null , TIME_VAR , DataType . DOUBLE , ( String ) null ) ; timeVar . addAttribute ( new Attribute ( CDM . UNITS , "seconds since 1970-01-01 00:00:00" ) ) ; timeVar . addAttribute ( new Attribute ( "long_name" , TIME_VAR ) ) ; ncfile . addDimension ( null , DIM_LEN8 ) ; ncfile . addDimension ( null , DIM_LEN4 ) ; ncfile . addDimension ( null , DIM_LEN2 ) ; List < Variable > stationVars = makeStationVars ( stations , null ) ; List < GempakParameter > params = gemreader . getParameters ( GempakSurfaceFileReader . SFDT ) ; if ( params == null ) { return ; } Structure sVar = new Structure ( ncfile , null , null , "Obs" ) ; sVar . setDimensions ( records ) ; // loop through and add to ncfile
 boolean hasElevation = false ; for ( Variable stnVar : stationVars ) { if ( stnVar . getShortName ( ) . equals ( "SELV" ) ) { hasElevation = true ; } sVar . addMemberVariable ( stnVar ) ; } sVar . addMemberVariable ( timeVar ) ; for ( GempakParameter param : params ) { Variable var = makeParamVariable ( param , null ) ; sVar . addMemberVariable ( var ) ; } sVar . addMemberVariable ( makeMissingVariable ( ) ) ; String coords = "Obs.time Obs.SLAT Obs.SLON" ; if ( hasElevation ) { coords = coords + " Obs.SELV" ; } sVar . addAttribute ( new Attribute ( CF . COORDINATES , coords ) ) ; ncfile . addVariable ( null , sVar ) ; ncfile . addAttribute ( null , new Attribute ( "CF:featureType" , CF . FeatureType . point . toString ( ) ) ) ; }


Input: Returns the absolute difference between two numbers i . e . { @code |a - b| } . [CODESPLIT] public static float absoluteDifference ( float a , float b ) { if ( Float . compare ( a , b ) == 0 ) { // Shortcut: handles infinities and NaNs. return 0 ; } else { return Math . abs ( a - b ) ; } }


Input: Same as { [CODESPLIT] public static double absoluteDifference ( double a , double b ) { if ( Double . compare ( a , b ) == 0 ) { // Shortcut: handles infinities and NaNs. return 0 ; } else { return Math . abs ( a - b ) ; } }


Input: Returns the relative difference between two numbers i . e . { @code |a - b| / max ( |a| |b| ) } . <p > For cases where { @code a == 0 } { @code b == 0 } or { @code a } and { @code b } are extremely close traditional relative difference calculation breaks down . So in those instances we compute the difference relative to { @link Float#MIN_NORMAL } i . e . { @code |a - b| / Float . MIN_NORMAL } . [CODESPLIT] public static float relativeDifference ( float a , float b ) { float absDiff = absoluteDifference ( a , b ) ; if ( Float . compare ( a , b ) == 0 ) { // Shortcut: handles infinities and NaNs. return 0 ; } else if ( a == 0 || b == 0 || absDiff < Float . MIN_NORMAL ) { return absDiff / Float . MIN_NORMAL ; } else { float maxAbsValue = Math . max ( Math . abs ( a ) , Math . abs ( b ) ) ; return absDiff / maxAbsValue ; } }


Input: Check if two numbers are nearly equal with given absolute tolerance . [CODESPLIT] public static boolean nearlyEqualsAbs ( float a , float b , float maxAbsDiff ) { return absoluteDifference ( a , b ) <= Math . abs ( maxAbsDiff ) ; }


Input: //////////////////////////////////////////////////////////////////// [CODESPLIT] static public boolean compare ( byte [ ] raw1 , byte [ ] raw2 , Formatter f ) { if ( raw1 == null || raw2 == null ) return false ; if ( raw1 . length != raw2 . length ) { f . format ( "length 1= %3d != length 2=%3d%n" , raw1 . length , raw2 . length ) ; } int len = Math . min ( raw1 . length , raw2 . length ) ; int ndiff = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( raw1 [ i ] != raw2 [ i ] ) { f . format ( " %3d : %3d != %3d%n" , i + 1 , raw1 [ i ] , raw2 [ i ] ) ; ndiff ++ ; } } f . format ( "tested %d bytes  diff = %d %n" , len , ndiff ) ; return ndiff == 0 && ( raw1 . length == raw2 . length ) ; }


Input: } [CODESPLIT] public static InvDataset copyDataset ( InvDataset dataset , List < InvService > availableServices , boolean copyInheritedMetadataFromParents ) { if ( dataset == null ) throw new IllegalArgumentException ( "Dataset may not be null." ) ; if ( availableServices == null ) throw new IllegalArgumentException ( "List of available services may not be null." ) ; InvDatasetImpl resultDs ; // ToDo Deal with InvDatasetScan and its ilk. if ( dataset instanceof InvCatalogRef ) { InvCatalogRef catRef = ( InvCatalogRef ) dataset ; resultDs = new InvCatalogRef ( null , catRef . getName ( ) , catRef . getXlinkHref ( ) ) ; } else { resultDs = new InvDatasetImpl ( null , dataset . getName ( ) ) ; } resultDs . setID ( dataset . getID ( ) ) ; resultDs . transferMetadata ( ( InvDatasetImpl ) dataset , copyInheritedMetadataFromParents ) ; // Only copy child InvAccess if the current dataset is not an InvCatalogRef. if ( ! ( dataset instanceof InvCatalogRef ) ) { String urlPath = ( ( InvDatasetImpl ) dataset ) . getUrlPath ( ) ; if ( urlPath != null ) resultDs . setUrlPath ( urlPath ) ; else { for ( InvAccess curAccess : dataset . getAccess ( ) ) { InvAccess access = copyAccess ( curAccess , resultDs , availableServices ) ; if ( access != null ) resultDs . addAccess ( access ) ; } } } // Only recurse into child datasets if the current dataset is not an InvCatalogRef. if ( ! ( dataset instanceof InvCatalogRef ) ) { for ( InvDataset curDs : dataset . getDatasets ( ) ) { InvDatasetImpl curDsCopy = ( InvDatasetImpl ) copyDataset ( curDs , availableServices , false ) ; curDsCopy . setParent ( resultDs ) ; resultDs . addDataset ( curDsCopy ) ; } } return resultDs ; }


Input:
/ * 14 . 1 <BC_TableB_BUFR14_1_0_CREX_6_1_0 > <SNo > 1< / SNo > <Class > 00< / Class > <FXY > 000001< / FXY > <ElementName_E > Table A : entry< / ElementName_E > <ElementName_F > Table A : entr?e< / ElementName_F > <ElementName_R > ??????? ? : ???????< / ElementName_R > <ElementName_S > Tabla A : elemento< / ElementName_S > <BUFR_Unit > CCITT IA5< / BUFR_Unit > <BUFR_Scale > 0< / BUFR_Scale > <BUFR_ReferenceValue > 0< / BUFR_ReferenceValue > <BUFR_DataWidth_Bits > 24< / BUFR_DataWidth_Bits > <CREX_Unit > Character< / CREX_Unit > <CREX_Scale > 0< / CREX_Scale > <CREX_DataWidth > 3< / CREX_DataWidth > <Status > Operational< / Status > <NotesToTable_E > Notes : ( see ) #BUFR14_1_0_CREX6_1_0_Notes . doc#BC_Cl000< / NotesToTable_E > < / BC_TableB_BUFR14_1_0_CREX_6_1_0 > [CODESPLIT] static void readWmoXmlTableB ( InputStream ios , TableB b ) throws IOException { org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; doc = builder . build ( ios ) ; } catch ( JDOMException e ) { throw new IOException ( e . getMessage ( ) ) ; } Element root = doc . getRootElement ( ) ; String [ ] elems = null ; for ( Version v : Version . values ( ) ) { elems = v . getElemNamesB ( ) ; List < Element > featList = root . getChildren ( elems [ 0 ] ) ; if ( featList != null && featList . size ( ) > 0 ) { break ; } } // if not found using element name, assume its BUFR_WMO
 if ( elems == null ) { elems = Version . BUFR_WMO . getElemNamesB ( ) ; } List < Element > featList = root . getChildren ( ) ; for ( Element elem : featList ) { Element ce = elem . getChild ( elems [ 1 ] ) ; if ( ce == null ) continue ; String name = Util . cleanName ( elem . getChildTextNormalize ( elems [ 1 ] ) ) ; String units = cleanUnit ( elem . getChildTextNormalize ( "BUFR_Unit" ) ) ; int x = 0 , y = 0 , scale = 0 , reference = 0 , width = 0 ; String fxy = null ; String s = null ; try { fxy = elem . getChildTextNormalize ( "FXY" ) ; int xy = Integer . parseInt ( cleanNumber ( fxy ) ) ; x = xy / 1000 ; y = xy % 1000 ; } catch ( NumberFormatException e ) { System . out . printf ( " key %s name '%s' fails parsing %n" , fxy , name ) ; } try { s = elem . getChildTextNormalize ( "BUFR_Scale" ) ; scale = Integer . parseInt ( cleanNumber ( s ) ) ; } catch ( NumberFormatException e ) { System . out . printf ( " key %s name '%s' has bad scale='%s'%n" , fxy , name , s ) ; } try { s = elem . getChildTextNormalize ( "BUFR_ReferenceValue" ) ; reference = Integer . parseInt ( cleanNumber ( s ) ) ; } catch ( NumberFormatException e ) { System . out . printf ( " key %s name '%s' has bad reference='%s' %n" , fxy , name , s ) ; } try { s = elem . getChildTextNormalize ( "BUFR_DataWidth_Bits" ) ; width = Integer . parseInt ( cleanNumber ( s ) ) ; } catch ( NumberFormatException e ) { System . out . printf ( " key %s name '%s' has bad width='%s' %n" , fxy , name , s ) ; } b . addDescriptor ( ( short ) x , ( short ) y , scale , reference , width , name , units , null ) ; } ios . close ( ) ; }


Input: / * <B_TableD_BUFR14_1_0_CREX_6_1_0 > <SNo > 2647< / SNo > <Category > 10< / Category > <FXY1 > 310013< / FXY1 > <ElementName1_E > ( AVHRR ( GAC ) report ) < / ElementName1_E > <FXY2 > 004005< / FXY2 > <ElementName2_E > Minute< / ElementName2_E > <Remarks_E > Minute< / Remarks_E > <Status > Operational< / Status > < / B_TableD_BUFR14_1_0_CREX_6_1_0 > [CODESPLIT] static void readWmoXmlTableD ( InputStream ios , TableD tableD ) throws IOException { org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; doc = builder . build ( ios ) ; } catch ( JDOMException e ) { throw new IOException ( e . getMessage ( ) ) ; } int currSeqno = - 1 ; TableD . Descriptor currDesc = null ; Element root = doc . getRootElement ( ) ; String [ ] elems = null ; for ( Version v : Version . values ( ) ) { elems = v . getElemNamesD ( ) ; List < Element > featList = root . getChildren ( elems [ 0 ] ) ; if ( featList != null && featList . size ( ) > 0 ) { break ; } } if ( elems == null ) { elems = Version . BUFR_WMO . getElemNamesD ( ) ; } List < Element > featList = root . getChildren ( ) ; for ( Element elem : featList ) { Element ce = elem . getChild ( elems [ 1 ] ) ; if ( ce == null ) continue ; String seqs = elem . getChildTextNormalize ( "FXY1" ) ; int seq = Integer . parseInt ( seqs ) ; if ( currSeqno != seq ) { int y = seq % 1000 ; int w = seq / 1000 ; int x = w % 100 ; String seqName = Util . cleanName ( elem . getChildTextNormalize ( elems [ 1 ] ) ) ; currDesc = tableD . addDescriptor ( ( short ) x , ( short ) y , seqName , new ArrayList < Short > ( ) ) ; currSeqno = seq ; } String fnos = elem . getChildTextNormalize ( "FXY2" ) ; int fno = Integer . parseInt ( fnos ) ; int y = fno % 1000 ; int w = fno / 1000 ; int x = w % 100 ; int f = w / 100 ; int fxy = ( f << 14 ) + ( x << 8 ) + y ; currDesc . addFeature ( ( short ) fxy ) ; } ios . close ( ) ; }


Input: / * message Gds { bytes gds = 1 ; // raw gds : Grib1SectionGridDefinition or Grib2SectionGridDefinition uint32 predefinedGridDefinition = 2 ; // only grib1 ; instead of gds raw bytes ; need center subcenter to interpret } [CODESPLIT] static GribCollectionProto . Gds writeGdsProto ( byte [ ] rawGds , int predefinedGridDefinition ) { GribCollectionProto . Gds . Builder b = GribCollectionProto . Gds . newBuilder ( ) ; if ( predefinedGridDefinition >= 0 ) b . setPredefinedGridDefinition ( predefinedGridDefinition ) ; else { b . setGds ( ByteString . copyFrom ( rawGds ) ) ; } return b . build ( ) ; }


Input: / * message Coord { GribAxisType axisType = 1 ; int32 code = 2 ; // time unit ; level type string unit = 3 ; repeated float values = 4 ; repeated float bound = 5 ; // only used if interval then = ( value bound ) repeated int64 msecs = 6 ; // calendar date [CODESPLIT] GribCollectionProto . Coord writeCoordProto ( CoordinateRuntime coord ) { GribCollectionProto . Coord . Builder b = GribCollectionProto . Coord . newBuilder ( ) ; b . setAxisType ( convertAxisType ( coord . getType ( ) ) ) ; b . setCode ( coord . getCode ( ) ) ; if ( coord . getUnit ( ) != null ) b . setUnit ( coord . getUnit ( ) ) ; for ( int idx = 0 ; idx < coord . getSize ( ) ; idx ++ ) { long runtime = coord . getRuntime ( idx ) ; b . addMsecs ( runtime ) ; } return b . build ( ) ; }


Input: / * not currently used [CODESPLIT] public static GribCollectionProto . GribAxisType convertAxisType ( Coordinate . Type type ) { switch ( type ) { case runtime : return GribCollectionProto . GribAxisType . runtime ; case time : return GribCollectionProto . GribAxisType . time ; case time2D : return GribCollectionProto . GribAxisType . time2D ; case timeIntv : return GribCollectionProto . GribAxisType . timeIntv ; case ens : return GribCollectionProto . GribAxisType . ens ; case vert : return GribCollectionProto . GribAxisType . vert ; } throw new IllegalStateException ( "illegal axis type " + type ) ; }


Input: Selected consult or iterator overrides for efficiency [CODESPLIT] @ Override public boolean references ( DapNode node ) { switch ( node . getSort ( ) ) { case DIMENSION : case ENUMERATION : case VARIABLE : case GROUP : case DATASET : return true ; default : break ; } return false ; }


Input: Parses a unit specification . This method is thread - safe . [CODESPLIT] public final Unit parse ( final String spec ) throws NoSuchUnitException , UnitParseException , SpecificationException , UnitDBException , PrefixDBException , UnitSystemException { synchronized ( MUTEX ) { return parse ( spec , UnitDBManager . instance ( ) ) ; } }


Input:
Sort Ray objects in the same sweep according to the ascended azimuth ( from 0 to 360 ) and time . [CODESPLIT] void checkSort ( Ray [ ] r ) { int j = 0 , n = 0 , n1 = 0 , n2 = 0 ; short time1 = 0 , time2 = 0 ; int [ ] k1 = new int [ 300 ] ; int [ ] k2 = new int [ 300 ] ; //      define the groups of rays with the same "time". For ex.:
 //      group1 - ray[0]={time=1,az=344}, ray[1]={time=1,az=345}, ... ray[11]={time=1,az=359}
 //      group2 - ray[12]={time=1,az=0}, ray[13]={time=1,az=1}, ... ray[15]={time=1,az=5}
 //      k1- array of begin indx (0,12), k2- array of end indx (11,15)
 for ( int i = 0 ; i < r . length - 1 ; i ++ ) { time1 = r [ i ] . getTime ( ) ; time2 = r [ i + 1 ] . getTime ( ) ; if ( time1 != time2 ) { k2 [ j ] = i ; j = j + 1 ; k1 [ j ] = i + 1 ; } } if ( k2 [ j ] < r . length - 1 ) { k1 [ j ] = k2 [ j - 1 ] + 1 ; k2 [ j ] = r . length - 1 ; n = j + 1 ; } //      if different groups have the same value of "time" (may be 2 and more groups) -
 //      it1= indx of "k1" of 1st group, it2= indx of "k2" of last group
 int it1 = 0 , it2 = 0 ; for ( int ii = 0 ; ii < j + 1 ; ii ++ ) { n1 = k1 [ ii ] ; for ( int i = 0 ; i < j + 1 ; i ++ ) { if ( i != ii ) { n2 = k1 [ i ] ; if ( r [ n1 ] . getTime ( ) == r [ n2 ] . getTime ( ) ) { it1 = ii ; it2 = i ; } } } } n1 = k1 [ it1 ] ; n2 = k1 [ it2 ] ; int s1 = k2 [ it1 ] - k1 [ it1 ] + 1 ; int s2 = k2 [ it2 ] - k1 [ it2 ] + 1 ; float [ ] t0 = new float [ s1 ] ; float [ ] t00 = new float [ s2 ] ; for ( int i = 0 ; i < s1 ; i ++ ) { t0 [ i ] = r [ n1 + i ] . getAz ( ) ; } for ( int i = 0 ; i < s2 ; i ++ ) { t00 [ i ] = r [ n2 + i ] . getAz ( ) ; } float mx0 = t0 [ 0 ] ; for ( int i = 0 ; i < s1 ; i ++ ) { if ( mx0 < t0 [ i ] ) mx0 = t0 [ i ] ; } float mx00 = t00 [ 0 ] ; for ( int i = 0 ; i < s2 ; i ++ ) { if ( mx00 < t00 [ i ] ) mx00 = t00 [ i ] ; } if ( ( mx0 > 330.0f & mx00 < 50.0f ) ) { for ( int i = 0 ; i < s1 ; i ++ ) { float q = r [ n1 + i ] . getAz ( ) ; r [ n1 + i ] . setAz ( q - 360.0f ) ; } } Arrays . sort ( r , new RayComparator ( ) ) ; for ( int i = 0 ; i < r . length ; i ++ ) { float a = r [ i ] . getAz ( ) ; if ( a < 0 & a > - 361.0f ) { float qa = r [ i ] . getAz ( ) ; r [ i ] . setAz ( qa + 360.0f ) ; } } }


Input: Show me lots of stuff about the passed in object [CODESPLIT] public static void probeObject ( Object o ) { Class c = o . getClass ( ) ; Class interfaces [ ] = c . getInterfaces ( ) ; Class parent = c . getSuperclass ( ) ; Method m [ ] = c . getMethods ( ) ; System . out . println ( "********* OBJECT PROBE *********" ) ; System . out . println ( "Class Name:  " + c . getName ( ) ) ; System . out . println ( "Super Class: " + parent . getName ( ) ) ; System . out . println ( "Interfaces: " ) ; for ( int i = 0 ; i < interfaces . length ; i ++ ) { System . out . println ( "    " + interfaces [ i ] . getName ( ) ) ; } System . out . println ( "Methods:" ) ; for ( int i = 0 ; i < m . length ; i ++ ) { Class params [ ] = m [ i ] . getParameterTypes ( ) ; Class excepts [ ] = m [ i ] . getExceptionTypes ( ) ; Class ret = m [ i ] . getReturnType ( ) ; System . out . print ( "    " + ret . getName ( ) + "  " + m [ i ] . getName ( ) + "(" ) ; for ( int j = 0 ; j < params . length ; j ++ ) { if ( j > 0 ) System . out . print ( ", " ) ; System . out . print ( params [ j ] . getName ( ) ) ; } System . out . print ( ")  throws " ) ; for ( int j = 0 ; j < excepts . length ; j ++ ) { if ( j > 0 ) System . out . print ( ", " ) ; System . out . print ( excepts [ j ] . getName ( ) ) ; } System . out . println ( "" ) ; } System . out . println ( "******************" ) ; }


Input:
Write a subset of the data to a  DataOutputStream . [CODESPLIT] public void externalize ( DataOutputStream sink , int start , int stop , int stride ) throws IOException { for ( int i = start ; i <= stop ; i += stride ) sink . writeInt ( ( int ) vals [ i ] ) ; } /**
     * Returns (a reference to) the internal storage for this PrimitiveVector
     * object.
     *
WARNING:

     * Because this method breaks encapsulation rules the user must beware!
     * If we (the OPeNDAP prgramming team) choose to change the internal
     * representation(s) of these types your code will probably break.
     *

     * This method is provided as an optimization to eliminate massive
     * copying of data.
     *
     * @return The internal array of shorts.
     */ public Object getInternalStorage ( ) { return ( vals ) ; } /**
     * Set the internal storage for PrimitiveVector.
     *
WARNING:

     * Because this method breaks encapsulation rules the user must beware!
     * If we (the OPeNDAP prgramming team) choose to change the internal
     * representation(s) of these types your code will probably break.
     *

     * This method is provided as an optimization to eliminate massive
     * copying of data.
     */ public void setInternalStorage  ( Object o ) { vals = ( short [ ] ) o ; } /**
     * Create a new primitive vector using a subset of the data.
     *
     * @param start  starting index (i=start)
     * @param stop   ending index (i<=stop)
     * @param stride index stride (i+=stride)
     * @return new primitive vector, of type Int16PrimitiveVector.
     */ public PrimitiveVector subset  ( int start , int stop , int stride ) { Int16PrimitiveVector n = new Int16PrimitiveVector ( getTemplate ( ) ) ; stride = Math . max ( stride , 1 ) ; stop = Math . max ( start , stop ) ; int length = 1 + ( stop - start ) / stride ; n . setLength ( length ) ; int count = 0 ; for ( int i = start ; i <= stop ; i += stride ) { n . setValue ( count , vals [ i ] ) ; count ++ ; } return n ; } /**
   * Prints the value of the variable, with its declaration.  This
   * function is primarily intended for debugging OPeNDAP applications and
   * text-based clients such as geturl.
   *
   * @param os           the PrintWriter on which to print the value.
   * @param space        this value is passed to the printDecl method,
   *                     and controls the leading spaces of the output.
   * @param print_decl_p a boolean value controlling whether the
   *                     variable declaration is printed as well as the value.
   */ public void printVal  ( PrintWriter os , String space , boolean print_decl_p ) { } /**
     * Returns a clone of this Int16PrimitiveVector.
     * See DAPNode.cloneDag()
     *
     * @param map track previously cloned nodes
     * @return a clone of this Int16PrimitiveVector.
     */ public DAPNode cloneDAG ( CloneMap map ) throws CloneNotSupportedException { Int16PrimitiveVector v = ( Int16PrimitiveVector ) super . cloneDAG ( map ) ; if ( vals != null ) { v . vals = new short [ vals . length ] ; System . arraycopy ( vals , 0 , v . vals , 0 , vals . length ) ; } return v ; } }


Input: a variable is tiled if any of its dimensions are tiled [CODESPLIT] private boolean isTiled ( Variable v ) { for ( Dimension d : v . getDimensions ( ) ) { for ( Range r : section . getRanges ( ) ) { if ( d . getShortName ( ) . equals ( r . getName ( ) ) ) return true ; } } return false ; }


Input: Implements coverting a complete best to a monotonic best . The reftime is not allowed to decrease [CODESPLIT] public CoordinateTimeAbstract makeBestFromComplete ( ) { int [ ] best = new int [ time2runtime . length ] ; int last = - 1 ; int count = 0 ; for ( int i = 0 ; i < time2runtime . length ; i ++ ) { int time = time2runtime [ i ] ; if ( time >= last ) { last = time ; best [ i ] = time ; count ++ ; } else { best [ i ] = - 1 ; } } return makeBestFromComplete ( best , count ) ; }


Input: Convert a LatLonPoint to projection coordinates [CODESPLIT] public ProjectionPoint latLonToProj ( LatLonPoint latlon , ProjectionPointImpl result ) { result . setLocation ( LatLonPointImpl . lonNormal ( latlon . getLongitude ( ) , centerLon ) , latlon . getLatitude ( ) ) ; return result ; }


Input: Convert projection coordinates to a LatLonPoint Note : a new object is not created on each call for the return value . [CODESPLIT] public LatLonPoint projToLatLon ( ProjectionPoint world , LatLonPointImpl result ) { result . setLongitude ( world . getX ( ) ) ; result . setLatitude ( world . getY ( ) ) ; return result ; }


Input: Convert projection coordinates to lat / lon coordinate . [CODESPLIT] public float [ ] [ ] projToLatLon ( float [ ] [ ] from , float [ ] [ ] to ) { float [ ] fromX = from [ INDEX_X ] ; float [ ] fromY = from [ INDEX_Y ] ; to [ INDEX_LAT ] = fromY ; to [ INDEX_LON ] = fromX ; return to ; }


Input: Convert lat / lon coordinates to projection coordinates . [CODESPLIT] public double [ ] [ ] latLonToProj ( double [ ] [ ] from , double [ ] [ ] to , int latIndex , int lonIndex ) { int cnt = from [ 0 ] . length ; double [ ] toX = to [ INDEX_X ] ; double [ ] toY = to [ INDEX_Y ] ; double [ ] fromLat = from [ latIndex ] ; double [ ] fromLon = from [ lonIndex ] ; double lat , lon ; for ( int i = 0 ; i < cnt ; i ++ ) { lat = fromLat [ i ] ; lon = centerLon + Math . IEEEremainder ( fromLon [ i ] - centerLon , 360.0 ) ; toX [ i ] = lon ; toY [ i ] = lat ; } return to ; }


Input:
Does the line between these two points cross the projection seam . [CODESPLIT] public boolean crossSeam ( ProjectionPoint pt1 , ProjectionPoint pt2 ) { return Math . abs ( pt1 . getX ( ) - pt2 . getX ( ) ) > 270.0 ; // ?? LOOK: do I believe this
 }


Input: Split a latlon rectangle to the equivalent ProjectionRect using this LatLonProjection to split it at the seam if needed . [CODESPLIT] public ProjectionRect [ ] latLonToProjRect ( LatLonRect latlonR ) { double lat0 = latlonR . getLowerLeftPoint ( ) . getLatitude ( ) ; double height = Math . abs ( latlonR . getUpperRightPoint ( ) . getLatitude ( ) - lat0 ) ; double width = latlonR . getWidth ( ) ; double lon0 = LatLonPointImpl . lonNormal ( latlonR . getLowerLeftPoint ( ) . getLongitude ( ) , centerLon ) ; double lon1 = LatLonPointImpl . lonNormal ( latlonR . getUpperRightPoint ( ) . getLongitude ( ) , centerLon ) ; ProjectionRect [ ] rects = new ProjectionRect [ ] { new ProjectionRect ( ) , new ProjectionRect ( ) } ; if ( lon0 < lon1 ) { rects [ 0 ] . setRect ( lon0 , lat0 , width , height ) ; rects [ 1 ] = null ; } else { double y = centerLon + 180 - lon0 ; rects [ 0 ] . setRect ( lon0 , lat0 , y , height ) ; rects [ 1 ] . setRect ( lon1 - width + y , lat0 , width - y , height ) ; } return rects ; }


Input:
Create a latlon rectangle and split it into the equivalent ProjectionRect using this LatLonProjection . The latlon rect is constructed from 2 lat / lon points . The lon values are considered coords in the latlonProjection and so do not have to be + / - 180 . [CODESPLIT] public ProjectionRect [ ] latLonToProjRect ( double lat0 , double lon0 , double lat1 , double lon1 ) { double height = Math . abs ( lat1 - lat0 ) ; lat0 = Math . min ( lat1 , lat0 ) ; double width = lon1 - lon0 ; if ( width < 1.0e-8 ) { width = 360.0 ; // assume its the whole thing
 } lon0 = LatLonPointImpl . lonNormal ( lon0 , centerLon ) ; lon1 = LatLonPointImpl . lonNormal ( lon1 , centerLon ) ; ProjectionRect [ ] rects = new ProjectionRect [ ] { new ProjectionRect ( ) , new ProjectionRect ( ) } ; if ( width >= 360.0 ) { rects [ 0 ] . setRect ( centerLon - 180.0 , lat0 , 360.0 , height ) ; rects [ 1 ] = null ; } else if ( lon0 < lon1 ) { rects [ 0 ] . setRect ( lon0 , lat0 , width , height ) ; rects [ 1 ] = null ; } else { double y = centerLon + 180 - lon0 ; rects [ 0 ] . setRect ( lon0 , lat0 , y , height ) ; rects [ 1 ] . setRect ( lon1 - width + y , lat0 , width - y , height ) ; } return rects ; }


Input:
LOOK change to ResponseEntity<String > [CODESPLIT] @ RequestMapping ( method = RequestMethod . GET ) protected void showDebugPage ( HttpServletRequest request , HttpServletResponse response ) throws IOException { response . setContentType ( ContentType . html . getContentHeader ( ) ) ; response . setHeader ( "Content-Description" , "thredds_debug" ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; PrintStream pw = new PrintStream ( bos , false , CDM . UTF8 ) ; pw . println ( htmlu . getHtmlDoctypeAndOpenTag ( ) ) ; pw . println ( "" ) ; pw . println ( "<title>THREDDS Debug</title>" ) ; pw . println ( "<meta http-equiv=\"Content-Type\" content=\"text/html\">" ) ; pw . println ( htmlu . getTdsPageCssLink ( ) ) ; pw . println ( htmlu . getGoogleTrackingContent ( ) ) ; pw . println ( "" ) ; pw . println ( "" ) ; pw . println ( htmlu . getOldStyleHeader ( ) ) ; pw . println ( "
Show TDS Logs" ) ; pw . println ( "
Show TDM Logs" ) ; pw . println ( "
Show Tomcat Logs" ) ; pw . println ( "
Show Config Catalogs" ) ; pw . println ( "
Show Spring Controllers" ) ; pw . println ( "
Debug Actions
" ) ; pw . println ( "
" ) ; String cmds = request . getQueryString ( ) ; if ( ( cmds == null ) || ( cmds . length ( ) == 0 ) ) { showDebugActions ( request , pw ) ; } else { StringTokenizer tz = new StringTokenizer ( cmds , ";" ) ; while ( tz . hasMoreTokens ( ) ) { String cmd = tz . nextToken ( ) ; String target = null ; pw . println ( "Cmd= " + cmd ) ; int pos = cmd . indexOf ( ' ' ) ; String dhName = "General" ; if ( pos > 0 ) { dhName = cmd . substring ( 0 , pos ) ; cmd = cmd . substring ( pos + 1 ) ; } pos = cmd . indexOf ( ' ' ) ; if ( pos >= 0 ) { target = cmd . substring ( pos + 1 ) ; cmd = cmd . substring ( 0 , pos ) ; } DebugCommands . Category dh = debugCommands . findCategory ( dhName ) ; if ( dh == null ) { pw . println ( " Unknown Debug Category=" + dhName + "=" ) ; } else { DebugCommands . Action action = dh . actions . get ( cmd ) ; if ( action == null ) pw . println ( " Unknown action=" + cmd + "=" ) ; else action . doAction ( new DebugCommands . Event ( request , response , pw , bos , target ) ) ; } } } pw . println ( "
" ) ; response . setStatus ( HttpServletResponse . SC_OK ) ; // send it out PrintWriter responsePS = response . getWriter ( ) ; responsePS . write ( bos . toString ( CDM . UTF8 ) ) ; responsePS . flush ( ) ; }


Input:
everything but header data which is binary data and capabilities which is XML [CODESPLIT] @ RequestMapping ( value = "/**" , method = RequestMethod . GET ) public ResponseEntity < String > handleCapabilitiesRequest ( HttpServletRequest request , HttpServletResponse response , @ RequestParam String req ) throws IOException { if ( ! allowedServices . isAllowed ( StandardService . cdmRemote ) ) throw new ServiceNotAllowed ( StandardService . cdmRemote . toString ( ) ) ; String datasetPath = TdsPathUtils . extractPath ( request , "/cdmremote" ) ; String absPath = getAbsolutePath ( request ) ; HttpHeaders responseHeaders ; if ( showReq ) System . out . printf ( "CdmRemoteController req=%s%n" , absPath + "?" + request . getQueryString ( ) ) ; if ( debug ) System . out . printf ( " path=%s%n query=%s%n" , datasetPath , request . getQueryString ( ) ) ; // LOOK heres where we want the Dataset, not the netcdfFile (!)
 try ( NetcdfFile ncfile = TdsRequestedDataset . getNetcdfFile ( request , response , datasetPath ) ) { if ( ncfile == null ) return null ; // failed resource control
 responseHeaders = new HttpHeaders ( ) ; responseHeaders . setDate ( "Last-Modified" , TdsRequestedDataset . getLastModified ( datasetPath ) ) ; // a request without a parameter is a test to see if this is a valid cdremote endpoint.
 // just setHeader("Content-Description", "ncstream"), no body
 // on client, see DatasetUrl.disambiguateHttp
 if ( req == null ) { response . setContentType ( ContentType . binary . getContentHeader ( ) ) ; response . setHeader ( "Content-Description" , "ncstream" ) ; return new ResponseEntity <> ( null , responseHeaders , HttpStatus . OK ) ; } switch ( req . toLowerCase ( ) ) { case "form" : // ol
 case "cdl" : ncfile . setLocation ( datasetPath ) ; // hide where the file is stored  LOOK
 String cdl = ncfile . toString ( ) ; responseHeaders . set ( ContentType . HEADER , ContentType . text . getContentHeader ( ) ) ; return new ResponseEntity <> ( cdl , responseHeaders , HttpStatus . OK ) ; case "ncml" : String ncml = ncfile . toNcML ( absPath ) ; responseHeaders . set ( ContentType . HEADER , ContentType . xml . getContentHeader ( ) ) ; return new ResponseEntity <> ( ncml , responseHeaders , HttpStatus . OK ) ; default : return new ResponseEntity <> ( "Unrecognized request" , null , HttpStatus . BAD_REQUEST ) ; } } }


Input: experimental : should be package private [CODESPLIT] int setDirect ( int v0 , int v1 , int v2 , int v3 , int v4 ) { return offset + v0 * stride0 + v1 * stride1 + v2 * stride2 + v3 * stride3 + v4 * stride4 ; }


Input: construct the TImeSeries plot for the list of logs passed in [CODESPLIT] private void showTimeSeriesAll ( java . util . List < LogReader . Log > logs ) { TimeSeries bytesSentData = new TimeSeries ( "Bytes Sent" , Minute . class ) ; TimeSeries timeTookData = new TimeSeries ( "Average Latency" , Minute . class ) ; TimeSeries nreqData = new TimeSeries ( "Number of Requests" , Minute . class ) ; String intervalS = "5 minute" ; // interval.getText().trim(); // if (intervalS.length() == 0) intervalS = "5 minute"; long period = 1000 * 60 * 5 ; try { TimeDuration tu = new TimeDuration ( intervalS ) ; period = ( long ) ( 1000 * tu . getValueInSeconds ( ) ) ; } catch ( Exception e ) { System . out . printf ( "Illegal Time interval=%s %n" , intervalS ) ; } long current = 0 ; long bytes = 0 ; long timeTook = 0 ; long total_count = 0 ; long count = 0 ; for ( LogReader . Log log : logs ) { long msecs = log . date ; if ( msecs - current > period ) { if ( current > 0 ) { total_count += count ; addPoint ( bytesSentData , timeTookData , nreqData , new Date ( current ) , bytes , count , timeTook ) ; } bytes = 0 ; count = 0 ; timeTook = 0 ; current = msecs ; } bytes += log . getBytes ( ) ; timeTook += log . getMsecs ( ) ; count ++ ; } if ( count > 0 ) addPoint ( bytesSentData , timeTookData , nreqData , new Date ( current ) , bytes , count , timeTook ) ; total_count += count ; System . out . printf ( "showTimeSeriesAll: total_count = %d logs = %d%n" , total_count , logs . size ( ) ) ; MultipleAxisChart mc = new MultipleAxisChart ( "Access Logs" , intervalS + " average" , "Mbytes Sent" , bytesSentData ) ; mc . addSeries ( "Number of Requests" , nreqData ) ; mc . addSeries ( "Average Latency (secs)" , timeTookData ) ; mc . finish ( new java . awt . Dimension ( 1000 , 1000 ) ) ; //MultipleAxisChart mc = new MultipleAxisChart("Bytes Sent", "5 min average", "Mbytes/sec", bytesSentData); //Chart c2 = new Chart("Average Latency", "5 min average", "Millisecs", timeTookData); //Chart c3 = new Chart("Number of Requests/sec", "5 min average", "", nreqData); timeSeriesPanel . removeAll ( ) ; timeSeriesPanel . add ( mc ) ; }


Input: Turn a list into a map [CODESPLIT] static public Map < String , Attribute > makeMap ( List < Attribute > atts ) { int size = ( atts == null ) ? 1 : atts . size ( ) ; Map < String , Attribute > result = new HashMap <> ( size ) ; if ( atts == null ) return result ; for ( Attribute att : atts ) result . put ( att . getShortName ( ) , att ) ; return result ; }


Input: Get the value as an Array . [CODESPLIT] public Array getValues ( ) { if ( values == null && svalue != null ) { values = Array . factory ( DataType . STRING , new int [ ] { 1 } ) ; values . setObject ( values . getIndex ( ) , svalue ) ; } return values ; }


Input: Retrieve String value ; only call if isString () is true . [CODESPLIT] public String getStringValue ( ) { if ( dataType != DataType . STRING ) return null ; return ( svalue != null ) ? svalue : _getStringValue ( 0 ) ; }


Input: Retrieve a numeric value by index . If it s a String it will try to parse it as a double . [CODESPLIT] public Number getNumericValue ( int index ) { if ( ( index < 0 ) || ( index >= nelems ) ) return null ; // LOOK can attributes be enum valued? for now, no switch ( dataType ) { case STRING : try { return new Double ( getStringValue ( index ) ) ; } catch ( NumberFormatException e ) { return null ; } case BYTE : case UBYTE : return values . getByte ( index ) ; case SHORT : case USHORT : return values . getShort ( index ) ; case INT : case UINT : return values . getInt ( index ) ; case FLOAT : return values . getFloat ( index ) ; case DOUBLE : return values . getDouble ( index ) ; case LONG : case ULONG : return values . getLong ( index ) ; } return null ; }


Input: Write CDL representation into f [CODESPLIT] protected void writeCDL ( Formatter f , boolean strict , String parentname ) { if ( strict && ( isString ( ) || this . getEnumType ( ) != null ) ) // Force type explicitly for string. f . format ( "string " ) ; //note lower case and trailing blank if ( strict && parentname != null ) f . format ( NetcdfFile . makeValidCDLName ( parentname ) ) ; f . format ( ":" ) ; f . format ( "%s" , strict ? NetcdfFile . makeValidCDLName ( getShortName ( ) ) : getShortName ( ) ) ; if ( isString ( ) ) { f . format ( " = " ) ; for ( int i = 0 ; i < getLength ( ) ; i ++ ) { if ( i != 0 ) f . format ( ", " ) ; String val = getStringValue ( i ) ; if ( val != null ) f . format ( "\"%s\"" , encodeString ( val ) ) ; } } else if ( getEnumType ( ) != null ) { f . format ( " = " ) ; for ( int i = 0 ; i < getLength ( ) ; i ++ ) { if ( i != 0 ) f . format ( ", " ) ; EnumTypedef en = getEnumType ( ) ; String econst = getStringValue ( i ) ; Integer ecint = en . lookupEnumInt ( econst ) ; if ( ecint == null ) throw new ForbiddenConversionException ( "Illegal enum constant: " + econst ) ; f . format ( "\"%s\"" , encodeString ( econst ) ) ; } } else { f . format ( " = " ) ; for ( int i = 0 ; i < getLength ( ) ; i ++ ) { if ( i != 0 ) f . format ( ", " ) ; Number number = getNumericValue ( i ) ; if ( dataType . isUnsigned ( ) ) { // 'number' is unsigned, but will be treated as signed when we print it below, because Java only has signed // types. If it is large enough ( >= 2^(BIT_WIDTH-1) ), its most-significant bit will be interpreted as the // sign bit, which will result in an invalid (negative) value being printed. To prevent that, we're going // to widen the number before printing it. number = DataType . widenNumber ( number ) ; } f . format ( "%s" , number ) ; if ( dataType . isUnsigned ( ) ) { f . format ( "U" ) ; } if ( dataType == DataType . FLOAT ) f . format ( "f" ) ; else if ( dataType == DataType . SHORT || dataType == DataType . USHORT ) { f . format ( "S" ) ; } else if ( dataType == DataType . BYTE || dataType == DataType . UBYTE ) { f . format ( "B" ) ; } else if ( dataType == DataType . LONG || dataType == DataType . ULONG ) { f . format ( "L" ) ; } } } }


Input: set the value as a String trimming trailing zeroes [CODESPLIT] private void setStringValue ( String val ) { if ( val == null ) throw new IllegalArgumentException ( "Attribute value cannot be null" ) ; // get rid of trailing nul characters int len = val . length ( ) ; while ( ( len > 0 ) && ( val . charAt ( len - 1 ) == 0 ) ) len -- ; if ( len != val . length ( ) ) val = val . substring ( 0 , len ) ; this . svalue = val ; this . nelems = 1 ; this . dataType = DataType . STRING ; //values = Array.factory(String.class, new int[]{1}); //values.setObject(values.getIndex(), val); //setValues(values); }


Input: set the values from a list [CODESPLIT] public void setValues ( List values ) { if ( values == null || values . size ( ) == 0 ) throw new IllegalArgumentException ( "Cannot determine attribute's type" ) ; int n = values . size ( ) ; Class c = values . get ( 0 ) . getClass ( ) ; Object pa ; if ( c == String . class ) { String [ ] va = new String [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( String ) values . get ( i ) ; } else if ( c == Integer . class ) { int [ ] va = new int [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Integer ) values . get ( i ) ; } else if ( c == Double . class ) { double [ ] va = new double [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Double ) values . get ( i ) ; } else if ( c == Float . class ) { float [ ] va = new float [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Float ) values . get ( i ) ; } else if ( c == Short . class ) { short [ ] va = new short [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Short ) values . get ( i ) ; } else if ( c == Byte . class ) { byte [ ] va = new byte [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Byte ) values . get ( i ) ; } else if ( c == Long . class ) { long [ ] va = new long [ n ] ; pa = va ; for ( int i = 0 ; i < n ; i ++ ) va [ i ] = ( Long ) values . get ( i ) ; } else { throw new IllegalArgumentException ( "Unknown type for Attribute = " + c . getName ( ) ) ; } setValues ( Array . factory ( this . dataType , new int [ ] { n } , pa ) ) ; }


Input: set the values from an Array [CODESPLIT] public void setValues ( Array arr ) { if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( arr == null ) { dataType = DataType . STRING ; return ; } if ( arr . getElementType ( ) == char . class ) { // turn CHAR into STRING ArrayChar carr = ( ArrayChar ) arr ; if ( carr . getRank ( ) == 1 ) { // common case svalue = carr . getString ( ) ; this . nelems = 1 ; this . dataType = DataType . STRING ; return ; } // otherwise its an array of Strings arr = carr . make1DStringArray ( ) ; } // this should be a utility somewhere if ( arr . getElementType ( ) == ByteBuffer . class ) { // turn OPAQUE into BYTE int totalLen = 0 ; arr . resetLocalIterator ( ) ; while ( arr . hasNext ( ) ) { ByteBuffer bb = ( ByteBuffer ) arr . next ( ) ; totalLen += bb . limit ( ) ; } byte [ ] ba = new byte [ totalLen ] ; int pos = 0 ; arr . resetLocalIterator ( ) ; while ( arr . hasNext ( ) ) { ByteBuffer bb = ( ByteBuffer ) arr . next ( ) ; System . arraycopy ( bb . array ( ) , 0 , ba , pos , bb . limit ( ) ) ; pos += bb . limit ( ) ; } arr = Array . factory ( DataType . BYTE , new int [ ] { totalLen } , ba ) ; } if ( DataType . getType ( arr ) == DataType . OBJECT ) throw new IllegalArgumentException ( "Cant set Attribute with type " + arr . getElementType ( ) ) ; if ( arr . getRank ( ) > 1 ) arr = arr . reshape ( new int [ ] { ( int ) arr . getSize ( ) } ) ; // make sure 1D this . values = arr ; this . nelems = ( int ) arr . getSize ( ) ; this . dataType = DataType . getType ( arr ) ; }


Input: Scan the collection and gather information on contained datasets . [CODESPLIT] public void scan ( ) throws IOException { if ( state == 1 ) throw new IllegalStateException ( "Scan already underway." ) ; if ( state >= 2 ) throw new IllegalStateException ( "Scan has already been generated." ) ; state = 1 ; // Make sure proxyDsHandlers Map is not null. if ( proxyDsHandlers == null ) proxyDsHandlers = Collections . EMPTY_MAP ; // Create a skeleton catalog. genCatalog = createSkeletonCatalog ( currentLevel ) ; InvDatasetImpl topInvDs = ( InvDatasetImpl ) genCatalog . getDatasets ( ) . get ( 0 ) ; // Get the datasets in this collection. List crDsList = currentLevel . listDatasets ( this . filter ) ; // Sort the datasets in this collection. // @todo Should we move sort to end of this method? As is, we can't use naming or enhancements to determine sort order. if ( sorter != null ) sorter . sort ( crDsList ) ; // Add the datasets to the catalog. for ( int i = 0 ; i < crDsList . size ( ) ; i ++ ) //for ( Iterator it = crDsList.iterator(); it.hasNext(); ) { CrawlableDataset curCrDs = ( CrawlableDataset ) crDsList . get ( i ) ; InvDatasetImpl curInvDs = ( InvDatasetImpl ) createInvDatasetFromCrawlableDataset ( curCrDs , topInvDs , null ) ; // Add dataset info to appropriate lists. InvCrawlablePair dsInfo = new InvCrawlablePair ( curCrDs , curInvDs ) ; //allDsInfo.add( dsInfo ); if ( curCrDs . isCollection ( ) ) catRefInfo . add ( dsInfo ) ; else atomicDsInfo . add ( dsInfo ) ; // Add current InvDataset to top dataset. topInvDs . addDataset ( curInvDs ) ; } // Tie up any loose ends in catalog with finish(). ( ( InvCatalogImpl ) genCatalog ) . finish ( ) ; // Add proxy datasets to list (only if some atomic datasets in this collection). if ( atomicDsInfo . size ( ) > 0 ) { boolean anyProxiesAdded = false ; for ( Iterator it = proxyDsHandlers . values ( ) . iterator ( ) ; it . hasNext ( ) ; ) { // Get current ProxyDatasetHandler curProxy = ( ProxyDatasetHandler ) it . next ( ) ; InvService proxyService = curProxy . getProxyDatasetService ( currentLevel ) ; if ( proxyService != null ) { // Create proxy CrawlableDataset and corresponding InvDataset CrawlableDataset crDsToAdd = curProxy . createProxyDataset ( currentLevel ) ; InvDatasetImpl invDsToAdd = createInvDatasetFromCrawlableDataset ( crDsToAdd , topInvDs , proxyService ) ; // Add dataset info to appropriate lists. InvCrawlablePair dsInfo = new InvCrawlablePair ( crDsToAdd , invDsToAdd ) ; proxyDsInfo . add ( dsInfo ) ; // Add dataset to catalog int index = curProxy . getProxyDatasetLocation ( currentLevel , topInvDs . getDatasets ( ) . size ( ) ) ; topInvDs . addDataset ( index , ( InvDatasetImpl ) invDsToAdd ) ; genCatalog . addService ( proxyService ) ; anyProxiesAdded = true ; } } // Tie up any proxy dataset loose ends. if ( anyProxiesAdded ) ( ( InvCatalogImpl ) genCatalog ) . finish ( ) ; } // Add any top-level metadata. this . addTopLevelMetadata ( genCatalog , true ) ; state = 2 ; return ; }


Input: Generate the catalog for a resolver request of the given ProxyDatasetHandler . [CODESPLIT] public InvCatalogImpl generateProxyDsResolverCatalog ( ProxyDatasetHandler pdh ) { if ( state != 2 ) throw new IllegalStateException ( "Scan has not been performed." ) ; if ( ! proxyDsHandlers . containsValue ( pdh ) ) throw new IllegalArgumentException ( "Unknown ProxyDatasetHandler." ) ; // Create a skeleton catalog. InvCatalogImpl catalog = createSkeletonCatalog ( currentLevel ) ; InvDatasetImpl topDs = ( InvDatasetImpl ) catalog . getDatasets ( ) . get ( 0 ) ; // Find actual dataset in the list of atomic dataset InvCrawlablePairs. InvCrawlablePair actualDsInfo = pdh . getActualDataset ( atomicDsInfo ) ; if ( actualDsInfo == null ) return catalog ; // TODO Test this case in TestDataRootHandler. InvDatasetImpl actualInvDs = ( InvDatasetImpl ) actualDsInfo . getInvDataset ( ) ; actualInvDs . setName ( pdh . getActualDatasetName ( actualDsInfo , topDs . getName ( ) ) ) ; // Add current InvDataset to top dataset. catalog . removeDataset ( topDs ) ; catalog . addDataset ( actualInvDs ) ; // topDs.addDataset( actualInvDs ); // Finish catalog. catalog . finish ( ) ; // Add any top-level metadata. this . addTopLevelMetadata ( catalog , false ) ; return catalog ; }


Input: - baseID + / + node . getPath () . substring ( collectionLevel . length ) [ when ID added at catalog construction using node info ] [CODESPLIT] private String getID ( CrawlableDataset dataset ) { if ( dataset == null ) return null ; if ( collectionId == null ) return null ; int i = collectionLevel . getPath ( ) . length ( ) ; String id = dataset . getPath ( ) . substring ( i ) ; if ( id . startsWith ( "/" ) ) id = id . substring ( 1 ) ; if ( collectionId . equals ( "" ) ) { if ( id . equals ( "" ) ) return null ; return id ; } if ( id . equals ( "" ) ) return collectionId ; return ( collectionId + "/" + id ) ; }


Input: - collectionPath + / + node . getPath () . substring ( collectionLevel . length ) [ when service is absolute ( i . e . relative to collection ) ] [CODESPLIT] private String getUrlPath ( CrawlableDataset dataset , InvService service ) { InvService serviceForThisDs = service != null ? service : this . service ; if ( serviceForThisDs . getBase ( ) . equals ( "" ) && ! serviceForThisDs . getServiceType ( ) . equals ( ServiceType . COMPOUND ) ) { // Service is relative to the catalog URL. String urlPath = dataset . getPath ( ) . substring ( catalogLevel . getPath ( ) . length ( ) ) ; if ( urlPath . startsWith ( "/" ) ) urlPath = urlPath . substring ( 1 ) ; return urlPath ; } else { if ( serviceForThisDs . isRelativeBase ( ) ) { // Service is relative to the collection root. String relPath = dataset . getPath ( ) . substring ( collectionLevel . getPath ( ) . length ( ) ) ; if ( relPath . startsWith ( "/" ) ) relPath = relPath . substring ( 1 ) ; return ( ( collectionPath . equals ( "" ) ? "" : collectionPath + "/" ) + relPath ) ; } else { // Service base URI is Absolute so don't use collectionPath. String relPath = dataset . getPath ( ) . substring ( collectionLevel . getPath ( ) . length ( ) ) ; if ( relPath . startsWith ( "/" ) ) relPath = relPath . substring ( 1 ) ; return relPath ; } } }


Input: - node . getPath () . substring ( catalogLevel . length ) + / catalog . xml [CODESPLIT] private String getXlinkHref ( CrawlableDataset dataset ) { // @todo Remove alias until sure how to handle things like ".scour*" being a regular file. //    if ( ! CrawlableDatasetAlias.isAlias( catalogLevel.getPath()) ) //    { String path = dataset . getPath ( ) . substring ( catalogLevel . getPath ( ) . length ( ) ) ; if ( path . startsWith ( "/" ) ) path = path . substring ( 1 ) ; if ( path . endsWith ( "/" ) ) path += "catalog.xml" ; else path += "/catalog.xml" ; return CatalogUtils . escapePathForURL ( path ) ; //    } //    else //    { //      // @todo Move this functionality into CrawlableDatasetAlias //      String path = dataset.getPath(); //      int curIndex = path.length(); //      int numSegments = catalogLevel.getName().split( "/" ).length; //      for ( int i = 0 ; i < numSegments; i++ ) //      { //        curIndex = dataset.getPath().lastIndexOf( "/", curIndex - 1); //      } //      return( dataset.getPath().substring( curIndex + 1 ) + "/catalog.xml"); //    } }


Input: Caller must iter . finish () and out . close () . [CODESPLIT] public static int write ( OutputStream out , PointFeatureIterator pointFeatIter , String name , String timeUnitString , String altUnits ) throws IOException { int numWritten = 0 ; while ( pointFeatIter . hasNext ( ) ) { try { PointFeature pointFeat = pointFeatIter . next ( ) ; if ( numWritten == 0 ) { PointStreamProto . PointFeatureCollection protoPfc = PointStream . encodePointFeatureCollection ( name , timeUnitString , altUnits , pointFeat ) ; byte [ ] data = protoPfc . toByteArray ( ) ; PointStream . writeMagic ( out , MessageType . PointFeatureCollection ) ; NcStream . writeVInt ( out , data . length ) ; out . write ( data ) ; } PointStreamProto . PointFeature protoPointFeat = PointStream . encodePointFeature ( pointFeat ) ; byte [ ] data = protoPointFeat . toByteArray ( ) ; PointStream . writeMagic ( out , MessageType . PointFeature ) ; NcStream . writeVInt ( out , data . length ) ; out . write ( data ) ; ++ numWritten ; } catch ( Throwable t ) { NcStreamProto . Error protoError = NcStream . encodeErrorMessage ( t . getMessage ( ) != null ? t . getMessage ( ) : t . getClass ( ) . getName ( ) ) ; byte [ ] data = protoError . toByteArray ( ) ; PointStream . writeMagic ( out , PointStream . MessageType . Error ) ; NcStream . writeVInt ( out , data . length ) ; out . write ( data ) ; throw new IOException ( t ) ; } } PointStream . writeMagic ( out , PointStream . MessageType . End ) ; return numWritten ; }


Input: put a message on the queue schedule writing if not already scheduled . [CODESPLIT] void scheduleWrite ( Message m ) { q . add ( m ) ; if ( ! isScheduled . getAndSet ( true ) ) { executor . submit ( this ) ; } }


Input: Returns a string representation of the variables value . This is really foreshadowing functionality for Server types but as it may come in useful for clients it is added here . Simple types ( example : DFloat32 ) will return a single value . DConstuctor and DVector types will be flattened . DStrings and DURL s will have double quotes around them . [CODESPLIT] public void toASCII ( PrintWriter pw , boolean addName , String rootName , boolean newLine ) { if ( _Debug ) System . out . println ( "asciiGrid.toASCII(" + addName + ",'" + rootName + "')  getName(): " + getEncodedName ( ) ) ; if ( rootName != null ) rootName += "." + getEncodedName ( ) ; else rootName = getEncodedName ( ) ; boolean firstPass = true ; Enumeration e = getVariables ( ) ; while ( e . hasMoreElements ( ) ) { toASCII ta = ( toASCII ) e . nextElement ( ) ; if ( ! newLine && ! firstPass ) pw . print ( ", " ) ; ta . toASCII ( pw , addName , rootName , newLine ) ; firstPass = false ; } if ( newLine ) pw . print ( "\n" ) ; }


Input:
deferred creation of components to minimize startup [CODESPLIT] public void makeComponent ( JTabbedPane parent , final String title ) { if ( parent == null ) { parent = tabbedPane ; } // find the correct index
 int n = parent . getTabCount ( ) ; int idx ; for ( idx = 0 ; idx < n ; idx ++ ) { String cTitle = parent . getTitleAt ( idx ) ; if ( cTitle . equals ( title ) ) break ; } if ( idx >= n ) { log . debug ( "Cant find {} in {}" , title , parent ) ; return ; } Component c ; switch ( title ) { case "Aggregation" : aggPanel = new AggPanel ( ( PreferencesExt ) mainPrefs . node ( "NcMLAggregation" ) ) ; c = aggPanel ; break ; case "BUFR" : bufrPanel = new BufrPanel ( ( PreferencesExt ) mainPrefs . node ( "bufr" ) ) ; c = bufrPanel ; break ; case "BUFRTableB" : bufrTableBPanel = new BufrTableBPanel ( ( PreferencesExt ) mainPrefs . node ( "bufr2" ) ) ; c = bufrTableBPanel ; break ; case "BUFRTableD" : bufrTableDPanel = new BufrTableDPanel ( ( PreferencesExt ) mainPrefs . node ( "bufrD" ) ) ; c = bufrTableDPanel ; break ; case "BufrReports" : { PreferencesExt prefs = ( PreferencesExt ) mainPrefs . node ( "bufrReports" ) ; ReportPanel rp = new BufrReportPanel ( prefs ) ; bufrReportPanel = new ReportOpPanel ( prefs , rp ) ; c = bufrReportPanel ; break ; } case "BUFR-CODES" : bufrCodePanel = new BufrCodePanel ( ( PreferencesExt ) mainPrefs . node ( "bufr-codes" ) ) ; c = bufrCodePanel ; break ; case "CdmrFeature" : cdmremotePanel = new CdmrFeatureOpPanel ( ( PreferencesExt ) mainPrefs . node ( "CdmrFeature" ) ) ; c = cdmremotePanel ; break ; case "CollectionSpec" : fcPanel = new CollectionSpecPanel ( ( PreferencesExt ) mainPrefs . node ( "collSpec" ) ) ; c = fcPanel ; break ; case "DirectoryPartition" : dirPartPanel = new DirectoryPartitionPanel ( ( PreferencesExt ) mainPrefs . node ( "dirPartition" ) ) ; c = dirPartPanel ; break ; case "NcStream" : ncStreamPanel = new NcStreamOpPanel ( ( PreferencesExt ) mainPrefs . node ( "NcStream" ) ) ; c = ncStreamPanel ; break ; case "GRIB1collection" : grib1CollectionPanel = new Grib1CollectionOpPanel ( ( PreferencesExt ) mainPrefs . node ( "grib1raw" ) ) ; c = grib1CollectionPanel ; break ; case "GRIB1data" : grib1DataPanel = new Grib1DataOpPanel ( ( PreferencesExt ) mainPrefs . node ( "grib1Data" ) ) ; c = grib1DataPanel ; break ; case "GRIB-FILES" : gribFilesPanel = new GribFilesOpPanel ( ( PreferencesExt ) mainPrefs . node ( "gribFiles" ) ) ; c = gribFilesPanel ; break ; case "GRIB2collection" : grib2CollectionPanel = new Grib2CollectionOpPanel ( ( PreferencesExt ) mainPrefs . node ( "gribNew" ) ) ; c = grib2CollectionPanel ; break ; case "GRIB2data" : grib2DataPanel = new Grib2DataOpPanel ( ( PreferencesExt ) mainPrefs . node ( "grib2Data" ) ) ; c = grib2DataPanel ; break ; case "BufrCdmIndex" : bufrCdmIndexPanel = new BufrCdmIndexOpPanel ( ( PreferencesExt ) mainPrefs . node ( "bufrCdmIdx" ) ) ; c = bufrCdmIndexPanel ; /* } else if (title.equals("CdmIndex")) {
          gribCdmIndexPanel = new GribCdmIndexPanel((PreferencesExt) mainPrefs.node("cdmIdx"));
          c = gribCdmIndexPanel; */ break ; case "CdmIndex4" : cdmIndexPanel = new CdmIndexOpPanel ( ( PreferencesExt ) mainPrefs . node ( "cdmIdx3" ) ) ; c = cdmIndexPanel ; break ; case "CdmIndexReport" : { PreferencesExt prefs = ( PreferencesExt ) mainPrefs . node ( "CdmIndexReport" ) ; ReportPanel rp = new CdmIndexReportPanel ( prefs ) ; cdmIndexReportPanel = new ReportOpPanel ( prefs , rp ) ; c = cdmIndexReportPanel ; break ; } case "GribIndex" : gribIdxPanel = new GribIndexOpPanel ( ( PreferencesExt ) mainPrefs . node ( "gribIdx" ) ) ; c = gribIdxPanel ; break ; case "GRIB1-REPORT" : { PreferencesExt prefs = ( PreferencesExt ) mainPrefs . node ( "grib1Report" ) ; ReportPanel rp = new Grib1ReportPanel ( prefs ) ; grib1ReportPanel = new ReportOpPanel ( prefs , rp ) ; c = grib1ReportPanel ; break ; } case "GRIB2-REPORT" : { PreferencesExt prefs = ( PreferencesExt ) mainPrefs . node ( "gribReport" ) ; ReportPanel rp = new Grib2ReportPanel ( prefs ) ; grib2ReportPanel = new ReportOpPanel ( prefs , rp ) ; c = grib2ReportPanel ; break ; } case "WMO-COMMON" : wmoCommonCodePanel = new WmoCCPanel ( ( PreferencesExt ) mainPrefs . node ( "wmo-common" ) ) ; c = wmoCommonCodePanel ; break ; case "WMO-CODES" : gribCodePanel = new GribCodePanel ( ( PreferencesExt ) mainPrefs . node ( "wmo-codes" ) ) ; c = gribCodePanel ; break ; case "WMO-TEMPLATES" : gribTemplatePanel = new GribTemplatePanel ( ( PreferencesExt ) mainPrefs . node ( "wmo-templates" ) ) ; c = gribTemplatePanel ; break ; case "GRIB1-TABLES" : grib1TablePanel = new Grib1TablePanel ( ( PreferencesExt ) mainPrefs . node ( "grib1-tables" ) ) ; c = grib1TablePanel ; break ; case "GRIB2-TABLES" : grib2TablePanel = new Grib2TablePanel ( ( PreferencesExt ) mainPrefs . node ( "grib2-tables" ) ) ; c = grib2TablePanel ; break ; case "GRIB-Rewrite" : gribRewritePanel = new GribRewriteOpPanel ( ( PreferencesExt ) mainPrefs . node ( "grib-rewrite" ) ) ; c = gribRewritePanel ; break ; case "CoordSys" : coordSysPanel = new CoordSysPanel ( ( PreferencesExt ) mainPrefs . node ( "CoordSys" ) ) ; c = coordSysPanel ; break ; case "FeatureScan" : ftPanel = new FeatureScanPanel ( ( PreferencesExt ) mainPrefs . node ( "ftPanel" ) ) ; c = ftPanel ; break ; case "GeoTiff" : geotiffPanel = new GeotiffPanel ( ( PreferencesExt ) mainPrefs . node ( "WCS" ) ) ; c = geotiffPanel ; break ; case "Grids" : gridPanel = new GeoGridPanel ( ( PreferencesExt ) mainPrefs . node ( "grid" ) ) ; c = gridPanel ; break ; case "SimpleGeometry" : simpleGeomPanel = new SimpleGeomPanel ( ( PreferencesExt ) mainPrefs . node ( "simpleGeom" ) ) ; c = simpleGeomPanel ; break ; case "Coverages" : coveragePanel = new CoveragePanel ( ( PreferencesExt ) mainPrefs . node ( "coverage2" ) ) ; c = coveragePanel ; break ; case "HDF5-Objects" : hdf5ObjectPanel = new Hdf5ObjectPanel ( ( PreferencesExt ) mainPrefs . node ( "hdf5" ) ) ; c = hdf5ObjectPanel ; break ; case "HDF5-Data" : hdf5DataPanel = new Hdf5DataPanel ( ( PreferencesExt ) mainPrefs . node ( "hdf5data" ) ) ; c = hdf5DataPanel ; break ; case "Netcdf4-JNI" : nc4viewer = new DatasetViewerPanel ( ( PreferencesExt ) mainPrefs . node ( "nc4viewer" ) , true ) ; c = nc4viewer ; break ; case "HDF4" : hdf4Panel = new Hdf4Panel ( ( PreferencesExt ) mainPrefs . node ( "hdf4" ) ) ; c = hdf4Panel ; break ; case "Images" : imagePanel = new ImagePanel ( ( PreferencesExt ) mainPrefs . node ( "images" ) ) ; c = imagePanel ; break ; case "Fmrc" : fmrcPanel = new FmrcPanel ( ( PreferencesExt ) mainPrefs . node ( "fmrc2" ) ) ; c = fmrcPanel ; break ; case "Collections" : fmrcCollectionPanel = new FmrcCollectionPanel ( ( PreferencesExt ) mainPrefs . node ( "collections" ) ) ; c = fmrcCollectionPanel ; break ; case "NCDump" : ncdumpPanel = new NCdumpPanel ( ( PreferencesExt ) mainPrefs . node ( "NCDump" ) ) ; c = ncdumpPanel ; break ; case "NcmlEditor" : ncmlEditorPanel = new NcmlEditorPanel ( ( PreferencesExt ) mainPrefs . node ( "NcmlEditor" ) ) ; c = ncmlEditorPanel ; break ; case "PointFeature" : pointFeaturePanel = new PointFeaturePanel ( ( PreferencesExt ) mainPrefs . node ( "pointFeature" ) ) ; c = pointFeaturePanel ; break ; case "Radial" : radialPanel = new RadialPanel ( ( PreferencesExt ) mainPrefs . node ( "radial" ) ) ; c = radialPanel ; break ; case "StationRadial" : stationRadialPanel = new StationRadialPanel ( ( PreferencesExt ) mainPrefs . node ( "stationRadar" ) ) ; c = stationRadialPanel ; break ; case "THREDDS" : threddsUI = new ThreddsUI ( parentFrame , ( PreferencesExt ) mainPrefs . node ( "thredds" ) ) ; threddsUI . addPropertyChangeListener ( new PropertyChangeListener ( ) { public void propertyChange ( PropertyChangeEvent e ) { if ( e . getPropertyName ( ) . equals ( "InvAccess" ) ) { thredds . client . catalog . Access access = ( thredds . client . catalog . Access ) e . getNewValue ( ) ; jumptoThreddsDatatype ( access ) ; } if ( e . getPropertyName ( ) . equals ( "Dataset" ) || e . getPropertyName ( ) . equals ( "CoordSys" ) || e . getPropertyName ( ) . equals ( "File" ) ) { thredds . client . catalog . Dataset ds = ( thredds . client . catalog . Dataset ) e . getNewValue ( ) ; setThreddsDatatype ( ds , e . getPropertyName ( ) ) ; } } } ) ; c = threddsUI ; break ; case "Units" : unitsPanel = new UnitsPanel ( ( PreferencesExt ) mainPrefs . node ( "units" ) ) ; c = unitsPanel ; break ; case "URLdump" : urlPanel = new URLDumpPane ( ( PreferencesExt ) mainPrefs . node ( "urlDump" ) ) ; c = urlPanel ; break ; case "Viewer" : c = viewerPanel ; break ; case "Writer" : writerPanel = new DatasetWriterPanel ( ( PreferencesExt ) mainPrefs . node ( "writer" ) ) ; c = writerPanel ; break ; case "WMS" : wmsPanel = new WmsPanel ( ( PreferencesExt ) mainPrefs . node ( "wms" ) ) ; c = wmsPanel ; break ; default : log . warn ( "tabbedPane unknown component {}" , title ) ; return ; } parent . setComponentAt ( idx , c ) ; log . trace ( "tabbedPane changed {} added " , title ) ; }


Input:
Jump to the appropriate tab based on datatype of InvDataset [CODESPLIT] private void setThreddsDatatype ( thredds . client . catalog . Dataset invDataset , String wants ) { if ( invDataset == null ) return ; boolean wantsViewer = wants . equals ( "File" ) ; boolean wantsCoordSys = wants . equals ( "CoordSys" ) ; try { // just open as a NetcdfDataset
 if ( wantsViewer ) { openNetcdfFile ( threddsDataFactory . openDataset ( invDataset , true , null , null ) ) ; return ; } if ( wantsCoordSys ) { NetcdfDataset ncd = threddsDataFactory . openDataset ( invDataset , true , null , null ) ; ncd . enhance ( ) ; // make sure its enhanced
 openCoordSystems ( ncd ) ; return ; } // otherwise do the datatype thing
 DataFactory . Result threddsData = threddsDataFactory . openFeatureDataset ( invDataset , null ) ; if ( threddsData . fatalError ) { JOptionPane . showMessageDialog ( null , "Failed to open err=" + threddsData . errLog ) ; return ; } jumptoThreddsDatatype ( threddsData ) ; } catch ( IOException ioe ) { JOptionPane . showMessageDialog ( null , "Error on setThreddsDatatype = " + ioe . getMessage ( ) ) ; ioe . printStackTrace ( ) ; } }


Input:
jump to the appropriate tab based on datatype of InvAccess [CODESPLIT] private void jumptoThreddsDatatype ( thredds . client . catalog . Access invAccess ) { if ( invAccess == null ) { return ; } thredds . client . catalog . Service s = invAccess . getService ( ) ; if ( s . getType ( ) == ServiceType . HTTPServer ) { downloadFile ( invAccess . getStandardUrlName ( ) ) ; return ; } if ( s . getType ( ) == ServiceType . WMS ) { openWMSDataset ( invAccess . getStandardUrlName ( ) ) ; return ; } if ( s . getType ( ) == ServiceType . CdmrFeature ) { openCoverageDataset ( invAccess . getWrappedUrlName ( ) ) ; return ; } thredds . client . catalog . Dataset ds = invAccess . getDataset ( ) ; if ( ds . getFeatureType ( ) == null ) { // if no feature type, just open as a NetcdfDataset
 try { openNetcdfFile ( threddsDataFactory . openDataset ( invAccess , true , null , null ) ) ; } catch ( IOException ioe ) { JOptionPane . showMessageDialog ( null , "Error on setThreddsDatatype = " + ioe . getMessage ( ) ) ; } return ; } DataFactory . Result threddsData = null ; try { threddsData = threddsDataFactory . openFeatureDataset ( invAccess , null ) ; if ( threddsData . fatalError ) { JOptionPane . showMessageDialog ( null , "Failed to open err=" + threddsData . errLog ) ; return ; } jumptoThreddsDatatype ( threddsData ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; JOptionPane . showMessageDialog ( null , "Error on setThreddsDatatype = " + ioe . getMessage ( ) ) ; if ( threddsData != null ) { try { threddsData . close ( ) ; } catch ( IOException ioe2 ) { // Okay to fall through?
 } } } }


Input: Jump to the appropriate tab based on datatype of threddsData [CODESPLIT] private void jumptoThreddsDatatype ( DataFactory . Result threddsData ) { if ( threddsData . fatalError ) { JOptionPane . showMessageDialog ( this , "Cant open dataset=" + threddsData . errLog ) ; try { threddsData . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return ; } if ( threddsData . featureType . isCoverageFeatureType ( ) ) { if ( threddsData . featureDataset instanceof FeatureDatasetCoverage ) { makeComponent ( ftTabPane , "Coverages" ) ; coveragePanel . setDataset ( threddsData . featureDataset ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( coveragePanel ) ; } else if ( threddsData . featureDataset instanceof GridDataset ) { makeComponent ( ftTabPane , "Grids" ) ; gridPanel . setDataset ( ( GridDataset ) threddsData . featureDataset ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( gridPanel ) ; } } else if ( threddsData . featureType == FeatureType . IMAGE ) { makeComponent ( ftTabPane , "Images" ) ; imagePanel . setImageLocation ( threddsData . imageURL ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( imagePanel ) ; } else if ( threddsData . featureType == FeatureType . RADIAL ) { makeComponent ( ftTabPane , "Radial" ) ; radialPanel . setDataset ( ( RadialDatasetSweep ) threddsData . featureDataset ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( radialPanel ) ; } else if ( threddsData . featureType . isPointFeatureType ( ) ) { makeComponent ( ftTabPane , "PointFeature" ) ; pointFeaturePanel . setPointFeatureDataset ( ( PointDatasetImpl ) threddsData . featureDataset ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( pointFeaturePanel ) ; } else if ( threddsData . featureType == FeatureType . STATION_RADIAL ) { makeComponent ( ftTabPane , "StationRadial" ) ; stationRadialPanel . setStationRadialDataset ( threddsData . featureDataset ) ; tabbedPane . setSelectedComponent ( ftTabPane ) ; ftTabPane . setSelectedComponent ( stationRadialPanel ) ; } }


Input:
Handle messages . [CODESPLIT] private static void setDataset ( ) { // do it in the swing event thread
 SwingUtilities . invokeLater ( ( ) -> { int pos = wantDataset . indexOf ( ' ' ) ; if ( pos > 0 ) { final String catName = wantDataset . substring ( 0 , pos ) ; // {catalog}#{dataset}
 if ( catName . endsWith ( ".xml" ) ) { ui . makeComponent ( null , "THREDDS" ) ; ui . threddsUI . setDataset ( wantDataset ) ; ui . tabbedPane . setSelectedComponent ( ui . threddsUI ) ; } return ; } // default
 ui . openNetcdfFile ( wantDataset ) ; } ) ; }


Input:
Set look - and - feel . [CODESPLIT] private static void prepareGui ( ) { final String osName = System . getProperty ( "os.name" ) . toLowerCase ( ) ; final boolean isMacOs = osName . startsWith ( "mac os x" ) ; if ( isMacOs ) { System . setProperty ( "apple.laf.useScreenMenuBar" , "true" ) ; // fixes the case on macOS where users use the system menu option to quit rather than
 // closing a window using the 'x' button.
 Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ) { @ Override public void run ( ) { doSavePrefsAndUI ( ) ; } } ) ; } else { // Not macOS, so try applying Nimbus L&F, if available.
 try { for ( UIManager . LookAndFeelInfo info : UIManager . getInstalledLookAndFeels ( ) ) { if ( "Nimbus" . equals ( info . getName ( ) ) ) { UIManager . setLookAndFeel ( info . getClassName ( ) ) ; break ; } } } catch ( Exception exc ) { log . warn ( "Unable to apply Nimbus look-and-feel due to {}" , exc . toString ( ) ) ; if ( log . isTraceEnabled ( ) ) { exc . printStackTrace ( ) ; } } } // misc Gui initialization(s)
 BAMutil . setResourcePath ( "/resources/nj22/ui/icons/" ) ; // Setting up a font metrics object triggers one of the most time-wasting steps of GUI set up.
 // We do it now before trying to create the splash or tools interface.
 SwingUtilities . invokeLater ( ( ) -> { final Toolkit tk = Toolkit . getDefaultToolkit ( ) ; final Font f = new Font ( "SansSerif" , Font . PLAIN , 12 ) ; @ SuppressWarnings ( "deprecation" ) final FontMetrics fm = tk . getFontMetrics ( f ) ; } ) ; }


Input:
Must call this method on the event thread . [CODESPLIT] private static void createToolsFrame ( ) { // put UI in a JFrame
 frame = new JFrame ( "NetCDF (" + DIALOG_VERSION + ") Tools" ) ; ui = new ToolsUI ( prefs , frame ) ; frame . setIconImage ( BAMutil . getImage ( "netcdfUI" ) ) ; frame . addWindowListener ( new WindowAdapter ( ) { @ Override public void windowActivated ( final WindowEvent e ) { ToolsSplashScreen . getSharedInstance ( ) . setVisible ( false ) ; } @ Override public void windowClosing ( final WindowEvent e ) { if ( ! done ) { exit ( ) ; } } } ) ; frame . getContentPane ( ) . add ( ui ) ; final Rectangle have = frame . getGraphicsConfiguration ( ) . getBounds ( ) ; final Rectangle def = new Rectangle ( 50 , 50 , 800 , 800 ) ; Rectangle want = ( Rectangle ) prefs . getBean ( FRAME_SIZE , def ) ; if ( want . getX ( ) > have . getWidth ( ) - 25 ) { // may be off screen when switcing between 2 monitor system
 want = def ; } frame . setBounds ( want ) ; frame . pack ( ) ; frame . setBounds ( want ) ; // in case a dataset was on the command line
 if ( wantDataset != null ) { setDataset ( ) ; } }


Input: Build an unnamed InvCatalog for this DatasetSource and return the top - level InvDataset . The ResultService for this DatasetSource is used to create the InvService for the new InvCatalog . Each InvDataset in the catalog is named with the location of the object they represent on the dataset source . [CODESPLIT] protected InvCatalog createSkeletonCatalog ( String prefixUrlPath ) throws IOException { String aphString = this . getResultService ( ) . getAccessPointHeader ( ) ; String apString = this . getAccessPoint ( ) ; // Check that accessPoint URL starts with accessPointHeader. if ( ! apString . startsWith ( aphString ) ) throw new IOException ( "The accessPoint <" + apString + "> must start with the accessPointHeader <" + aphString + ">." ) ; // Check that accessPoint URL ends with a slash ("/"). if ( ! apString . endsWith ( "/" ) ) throw new IOException ( "The accessPoint URL must end with a \"/\" <" + apString + ">." ) ; // Check that accessPoint URL is an OPeNDAP server URL. String apVersionString = apString + "version" ; String apVersionResultContent = null ; try { apVersionResultContent = urlExtractor . getTextContent ( apVersionString ) ; } catch ( java . io . IOException e ) { String tmpMsg = "The accessPoint URL is not an OPeNDAP server URL (no version info) <" + apVersionString + ">" ; log . error ( "expandThisType(): " + tmpMsg , e ) ; IOException myE = new IOException ( tmpMsg + e . getMessage ( ) ) ; myE . initCause ( e ) ; throw ( myE ) ; } if ( apVersionResultContent . indexOf ( "DODS" ) == - 1 && apVersionResultContent . indexOf ( "OPeNDAP" ) == - 1 && apVersionResultContent . indexOf ( "DAP" ) == - 1 ) { String tmpMsg = "The accessPoint URL version info is not valid <" + apVersionResultContent + ">" ; log . error ( "expandThisType(): " + tmpMsg ) ; throw new IOException ( tmpMsg ) ; } // Some setup stuff try { accessPointHeaderUri = new URI ( aphString ) ; } catch ( URISyntaxException e ) { throw new IOException ( "The accessPointHeader URL failed to map to a URI <" + aphString + ">." ) ; } // Create catalog. InvCatalogImpl catalog = new InvCatalogImpl ( null , null , null ) ; //this.getName(), null, null); // Create service. InvService service = new InvService ( this . getResultService ( ) . getName ( ) , this . getResultService ( ) . getServiceType ( ) . toString ( ) , this . getResultService ( ) . getBase ( ) , this . getResultService ( ) . getSuffix ( ) , this . getResultService ( ) . getDescription ( ) ) ; for ( Iterator it = this . getResultService ( ) . getProperties ( ) . iterator ( ) ; it . hasNext ( ) ; ) { service . addProperty ( ( InvProperty ) it . next ( ) ) ; } for ( Iterator it = this . getResultService ( ) . getServices ( ) . iterator ( ) ; it . hasNext ( ) ; ) { service . addService ( ( InvService ) it . next ( ) ) ; } // Add service to catalog. catalog . addService ( service ) ; // Create top-level dataset. DodsDirInvDataset topDs = null ; try { topDs = new DodsDirInvDataset ( null , new URI ( apString ) ) ; } catch ( URISyntaxException e ) { throw new IOException ( "The accessPoint URL failed to map to a URI <" + apString + ">." ) ; } // Set the serviceName (inherited by all datasets) in top-level dataset. ThreddsMetadata tm = new ThreddsMetadata ( false ) ; tm . setServiceName ( service . getName ( ) ) ; InvMetadata md = new InvMetadata ( topDs , null , XMLEntityResolver . CATALOG_NAMESPACE_10 , "" , true , true , null , tm ) ; ThreddsMetadata tm2 = new ThreddsMetadata ( false ) ; tm2 . addMetadata ( md ) ; topDs . setLocalMetadata ( tm2 ) ; // Add top-level dataset to catalog. catalog . addDataset ( topDs ) ; // Tie up any loose ends in catalog with finish(). ( ( InvCatalogImpl ) catalog ) . finish ( ) ; return ( catalog ) ; }


Input: Return a list of the InvDatasets contained in the given collection dataset on this DatasetSource . [CODESPLIT] protected List expandThisLevel ( InvDataset dataset , String prefixUrlPath ) { // @todo Switch to return type of InvDataset (???) so can return error messages about datasets removed from list. if ( dataset == null ) throw new NullPointerException ( "Given dataset cannot be null." ) ; if ( ! isCollection ( dataset ) ) throw new IllegalArgumentException ( "Dataset \"" + dataset . getName ( ) + "\" is not a collection dataset." ) ; List dsList = new ArrayList ( ) ; // Get list of possible datasets from current URL. List possibleDsList = null ; try { possibleDsList = urlExtractor . extract ( dataset . getName ( ) ) ; } catch ( java . io . IOException e ) { log . warn ( "expandThisLevel(): IOException while extracting dataset info from given OPeNDAP directory <" + dataset . getName ( ) + ">, return empty list: " + e . getMessage ( ) ) ; return ( dsList ) ; } // Handle each link in the current access path. String curDsUrlString = null ; URI curDsUri = null ; InvDataset curDs = null ; for ( Iterator it = possibleDsList . iterator ( ) ; it . hasNext ( ) ; ) // @todo curDsUrlString = (String) it.next()) { curDsUrlString = ( String ) it . next ( ) ; // Skip datasets that aren't OPeNDAP datasets (".html") or collection datasets ("/"). if ( ( ! curDsUrlString . endsWith ( ".html" ) ) && ( ! curDsUrlString . endsWith ( "/" ) ) ) { log . warn ( "expandThisLevel(): Dataset isn't an OPeNDAP dataset or collection dataset, skip <" + dataset . getName ( ) + ">." ) ; continue ; } // Remove ".html" extension. if ( curDsUrlString . endsWith ( ".html" ) ) { curDsUrlString = curDsUrlString . substring ( 0 , curDsUrlString . length ( ) - 5 ) ; } // Avoid links back down the path hierarchy (i.e., parent directory links). if ( ! curDsUrlString . startsWith ( this . accessPointHeaderUri . toString ( ) ) ) { log . debug ( "expandThisLevel(): current path <" + curDsUrlString + "> not child of given" + " location <" + this . accessPointHeaderUri . toString ( ) + ">, skip." ) ; continue ; } // Get URI from URL string. try { curDsUri = new URI ( curDsUrlString ) ; } catch ( URISyntaxException e ) { log . error ( "expandThisLevel(): Skipping dataset  <" + curDsUrlString + "> due to URISyntaxException: " + e . getMessage ( ) ) ; continue ; } log . debug ( "expandThisLevel(): handle dataset (" + curDsUrlString + ")" ) ; try { curDs = new DodsDirInvDataset ( null , curDsUri ) ; } catch ( IOException e ) { log . warn ( "expandThisLevel(): skipping dataset <" + curDsUri . toString ( ) + ">, not under accessPointHeader: " + e . getMessage ( ) ) ; continue ; } dsList . add ( curDs ) ; } // END - loop through files in current directory return ( dsList ) ; }


Input: Create standard name from list of axes . Sort the axes first [CODESPLIT] static public String makeName ( List < CoordinateAxis > axes ) { List < CoordinateAxis > axesSorted = new ArrayList <> ( axes ) ; Collections . sort ( axesSorted , new CoordinateAxis . AxisComparator ( ) ) ; StringBuilder buff = new StringBuilder ( ) ; for ( int i = 0 ; i < axesSorted . size ( ) ; i ++ ) { CoordinateAxis axis = axesSorted . get ( i ) ; if ( i > 0 ) buff . append ( " " ) ; buff . append ( axis . getFullNameEscaped ( ) ) ; } return buff . toString ( ) ; }


Input: prefer smaller ranks in case more than one [CODESPLIT] private CoordinateAxis lesserRank ( CoordinateAxis a1 , CoordinateAxis a2 ) { if ( a1 == null ) return a2 ; return ( a1 . getRank ( ) <= a2 . getRank ( ) ) ? a1 : a2 ; }


Input: Find the CoordinateAxis that has the given AxisType . If more than one return the one with lesser rank . [CODESPLIT] public CoordinateAxis findAxis ( AxisType type ) { CoordinateAxis result = null ; for ( CoordinateAxis axis : coordAxes ) { AxisType axisType = axis . getAxisType ( ) ; if ( ( axisType != null ) && ( axisType == type ) ) result = lesserRank ( result , axis ) ; } return result ; }


Input: Find the first ProjectionCT from the list of CoordinateTransforms . [CODESPLIT] public ProjectionCT getProjectionCT ( ) { for ( CoordinateTransform ct : coordTrans ) { if ( ct instanceof ProjectionCT ) return ( ProjectionCT ) ct ; } return null ; }


Input: Get the Projection for this coordinate system . If isLatLon () then returns a LatLonProjection . Otherwise extracts the projection from any ProjectionCT CoordinateTransform . [CODESPLIT] public ProjectionImpl getProjection ( ) { if ( projection == null ) { if ( isLatLon ( ) ) projection = new LatLonProjection ( ) ; ProjectionCT projCT = getProjectionCT ( ) ; if ( null != projCT ) projection = projCT . getProjection ( ) ; } return projection ; }


Input: true if it has X and Y CoordinateAxis and a CoordTransform Projection [CODESPLIT] public boolean isGeoXY ( ) { if ( ( xAxis == null ) || ( yAxis == null ) ) return false ; return null != getProjection ( ) && ! ( projection instanceof LatLonProjection ) ; }


Input: true if all axes are CoordinateAxis1D and are regular [CODESPLIT] public boolean isRegular ( ) { for ( CoordinateAxis axis : coordAxes ) { if ( ! ( axis instanceof CoordinateAxis1D ) ) return false ; if ( ! ( ( CoordinateAxis1D ) axis ) . isRegular ( ) ) return false ; } return true ; }


Input: Test if all the Dimensions in subset are in set [CODESPLIT] public static boolean isSubset ( Collection < Dimension > subset , Collection < Dimension > set ) { for ( Dimension d : subset ) { if ( ! ( set . contains ( d ) ) ) return false ; } return true ; }


Input: Do we have all the axes in the list? [CODESPLIT] public boolean containsAxes ( List < CoordinateAxis > wantAxes ) { for ( CoordinateAxis ca : wantAxes ) { if ( ! containsAxis ( ca . getFullName ( ) ) ) return false ; } return true ; }


Input: Do we have the named axis? [CODESPLIT] public boolean containsAxis ( String axisName ) { for ( CoordinateAxis ca : coordAxes ) { if ( ca . getFullName ( ) . equals ( axisName ) ) return true ; } return false ; }


Input: Do we have all the dimensions in the list? [CODESPLIT] public boolean containsDomain ( List < Dimension > wantDimensions ) { for ( Dimension d : wantDimensions ) { if ( ! domain . contains ( d ) ) return false ; } return true ; }


Input: Do we have all the axes types in the list? [CODESPLIT] public boolean containsAxisTypes ( List < AxisType > wantAxes ) { for ( AxisType wantAxisType : wantAxes ) { if ( ! containsAxisType ( wantAxisType ) ) return false ; } return true ; }


Input: Do we have an axes of the given type? [CODESPLIT] public boolean containsAxisType ( AxisType wantAxisType ) { for ( CoordinateAxis ca : coordAxes ) { if ( ca . getAxisType ( ) == wantAxisType ) return true ; } return false ; }


Input: This version of cloneDAG () is the primary point of cloning . If the src is already cloned then that existing clone is immediately returned . Otherwise cloneDAG ( map ) is called to have the object clone itself . Note this is static because it uses no existing state . [CODESPLIT] static public DAPNode cloneDAG ( CloneMap map , DAPNode src ) throws CloneNotSupportedException { DAPNode bt = map . nodes . get ( src ) ; if ( bt == null ) bt = src . cloneDAG ( map ) ; return bt ; }


Input:
This procedure does the actual recursive clone . [CODESPLIT] public DAPNode cloneDAG ( CloneMap map ) throws CloneNotSupportedException { DAPNode node = ( DAPNode ) super . clone ( ) ; // Object.clone
 map . nodes . put ( this , node ) ; DAPNode tmp = map . nodes . get ( _myParent ) ; if ( tmp != node ) _myParent = tmp ; return node ; }


Input:
************************************************************************ Default handler for OPeNDAP . html requests . Returns an html form and javascript code that allows the user to use their browser to select variables and build constraints for a data request . The DDS and DAS for the data set are used to build the form . The types in opendap . servlet . www are integral to the form generation . [CODESPLIT] public void sendDataRequestForm ( ReqState rs , String dataSet , ServerDDS sdds , DAS myDAS ) // changed jc
 throws DAP2Exception , ParseException { if ( _Debug ) System . out . println ( "Sending DODS Data Request Form For: " + dataSet + "    CE: '" + rs . getRequest ( ) . getQueryString ( ) + "'" ) ; String requestURL ; /*
        // Turn this on later if we discover we're supposed to accept
        // constraint expressions as input to the Data Request Web Form
    String ce;
    if(request.getQueryString() == null){
        ce = "";
        }
    else {
        ce = "?" + request.getQueryString();
        }
*/ int suffixIndex = rs . getRequest ( ) . getRequestURL ( ) . toString ( ) . lastIndexOf ( "." ) ; requestURL = rs . getRequest ( ) . getRequestURL ( ) . substring ( 0 , suffixIndex ) ; String dapCssUrl = "/" + requestURL . split ( "/" , 5 ) [ 3 ] + "/" + "tdsDap.css" ; try { //PrintWriter pw = new PrintWriter(response.getOutputStream());
 PrintWriter pw ; if ( false ) { pw = new PrintWriter ( new FileOutputStream ( new File ( "debug.html" ) ) ) ; } else pw = new PrintWriter ( new OutputStreamWriter ( rs . getResponse ( ) . getOutputStream ( ) , Util . UTF8 ) ) ; wwwOutPut wOut = new wwwOutPut ( pw ) ; // Get the DDS and the DAS (if one exists) for the dataSet.
 DDS myDDS = getWebFormDDS ( dataSet , sdds ) ; //DAS myDAS = dServ.getDAS(dataSet); // change jc
 jscriptCore jsc = new jscriptCore ( ) ; pw . println ( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n" + "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n" + "<title>OPeNDAP Dataset Query Form</title>\n" + "<link type=\"text/css\" rel=\"stylesheet\" media=\"screen\" href=\"" + dapCssUrl + "\"/>\n" + "<base href=\"" + helpLocation + "\">\n" + "\n" + "\n" + "\n" + "

OPeNDAP Dataset Access Form
\n" + "
\n" + "<form action=\"\">\n" + "
\n" ) ; pw . flush ( ) ; wOut . writeDisposition ( requestURL ) ; pw . println ( "

\n" ) ; wOut . writeGlobalAttributes ( myDAS , myDDS ) ; pw . println ( "

\n" ) ; wOut . writeVariableEntries ( myDAS , myDDS ) ; pw . println ( "
</form>\n" ) ; pw . println ( "
\n" ) ; pw . println ( "<address>Send questions or comments to: " + "" + "support@unidata.ucar.edu" + "</address>" + "\n" ) ; pw . println ( "
" ) ; pw . println ( "
DDS:
" ) ; pw . println ( "
" ) ; myDDS . print ( pw ) ; pw . println ( "
" ) ; pw . println ( "
" ) ; pw . flush ( ) ; } catch ( IOException ioe ) { System . out . println ( "OUCH! IOException: " + ioe . getMessage ( ) ) ; ioe . printStackTrace ( System . out ) ; } }


Input: //////////////////////////////////////////////////// [CODESPLIT] private static TypeAndOrder findTao ( int center , String key ) { Map < String , BufrCdmIndexProto . FldType > local = locals . get ( center ) ; if ( local != null ) { BufrCdmIndexProto . FldType result = local . get ( key ) ; if ( result != null ) return new TypeAndOrder ( result , - 1 ) ; } return fld2type . get ( key ) ; }


Input: /////////////////////////////////////////////////////////////////////////////////////// [CODESPLIT] public static StandardFieldsFromMessage extract ( Message m ) throws IOException { StandardFieldsFromMessage result = new StandardFieldsFromMessage ( ) ; extract ( m . ids . getCenterId ( ) , m . getRootDataDescriptor ( ) , result ) ; return result ; }


Input: debug [CODESPLIT] public String getToolTipText ( MouseEvent event ) { String text = super . getToolTipText ( event ) ; System . out . println ( "BeanTable tooltip " + text ) ; return text ; }