signature:
public class CatGenConfigMetadataFactory { /** * Return a DatasetSource when given a ' datasetSource ' JDOM element . */
private DatasetSource readDatasetSourceElement ( InvDataset parentDataset , Element dsSourceElement ) { } }

implementation:
String name = dsSourceElement . getAttributeValue ( "name" ) ; String type = dsSourceElement . getAttributeValue ( "type" ) ; String structure = dsSourceElement . getAttributeValue ( "structure" ) ; String accessPoint = dsSourceElement . getAttributeValue ( "accessPoint" ) ; String createCatalogRefs = dsSourceElement . getAttributeValue ( "createCatalogRefs" ) ; // get the resultService element
Element resultServiceElement = dsSourceElement . getChild ( "resultService" , dsSourceElement . getNamespace ( ) ) ; ResultService resultService = readResultServiceElement ( parentDataset , resultServiceElement ) ; DatasetSource dsSource = DatasetSource . newDatasetSource ( name , DatasetSourceType . getType ( type ) , DatasetSourceStructure . getStructure ( structure ) , accessPoint , resultService ) ; if ( createCatalogRefs != null ) { dsSource . setCreateCatalogRefs ( Boolean . valueOf ( createCatalogRefs ) . booleanValue ( ) ) ; } // get any datasetNamer elements
java . util . List list = dsSourceElement . getChildren ( "datasetNamer" , dsSourceElement . getNamespace ( ) ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Element dsNamerElement = ( Element ) list . get ( i ) ; dsSource . addDatasetNamer ( readDatasetNamerElement ( parentDataset , dsNamerElement ) ) ; } // get any datasetFilter elements
list = dsSourceElement . getChildren ( "datasetFilter" , dsSourceElement . getNamespace ( ) ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Element dsFilterElement = ( Element ) list . get ( i ) ; dsSource . addDatasetFilter ( readDatasetFilterElement ( dsSource , dsFilterElement ) ) ; } return ( dsSource ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Return a DatasetNamer when given a ' datasetNamer ' JDOM element . */
private DatasetNamer readDatasetNamerElement ( InvDataset parentDataset , Element dsNamerElement ) { } }

implementation: String name = dsNamerElement . getAttributeValue ( "name" ) ; String addLevel = dsNamerElement . getAttributeValue ( "addLevel" ) ; String type = dsNamerElement . getAttributeValue ( "type" ) ; String matchPattern = dsNamerElement . getAttributeValue ( "matchPattern" ) ; String substitutePattern = dsNamerElement . getAttributeValue ( "substitutePattern" ) ; String attribContainer = dsNamerElement . getAttributeValue ( "attribContainer" ) ; String attribName = dsNamerElement . getAttributeValue ( "attribName" ) ; DatasetNamer dsNamer = new DatasetNamer ( parentDataset , name , addLevel , type , matchPattern , substitutePattern , attribContainer , attribName ) ; return ( dsNamer ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Return a DatasetFilter when given a ' datasetFilter ' JDOM element . */
private DatasetFilter readDatasetFilterElement ( DatasetSource parentDatasetSource , Element dsFilterElement ) { } }

implementation: String name = dsFilterElement . getAttributeValue ( "name" ) ; String type = dsFilterElement . getAttributeValue ( "type" ) ; String matchPattern = dsFilterElement . getAttributeValue ( "matchPattern" ) ; DatasetFilter dsFilter = new DatasetFilter ( parentDatasetSource , name , DatasetFilter . Type . getType ( type ) , matchPattern ) ; String matchPatternTarget = dsFilterElement . getAttributeValue ( "matchPatternTarget" ) ; dsFilter . setMatchPatternTarget ( matchPatternTarget ) ; if ( dsFilterElement . getAttributeValue ( "applyToCollectionDatasets" ) != null ) { boolean applyToCollectionDatasets = Boolean . valueOf ( dsFilterElement . getAttributeValue ( "applyToCollectionDatasets" ) ) . booleanValue ( ) ; dsFilter . setApplyToCollectionDatasets ( applyToCollectionDatasets ) ; } if ( dsFilterElement . getAttributeValue ( "applyToAtomicDatasets" ) != null ) { boolean applyToAtomicDatasets = Boolean . valueOf ( dsFilterElement . getAttributeValue ( "applyToAtomicDatasets" ) ) . booleanValue ( ) ; dsFilter . setApplyToAtomicDatasets ( applyToAtomicDatasets ) ; } if ( dsFilterElement . getAttributeValue ( "rejectMatchingDatasets" ) != null ) { boolean rejectMatchingDatasets = Boolean . valueOf ( dsFilterElement . getAttributeValue ( "rejectMatchingDatasets" ) ) . booleanValue ( ) ; dsFilter . setRejectMatchingDatasets ( rejectMatchingDatasets ) ; } return ( dsFilter ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Return a ResultService when given a ' resultService ' JDOM element . */
private ResultService readResultServiceElement ( InvDataset parentDataset , Element resultServiceElement ) { } }

implementation: String name = resultServiceElement . getAttributeValue ( "name" ) ; String serviceType = resultServiceElement . getAttributeValue ( "serviceType" ) ; String base = resultServiceElement . getAttributeValue ( "base" ) ; String suffix = resultServiceElement . getAttributeValue ( "suffix" ) ; String accessPointHeader = resultServiceElement . getAttributeValue ( "accessPointHeader" ) ; return ( new ResultService ( name , ServiceType . getType ( serviceType ) , base , suffix , accessPointHeader ) ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Create a ' catalogGenConfig ' JDOM element */
private org . jdom2 . Element createCatGenConfigElement ( CatalogGenConfig cgc ) { } }

implementation:
// @ todo Need to deal with the 0.6 and 1.0 namespaces .
Element cgcElem = new Element ( "catalogGenConfig" , CATALOG_GEN_CONFIG_NAMESPACE_0_5 ) ; if ( cgc != null ) { if ( cgc . getType ( ) != null ) { cgcElem . setAttribute ( "type" , cgc . getType ( ) . toString ( ) ) ; } // Add ' datasetSource ' element
DatasetSource dsSource = cgc . getDatasetSource ( ) ; cgcElem . addContent ( createDatasetSourceElement ( dsSource ) ) ; } return ( cgcElem ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Create a ' DatasetSource ' JDOM element */
private org . jdom2 . Element createDatasetSourceElement ( DatasetSource dsSource ) { } }

implementation:
Element dssElem = new Element ( "datasetSource" , CATALOG_GEN_CONFIG_NAMESPACE_0_5 ) ; if ( dsSource != null ) { // Add ' name ' attribute .
if ( dsSource . getName ( ) != null ) { dssElem . setAttribute ( "name" , dsSource . getName ( ) ) ; } // Add ' type ' attribute .
if ( dsSource . getType ( ) != null ) { dssElem . setAttribute ( "type" , dsSource . getType ( ) . toString ( ) ) ; } // Add ' structure ' attribute .
if ( dsSource . getStructure ( ) != null ) { dssElem . setAttribute ( "structure" , dsSource . getStructure ( ) . toString ( ) ) ; } // Add ' accessPoint ' attribute .
if ( dsSource . getAccessPoint ( ) != null ) { dssElem . setAttribute ( "accessPoint" , dsSource . getAccessPoint ( ) ) ; } // Add ' createCatalogRefs ' attribute .
dssElem . setAttribute ( "createCatalogRefs" , Boolean . toString ( dsSource . isCreateCatalogRefs ( ) ) ) ; // Add ' resultService ' element
ResultService rs = dsSource . getResultService ( ) ; dssElem . addContent ( createResultServiceElement ( rs ) ) ; // Add ' datasetNamer ' elements
java . util . List list = dsSource . getDatasetNamerList ( ) ; for ( int j = 0 ; j < list . size ( ) ; j ++ ) { DatasetNamer dsNamer = ( DatasetNamer ) list . get ( j ) ; dssElem . addContent ( createDatasetNamerElement ( dsNamer ) ) ; } // Add ' datasetFilter ' elements
list = dsSource . getDatasetFilterList ( ) ; for ( int j = 0 ; j < list . size ( ) ; j ++ ) { DatasetFilter dsFilter = ( DatasetFilter ) list . get ( j ) ; dssElem . addContent ( createDatasetFilterElement ( dsFilter ) ) ; } } return ( dssElem ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Create a ' DatasetNamer ' JDOM element */
private org . jdom2 . Element createDatasetNamerElement ( DatasetNamer dsNamer ) { } }

implementation:
Element dsnElem = new Element ( "datasetNamer" , CATALOG_GEN_CONFIG_NAMESPACE_0_5 ) ; if ( dsNamer != null ) { // Add ' name ' attribute .
if ( dsNamer . getName ( ) != null ) { dsnElem . setAttribute ( "name" , dsNamer . getName ( ) ) ; } // Add ' addLevel ' attribute .
dsnElem . setAttribute ( "addLevel" , Boolean . toString ( dsNamer . getAddLevel ( ) ) ) ; // Add ' type ' attribute .
if ( dsNamer . getType ( ) != null ) { dsnElem . setAttribute ( "type" , dsNamer . getType ( ) . toString ( ) ) ; } // Add ' matchPattern ' attribute .
if ( dsNamer . getMatchPattern ( ) != null ) { dsnElem . setAttribute ( "matchPattern" , dsNamer . getMatchPattern ( ) ) ; } // Add ' subsitutePattern ' attribute .
if ( dsNamer . getSubstitutePattern ( ) != null ) { dsnElem . setAttribute ( "substitutePattern" , dsNamer . getSubstitutePattern ( ) ) ; } // Add ' attribContainer ' attribute .
if ( dsNamer . getAttribContainer ( ) != null ) { dsnElem . setAttribute ( "attribContainer" , dsNamer . getAttribContainer ( ) ) ; } // Add ' attribName ' attribute .
if ( dsNamer . getAttribName ( ) != null ) { dsnElem . setAttribute ( "attribName" , dsNamer . getAttribName ( ) ) ; } } return ( dsnElem ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Create a ' DatasetFilter ' JDOM element */
private org . jdom2 . Element createDatasetFilterElement ( DatasetFilter dsFilter ) { } }

implementation:
Element dsfElem = new Element ( "datasetFilter" , CATALOG_GEN_CONFIG_NAMESPACE_0_5 ) ; if ( dsFilter != null ) { // Add ' name ' attribute .
if ( dsFilter . getName ( ) != null ) { dsfElem . setAttribute ( "name" , dsFilter . getName ( ) ) ; } // Add ' type ' attribute .
if ( dsFilter . getType ( ) != null ) { dsfElem . setAttribute ( "type" , dsFilter . getType ( ) . toString ( ) ) ; } // Add ' matchPattern ' attribute .
if ( dsFilter . getMatchPattern ( ) != null ) { dsfElem . setAttribute ( "matchPattern" , dsFilter . getMatchPattern ( ) ) ; } // Add ' matchPatternTarget ' attribute .
if ( dsFilter . getMatchPatternTarget ( ) != null ) { dsfElem . setAttribute ( "matchPatternTarget" , dsFilter . getMatchPatternTarget ( ) ) ; } // Add ' applyToCollectionDatasets ' attribute .
dsfElem . setAttribute ( "applyToCollectionDatasets" , String . valueOf ( dsFilter . isApplyToCollectionDatasets ( ) ) ) ; // Add ' applyToAtomicDatasets ' attribute .
dsfElem . setAttribute ( "applyToAtomicDatasets" , String . valueOf ( dsFilter . isApplyToAtomicDatasets ( ) ) ) ; // Add ' rejectMatchingDatasets ' attribute .
dsfElem . setAttribute ( "rejectMatchingDatasets" , String . valueOf ( dsFilter . isRejectMatchingDatasets ( ) ) ) ; } return ( dsfElem ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Create a ' ResultService ' JDOM element */
private org . jdom2 . Element createResultServiceElement ( ResultService resultService ) { } }

implementation:
Element rsElem = new Element ( "resultService" , CATALOG_GEN_CONFIG_NAMESPACE_0_5 ) ; if ( resultService != null ) { // Add ' name ' attribute .
if ( resultService . getName ( ) != null ) { rsElem . setAttribute ( "name" , resultService . getName ( ) ) ; } // Add ' serviceType ' attribute .
if ( resultService . getServiceType ( ) != null ) { rsElem . setAttribute ( "serviceType" , resultService . getServiceType ( ) . toString ( ) ) ; } // Add ' base ' attribute .
if ( resultService . getBase ( ) != null ) { rsElem . setAttribute ( "base" , resultService . getBase ( ) ) ; } // Add ' suffix ' attribute .
if ( resultService . getSuffix ( ) != null ) { rsElem . setAttribute ( "suffix" , resultService . getSuffix ( ) ) ; } // Add ' accessPointHeader ' attribute .
if ( resultService . getAccessPointHeader ( ) != null ) { rsElem . setAttribute ( "accessPointHeader" , resultService . getAccessPointHeader ( ) ) ; } } return ( rsElem ) ;


signature:
public class Debug { /** * Return the value of the named flag . If it doesnt exist , it will be added
 * to the store and the menu with a value of " false " . */
static public boolean isSet ( String flagName ) { } }

implementation:
if ( store == null ) return false ; NamePart np = partit ( flagName ) ; if ( debug ) { try { if ( ( np . storeName . length ( ) > 0 ) && ! store . nodeExists ( np . storeName ) ) System . out . println ( "Debug.isSet create node = " + flagName + " " + np ) ; else if ( null == store . node ( np . storeName ) . get ( np . keyName , null ) ) System . out . println ( "Debug.isSet create flag = " + flagName + " " + np ) ; } catch ( BackingStoreException e ) { } } // add it if it doesnt already exist
boolean value = store . node ( np . storeName ) . getBoolean ( np . keyName , false ) ; store . node ( np . storeName ) . putBoolean ( np . keyName , value ) ; return value ;


signature:
public class Debug { /** * Construct cascading pull - aside menus using the values of the debug flags
 * in the Preferences object .
 * @ param topMenu attach the menus as children of this one . */
static public void constructMenu ( JMenu topMenu ) { } }

implementation:
if ( debug ) System . out . println ( "Debug.constructMenu " ) ; if ( topMenu . getItemCount ( ) > 0 ) topMenu . removeAll ( ) ; try { addToMenu ( topMenu , store ) ; // recursive
} catch ( BackingStoreException e ) { } topMenu . revalidate ( ) ;


signature:
public class Debug { /** * recursive menu adding */
static private void addToMenu ( JMenu menu , Preferences prefs ) throws BackingStoreException { } }

implementation:
if ( debug ) System . out . println ( " addMenu " + prefs . name ( ) ) ; String [ ] keys = prefs . keys ( ) ; for ( String key : keys ) { boolean bval = prefs . getBoolean ( key , false ) ; String fullname = prefs . absolutePath ( ) + "/" + key ; menu . add ( new DebugMenuItem ( fullname , key , bval ) ) ; // menu leaf
if ( debug ) System . out . println ( "   leaf= <" + key + "><" + fullname + ">" ) ; } String [ ] kidName = prefs . childrenNames ( ) ; for ( String aKidName : kidName ) { Preferences pkid = prefs . node ( aKidName ) ; JMenu subMenu = new JMenu ( pkid . name ( ) ) ; menu . add ( subMenu ) ; addToMenu ( subMenu , pkid ) ; }


signature:
public class GempakParameterTable { /** * Add parameters from the table
 * @ param tbl table location
 * @ throws IOException problem reading table . */
public void addParameters ( String tbl ) throws IOException { } }

implementation:
try ( InputStream is = getInputStream ( tbl ) ) { if ( is == null ) { throw new IOException ( "Unable to open " + tbl ) ; } String content = readContents ( is ) ; // LOOK this is silly - should just read one line at a time
// List lines = StringUtil . split ( content , " \ n " , false ) ;
String [ ] lines = content . split ( "\n" ) ; List < String [ ] > result = new ArrayList < > ( ) ; for ( String line : lines ) { // String line = ( String ) lines . get ( i ) ;
String tline = line . trim ( ) ; if ( tline . length ( ) == 0 ) { continue ; } if ( tline . startsWith ( "!" ) ) { continue ; } String [ ] words = new String [ indices . length ] ; for ( int idx = 0 ; idx < indices . length ; idx ++ ) { if ( indices [ idx ] >= tline . length ( ) ) { continue ; } if ( indices [ idx ] + lengths [ idx ] > tline . length ( ) ) { words [ idx ] = line . substring ( indices [ idx ] ) ; } else { words [ idx ] = line . substring ( indices [ idx ] , indices [ idx ] + lengths [ idx ] ) ; } // if ( trimWords ) {
words [ idx ] = words [ idx ] . trim ( ) ; } result . add ( words ) ; } for ( String [ ] aResult : result ) { GempakParameter p = makeParameter ( aResult ) ; if ( p != null ) { if ( p . getName ( ) . contains ( "(" ) ) { templateParamMap . put ( p . getName ( ) , p ) ; } else { paramMap . put ( p . getName ( ) , p ) ; } } } }


signature:
public class GempakParameterTable { /** * Make a parameter from the tokens
 * @ param words the tokens
 * @ return a grid parameter ( may be null ) */
private GempakParameter makeParameter ( String [ ] words ) { } }

implementation:
int num = 0 ; String description ; if ( words [ 0 ] != null ) { num = ( int ) Double . parseDouble ( words [ 0 ] ) ; } if ( ( words [ 3 ] == null ) || words [ 3 ] . equals ( "" ) ) { // no param name
return null ; } String name = words [ 3 ] ; if ( name . contains ( "-" ) ) { int first = name . indexOf ( "-" ) ; int last = name . lastIndexOf ( "-" ) ; StringBuilder buf = new StringBuilder ( name . substring ( 0 , first ) ) ; buf . append ( "(" ) ; for ( int i = first ; i <= last ; i ++ ) { buf . append ( "\\d" ) ; } buf . append ( ")" ) ; buf . append ( name . substring ( last + 1 ) ) ; name = buf . toString ( ) ; } if ( ( words [ 1 ] == null ) || words [ 1 ] . equals ( "" ) ) { description = words [ 3 ] ; } else { description = words [ 1 ] ; } String unit = words [ 2 ] ; if ( unit != null ) { unit = unit . replaceAll ( "\\*\\*" , "" ) ; if ( unit . equals ( "-" ) ) { unit = "" ; } } int decimalScale ; try { decimalScale = Integer . parseInt ( words [ 4 ] . trim ( ) ) ; } catch ( NumberFormatException ne ) { decimalScale = 0 ; } return new GempakParameter ( num , name , description , unit , decimalScale ) ;


signature:
public class GempakParameterTable { /** * Get the parameter for the given name
 * @ param name name of the parameter ( eg : , TMPK ) ;
 * @ return corresponding parameter or null if not found in table */
public GempakParameter getParameter ( String name ) { } }

implementation:
GempakParameter param = paramMap . get ( name ) ; if ( param == null ) { // try the regex list
Set < String > keys = templateParamMap . keySet ( ) ; if ( ! keys . isEmpty ( ) ) { for ( String key : keys ) { Pattern p = Pattern . compile ( key ) ; Matcher m = p . matcher ( name ) ; if ( m . matches ( ) ) { // System . out . println ( " found match " + key + " for " + name ) ;
String value = m . group ( 1 ) ; GempakParameter match = templateParamMap . get ( key ) ; param = new GempakParameter ( match . getNumber ( ) , name , match . getDescription ( ) + " (" + value + " hour)" , match . getUnit ( ) , match . getDecimalScale ( ) ) ; paramMap . put ( name , param ) ; break ; } } } } return param ;


signature:
public class GempakParameterTable { /** * Test
 * @ param args ignored
 * @ throws IOException problem reading the table . */
public static void main ( String [ ] args ) throws IOException { } }

implementation:
GempakParameterTable pt = new GempakParameterTable ( ) ; // pt . addParameters ( " resources / nj22 / tables / gempak / wmogrib3 . tbl " ) ;
pt . addParameters ( "resources/nj22/tables/gempak/params.tbl" ) ; if ( args . length > 0 ) { String param = args [ 0 ] ; GempakParameter parm = pt . getParameter ( param ) ; if ( parm != null ) { System . out . println ( "Found " + param + ": " + parm ) ; } }


signature:
public class GempakParameterTable { /** * Read in the bytes from the given InputStream
 * and construct and return a String .
 * Closes the InputStream argument .
 * @ param is InputStream to read from
 * @ return contents as a String
 * @ throws IOException problem reading contents */
private String readContents ( InputStream is ) throws IOException { } }

implementation: return new String ( readBytes ( is ) , CDM . utf8Charset ) ;


signature:
public class GempakParameterTable { /** * Read the bytes in the given input stream .
 * @ param is The input stream
 * @ return The bytes
 * @ throws IOException On badness */
private byte [ ] readBytes ( InputStream is ) throws IOException { } }

implementation: int totalRead = 0 ; byte [ ] content = new byte [ 1000000 ] ; while ( true ) { int howMany = is . read ( content , totalRead , content . length - totalRead ) ; if ( howMany < 0 ) { break ; } if ( howMany == 0 ) { continue ; } totalRead += howMany ; if ( totalRead >= content . length ) { byte [ ] tmp = content ; int newLength = ( ( content . length < 25000000 ) ? content . length * 2 : content . length + 5000000 ) ; content = new byte [ newLength ] ; System . arraycopy ( tmp , 0 , content , 0 , totalRead ) ; } } is . close ( ) ; byte [ ] results = new byte [ totalRead ] ; System . arraycopy ( content , 0 , results , 0 , totalRead ) ; return results ;


signature:
public class GempakParameterTable { /** * Get the input stream to the given resource
 * @ param resourceName The resource name . May be a file , url ,
 * java resource , etc .
 * @ return The input stream to the resource */
private InputStream getInputStream ( String resourceName ) throws IOException { } }

implementation:
// Try class loader to get resource
ClassLoader cl = GempakParameterTable . class . getClassLoader ( ) ; InputStream s = cl . getResourceAsStream ( resourceName ) ; if ( s != null ) { return s ; } // Try the file system
File f = new File ( resourceName ) ; if ( f . exists ( ) ) { s = new FileInputStream ( f ) ; } if ( s != null ) { return s ; } // Try it as a url
Matcher m = Pattern . compile ( " " ) . matcher ( resourceName ) ; String encodedUrl = m . replaceAll ( "%20" ) ; URL dataUrl = new URL ( encodedUrl ) ; URLConnection connection = dataUrl . openConnection ( ) ; return connection . getInputStream ( ) ;


signature:
public class NcUnitReference { /** * wml2 : defaultPointMetadata / wml2 : DefaultTVPMeasurementMetadata / wml2 : uom */
public static UnitReference initUom ( UnitReference uom , VariableSimpleIF dataVar ) { } }

implementation:
// @ code
String udunits = dataVar . getUnitsString ( ) ; if ( udunits == null ) { // Variable may not have a " units " attribute .
return null ; } String ucum = ErddapEDUnits . udunitsToUcum ( udunits ) ; uom . setCode ( ucum ) ; return uom ;


signature:
public class TrajectoryObsDatasetImpl { /** * _ more _
 * @ param unitsString _ more _
 * @ return _ more _
 * @ throws Exception _ more _ */
protected static double getMetersConversionFactor ( String unitsString ) throws Exception { } }

implementation: SimpleUnit unit = SimpleUnit . factoryWithExceptions ( unitsString ) ; return unit . convertTo ( 1.0 , SimpleUnit . meterUnit ) ;


signature:
public class TrajectoryObsDatasetImpl { /** * _ more _
 * @ return _ more _ */
public String getDetailInfo ( ) { } }

implementation: StringBuffer sbuff = new StringBuffer ( ) ; sbuff . append ( "TrajectoryObsDataset\n" ) ; sbuff . append ( "  adapter   = " + getClass ( ) . getName ( ) + "\n" ) ; sbuff . append ( "  trajectories:" + "\n" ) ; for ( Iterator it = this . getTrajectoryIds ( ) . iterator ( ) ; it . hasNext ( ) ; ) { sbuff . append ( "      " + ( String ) it . next ( ) + "\n" ) ; } sbuff . append ( super . getDetailInfo ( ) ) ; return sbuff . toString ( ) ;


signature:
public class TrajectoryObsDatasetImpl { /** * _ more _
 * @ return _ more _ */
public boolean syncExtend ( ) { } }

implementation:
if ( ! this . netcdfDataset . hasUnlimitedDimension ( ) ) { return false ; } try { if ( ! this . netcdfDataset . syncExtend ( ) ) { return false ; } } catch ( IOException e ) { return false ; } // Update number of points in this TrajectoryObsDataset and in the child TrajectoryObsDatatype .
int newNumPoints = this . trajectoryDim . getLength ( ) ; if ( this . trajectoryNumPoint >= newNumPoints ) { return false ; } this . trajectoryNumPoint = newNumPoints ; ( ( Trajectory ) this . trajectory ) . setNumPoints ( this . trajectoryNumPoint ) ; // Update end date in this TrajectoryObsDataset and in the child TrajectoryObsDatatype .
try { endDate = trajectory . getTime ( trajectoryNumPoint - 1 ) ; } catch ( IOException e ) { return false ; } ( ( Trajectory ) trajectory ) . setEndDate ( endDate ) ; return true ;


signature:
public class PointIteratorAdapter { /** * but we can define a stronger contract . */
@ Override public PointFeature next ( ) throws NoSuchElementException { } }

implementation: if ( ! hasNext ( ) ) { throw new NoSuchElementException ( "The iteration has no more elements." ) ; } PointFeature pointFeat = pointIter . next ( ) ; assert pointFeat != null : "hasNext() should have been false. WTF?" ; calcBounds ( pointFeat ) ; return pointFeat ;


signature:
public class GradsEnsembleDimension { /** * Make the level values from the specifications
 * @ return the level values */
protected double [ ] makeLevelValues ( ) { } }

implementation: double [ ] vals = new double [ getSize ( ) ] ; for ( int i = 0 ; i < getSize ( ) ; i ++ ) { vals [ i ] = i ; } return vals ;


signature:
public class GradsEnsembleDimension { /** * Replace the ensemble template parameter in a filename
 * @ param filespec the file template
 * @ param ensIndex the ensemble index
 * @ return the filled in template */
public String replaceFileTemplate ( String filespec , int ensIndex ) { } }

implementation: return filespec . replaceAll ( ENS_TEMPLATE_ID , getEnsembleNames ( ) . get ( ensIndex ) ) ;


signature:
public class RecordDatasetHelper { /** * Set extra information used by station obs datasets .
 * @ param stnIdVName the obs variable that is used to find the station in the stnHash ; may be type int or a String ( char ) .
 * @ param stnDescVName optional station var containing station description */
public void setStationInfo ( String stnIdVName , String stnDescVName ) { } }

implementation: this . stnIdVName = stnIdVName ; this . stnDescVName = stnDescVName ; Variable stationVar = ncfile . findVariable ( stnIdVName ) ; stationIdType = stationVar . getDataType ( ) ;


signature:
public class RecordDatasetHelper { /** * This reads through all the records in the dataset , and constructs a list of
 * RecordPointObs or RecordStationObs . It does not cache the data .
 * < p > If stnIdVName is not null , its a StationDataset , then construct a Station HashMap of StationImpl
 * objects . Add the RecordStationObs into the list of obs for that station .
 * @ param cancel allow user to cancel
 * @ return List of RecordPointObs or RecordStationObs
 * @ throws IOException */
public ArrayList readAllCreateObs ( CancelTask cancel ) throws IOException { } }

implementation:
// see if its a station or point dataset
boolean hasStations = stnIdVName != null ; if ( hasStations ) stnHash = new HashMap < Object , ucar . unidata . geoloc . Station > ( ) ; // get min and max date and lat , lon
double minDate = Double . MAX_VALUE ; double maxDate = - Double . MAX_VALUE ; double minLat = Double . MAX_VALUE ; double maxLat = - Double . MAX_VALUE ; double minLon = Double . MAX_VALUE ; double maxLon = - Double . MAX_VALUE ; // read all the data , create a RecordObs
ArrayList records = new ArrayList ( ) ; int recno = 0 ; try ( StructureDataIterator ii = recordVar . getStructureIterator ( ) ) { while ( ii . hasNext ( ) ) { StructureData sdata = ii . next ( ) ; StructureMembers members = sdata . getStructureMembers ( ) ; Object stationId = null ; if ( hasStations ) { if ( stationIdType == DataType . INT ) { int stationNum = sdata . getScalarInt ( stnIdVName ) ; stationId = new Integer ( stationNum ) ; } else stationId = sdata . getScalarString ( stnIdVName ) . trim ( ) ; } String desc = ( stnDescVName == null ) ? null : sdata . getScalarString ( stnDescVName ) ; double lat = sdata . convertScalarDouble ( latVName ) ; double lon = sdata . convertScalarDouble ( lonVName ) ; double alt = ( altVName == null ) ? Double . NaN : altScaleFactor * sdata . convertScalarDouble ( altVName ) ; double obsTime = sdata . convertScalarDouble ( members . findMember ( obsTimeVName ) ) ; double nomTime = ( nomTimeVName == null ) ? obsTime : sdata . convertScalarDouble ( members . findMember ( nomTimeVName ) ) ; // double obsTime = sdata . convertScalarDouble ( members . findMember ( obsTimeVName ) ) ;
// double nomTime = ( nomTimeVName = = null ) ? obsTime : sdata . convertScalarDouble ( members . findMember ( nomTimeVName ) ) ;
if ( hasStations ) { StationImpl stn = ( StationImpl ) stnHash . get ( stationId ) ; if ( stn == null ) { stn = new StationImpl ( stationId . toString ( ) , desc , lat , lon , alt ) ; stnHash . put ( stationId , stn ) ; } RecordStationObs stnObs = new RecordStationObs ( stn , obsTime , nomTime , recno ) ; records . add ( stnObs ) ; stn . addObs ( stnObs ) ; } else { records . add ( new RecordPointObs ( new ucar . unidata . geoloc . EarthLocationImpl ( lat , lon , alt ) , obsTime , nomTime , recno ) ) ; } // track date range and bounding box
minDate = Math . min ( minDate , obsTime ) ; maxDate = Math . max ( maxDate , obsTime ) ; minLat = Math . min ( minLat , lat ) ; maxLat = Math . max ( maxLat , lat ) ; minLon = Math . min ( minLon , lon ) ; maxLon = Math . max ( maxLon , lon ) ; recno ++ ; if ( ( cancel != null ) && cancel . isCancel ( ) ) return null ; } } boundingBox = new LatLonRect ( new LatLonPointImpl ( minLat , minLon ) , new LatLonPointImpl ( maxLat , maxLon ) ) ; return records ;


signature:
public class Field { /** * Register for PropertyChange events when the value of the Field changes .
 * When accept ( ) is called ,
 * you will get a new PropertyChangeEvent ( this , fldName , oldValue , newValue ) , where
 * the oldValue , newValue will be String , Integer , Boolean , etc . */
public void addPropertyChangeListener ( PropertyChangeListener pcl ) { } }

implementation: if ( listenerList == null ) listenerList = new javax . swing . event . EventListenerList ( ) ; listenerList . add ( PropertyChangeListener . class , pcl ) ;


signature:
public class Field { /** * See if edit value is valid , put error message in buff . */
protected boolean validate ( StringBuffer buff ) { } }

implementation: if ( ! _validate ( buff ) ) return false ; Object editValue = getEditValue ( ) ; if ( editValue == null ) return false ; for ( FieldValidator v : validators ) { if ( ! v . validate ( this , editValue , buff ) ) return false ; } if ( acceptIfDifferent ( editValue ) ) { setEditValue ( validValue ) ; sendEvent ( ) ; } return true ;


signature:
public class Field { /** * Get current value from editComponent , save to store .
 * If different from old value , fire PropertyChangeEvent .
 * Return false if invalid format , add error message to buff if not null . */
protected boolean accept ( StringBuffer buff ) { } }

implementation: if ( ! validate ( buff ) ) { validate ( buff ) ; return false ; } if ( acceptIfDifferent ( getEditValue ( ) ) ) { setStoreValue ( validValue ) ; sendEvent ( ) ; } return true ;


signature:
public class Field { /** * See if this value is different from current accepted value ( using equals ( ) ) ;
 * If so , set old value to accepted value , then accepted value to this value .
 * @ return true if its different . */
protected boolean acceptIfDifferent ( Object newValue ) { } }

implementation:
// System . out . println ( " isDifferent " + newValue + " " + value ) ;
if ( ( newValue == null ) && ( validValue == null ) ) return false ; if ( ( validValue != null ) && validValue . equals ( newValue ) ) return false ; previousValue = getValue ( ) ; validValue = newValue ; return true ;


signature:
public class Field { /** * / * Get value from store , put value into editComponent */
protected void restoreValue ( Object defValue ) { } }

implementation: if ( storeData != null ) { validValue = getStoreValue ( defValue ) ; setEditValue ( validValue ) ; }


signature:
public class Field { /** * The value in the store has changed : update the edit component
 * send event if its different from previous */
protected void setNewValueFromStore ( ) { } }

implementation: Object newValue = getStoreValue ( validValue ) ; if ( acceptIfDifferent ( newValue ) ) { setEditValue ( newValue ) ; sendEvent ( ) ; }


signature:
public class Field { /** * send PropertyChangeEvent */
protected void sendEvent ( ) { } }

implementation: if ( listenerList != null ) { PropertyChangeEvent event = new PropertyChangeEvent ( this , name , previousValue , getValue ( ) ) ; Object [ ] listeners = listenerList . getListenerList ( ) ; for ( int i = listeners . length - 2 ; i >= 0 ; i -= 2 ) ( ( PropertyChangeListener ) listeners [ i + 1 ] ) . propertyChange ( event ) ; }


signature:
public class Field { /** * An integer input field with an associated CDM . UNITS label .
 * static public class IntUnits extends Int implements UnitsField {
 * private String units ;
 * IntUnits ( String name , String label , String units , int defValue , PersistenceManager storeData ) {
 * super ( name , label , defValue , storeData ) ;
 * this . units = units ;
 * public String getUnits ( ) { return units ; }
 * A boolean input box that is used to enable / disable another field .
 * static public class BooleanEnabler extends YesNo {
 * private JRadioButton enabler ;
 * private Field enabledField ;
 * BooleanEnabler ( String fldName , boolean initValue , Field enField , PersistenceManager storeData ) {
 * super ( fldName , " " , initValue , storeData ) ;
 * this . enabledField = enField ;
 * enabler = new JRadioButton ( ) ;
 * enabler . setSelected ( ( ( Boolean ) valueObj ) . booleanValue ( ) ) ;
 * editComp = ( JComponent ) enabler ;
 * enabledField . setEnabled ( initValue ) ;
 * enabler . addItemListener ( new ItemListener ( ) {
 * public void itemStateChanged ( ItemEvent e ) {
 * boolean isOn = ( e . getStateChange ( ) = = ItemEvent . SELECTED ) ;
 * enabledField . setEnabled ( isOn ) ;
 * protected void setValue ( Object newValue ) {
 * boolean bvalue = ( ( Boolean ) newValue ) . booleanValue ( ) ;
 * enabler . setSelected ( bvalue ) ;
 * enabledField . setEnabled ( bvalue ) ;
 * _ setValue ( newValue ) ;
 * public boolean isSelected ( ) { return enabler . isSelected ( ) ; }
 * public void setSelected ( boolean v ) { enabler . setSelected ( v ) ; }
 * Field getEnabledField ( ) { return enabledField ; } */
static private void showFormatInfo ( JFormattedTextField tf ) { } }

implementation: JFormattedTextField . AbstractFormatter ff = tf . getFormatter ( ) ; System . out . println ( "AbstractFormatter  " + ff . getClass ( ) . getName ( ) ) ; if ( ff instanceof NumberFormatter ) { NumberFormatter nf = ( NumberFormatter ) ff ; Format f = nf . getFormat ( ) ; System . out . println ( " Format  = " + f . getClass ( ) . getName ( ) ) ; if ( f instanceof NumberFormat ) { NumberFormat nfat = ( NumberFormat ) f ; System . out . println ( " getMinimumIntegerDigits=" + nfat . getMinimumIntegerDigits ( ) ) ; System . out . println ( " getMaximumIntegerDigits=" + nfat . getMaximumIntegerDigits ( ) ) ; System . out . println ( " getMinimumFractionDigits=" + nfat . getMinimumFractionDigits ( ) ) ; System . out . println ( " getMaximumFractionDigits=" + nfat . getMaximumFractionDigits ( ) ) ; } if ( f instanceof DecimalFormat ) { DecimalFormat df = ( DecimalFormat ) f ; System . out . println ( " Pattern  = " + df . toPattern ( ) ) ; } }


signature:
public class Field { /** * / * This dorks with Double . toString ( ) :
 * From Double . toString ( ) ( m = magnitude of the number ) :
 * If m is greater than or equal to 10 ^ - 3 but less than 10 ^ 7 , then it is represented as the
 * integer part of m , in decimal form with no leading zeroes , followed by ' . ' ( . ) ,
 * followed by one or more decimal digits representing the fractional part of m .
 * If m is less than 10 ^ - 3 or greater than 10 ^ 7 , then it is represented in scientific notation .
 * Let n be the unique integer such that 10n < = m < 10n + 1 ; then let a be the mathematically exact
 * quotient of m and 10n so that 1 < = a < 10 . The magnitude is then represented as the integer part
 * of a , as a single decimal digit , followed by ' . ' ( . ) , followed by decimal digits representing
 * the fractional part of a , followed by the letter ' E ' ( E ) , followed by a representation of n
 * as a decimal integer , as produced by the method Integer . toString ( int ) .
 * How many digits must be printed for the fractional part of m or a ? There must be
 * at least one digit to represent the fractional part , and beyond that as many ,
 * but only as many , more digits as are needed to uniquely distinguish the argument
 * value from adjacent values of type double . That is , suppose that x is the exact
 * mathematical value represented by the decimal representation produced by this method
 * for a finite nonzero argument d . Then d must be the double value nearest to x ; or if
 * two double values are equally close to x , then d must be one of them and the least
 * significant bit of the significand of d must be 0. */
private static String formatDouble ( double d , int min_sigFigs , int fixed_decimals ) { } }

implementation:
String s = java . lang . Double . toString ( d ) ; if ( java . lang . Double . isNaN ( d ) ) return s ; // extract the sign
String sign ; String unsigned ; if ( s . startsWith ( "-" ) || s . startsWith ( "+" ) ) { sign = s . substring ( 0 , 1 ) ; unsigned = s . substring ( 1 ) ; } else { sign = "" ; unsigned = s ; } // deal with exponential notation
String mantissa ; String exponent ; int eInd = unsigned . indexOf ( 'E' ) ; if ( eInd == - 1 ) eInd = unsigned . indexOf ( 'e' ) ; if ( eInd == - 1 ) { mantissa = unsigned ; exponent = "" ; } else { mantissa = unsigned . substring ( 0 , eInd ) ; exponent = unsigned . substring ( eInd ) ; } // deal with decimal point
StringBuffer number , fraction ; int dotInd = mantissa . indexOf ( '.' ) ; if ( dotInd == - 1 ) { number = new StringBuffer ( mantissa ) ; fraction = new StringBuffer ( "" ) ; } else { number = new StringBuffer ( mantissa . substring ( 0 , dotInd ) ) ; fraction = new StringBuffer ( mantissa . substring ( dotInd + 1 ) ) ; } // number of significant figures
int numFigs = number . length ( ) ; int fracFigs = fraction . length ( ) ; // can do either fixed _ decimals or min _ sigFigs
if ( fixed_decimals != - 1 ) { if ( fixed_decimals == 0 ) { fraction . setLength ( 0 ) ; } else if ( fixed_decimals > fracFigs ) { int want = fixed_decimals - fracFigs ; for ( int i = 0 ; i < want ; i ++ ) fraction . append ( "0" ) ; } else if ( fixed_decimals < fracFigs ) { int chop = fracFigs - fixed_decimals ; // LOOK should round ! !
fraction . setLength ( fraction . length ( ) - chop ) ; } fracFigs = fixed_decimals ; } else { // Don ' t count leading zeros in the fraction , if no number
if ( ( numFigs == 0 || number . toString ( ) . equals ( "0" ) ) && fracFigs > 0 ) { numFigs = 0 ; number = new StringBuffer ( "" ) ; for ( int i = 0 ; i < fraction . length ( ) ; ++ i ) { if ( fraction . charAt ( i ) != '0' ) break ; -- fracFigs ; } } // Don ' t count trailing zeroes in the number if no fraction
if ( ( fracFigs == 0 ) && numFigs > 0 ) { for ( int i = number . length ( ) - 1 ; i > 0 ; i -- ) { if ( number . charAt ( i ) != '0' ) break ; -- numFigs ; } } // deal with min sig figures
int sigFigs = numFigs + fracFigs ; if ( sigFigs > min_sigFigs ) { // Want fewer figures in the fraction ; chop ( should round ? )
int chop = Math . min ( sigFigs - min_sigFigs , fracFigs ) ; fraction . setLength ( fraction . length ( ) - chop ) ; fracFigs -= chop ; } } /* int sigFigs = numFigs + fracFigs ;
 if ( sigFigs > max _ sigFigs ) {
 if ( numFigs > = max _ sigFigs ) { / / enough sig figs in just the number part
 fraction . setLength ( 0 ) ;
 for ( int i = max _ sigFigs ; i < numFigs ; + + i )
 number . setCharAt ( i , ' 0 ' ) ; / / should round ?
 } else {
 / / Want fewer figures in the fraction ; chop ( should round ? )
 int chop = sigFigs - max _ sigFigs ;
 fraction . setLength ( fraction . length ( ) - chop ) ;
 / * may want a fixed decimal place
 if ( dec _ places ! = - 1 ) {
 if ( dec _ places = = 0 ) {
 fraction . setLength ( 0 ) ;
 fracFigs = 0;
 } else if ( dec _ places > fracFigs ) {
 int want = dec _ places - fracFigs ;
 for ( int i = 0 ; i < want ; i + + )
 fraction . append ( " 0 " ) ;
 } else if ( dec _ places < fracFigs ) {
 int chop = fracFigs - dec _ places ;
 fraction . setLength ( fraction . length ( ) - chop ) ;
 fracFigs = dec _ places ; */
if ( fraction . length ( ) == 0 ) return sign + number + exponent ; else return sign + number + "." + fraction + exponent ; }


signature:
public class Grib2SectionBitMap { /** * Read the bit map array .
 * @ param raf read from here
 * @ return bit map as array of byte values , or null if none .
 * @ throws java . io . IOException on read error */
@ Nullable public byte [ ] getBitmap ( RandomAccessFile raf ) throws IOException { } }

implementation:
// no bitMap
if ( bitMapIndicator == 255 ) return null ; // LOOK : bitMapIndicator = 254 = = previously defined bitmap
if ( bitMapIndicator == 254 ) logger . debug ( "HEY bitMapIndicator=254 previously defined bitmap" ) ; if ( bitMapIndicator != 0 ) { throw new UnsupportedOperationException ( "Grib2 Bit map section pre-defined (provided by center) = " + bitMapIndicator ) ; } raf . seek ( startingPosition ) ; int length = GribNumbers . int4 ( raf ) ; raf . skipBytes ( 2 ) ; byte [ ] data = new byte [ length - 6 ] ; raf . readFully ( data ) ; return data ;


signature:
public class CatalogExt { /** * message Catalog {
 * uint64 catId = 1 ; / / sequence no
 * string catLocation = 2;
 * bool isRoot = 3;
 * uint64 lastRead = 4; */
public void writeExternal ( DataOutputStream out ) throws IOException { } }

implementation: ConfigCatalogExtProto . Catalog . Builder builder = ConfigCatalogExtProto . Catalog . newBuilder ( ) ; builder . setCatId ( catId ) ; builder . setCatLocation ( catRelLocation ) ; builder . setIsRoot ( isRoot ) ; builder . setLastRead ( lastRead ) ; ConfigCatalogExtProto . Catalog index = builder . build ( ) ; byte [ ] b = index . toByteArray ( ) ; out . writeInt ( b . length ) ; out . write ( b ) ; total_count ++ ; total_nbytes += b . length + 4 ;


signature:
public class DataFormatType { /** * Find the known DataFormatType that matches the given name ( ignoring case )
 * or null if the name is unknown .
 * @ param name name of the desired DataFormatType .
 * @ return DataFormatType or null if no match . */
public static DataFormatType findType ( String name ) { } }

implementation: if ( name == null ) return null ; for ( DataFormatType m : members ) { if ( m . name . equalsIgnoreCase ( name ) ) return m ; } return null ;


signature:
public class DataFormatType { /** * Return a DataFormatType for the given name by either matching
 * a known type ( ignoring case ) or creating an unknown type .
 * @ param name name of the desired DataFormatType .
 * @ return the named DataFormatType or null if given name is null . */
public static DataFormatType getType ( String name ) { } }

implementation: if ( name == null ) return null ; DataFormatType t = findType ( name ) ; return t != null ? t : new DataFormatType ( name , false ) ;


signature:
public class NcPointType { /** * gml : Point */
public static PointType initPoint ( PointType point , StationTimeSeriesFeature stationFeat ) { } }

implementation:
// @ gml : id
String id = MarshallingUtil . createIdForType ( PointType . class ) ; point . setId ( id ) ; // gml : pos
NcDirectPositionType . initPos ( point . addNewPos ( ) , stationFeat ) ; return point ;


signature:
public class NCdumpPanel { /** * allow calling from outside */
public void setNetcdfFile ( NetcdfFile ncf ) { } }

implementation: this . ncfile = ncf ; this . filename = ncf . getLocation ( ) ; final GetDataRunnable runner = new GetDataRunnable ( ) { public void run ( Object o ) throws IOException { final StringWriter sw = new StringWriter ( 50000 ) ; NCdumpW . print ( ncfile , command , sw , task ) ; result = sw . toString ( ) ; } } ; task = new GetDataTask ( runner , filename , null ) ; stopButton . startProgressMonitorTask ( task ) ;


signature:
public class Time2DOffsetCoordSys { /** * 1 ) single runtime
 * 1a timeOffset
 * 1b time or timeRange
 * 1c none = constant runtime dataset
 * 2 ) multiple runtimes
 * 2a timeOffset = constant offset dataset
 * 2b time ( not range ) = constant forecast dataset */
public Optional < List < CoverageCoordAxis > > subset ( SubsetParams params , AtomicBoolean isConstantForcast , boolean makeCFcompliant ) { } }

implementation:
List < CoverageCoordAxis > result = new ArrayList < > ( ) ; Optional < CoverageCoordAxis > axiso = runAxis . subset ( params ) ; if ( ! axiso . isPresent ( ) ) return Optional . empty ( axiso . getErrorMessage ( ) ) ; CoverageCoordAxis1D runAxisSubset = ( CoverageCoordAxis1D ) axiso . get ( ) ; result . add ( runAxisSubset ) ; // subset on timeOffset ( 1a , 1c , 2a )
if ( params . hasTimeOffsetParam ( ) || ! params . hasTimeParam ( ) ) { axiso = timeOffset . subset ( params ) ; if ( ! axiso . isPresent ( ) ) return Optional . empty ( axiso . getErrorMessage ( ) ) ; CoverageCoordAxis timeOffsetSubset = axiso . get ( ) ; result . add ( timeOffsetSubset ) ; if ( makeCFcompliant ) // add a time cordinate
result . add ( makeCFTimeCoord ( runAxisSubset , ( CoverageCoordAxis1D ) timeOffsetSubset ) ) ; // possible the twoD time case , if nruns > 1
return Optional . of ( result ) ; } // subset on time , # runtimes = 1 ( 1b )
if ( runAxisSubset . getNcoords ( ) == 1 ) { double val = runAxisSubset . getCoordMidpoint ( 0 ) ; // not sure runAxis is needed . maybe use runtimeSubset
CalendarDate runDate = runAxisSubset . makeDate ( val ) ; Optional < TimeOffsetAxis > too = timeOffset . subsetFromTime ( params , runDate ) ; if ( ! too . isPresent ( ) ) return Optional . empty ( too . getErrorMessage ( ) ) ; TimeOffsetAxis timeOffsetSubset = too . get ( ) ; result . add ( timeOffsetSubset ) ; if ( makeCFcompliant ) result . add ( makeCFTimeCoord ( runAxisSubset , timeOffsetSubset ) ) ; return Optional . of ( result ) ; } // tricky case 2b time ( point only not range ) = constant forecast dataset
// data reader has to skip around the 2D times
// 1 ) the runtimes may be subset by whats available
// 2 ) timeOffset could become an aux coordinate
// 3 ) time coordinate becomes a scalar ,
isConstantForcast . set ( true ) ; CalendarDate dateWanted ; if ( params . isTrue ( SubsetParams . timePresent ) ) dateWanted = CalendarDate . present ( ) ; else dateWanted = ( CalendarDate ) params . get ( SubsetParams . time ) ; if ( dateWanted == null ) throw new IllegalStateException ( "Must have time parameter" ) ; double wantOffset = runAxisSubset . convert ( dateWanted ) ; // forecastDate offset from refdate
double start = timeOffset . getStartValue ( ) ; double end = timeOffset . getEndValue ( ) ; CoordAxisHelper helper = new CoordAxisHelper ( timeOffset ) ; // brute force search LOOK specialize for regular ?
List < Integer > runtimeIdx = new ArrayList < > ( ) ; // list of runtime indexes that have this forecast
// List < Integer > offsetIdx = new ArrayList < > ( ) ; / / list of offset indexes that have this forecast
List < Double > offset = new ArrayList < > ( ) ; // corresponding offset from start of run
for ( int i = 0 ; i < runAxisSubset . getNcoords ( ) ; i ++ ) { // public double getOffsetInTimeUnits ( CalendarDate convertFrom , CalendarDate convertTo ) ;
double runOffset = runAxisSubset . getCoordMidpoint ( i ) ; if ( end + runOffset < wantOffset ) continue ; if ( wantOffset < start + runOffset ) break ; int idx = helper . search ( wantOffset - runOffset ) ; if ( idx >= 0 ) { runtimeIdx . add ( i ) ; // the ith runtime
// offsetIdx . add ( idx ) ; / / the idx time offset
offset . add ( wantOffset - runOffset ) ; // the offset from the runtime
} } // here are the runtimes
int ncoords = runtimeIdx . size ( ) ; double [ ] runValues = new double [ ncoords ] ; double [ ] offsetValues = new double [ ncoords ] ; int count = 0 ; for ( int k = 0 ; k < ncoords ; k ++ ) { offsetValues [ count ] = offset . get ( k ) ; runValues [ count ++ ] = runAxisSubset . getCoordMidpoint ( runtimeIdx . get ( k ) ) ; } CoverageCoordAxisBuilder runbuilder = new CoverageCoordAxisBuilder ( runAxisSubset ) . subset ( null , CoverageCoordAxis . Spacing . irregularPoint , ncoords , runValues ) ; // LOOK check for regular ( in CovCoordAxis ? )
CoverageCoordAxis1D runAxisSubset2 = new CoverageCoordAxis1D ( runbuilder ) ; CoverageCoordAxisBuilder timebuilder = new CoverageCoordAxisBuilder ( timeOffset ) . subset ( runAxisSubset2 . getName ( ) , CoverageCoordAxis . Spacing . irregularPoint , ncoords , offsetValues ) ; // aux coord ( LOOK interval ) ? ?
CoverageCoordAxis1D timeOffsetSubset = new TimeOffsetAxis ( timebuilder ) ; CoverageCoordAxis scalarTimeCoord = makeScalarTimeCoord ( wantOffset , runAxisSubset ) ; // nothing needed for CF , the run coordinate acts as the CF time independent coord . timeOffset is aux , forecastTime is scalar
return Optional . of ( Lists . newArrayList ( runAxisSubset2 , timeOffsetSubset , scalarTimeCoord ) ) ;


signature:
public class asciiF32 { /** * 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 .
 * @ param addName is a flag indicating if the variable name should
 * appear at the begining of the returned string . */
public void toASCII ( PrintWriter pw , boolean addName , String rootName , boolean newLine ) { } }

implementation: if ( addName ) pw . print ( ", " ) ; pw . print ( ( new Float ( getValue ( ) ) ) . toString ( ) ) ; if ( newLine ) pw . print ( "\n" ) ;


signature:
public class DODSNetcdfFile { /** * Debugging flags . This is a way to decouple setting flags from particular implementations .
 * @ param debugFlag set of debug flags . */
static public void setDebugFlags ( ucar . nc2 . util . DebugFlags debugFlag ) { } }

implementation: debugCE = debugFlag . isSet ( "DODS/constraintExpression" ) ; debugServerCall = debugFlag . isSet ( "DODS/serverCall" ) ; debugOpenResult = debugFlag . isSet ( "DODS/debugOpenResult" ) ; debugDataResult = debugFlag . isSet ( "DODS/debugDataResult" ) ; debugCharArray = debugFlag . isSet ( "DODS/charArray" ) ; debugConstruct = debugFlag . isSet ( "DODS/constructNetcdf" ) ; debugPreload = debugFlag . isSet ( "DODS/preload" ) ; debugTime = debugFlag . isSet ( "DODS/timeCalls" ) ; showNCfile = debugFlag . isSet ( "DODS/showNCfile" ) ; debugAttributes = debugFlag . isSet ( "DODS/attributes" ) ; debugCached = debugFlag . isSet ( "DODS/cache" ) ;


signature:
public class DODSNetcdfFile { /** * Create the canonical form of the URL .
 * If the urlName starts with " http : " or " https : " , change it to start with " dods : " , otherwise
 * leave it alone .
 * @ param urlName the url string
 * @ return canonical form */
public static String canonicalURL ( String urlName ) { } }

implementation: if ( urlName . startsWith ( "http:" ) ) return "dods:" + urlName . substring ( 5 ) ; if ( urlName . startsWith ( "https:" ) ) return "dods:" + urlName . substring ( 6 ) ; return urlName ;


signature:
public class DODSNetcdfFile { /** * / * parse the DDS , creating a tree of DodsV objects
 * private ArrayList parseDDS ( DDS dds ) throws IOException {
 * ArrayList dodsVlist = new ArrayList ( ) ;
 * recursively get the Variables from the DDS
 * Enumeration variables = dds . getVariables ( ) ;
 * parseVariables ( null , variables , dodsVlist ) ;
 * assign depth first sequence number
 * nextInSequence = 0;
 * assignSequence ( dodsVlist ) ;
 * return dodsVlist ;
 * DDS - > { BaseType } for arrays , BaseType = DArray - > { elemType }
 * here we 1 ) put all Variables into a DodsV , 2 ) unravel DConstructors ( DSequence , DStructure , DGrid )
 * 3 ) for Darray , we put Variable = elemType , and store the darray seperately , not in the heirarchy .
 * so you need to get the parent from the dodsV .
 * private void parseVariables ( DodsV parent , Enumeration variables , ArrayList dodsVlist ) {
 * while ( variables . hasMoreElements ( ) ) {
 * dods . dap . BaseType bt = ( dods . dap . BaseType ) variables . nextElement ( ) ;
 * DodsV dodsV = new DodsV ( parent , bt ) ;
 * dodsVlist . add ( dodsV ) ;
 * if ( bt instanceof DConstructor ) {
 * DConstructor dcon = ( DConstructor ) bt ;
 * java . util . Enumeration enumerate2 = dcon . getVariables ( ) ;
 * parseVariables ( dodsV , enumerate2 , dodsV . children ) ;
 * } else if ( bt instanceof DArray ) {
 * DArray da = ( DArray ) bt ;
 * BaseType elemType = da . getPrimitiveVector ( ) . getTemplate ( ) ;
 * dodsV . bt = elemType ;
 * dodsV . darray = da ;
 * if ( elemType instanceof DConstructor ) { / / note that for DataDDS , cant traverse this further to find the data .
 * DConstructor dcon = ( DConstructor ) elemType ;
 * java . util . Enumeration nestedVariables = dcon . getVariables ( ) ;
 * parseVariables ( dodsV , nestedVariables , dodsV . children ) ;
 * assign depth first sequence number
 * private int nextInSequence = 0;
 * private void assignSequence ( ArrayList dodsVlist ) {
 * for ( int i = 0 ; i < dodsVlist . size ( ) ; i + + ) {
 * DodsV dodsV = ( DodsV ) dodsVlist . get ( i ) ;
 * assignSequence ( dodsV . children ) ;
 * dodsV . seq = nextInSequence ;
 * nextInSequence + + ;
 * parse the DAS , assign attribute tables to the DodsV objects .
 * nested attribute tables actuallly follow the tree we construct with dodsV , so its
 * easy to assign to correct dodsV .
 * private void parseDAS ( DAS das , ArrayList dodsVlist ) throws IOException {
 * recursively find the Attributes from the DAS
 * Enumeration tableNames = das . getNames ( ) ;
 * parseAttributes ( das , tableNames , dodsVlist ) ;
 * private void parseAttributes ( DAS das , Enumeration tableNames , ArrayList dodsVlist ) {
 * while ( tableNames . hasMoreElements ( ) ) {
 * String tableName = ( String ) tableNames . nextElement ( ) ;
 * AttributeTable attTable = das . getAttributeTable ( tableName ) ;
 * see if there ' s a matching variable
 * String name = attTable . getName ( ) ;
 * DodsV dodsV = findDodsV ( name , dodsVlist , false ) ; / / short name matches the table name
 * if ( dodsV ! = null ) {
 * dodsV . attTable = attTable ;
 * if ( debugAttributes ) System . out . println ( " DODSNetcdf getAttributes found < " + name + " > : " ) ;
 * continue ;
 * if ( debugAttributes ) System . out . println ( " DODSNetcdf getAttributes CANT find < " + name + " > : " ) ;
 * search the list for a BaseType with given name
 * private DodsV findDodsV ( String name , ArrayList dodsVlist , boolean useDone ) {
 * for ( int i = 0 ; i < dodsVlist . size ( ) ; i + + ) {
 * DodsV dodsV = ( DodsV ) dodsVlist . get ( i ) ;
 * if ( useDone & & dodsV . isDone ) continue ;
 * if ( name . equals ( dodsV . bt . getName ( ) ) )
 * return dodsV ;
 * return null ;
 * find the DodsV object in the dataVlist corresponding to the ddsV
 * private DodsV findDataV ( DodsV ddsV , ArrayList dataVlist ) {
 * if ( ddsV . parent ! = null ) {
 * DodsV parentV = findDataV ( ddsV . parent , dataVlist ) ;
 * if ( parentV = = null ) / / dataDDS may not have the structure wrapper
 * return findDodsV ( ddsV . bt . getName ( ) , dataVlist , true ) ;
 * return findDodsV ( ddsV . bt . getName ( ) , parentV . children , true ) ;
 * DodsV dataV = findDodsV ( ddsV . bt . getName ( ) , dataVlist , true ) ;
 * / * if ( ( dataV = = null ) & & ( ddsV . bt instanceof DGrid ) ) { / / when asking for the Grid array
 * DodsV gridArray = ( DodsV ) ddsV . children . get ( 0 ) ;
 * return findDodsV ( gridArray . bt . getName ( ) , dataVlist , true ) ;
 * return dataV ;
 * / * a container for dods basetypes , so we can add some stuff as we process it
 * class DodsV implements Comparable {
 * String name ; / / full name
 * BaseType bt ;
 * DodsV parent ;
 * ArrayList children = new ArrayList ( ) ;
 * DArray darray ; / / if its an array
 * AttributeTable attTable ;
 * Array data ; / / preload
 * boolean isDone ; / / nc var has been made
 * int seq ; / / " depth first " order
 * DodsV ( DodsV parent , BaseType bt ) {
 * this . parent = parent ;
 * this . bt = bt ;
 * public int compareTo ( Object o ) {
 * return seq - ( ( DodsV ) o ) . seq ; */
private void parseGlobalAttributes ( DAS das , DodsV root , DODSNetcdfFile dodsfile ) { } }

implementation:
List < DODSAttribute > atts = root . attributes ; for ( ucar . nc2 . Attribute ncatt : atts ) { rootGroup . addAttribute ( ncatt ) ; } // loop over attribute tables , collect global attributes
Enumeration tableNames = das . getNames ( ) ; while ( tableNames . hasMoreElements ( ) ) { String tableName = ( String ) tableNames . nextElement ( ) ; AttributeTable attTable = das . getAttributeTableN ( tableName ) ; if ( attTable == null ) continue ; // should probably never happen
/* if ( tableName . equals ( " NC _ GLOBAL " ) | | tableName . equals ( " HDF _ GLOBAL " ) ) {
 java . util . Enumeration attNames = attTable . getNames ( ) ;
 while ( attNames . hasMoreElements ( ) ) {
 String attName = ( String ) attNames . nextElement ( ) ;
 dods . dap . Attribute att = attTable . getAttribute ( attName ) ;
 DODSAttribute ncatt = new DODSAttribute ( attName , att ) ;
 addAttribute ( null , ncatt ) ;
 } else */
if ( tableName . equals ( "DODS_EXTRA" ) ) { Enumeration attNames = attTable . getNames ( ) ; while ( attNames . hasMoreElements ( ) ) { String attName = ( String ) attNames . nextElement ( ) ; if ( attName . equals ( "Unlimited_Dimension" ) ) { opendap . dap . Attribute att = attTable . getAttribute ( attName ) ; DODSAttribute ncatt = new DODSAttribute ( attName , att ) ; setUnlimited ( ncatt . getStringValue ( ) ) ; } else logger . warn ( " Unknown DODS_EXTRA attribute = " + attName + " " + location ) ; } } else if ( tableName . equals ( "EXTRA_DIMENSION" ) ) { Enumeration attNames = attTable . getNames ( ) ; while ( attNames . hasMoreElements ( ) ) { String attName = ( String ) attNames . nextElement ( ) ; opendap . dap . Attribute att = attTable . getAttribute ( attName ) ; DODSAttribute ncatt = new DODSAttribute ( attName , att ) ; int length = ncatt . getNumericValue ( ) . intValue ( ) ; Dimension extraDim = new Dimension ( attName , length ) ; addDimension ( null , extraDim ) ; } } /* else if ( null = = root . findDodsV ( tableName , false ) ) {
 addAttributes ( attTable . getName ( ) , attTable ) ; */
}


signature:
public class DODSNetcdfFile { /** * Go thru the variables / structure - variables and their attributes
 * and move to the proper groups . */
protected void reGroup ( ) throws DAP2Exception { } }

implementation:
assert ( RC . getUseGroups ( ) ) ; Group rootgroup = this . getRootGroup ( ) ; // Start by moving global attributes
// An issue to be addressed is that some attributes that should be attached
// to variables , instead get made global with name var . att .
Object [ ] gattlist = rootgroup . getAttributes ( ) . toArray ( ) ; for ( Object att : gattlist ) { Attribute ncatt = ( Attribute ) att ; String dodsname = ncatt . getDODSName ( ) ; NamePieces pieces = parseName ( dodsname ) ; if ( pieces . var != null ) { // Figure out which variable to which this attribute should be moved .
// In the event that there is no matching
// variable , then keep the attribute as is .
String searchname = pieces . var ; if ( pieces . prefix != null ) searchname = pieces . prefix + '/' + searchname ; Variable v = findVariable ( searchname ) ; if ( v != null ) { // move attribute
rootgroup . remove ( ncatt ) ; v . addAttribute ( ncatt ) ; // change attribute name to remove var .
String newname = pieces . name ; ncatt . setName ( newname ) ; } } else if ( pieces . prefix != null ) { // We have a true group global name to move to proper group
// convert prefix to an actual group
Group g = rootgroup . makeRelativeGroup ( this , dodsname , true ) ; rootgroup . remove ( ncatt ) ; g . addAttribute ( ncatt ) ; if ( OLDGROUPCODE ) { ncatt . setName ( pieces . name ) ; } } } Object [ ] varlist = rootgroup . getVariables ( ) . toArray ( ) ; if ( false ) { // This should have been done by computegroup ( )
// Now move variables
for ( Object var : varlist ) { if ( var instanceof DODSVariable ) { DODSVariable v = ( DODSVariable ) var ; reGroupVariable ( rootgroup , v ) ; } else throw new DAP2Exception ( "regroup: unexpected variable type: " + var . getClass ( ) . getCanonicalName ( ) ) ; } } // In theory , we should be able to fix variable attributes
// by just removing the group prefix . However , there is the issue
// that attribute names sometimes have as a suffix varname . attname .
// So , we should use that to adjust the attribute to attach to that
// variable .
for ( Object var : varlist ) { reGroupVariableAttributes ( rootgroup , ( Variable ) var ) ; }


signature:
public class DODSNetcdfFile { /** * Utility to decompose a name */
NamePieces parseName ( String name ) { } }

implementation:
NamePieces pieces = new NamePieces ( ) ; int dotpos = name . lastIndexOf ( '.' ) ; int slashpos = name . lastIndexOf ( '/' ) ; if ( slashpos < 0 && dotpos < 0 ) { pieces . name = name ; } else if ( slashpos >= 0 && dotpos < 0 ) { pieces . prefix = name . substring ( 0 , slashpos ) ; pieces . name = name . substring ( slashpos + 1 , name . length ( ) ) ; } else if ( slashpos < 0 && dotpos >= 0 ) { pieces . var = name . substring ( 0 , dotpos ) ; pieces . name = name . substring ( dotpos + 1 , name . length ( ) ) ; } else { // slashpos > = 0 & & dotpos > = 0)
if ( slashpos > dotpos ) { pieces . prefix = name . substring ( 0 , slashpos ) ; pieces . name = name . substring ( slashpos + 1 , name . length ( ) ) ; } else { // slashpos < dotpos )
pieces . prefix = name . substring ( 0 , slashpos ) ; pieces . var = name . substring ( slashpos + 1 , dotpos ) ; pieces . name = name . substring ( dotpos + 1 , name . length ( ) ) ; } } // fixup
if ( pieces . prefix != null && pieces . prefix . length ( ) == 0 ) pieces . prefix = null ; if ( pieces . var != null && pieces . var . length ( ) == 0 ) pieces . var = null ; if ( pieces . name . length ( ) == 0 ) pieces . name = null ; return pieces ;


signature: public class DODSNetcdfFile { private void constructTopVariables ( DodsV rootDodsV , CancelTask cancelTask ) throws IOException { } }

implementation: List < DodsV > topVariables = rootDodsV . children ; for ( DodsV dodsV : topVariables ) { if ( dodsV . bt instanceof DConstructor ) continue ; addVariable ( rootGroup , null , dodsV ) ; if ( cancelTask != null && cancelTask . isCancel ( ) ) return ; }


signature:
public class DODSNetcdfFile { /** * recursively make new variables : all new variables come through here */
Variable addVariable ( Group parentGroup , Structure parentStructure , DodsV dodsV ) throws IOException { } }

implementation: Variable v = makeVariable ( parentGroup , parentStructure , dodsV ) ; if ( v != null ) { addAttributes ( v , dodsV ) ; if ( parentStructure != null ) parentStructure . addMemberVariable ( v ) ; else { parentGroup = computeGroup ( v . getDODSName ( ) , v , parentGroup ) ; parentGroup . addVariable ( v ) ; } dodsV . isDone = true ; } return v ;


signature:
public class DODSNetcdfFile { /** * make a structure into a group if its scalar and all parents are groups */
private boolean isGroup ( DStructure dstruct ) { } }

implementation: BaseType parent = ( BaseType ) dstruct . getParent ( ) ; if ( parent == null ) return true ; if ( parent instanceof DStructure ) return isGroup ( ( DStructure ) parent ) ; return true ;


signature:
public class DODSNetcdfFile { /** * / * private void addAttributes ( String tableName , AttributeTable attTable ) {
 * java . util . Enumeration attNames = attTable . getNames ( ) ;
 * while ( attNames . hasMoreElements ( ) ) {
 * String attName = ( String ) attNames . nextElement ( ) ;
 * dods . dap . Attribute att = attTable . getAttribute ( attName ) ;
 * if ( ! att . isContainer ( ) ) {
 * DODSAttribute ncatt = new DODSAttribute ( tableName + " . " + attName , att ) ;
 * addAttribute ( null , ncatt ) ;
 * if ( debugAttributes ) System . out . println ( " addAttribute = " + tableName + " . " + attName ) ;
 * try {
 * look for nested ones
 * attNames = attTable . getNames ( ) ;
 * while ( attNames . hasMoreElements ( ) ) {
 * String attName = ( String ) attNames . nextElement ( ) ;
 * dods . dap . Attribute att = attTable . getAttribute ( attName ) ;
 * if ( att . isContainer ( ) ) {
 * addAttributes ( tableName + " . " + attName , att . getContainer ( ) ) ;
 * } catch ( Exception e ) { } / / WRONG
 * } catch ( NoSuchAttributeException e ) { }
 * an attTable name matches a Variable
 * private void addAttributes ( Variable v , AttributeTable attTable ) {
 * if ( attTable = = null ) return ;
 * if ( debugAttributes ) System . out . println ( " addAttributes to " + v . getName ( ) ) ;
 * java . util . Enumeration attNames = attTable . getNames ( ) ;
 * while ( attNames . hasMoreElements ( ) ) {
 * String attName = ( String ) attNames . nextElement ( ) ;
 * dods . dap . Attribute att = attTable . getAttribute ( attName ) ;
 * if ( att = = null ) continue ;
 * if ( ! att . isContainer ( ) ) {
 * DODSAttribute ncatt = new DODSAttribute ( attName , att ) ;
 * v . addAttribute ( ncatt ) ;
 * } else if ( v instanceof Structure ) {
 * Structure s = ( Structure ) v ;
 * Variable member = s . findVariable ( att . getShortName ( ) ) ;
 * if ( member ! = null ) {
 * addAttributes ( member , att . getContainer ( ) ) ;
 * } else {
 * if ( debugAttributes ) System . out . println ( " Cant find nested Variable " + att . getShortName ( ) + " in " + v . getName ( ) ) ;
 * } else {
 * if ( debugAttributes ) System . out . println ( " Container attribute " + att . getShortName ( ) + " in non structure variables " + v . getName ( ) ) ; */
private void addAttributes ( Variable v , DodsV dodsV ) { } }

implementation:
List < DODSAttribute > atts = dodsV . attributes ; for ( Attribute ncatt : atts ) { v . addAttribute ( ncatt ) ; } // this is the case where its ( probably ) a Grid , and so _ Coordinate . Axes has been assigned , but if
// theres also a coordinates attribute , need to add that info
Attribute axes = v . findAttribute ( CF . COORDINATES ) ; Attribute _axes = v . findAttribute ( _Coordinate . Axes ) ; if ( ( null != axes ) && ( null != _axes ) ) { v . addAttribute ( combineAxesAttrs ( axes , _axes ) ) ; }


signature:
public class DODSNetcdfFile { /** * Checks to see if this is netcdf char array .
 * @ param v must be type STRING
 * @ return string length dimension , else null */
Dimension getNetcdfStrlenDim ( DODSVariable v ) { } }

implementation:
AttributeTable table = das . getAttributeTableN ( v . getFullName ( ) ) ; // LOOK this probably doesnt work for nested variables
if ( table == null ) return null ; opendap . dap . Attribute dodsAtt = table . getAttribute ( "DODS" ) ; if ( dodsAtt == null ) return null ; AttributeTable dodsTable = dodsAtt . getContainerN ( ) ; if ( dodsTable == null ) return null ; opendap . dap . Attribute att = dodsTable . getAttribute ( "strlen" ) ; if ( att == null ) return null ; String strlen = att . getValueAtN ( 0 ) ; opendap . dap . Attribute att2 = dodsTable . getAttribute ( "dimName" ) ; String dimName = ( att2 == null ) ? null : att2 . getValueAtN ( 0 ) ; if ( debugCharArray ) System . out . println ( v . getFullName ( ) + " has strlen= " + strlen + " dimName= " + dimName ) ; int dimLength ; try { dimLength = Integer . parseInt ( strlen ) ; } catch ( NumberFormatException e ) { logger . warn ( "DODSNetcdfFile " + location + " var = " + v . getFullName ( ) + " error on strlen attribute = " + strlen ) ; return null ; } if ( dimLength <= 0 ) return null ; // LOOK what about unlimited ? ?
return new Dimension ( dimName , dimLength , dimName != null ) ;


signature:
public class DODSNetcdfFile { /** * If an equivilent shared dimension already exists , use it , else add d to shared dimensions .
 * Equivilent is same name and length .
 * @ param group from this group , if null , use rootGroup
 * @ param d find equivilent shared dimension to this one .
 * @ return equivilent shared dimension or d . */
Dimension getSharedDimension ( Group group , Dimension d ) { } }

implementation: if ( d . getShortName ( ) == null ) return d ; if ( group == null ) group = rootGroup ; for ( Dimension sd : group . getDimensions ( ) ) { if ( sd . getShortName ( ) . equals ( d . getShortName ( ) ) && sd . getLength ( ) == d . getLength ( ) ) return sd ; } d . setShared ( true ) ; group . addDimension ( d ) ; return d ;


signature:
public class DODSNetcdfFile { /** * construct list of dimensions to use */
List < Dimension > constructDimensions ( Group group , opendap . dap . DArray dodsArray ) { } }

implementation:
if ( group == null ) group = rootGroup ; List < Dimension > dims = new ArrayList < Dimension > ( ) ; Enumeration enumerate = dodsArray . getDimensions ( ) ; while ( enumerate . hasMoreElements ( ) ) { opendap . dap . DArrayDimension dad = ( opendap . dap . DArrayDimension ) enumerate . nextElement ( ) ; String name = dad . getEncodedName ( ) ; if ( name != null ) name = StringUtil2 . unescape ( name ) ; Dimension myd ; if ( name == null ) { // if no name , make an anonymous dimension
myd = new Dimension ( null , dad . getSize ( ) , false ) ; } else { // see if shared
if ( RC . getUseGroups ( ) ) { if ( name . indexOf ( '/' ) >= 0 ) { // place dimension in proper group
group = group . makeRelativeGroup ( this , name , true ) ; // change our name
name = name . substring ( name . lastIndexOf ( '/' ) + 1 ) ; } } myd = group . findDimension ( name ) ; if ( myd == null ) { // add as shared
myd = new Dimension ( name , dad . getSize ( ) ) ; group . addDimension ( myd ) ; } else if ( myd . getLength ( ) != dad . getSize ( ) ) { // make a non - shared dimension
myd = new Dimension ( name , dad . getSize ( ) , false ) ; } // else use existing , shared dimension
} dims . add ( myd ) ; // add it to the list
} return dims ;


signature:
public class DODSNetcdfFile { /** * full name */
private String makeDODSname ( DodsV dodsV ) { } }

implementation: DodsV parent = dodsV . parent ; if ( parent . bt != null ) return ( makeDODSname ( parent ) + "." + dodsV . bt . getEncodedName ( ) ) ; return dodsV . bt . getEncodedName ( ) ;


signature:
public class DODSNetcdfFile { /** * Get the DODS data class corresponding to the Netcdf data type .
 * This is the inverse of convertToNCType ( ) .
 * @ param dataType Netcdf data type .
 * @ return the corresponding DODS type enum , from opendap . dap . Attribute . XXXX . */
static public int convertToDODSType ( DataType dataType ) { } }

implementation:
if ( dataType == DataType . STRING ) return opendap . dap . Attribute . STRING ; if ( dataType == DataType . BYTE ) return opendap . dap . Attribute . BYTE ; if ( dataType == DataType . FLOAT ) return opendap . dap . Attribute . FLOAT32 ; if ( dataType == DataType . DOUBLE ) return opendap . dap . Attribute . FLOAT64 ; if ( dataType == DataType . SHORT ) return opendap . dap . Attribute . INT16 ; if ( dataType == DataType . USHORT ) return opendap . dap . Attribute . UINT16 ; if ( dataType == DataType . INT ) return opendap . dap . Attribute . INT32 ; if ( dataType == DataType . UINT ) return opendap . dap . Attribute . UINT32 ; if ( dataType == DataType . BOOLEAN ) return opendap . dap . Attribute . BYTE ; if ( dataType == DataType . LONG ) return opendap . dap . Attribute . INT32 ; // LOOK no LONG type !
// shouldnt happen
return opendap . dap . Attribute . STRING ;


signature:
public class DODSNetcdfFile { /** * Get the Netcdf data type corresponding to the DODS data type .
 * This is the inverse of convertToDODSType ( ) .
 * @ param dodsDataType DODS type enum , from dods . dap . Attribute . XXXX .
 * @ return the corresponding netcdf DataType .
 * @ see # isUnsigned */
static public DataType convertToNCType ( int dodsDataType , boolean isUnsigned ) { } }

implementation: switch ( dodsDataType ) { case opendap . dap . Attribute . BYTE : return isUnsigned ? DataType . UBYTE : DataType . BYTE ; case opendap . dap . Attribute . FLOAT32 : return DataType . FLOAT ; case opendap . dap . Attribute . FLOAT64 : return DataType . DOUBLE ; case opendap . dap . Attribute . INT16 : return DataType . SHORT ; case opendap . dap . Attribute . UINT16 : return DataType . USHORT ; case opendap . dap . Attribute . INT32 : return DataType . INT ; case opendap . dap . Attribute . UINT32 : return DataType . UINT ; default : return DataType . STRING ; }


signature:
public class DODSNetcdfFile { /** * Get the Netcdf data type corresponding to the DODS BaseType class .
 * This is the inverse of convertToDODSType ( ) .
 * @ param dtype DODS BaseType .
 * @ return the corresponding netcdf DataType .
 * @ see # isUnsigned */
static public DataType convertToNCType ( opendap . dap . BaseType dtype , boolean isUnsigned ) { } }

implementation: if ( dtype instanceof DString ) return DataType . STRING ; else if ( ( dtype instanceof DStructure ) || ( dtype instanceof DSequence ) || ( dtype instanceof DGrid ) ) return DataType . STRUCTURE ; else if ( dtype instanceof DFloat32 ) return DataType . FLOAT ; else if ( dtype instanceof DFloat64 ) return DataType . DOUBLE ; else if ( dtype instanceof DUInt32 ) return DataType . UINT ; else if ( dtype instanceof DUInt16 ) return DataType . USHORT ; else if ( dtype instanceof DInt32 ) return DataType . INT ; else if ( dtype instanceof DInt16 ) return DataType . SHORT ; else if ( dtype instanceof DByte ) return isUnsigned ? DataType . UBYTE : DataType . BYTE ; else throw new IllegalArgumentException ( "DODSVariable illegal type = " + dtype . getTypeName ( ) ) ;


signature:
public class DODSNetcdfFile { /** * Get whether this is an unsigned type .
 * @ param dtype DODS BaseType .
 * @ return true if unsigned */
static public boolean isUnsigned ( opendap . dap . BaseType dtype ) { } }

implementation: return ( dtype instanceof DByte ) || ( dtype instanceof DUInt16 ) || ( dtype instanceof DUInt32 ) ;


signature:
public class DODSNetcdfFile { /** * This does the actual connection to the opendap server and reading of the data .
 * All data calls go through here so we can add debugging .
 * @ param CE constraint expression ; use empty string if none
 * @ return DataDDS
 * @ throws java . io . IOException on io error
 * @ throws opendap . dap . parsers . ParseException
 * if error parsing return
 * @ throws opendap . dap . DAP2Exception if you have otherwise been bad */
DataDDS readDataDDSfromServer ( String CE ) throws IOException , opendap . dap . DAP2Exception { } }

implementation: if ( debugServerCall ) System . out . println ( "DODSNetcdfFile.readDataDDSfromServer = <" + CE + ">" ) ; long start = 0 ; if ( debugTime ) start = System . currentTimeMillis ( ) ; if ( ! CE . startsWith ( "?" ) ) CE = "?" + CE ; DataDDS data ; synchronized ( this ) { data = dodsConnection . getData ( CE , null ) ; } if ( debugTime ) System . out . println ( "DODSNetcdfFile.readDataDDSfromServer took = " + ( System . currentTimeMillis ( ) - start ) / 1000.0 ) ; if ( debugDataResult ) { System . out . println ( " dataDDS return:" ) ; data . print ( System . out ) ; } return data ;


signature:
public class DODSNetcdfFile { /** * Make a single call to the DODS Server to read all the named variable ' s data
 * in one client / server roundtrip .
 * @ param preloadVariables list of type Variable
 * @ return list of type Array , contains the data
 * @ throws IOException on error */
@ Override public List < Array > readArrays ( List < Variable > preloadVariables ) throws IOException { } }

implementation:
// For performance tests :
// if ( true ) return super . readArrays ( variables ) ;
if ( preloadVariables . size ( ) == 0 ) return new ArrayList < Array > ( ) ; // construct the list of variables , skipping ones with cached data
List < DodsV > reqDodsVlist = new ArrayList < DodsV > ( ) ; DodsV root ; for ( Variable var : preloadVariables ) { if ( var . hasCachedData ( ) ) continue ; reqDodsVlist . add ( ( DodsV ) var . getSPobject ( ) ) ; } Collections . sort ( reqDodsVlist ) ; // " depth first " order
// read the data
DataDDS dataDDS ; Map < DodsV , DodsV > map = new HashMap < DodsV , DodsV > ( 2 * reqDodsVlist . size ( ) + 1 ) ; if ( reqDodsVlist . size ( ) > 0 ) { // Create the request
StringBuilder requestString = new StringBuilder ( ) ; for ( int i = 0 ; i < reqDodsVlist . size ( ) ; i ++ ) { DodsV dodsV = reqDodsVlist . get ( i ) ; requestString . append ( i == 0 ? "?" : "," ) ; // requestString . append ( makeDODSname ( dodsV ) ) ;
requestString . append ( dodsV . getEncodedName ( ) ) ; } String s = requestString . toString ( ) ; try { dataDDS = readDataDDSfromServer ( requestString . toString ( ) ) ; root = DodsV . parseDataDDS ( dataDDS ) ; } catch ( Exception exc ) { logger . error ( "ERROR readDataDDSfromServer on " + requestString , exc ) ; throw new IOException ( exc . getMessage ( ) ) ; } // gotta find the corresponding data in " depth first " order
for ( DodsV ddsV : reqDodsVlist ) { DodsV dataV = root . findDataV ( ddsV ) ; if ( dataV != null ) { if ( debugConvertData ) System . out . println ( "readArray found dataV= " + makeDODSname ( ddsV ) ) ; dataV . isDone = true ; map . put ( ddsV , dataV ) ; // thread safe !
} else { logger . error ( "ERROR findDataV cant find " + makeDODSname ( ddsV ) + " on " + location ) ; } } } // For each variable either extract the data or use cached data .
List < Array > result = new ArrayList < Array > ( ) ; for ( Variable var : preloadVariables ) { if ( var . hasCachedData ( ) ) { result . add ( var . read ( ) ) ; } else { Array data = null ; DodsV ddsV = ( DodsV ) var . getSPobject ( ) ; DodsV dataV = map . get ( ddsV ) ; if ( dataV == null ) { logger . error ( "DODSNetcdfFile.readArrays cant find " + makeDODSname ( ddsV ) + " in dataDDS; " + location ) ; // dataDDS . print ( System . out ) ;
} else { if ( debugConvertData ) System . out . println ( "readArray converting " + makeDODSname ( ddsV ) ) ; dataV . isDone = true ; try { if ( var . isMemberOfStructure ( ) ) { // we want the top structure this variable is contained in .
while ( ( dataV . parent != null ) && ( dataV . parent . bt != null ) ) { dataV = dataV . parent ; } data = convertD2N . convertNestedVariable ( var , null , dataV , true ) ; } else data = convertD2N . convertTopVariable ( var , null , dataV ) ; } catch ( DAP2Exception de ) { logger . error ( "ERROR convertVariable on " + var . getFullName ( ) , de ) ; throw new IOException ( de . getMessage ( ) ) ; } if ( var . isCaching ( ) ) { var . setCachedData ( data ) ; if ( debugCached ) System . out . println ( " cache for <" + var . getFullName ( ) + "> length =" + data . getSize ( ) ) ; } } result . add ( data ) ; } } return result ;


signature:
public class DODSNetcdfFile { /** * / * this is for reading variables that are members of structures
 * protected Array readMemberData ( ucar . nc2 . Variable v , Section section , boolean flatten ) throws IOException , InvalidRangeException {
 * StringBuffer buff = new StringBuffer ( 100 ) ;
 * buff . setLength ( 0 ) ;
 * List < Range > ranges = section . getRanges ( ) ;
 * add the selector
 * addParents ( buff , v , ranges , 0 ) ;
 * Array dataArray ;
 * try {
 * DodsV root = DodsV . parseDDS ( readDataDDSfromServer ( buff . toString ( ) ) ) ;
 * data = convertD2N ( ( DodsV ) root . children . get ( 0 ) , v , section , flatten ) ; / / can only be one
 * DataDDS dataDDS = readDataDDSfromServer ( buff . toString ( ) ) ;
 * DodsV root = DodsV . parseDataDDS ( dataDDS ) ;
 * DodsV want = root . children . get ( 0 ) ; / / can only be one
 * dataArray = convertD2N . convertNestedVariable ( v , ranges , want , flatten ) ;
 * catch ( DAP2Exception ex ) {
 * ex . printStackTrace ( ) ;
 * throw new IOException ( ex . getMessage ( ) ) ;
 * catch ( ParseException ex ) {
 * ex . printStackTrace ( ) ;
 * throw new IOException ( ex . getMessage ( ) ) ;
 * return dataArray ; */
public Array readWithCE ( ucar . nc2 . Variable v , String CE ) throws IOException { } }

implementation:
Array dataArray ; try { DataDDS dataDDS = readDataDDSfromServer ( CE ) ; DodsV root = DodsV . parseDataDDS ( dataDDS ) ; DodsV want = root . children . get ( 0 ) ; // can only be one
if ( v . isMemberOfStructure ( ) ) dataArray = convertD2N . convertNestedVariable ( v , null , want , true ) ; else dataArray = convertD2N . convertTopVariable ( v , null , want ) ; } catch ( DAP2Exception ex ) { ex . printStackTrace ( ) ; throw new IOException ( ex . getMessage ( ) ) ; } catch ( ParseException ex ) { ex . printStackTrace ( ) ; throw new IOException ( ex . getMessage ( ) ) ; } return dataArray ;


signature:
public class DODSNetcdfFile { /** * debugging */
public void getDetailInfo ( Formatter f ) { } }

implementation: super . getDetailInfo ( f ) ; f . format ( "DDS = %n" ) ; ByteArrayOutputStream buffOS = new ByteArrayOutputStream ( 8000 ) ; dds . print ( buffOS ) ; f . format ( "%s%n" , new String ( buffOS . toByteArray ( ) , Util . UTF8 ) ) ; f . format ( "%nDAS = %n" ) ; buffOS = new ByteArrayOutputStream ( 8000 ) ; das . print ( buffOS ) ; f . format ( "%s%n" , new String ( buffOS . toByteArray ( ) , Util . UTF8 ) ) ;


signature:
public class Resource { /** * Get a gif file , make it into an ImageIcon .
 * @ param fullIconName full path name of gif file ( use forward slashes ! )
 * @ param errMsg print err message on failure
 * @ return ImageIcon or null on failure */
public static ImageIcon getIcon ( String fullIconName , boolean errMsg ) { } }

implementation: ImageIcon icon = null ; java . net . URL iconR = cl . getResource ( fullIconName ) ; if ( debugIcon ) { System . out . println ( "classLoader " + cl . getClassLoader ( ) ) ; System . out . println ( "  Resource.getIcon on " + fullIconName + " = " + iconR ) ; } if ( iconR != null ) icon = new ImageIcon ( iconR ) ; if ( ( icon == null ) && errMsg ) System . out . println ( "  ERROR: Resource.getIcon failed on " + fullIconName ) ; else if ( debugIcon ) System . out . println ( "  Resource.getIcon ok on " + fullIconName ) ; return icon ;


signature:
public class Resource { /** * Get a gif file , make it into an Image .
 * @ param fullImageName full path name of gif file ( use forward slashes ! )
 * @ return Image or null on failure */
public static Image getImage ( String fullImageName ) { } }

implementation: Image image = null ; java . net . URL url = cl . getResource ( fullImageName ) ; if ( url != null ) image = Toolkit . getDefaultToolkit ( ) . createImage ( url ) ; if ( image == null ) System . out . println ( "  ERROR: Resource.getImageResource failed on " + fullImageName ) ; return image ;


signature:
public class Resource { /** * Get a gif file , make it into a Cursor .
 * @ param name full path name of gif file ( use forward slashes ! )
 * @ return Cursor or null on failure */
public static Cursor makeCursor ( String name ) { } }

implementation: Image image = getImage ( name ) ; if ( null == image ) return null ; Cursor cursor ; try { Toolkit tk = Toolkit . getDefaultToolkit ( ) ; if ( debug ) { ImageObserver obs = new ImageObserver ( ) { public boolean imageUpdate ( Image image , int flags , int x , int y , int width , int height ) { return true ; } } ; System . out . println ( " bestCursorSize = " + tk . getBestCursorSize ( image . getWidth ( obs ) , image . getHeight ( obs ) ) ) ; System . out . println ( " getMaximumCursorColors = " + tk . getMaximumCursorColors ( ) ) ; } cursor = tk . createCustomCursor ( image , new Point ( 17 , 17 ) , name ) ; } catch ( IndexOutOfBoundsException e ) { System . out . println ( "NavigatedPanel createCustomCursor failed " + e ) ; return null ; } return cursor ;


signature:
public class Resource { /** * Open a resource as a Stream . First try ClassLoader . getResourceAsStream ( ) .
 * If that fails , try a plain old FileInputStream ( ) .
 * @ param resourcePath name of file path ( use forward slashes ! )
 * @ return InputStream or null on failure */
public static InputStream getFileResource ( String resourcePath ) { } }

implementation: InputStream is = cl . getResourceAsStream ( resourcePath ) ; if ( is != null ) { if ( debug ) System . out . println ( "Resource.getResourceAsStream ok on " + resourcePath ) ; return is ; } else if ( debug ) System . out . println ( "Resource.getResourceAsStream failed on (" + resourcePath + ")" ) ; try { is = new FileInputStream ( resourcePath ) ; if ( debug ) System . out . println ( "Resource.FileInputStream ok on " + resourcePath ) ; } catch ( FileNotFoundException e ) { if ( debug ) System . out . println ( "  FileNotFoundException: Resource.getFile failed on " + resourcePath ) ; } catch ( java . security . AccessControlException e ) { if ( debug ) System . out . println ( "  AccessControlException: Resource.getFile failed on " + resourcePath ) ; } return is ;


signature:
public class Resource { /** * test */
public static void main ( String [ ] args ) throws IOException { } }

implementation: System . out . println ( "java.class.path = " + System . getProperty ( "java.class.path" ) ) ; System . out . println ( "Class = " + cl ) ; System . out . println ( "Class Loader = " + cl . getClassLoader ( ) ) ; try ( InputStream is = getFileResource ( "/ucar.unidata.util/Resource.java" ) ) { } try ( InputStream is = getFileResource ( "Resource.java" ) ) { } try ( InputStream is = getFileResource ( "test/test/Resource.java" ) ) { }


signature:
public class IospHelper { /** * Read data subset from RandomAccessFile , create primitive array of size Layout . getTotalNelems .
 * Reading is controlled by the Layout object .
 * @ param raf read from here .
 * @ param index handles skipping around in the file .
 * @ param dataType dataType of the variable
 * @ param fillValue must be Number if dataType . isNumeric ( ) , or String for STRING , byte [ ] for Structure , or null for none
 * @ param byteOrder if equal to RandomAccessFile . ORDER _ XXXX , set the byte order just before reading
 * @ return primitive array with data read in
 * @ throws java . io . IOException on read error */
static public Object readDataFill ( RandomAccessFile raf , Layout index , DataType dataType , Object fillValue , int byteOrder ) throws java . io . IOException { } }

implementation: Object arr = ( fillValue == null ) ? makePrimitiveArray ( ( int ) index . getTotalNelems ( ) , dataType ) : makePrimitiveArray ( ( int ) index . getTotalNelems ( ) , dataType , fillValue ) ; return readData ( raf , index , dataType , arr , byteOrder , true ) ;


signature:
public class IospHelper { /** * Read data subset from RandomAccessFile , place in given primitive array .
 * Reading is controlled by the Layout object .
 * @ param raf read from here .
 * @ param layout handles skipping around in the file .
 * @ param dataType dataType of the variable
 * @ param arr primitive array to read data into
 * @ param byteOrder if equal to RandomAccessFile . ORDER _ XXXX , set the byte order just before reading
 * @ param convertChar true if bytes should be converted to char for dataType CHAR
 * @ return primitive array with data read in
 * @ throws java . io . IOException on read error */
static public Object readData ( RandomAccessFile raf , Layout layout , DataType dataType , Object arr , int byteOrder , boolean convertChar ) throws java . io . IOException { } }

implementation:
if ( showLayoutTypes ) System . out . println ( "***RAF LayoutType=" + layout . getClass ( ) . getName ( ) ) ; if ( dataType . getPrimitiveClassType ( ) == byte . class || dataType == DataType . CHAR ) { byte [ ] pa = ( byte [ ] ) arr ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; raf . order ( byteOrder ) ; raf . seek ( chunk . getSrcPos ( ) ) ; raf . readFully ( pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } if ( convertChar && dataType == DataType . CHAR ) return convertByteToChar ( pa ) ; else return pa ; // javac ternary compile error
} else if ( dataType . getPrimitiveClassType ( ) == short . class ) { short [ ] pa = ( short [ ] ) arr ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; raf . order ( byteOrder ) ; raf . seek ( chunk . getSrcPos ( ) ) ; raf . readShort ( pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } return pa ; } else if ( dataType . getPrimitiveClassType ( ) == int . class ) { int [ ] pa = ( int [ ] ) arr ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; raf . order ( byteOrder ) ; raf . seek ( chunk . getSrcPos ( ) ) ; raf . readInt ( pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } return pa ; } else if ( dataType == DataType . FLOAT ) { float [ ] pa = ( float [ ] ) arr ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; raf . order ( byteOrder ) ; raf . seek ( chunk . getSrcPos ( ) ) ; raf . readFloat ( pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } return pa ; } else if ( dataType == DataType . DOUBLE ) { double [ ] pa = ( double [ ] ) arr ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; raf . order ( byteOrder ) ; raf . seek ( chunk . getSrcPos ( ) ) ; raf . readDouble ( pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } return pa ; } else if ( dataType . getPrimitiveClassType ( ) == long . class ) { long [ ] pa = ( long [ ] ) arr ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; raf . order ( byteOrder ) ; raf . seek ( chunk . getSrcPos ( ) ) ; raf . readLong ( pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } return pa ; } else if ( dataType == DataType . STRUCTURE ) { byte [ ] pa = ( byte [ ] ) arr ; int recsize = layout . getElemSize ( ) ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; raf . order ( byteOrder ) ; raf . seek ( chunk . getSrcPos ( ) ) ; raf . readFully ( pa , ( int ) chunk . getDestElem ( ) * recsize , chunk . getNelems ( ) * recsize ) ; } return pa ; } throw new IllegalStateException ( "unknown type= " + dataType ) ;


signature:
public class IospHelper { /** * Read data subset from PositioningDataInputStream , create primitive array of size Layout . getTotalNelems .
 * Reading is controlled by the Layout object .
 * @ param is read from here .
 * @ param index handles skipping around in the file .
 * @ param dataType dataType of the variable
 * @ param fillValue must be Number if dataType . isNumeric ( ) , or String for STRING , byte [ ] for Structure , or null for none
 * @ return primitive array with data read in
 * @ throws java . io . IOException on read error */
static public Object readDataFill ( PositioningDataInputStream is , Layout index , DataType dataType , Object fillValue ) throws java . io . IOException { } }

implementation: Object arr = ( fillValue == null ) ? makePrimitiveArray ( ( int ) index . getTotalNelems ( ) , dataType ) : makePrimitiveArray ( ( int ) index . getTotalNelems ( ) , dataType , fillValue ) ; return readData ( is , index , dataType , arr ) ;


signature:
public class IospHelper { /** * Read data subset from PositioningDataInputStream , place in given primitive array .
 * Reading is controlled by the Layout object .
 * @ param raf read from here .
 * @ param index handles skipping around in the file .
 * @ param dataType dataType of the variable
 * @ param arr primitive array to read data into
 * @ return primitive array with data read in
 * @ throws java . io . IOException on read error */
static public Object readData ( PositioningDataInputStream raf , Layout index , DataType dataType , Object arr ) throws java . io . IOException { } }

implementation:
if ( showLayoutTypes ) System . out . println ( "***PositioningDataInputStream LayoutType=" + index . getClass ( ) . getName ( ) ) ; if ( dataType . getPrimitiveClassType ( ) == byte . class || dataType == DataType . CHAR ) { byte [ ] pa = ( byte [ ] ) arr ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . read ( chunk . getSrcPos ( ) , pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } // return ( dataType = = DataType . CHAR ) ? convertByteToChar ( pa ) : pa ;
if ( dataType == DataType . CHAR ) return convertByteToChar ( pa ) ; else return pa ; } else if ( dataType . getPrimitiveClassType ( ) == short . class ) { short [ ] pa = ( short [ ] ) arr ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . readShort ( chunk . getSrcPos ( ) , pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } return pa ; } else if ( dataType . getPrimitiveClassType ( ) == int . class ) { int [ ] pa = ( int [ ] ) arr ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . readInt ( chunk . getSrcPos ( ) , pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } return pa ; } else if ( dataType == DataType . FLOAT ) { float [ ] pa = ( float [ ] ) arr ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . readFloat ( chunk . getSrcPos ( ) , pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } return pa ; } else if ( dataType == DataType . DOUBLE ) { double [ ] pa = ( double [ ] ) arr ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . readDouble ( chunk . getSrcPos ( ) , pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } return pa ; } else if ( dataType . getPrimitiveClassType ( ) == long . class ) { long [ ] pa = ( long [ ] ) arr ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . readLong ( chunk . getSrcPos ( ) , pa , ( int ) chunk . getDestElem ( ) , chunk . getNelems ( ) ) ; } return pa ; } else if ( dataType == DataType . STRUCTURE ) { int recsize = index . getElemSize ( ) ; byte [ ] pa = ( byte [ ] ) arr ; while ( index . hasNext ( ) ) { Layout . Chunk chunk = index . next ( ) ; raf . read ( chunk . getSrcPos ( ) , pa , ( int ) chunk . getDestElem ( ) * recsize , chunk . getNelems ( ) * recsize ) ; } return pa ; } throw new IllegalStateException ( ) ;


signature:
public class IospHelper { /** * Read data subset from ByteBuffer , create primitive array of size Layout . getTotalNelems .
 * Reading is controlled by the Layout object .
 * @ param layout handles skipping around in the file , provide ByteBuffer to read from
 * @ param dataType dataType of the variable
 * @ param fillValue must be Number if dataType . isNumeric ( ) , or String for STRING , byte [ ] for Structure , or null for none
 * @ return primitive array with data read in
 * @ throws java . io . IOException on read error */
static public Object readDataFill ( LayoutBB layout , DataType dataType , Object fillValue ) throws java . io . IOException { } }

implementation: long size = layout . getTotalNelems ( ) ; if ( dataType == DataType . STRUCTURE ) size *= layout . getElemSize ( ) ; Object arr = ( fillValue == null ) ? makePrimitiveArray ( ( int ) size , dataType ) : makePrimitiveArray ( ( int ) size , dataType , fillValue ) ; return readData ( layout , dataType , arr ) ;


signature:
public class IospHelper { /** * Read data subset from ByteBuffer , place in given primitive array .
 * Reading is controlled by the LayoutBB object .
 * @ param layout handles skipping around in the file , privide ByteBuffer to read from
 * @ param dataType dataType of the variable
 * @ param arr primitive array to read data into
 * @ return the primitive array with data read in
 * @ throws java . io . IOException on read error */
static public Object readData ( LayoutBB layout , DataType dataType , Object arr ) throws java . io . IOException { } }

implementation:
if ( showLayoutTypes ) System . out . println ( "***BB LayoutType=" + layout . getClass ( ) . getName ( ) ) ; if ( dataType . getPrimitiveClassType ( ) == byte . class || ( dataType == DataType . CHAR ) ) { byte [ ] pa = ( byte [ ] ) arr ; while ( layout . hasNext ( ) ) { LayoutBB . Chunk chunk = layout . next ( ) ; ByteBuffer bb = chunk . getByteBuffer ( ) ; bb . position ( chunk . getSrcElem ( ) ) ; int pos = ( int ) chunk . getDestElem ( ) ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) pa [ pos ++ ] = bb . get ( ) ; } // return ( dataType = = DataType . CHAR ) ? convertByteToChar ( pa ) : pa ;
if ( dataType == DataType . CHAR ) return convertByteToChar ( pa ) ; else return pa ; } else if ( dataType . getPrimitiveClassType ( ) == short . class ) { short [ ] pa = ( short [ ] ) arr ; while ( layout . hasNext ( ) ) { LayoutBB . Chunk chunk = layout . next ( ) ; ShortBuffer buff = chunk . getShortBuffer ( ) ; buff . position ( chunk . getSrcElem ( ) ) ; int pos = ( int ) chunk . getDestElem ( ) ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) pa [ pos ++ ] = buff . get ( ) ; } return pa ; } else if ( dataType . getPrimitiveClassType ( ) == int . class ) { int [ ] pa = ( int [ ] ) arr ; while ( layout . hasNext ( ) ) { LayoutBB . Chunk chunk = layout . next ( ) ; IntBuffer buff = chunk . getIntBuffer ( ) ; buff . position ( chunk . getSrcElem ( ) ) ; int pos = ( int ) chunk . getDestElem ( ) ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) pa [ pos ++ ] = buff . get ( ) ; } return pa ; } else if ( dataType == DataType . FLOAT ) { float [ ] pa = ( float [ ] ) arr ; while ( layout . hasNext ( ) ) { LayoutBB . Chunk chunk = layout . next ( ) ; FloatBuffer buff = chunk . getFloatBuffer ( ) ; buff . position ( chunk . getSrcElem ( ) ) ; int pos = ( int ) chunk . getDestElem ( ) ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) pa [ pos ++ ] = buff . get ( ) ; } return pa ; } else if ( dataType == DataType . DOUBLE ) { double [ ] pa = ( double [ ] ) arr ; while ( layout . hasNext ( ) ) { LayoutBB . Chunk chunk = layout . next ( ) ; DoubleBuffer buff = chunk . getDoubleBuffer ( ) ; buff . position ( chunk . getSrcElem ( ) ) ; int pos = ( int ) chunk . getDestElem ( ) ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) pa [ pos ++ ] = buff . get ( ) ; } return pa ; } else if ( dataType . getPrimitiveClassType ( ) == long . class ) { long [ ] pa = ( long [ ] ) arr ; while ( layout . hasNext ( ) ) { LayoutBB . Chunk chunk = layout . next ( ) ; LongBuffer buff = chunk . getLongBuffer ( ) ; buff . position ( chunk . getSrcElem ( ) ) ; int pos = ( int ) chunk . getDestElem ( ) ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) pa [ pos ++ ] = buff . get ( ) ; } return pa ; } else if ( dataType == DataType . STRUCTURE ) { byte [ ] pa = ( byte [ ] ) arr ; int recsize = layout . getElemSize ( ) ; while ( layout . hasNext ( ) ) { LayoutBB . Chunk chunk = layout . next ( ) ; ByteBuffer bb = chunk . getByteBuffer ( ) ; bb . position ( chunk . getSrcElem ( ) * recsize ) ; int pos = ( int ) chunk . getDestElem ( ) * recsize ; for ( int i = 0 ; i < chunk . getNelems ( ) * recsize ; i ++ ) pa [ pos ++ ] = bb . get ( ) ; } return pa ; } throw new IllegalStateException ( ) ;