signature:
public class Evaluator { /** * Find first variable with given attribute name and value
 * @ param ds in this dataset
 * @ param attName attribute name , case insensitive
 * @ param attValue attribute value , case sensitive
 * @ return name of first variable with given attribute name and value , or null */
static public String findNameOfVariableWithAttributeValue ( NetcdfDataset ds , String attName , String attValue ) { } }

implementation: Variable v = findVariableWithAttributeValue ( ds , attName , attValue ) ; return ( v == null ) ? null : v . getShortName ( ) ;


signature:
public class Evaluator { /** * Find first member variable in this struct with given attribute name and value
 * @ param struct in this structure
 * @ param attName attribute name , case insensitive
 * @ param attValue attribute value , case sensitive
 * @ return first member variable with given attribute name and value , or null */
static public Variable findVariableWithAttributeValue ( Structure struct , String attName , String attValue ) { } }

implementation: for ( Variable v : struct . getVariables ( ) ) { Attribute att = v . findAttributeIgnoreCase ( attName ) ; if ( ( att != null ) && att . getStringValue ( ) . equals ( attValue ) ) return v ; } return null ;


signature:
public class Evaluator { /** * Find structure variable of rank 2 with the 2 given dimensions
 * ( or ) Find structure variable of rank 1 with the 1 given dimension
 * @ param ds in this dataset
 * @ param dim0 first dimension
 * @ param dim1 second dimension ( ok to be null )
 * @ return structure variable or null */
static public Structure findStructureWithDimensions ( NetcdfDataset ds , Dimension dim0 , Dimension dim1 ) { } }

implementation: for ( Variable v : ds . getVariables ( ) ) { if ( ! ( v instanceof Structure ) ) continue ; if ( dim1 != null && v . getRank ( ) == 2 && v . getDimension ( 0 ) . equals ( dim0 ) && v . getDimension ( 1 ) . equals ( dim1 ) ) return ( Structure ) v ; if ( dim1 == null && v . getRank ( ) == 1 && v . getDimension ( 0 ) . equals ( dim0 ) ) return ( Structure ) v ; } return null ;


signature:
public class Evaluator { /** * Find first nested structure
 * @ param s in this structure
 * @ return first nested structure or null */
static public Structure findNestedStructure ( Structure s ) { } }

implementation: for ( Variable v : s . getVariables ( ) ) { if ( ( v instanceof Structure ) ) return ( Structure ) v ; } return null ;


signature:
public class Evaluator { /** * Does this dataset have a record structure ? netcdf - 3 specific
 * @ param ds in this dataset
 * @ return true if record structure exists */
static public boolean hasNetcdf3RecordStructure ( NetcdfDataset ds ) { } }

implementation: Variable v = ds . findVariable ( "record" ) ; return ( v != null ) && ( v . getDataType ( ) == DataType . STRUCTURE ) ;


signature:
public class Evaluator { /** * Translate key to value
 * @ param ds search in this dataset
 * @ param key if starts with " : " , search for global attribute
 * @ param errlog error messages here
 * @ return return global attribute value or the key itself */
static public String getLiteral ( NetcdfDataset ds , String key , Formatter errlog ) { } }

implementation: if ( key . startsWith ( ":" ) ) { String val = ds . findAttValueIgnoreCase ( null , key . substring ( 1 ) , null ) ; if ( ( val == null ) && ( errlog != null ) ) errlog . format ( " Cant find global attribute %s%n" , key ) ; return val ; } return key ;


signature:
public class Evaluator { /** * Turn the key into a String and return the corresponding featureType , if any .
 * @ param ds look in this datset
 * @ param key if starts with " : " , replace with value of global attribute
 * @ param errlog error messages here
 * @ return featureType , or null */
static public FeatureType getFeatureType ( NetcdfDataset ds , String key , Formatter errlog ) { } }

implementation: FeatureType ft = null ; String fts = getLiteral ( ds , key , errlog ) ; if ( fts != null ) { ft = FeatureType . valueOf ( fts . toUpperCase ( ) ) ; if ( ( ft == null ) && ( errlog != null ) ) errlog . format ( " Cant find Feature type %s from %s%n" , fts , key ) ; } return ft ;


signature:
public class Evaluator { /** * Find the variable pointed to by key
 * @ param ds in this dataset
 * @ param key may be variable name or " : gatt " where gatt is local attribute whose value is the variable name
 * @ param errlog error messages here
 * @ return name of variable or null if not exist */
static public String getVariableName ( NetcdfDataset ds , String key , Formatter errlog ) { } }

implementation: Variable v = null ; String vs = getLiteral ( ds , key , errlog ) ; if ( vs != null ) { v = ds . findVariable ( vs ) ; if ( ( v == null ) && ( errlog != null ) ) errlog . format ( " Cant find Variable %s from %s%n" , vs , key ) ; } return v == null ? null : v . getShortName ( ) ;


signature:
public class Evaluator { /** * Find the dimension pointed to by key
 * @ param ds in this dataset
 * @ param key may be dimension name or " : gatt " where gatt is local attribute whose value is the dimension name
 * @ param errlog error messages here
 * @ return dimension or null if not exist */
static public Dimension getDimension ( NetcdfDataset ds , String key , Formatter errlog ) { } }

implementation:
Dimension d = null ; String s = getLiteral ( ds , key , errlog ) ; if ( s != null ) { d = ds . findDimension ( s ) ; // LOOK use group
if ( ( d == null ) && ( errlog != null ) ) errlog . format ( " Cant find Variable %s from %s%n" , s , key ) ; } return d ;


signature:
public class Evaluator { /** * Find the dimension pointed to by key
 * @ param ds in this dataset
 * @ param key may be dimension name or " : gatt " where gatt is local attribute whose value is the dimension name
 * @ param errlog error messages here
 * @ return name of dimension or null if not exist */
static public String getDimensionName ( NetcdfDataset ds , String key , Formatter errlog ) { } }

implementation: Dimension d = getDimension ( ds , key , errlog ) ; return ( d == null ) ? null : d . getShortName ( ) ;


signature:
public class CoordinateAxis2D { /** * Get the coordinate value at the i , j index .
 * @ param i index 0 ( fastest varying , right - most )
 * @ param j index 1
 * @ return midpoint . get ( j , i ) . */
public double getCoordValue ( int j , int i ) { } }

implementation: if ( coords == null ) doRead ( ) ; return coords . get ( j , i ) ;


signature:
public class CoordinateAxis2D { /** * larger than you would ever expect */
static private double connectLon ( double connect , double val ) { } }

implementation:
if ( Double . isNaN ( connect ) ) return val ; if ( Double . isNaN ( val ) ) return val ; double diff = val - connect ; if ( Math . abs ( diff ) < MAX_JUMP ) return val ; // common case fast
// we have to add or subtract 360
double result = diff > 0 ? val - 360 : val + 360 ; double diff2 = connect - result ; if ( ( Math . abs ( diff2 ) ) < Math . abs ( diff ) ) val = result ; return val ;


signature:
public class CoordinateAxis2D { /** * Get the coordinate values as a 1D double array , in canonical order .
 * @ return coordinate values
 * @ throws UnsupportedOperationException if ! isNumeric ( ) */
public double [ ] getCoordValues ( ) { } }

implementation: if ( coords == null ) doRead ( ) ; if ( ! isNumeric ( ) ) throw new UnsupportedOperationException ( "CoordinateAxis2D.getCoordValues() on non-numeric" ) ; return ( double [ ] ) coords . get1DJavaArray ( DataType . DOUBLE ) ;


signature:
public class CoordinateAxis2D { /** * Create a new CoordinateAxis2D as a section of this CoordinateAxis2D .
 * @ param r1 the section on the first index
 * @ param r2 the section on the second index
 * @ return a section of this CoordinateAxis2D
 * @ throws InvalidRangeException if specified Ranges are invalid */
public CoordinateAxis2D section ( Range r1 , Range r2 ) throws InvalidRangeException { } }

implementation: List < Range > section = new ArrayList < > ( ) ; section . add ( r1 ) ; section . add ( r2 ) ; return ( CoordinateAxis2D ) section ( section ) ;


signature:
public class CoordinateAxis2D { /** * Normal case : do something reasonable in deciding on the edges when we have the midpoints of a 2D coordinate .
 * @ param midpoints values of midpoints with shape ( ny , nx )
 * @ return values of edges with shape ( ny + 1 , nx + 1) */
static public ArrayDouble . D2 makeEdges ( ArrayDouble . D2 midpoints ) { } }

implementation:
int [ ] shape = midpoints . getShape ( ) ; int ny = shape [ 0 ] ; int nx = shape [ 1 ] ; ArrayDouble . D2 edge = new ArrayDouble . D2 ( ny + 1 , nx + 1 ) ; for ( int y = 0 ; y < ny - 1 ; y ++ ) { for ( int x = 0 ; x < nx - 1 ; x ++ ) { // the interior edges are the average of the 4 surrounding midpoints
double xval = ( midpoints . get ( y , x ) + midpoints . get ( y , x + 1 ) + midpoints . get ( y + 1 , x ) + midpoints . get ( y + 1 , x + 1 ) ) / 4 ; edge . set ( y + 1 , x + 1 , xval ) ; } // extrapolate to exterior points
edge . set ( y + 1 , 0 , edge . get ( y + 1 , 1 ) - ( edge . get ( y + 1 , 2 ) - edge . get ( y + 1 , 1 ) ) ) ; edge . set ( y + 1 , nx , edge . get ( y + 1 , nx - 1 ) + ( edge . get ( y + 1 , nx - 1 ) - edge . get ( y + 1 , nx - 2 ) ) ) ; } // extrapolate to the first and last row
for ( int x = 0 ; x < nx + 1 ; x ++ ) { edge . set ( 0 , x , edge . get ( 1 , x ) - ( edge . get ( 2 , x ) - edge . get ( 1 , x ) ) ) ; edge . set ( ny , x , edge . get ( ny - 1 , x ) + ( edge . get ( ny - 1 , x ) - edge . get ( ny - 2 , x ) ) ) ; } return edge ;


signature:
public class CoordinateAxis2D { /** * Experimental : for WRF rotated ( NMM " E " ) Grids
 * @ param midx x coordinates of midpoints
 * @ return x coordinates of edges with shape ( ny + 2 , nx + 1) */
static public ArrayDouble . D2 makeXEdgesRotated ( ArrayDouble . D2 midx ) { } }

implementation:
int [ ] shape = midx . getShape ( ) ; int ny = shape [ 0 ] ; int nx = shape [ 1 ] ; ArrayDouble . D2 edgex = new ArrayDouble . D2 ( ny + 2 , nx + 1 ) ; // compute the interior rows
for ( int y = 0 ; y < ny ; y ++ ) { for ( int x = 1 ; x < nx ; x ++ ) { double xval = ( midx . get ( y , x - 1 ) + midx . get ( y , x ) ) / 2 ; edgex . set ( y + 1 , x , xval ) ; } edgex . set ( y + 1 , 0 , midx . get ( y , 0 ) - ( edgex . get ( y + 1 , 1 ) - midx . get ( y , 0 ) ) ) ; edgex . set ( y + 1 , nx , midx . get ( y , nx - 1 ) - ( edgex . get ( y + 1 , nx - 1 ) - midx . get ( y , nx - 1 ) ) ) ; } // compute the first row
for ( int x = 0 ; x < nx ; x ++ ) { edgex . set ( 0 , x , midx . get ( 0 , x ) ) ; } // compute the last row
for ( int x = 0 ; x < nx - 1 ; x ++ ) { edgex . set ( ny + 1 , x , midx . get ( ny - 1 , x ) ) ; } return edgex ;


signature:
public class CoordinateAxis2D { /** * Experimental : for WRF rotated ( NMM " E " ) Grids
 * @ param midy y coordinates of midpoints
 * @ return y coordinates of edges with shape ( ny + 2 , nx + 1) */
static public ArrayDouble . D2 makeYEdgesRotated ( ArrayDouble . D2 midy ) { } }

implementation:
int [ ] shape = midy . getShape ( ) ; int ny = shape [ 0 ] ; int nx = shape [ 1 ] ; ArrayDouble . D2 edgey = new ArrayDouble . D2 ( ny + 2 , nx + 1 ) ; // compute the interior rows
for ( int y = 0 ; y < ny ; y ++ ) { for ( int x = 1 ; x < nx ; x ++ ) { double yval = ( midy . get ( y , x - 1 ) + midy . get ( y , x ) ) / 2 ; edgey . set ( y + 1 , x , yval ) ; } edgey . set ( y + 1 , 0 , midy . get ( y , 0 ) - ( edgey . get ( y + 1 , 1 ) - midy . get ( y , 0 ) ) ) ; edgey . set ( y + 1 , nx , midy . get ( y , nx - 1 ) - ( edgey . get ( y + 1 , nx - 1 ) - midy . get ( y , nx - 1 ) ) ) ; } // compute the first row
for ( int x = 0 ; x < nx ; x ++ ) { double pt0 = midy . get ( 0 , x ) ; double pt = edgey . get ( 2 , x ) ; double diff = pt0 - pt ; edgey . set ( 0 , x , pt0 + diff ) ; } // compute the last row
for ( int x = 0 ; x < nx - 1 ; x ++ ) { double pt0 = midy . get ( ny - 1 , x ) ; double pt = edgey . get ( ny - 1 , x ) ; double diff = pt0 - pt ; edgey . set ( ny + 1 , x , pt0 + diff ) ; } return edgey ;


signature:
public class CoordinateAxis2D { /** * bounds calculations */
private ArrayDouble . D3 makeBoundsFromAux ( ) { } }

implementation:
if ( ! computeIsInterval ( ) ) return null ; Attribute boundsAtt = findAttributeIgnoreCase ( CF . BOUNDS ) ; if ( boundsAtt == null ) return null ; String boundsVarName = boundsAtt . getStringValue ( ) ; VariableDS boundsVar = ( VariableDS ) ncd . findVariable ( getParentGroup ( ) , boundsVarName ) ; Array data ; try { // boundsVar . setUseNaNs ( false ) ; / / missing values not allowed
data = boundsVar . read ( ) ; } catch ( IOException e ) { log . warn ( "CoordinateAxis2D.makeBoundsFromAux read failed " , e ) ; return null ; } ArrayDouble . D3 bounds ; assert ( data . getRank ( ) == 3 ) && ( data . getShape ( ) [ 2 ] == 2 ) : "incorrect shape data for variable " + boundsVar ; if ( data instanceof ArrayDouble . D3 ) { bounds = ( ArrayDouble . D3 ) data ; } else { bounds = ( ArrayDouble . D3 ) Array . factory ( DataType . DOUBLE , data . getShape ( ) ) ; MAMath . copy ( data , bounds ) ; } return bounds ;


signature:
public class CoordinateAxis2D { /** * return index if only one match , if no matches return - 1 , if > 1 match return - nhits */
private int findSingleHit ( ArrayDouble . D2 boundsForRun , double target ) { } }

implementation: int hits = 0 ; int idxFound = - 1 ; int n = boundsForRun . getShape ( ) [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( contains ( target , boundsForRun . get ( i , 0 ) , boundsForRun . get ( i , 1 ) ) ) { hits ++ ; idxFound = i ; } } if ( hits == 1 ) return idxFound ; if ( hits == 0 ) return - 1 ; return - hits ;


signature:
public class CoordinateAxis2D { /** * return index of closest value to target */
private int findClosest ( ArrayDouble . D2 boundsForRun , double target ) { } }

implementation: double minDiff = Double . MAX_VALUE ; int idxFound = - 1 ; int n = boundsForRun . getShape ( ) [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { double midpoint = ( boundsForRun . get ( i , 0 ) + boundsForRun . get ( i , 1 ) ) / 2.0 ; double diff = Math . abs ( midpoint - target ) ; if ( diff < minDiff ) { minDiff = diff ; idxFound = i ; } } return idxFound ;


signature:
public class CollectionSpecParser { /** * / * private static void doit2 ( String spec , String timePart , Formatter errlog ) {
 * CollectionSpecParser specp = new CollectionSpecParser ( spec , timePart , errlog ) ;
 * System . out . printf ( " spec = % s timePart = % s % n % s % n " , spec , timePart , specp ) ;
 * String err = errlog . toString ( ) ;
 * if ( err . length ( ) > 0)
 * System . out . printf ( " % s % n " , err ) ;
 * System . out . printf ( " - - - - - % n " ) ;
 * public static void main ( String arg [ ] ) {
 * doit2 ( " G : / nomads / cfsr / timeseries / * * / . * grb2 $ " , " G : / nomads / cfsr / # timeseries / # yyyyMM " , new Formatter ( ) ) ;
 * doit ( " C : / data / formats / gempak / surface / # yyyyMMdd # _ sao \ \ . gem " , new Formatter ( ) ) ;
 * doit ( " Q : / station / ldm / metar / Surface _ METAR _ # yyyyMMdd _ HHmm # . nc " , new Formatter ( ) ) ; */
private static void doit ( String spec , Formatter errlog ) { } }

implementation: CollectionSpecParser specp = new CollectionSpecParser ( spec , errlog ) ; System . out . printf ( "spec= %s%n%s%n" , spec , specp ) ; String err = errlog . toString ( ) ; if ( err . length ( ) > 0 ) System . out . printf ( "%s%n" , err ) ; System . out . printf ( "-----------------------------------%n" ) ;


signature:
public class UnitSystemManager { /** * Sets the system of units . This must be called before any call to
 * < code > instance ( ) < / code > .
 * @ param instance
 * The system of units .
 * @ throws UnitSystemException
 * < code > instance ( ) < / code > was called earlier . */
public static synchronized void setInstance ( final UnitSystem instance ) throws UnitSystemException { } }

implementation: if ( instance != null ) { throw new UnitSystemException ( "Unit system already used" ) ; } UnitSystemManager . instance = instance ;


signature:
public class CDMNode { /** * getName is deprecated because , as the code below shows ,
 * it has no consistent meaning . Sometimes it returns
 * the short name , sometimes it returns the full name .
 * @ deprecated Replaced by { @ link # getShortName ( ) } and { @ link # getFullName ( ) } */
@ Deprecated public String getName ( ) { } }

implementation:
switch ( sort ) { case ATTRIBUTE : case DIMENSION : case ENUMERATION : // for these cases , getName is getShortName
return getShortName ( ) ; case VARIABLE : // Atomic
case SEQUENCE : case STRUCTURE : case GROUP : // for these cases , getName is getFullName
return getFullName ( ) ; default : break ; } return getShortName ( ) ; // default


signature:
public class CDMNode { /** * NetcdfDataset can end up wrapping a variable
 * in multiple wrapping classes ( e . g . VariableDS ) .
 * Goal of this procedure is to get down to the
 * lowest level Variable instance
 * @ param node possibly wrapped ode
 * @ return the lowest level node instance */
static public CDMNode unwrap ( CDMNode node ) { } }

implementation:
if ( ! ( node instanceof Variable ) ) return node ; Variable inner = ( Variable ) node ; for ( ; ; ) { if ( inner instanceof VariableDS ) { VariableDS vds = ( VariableDS ) inner ; inner = vds . getOriginalVariable ( ) ; if ( inner == null ) { inner = vds ; break ; } } else if ( inner instanceof StructureDS ) { StructureDS sds = ( StructureDS ) inner ; inner = sds . getOriginalVariable ( ) ; if ( inner == null ) { inner = sds ; break ; } } else break ; // base case we have straight Variable or Stucture
} return inner ;


signature:
public class PopupMenu { /** * Add an action to the popup menu .
 * Note that the menuName is made the NAME value of the action .
 * @ param menuName name of the action on the menu .
 * @ param act the Action . */
public void addAction ( String menuName , Action act ) { } }

implementation: act . putValue ( Action . NAME , menuName ) ; super . add ( act ) ;


signature:
public class PopupMenu { /** * Add an action to the popup menu , with an icon .
 * Note that the menuName is made the NAME value of the action .
 * @ param menuName name of the action on the menu .
 * @ param act the Action . */
public void addAction ( String menuName , String iconName , Action act ) { } }

implementation: addAction ( menuName , BAMutil . getIcon ( iconName , true ) , act ) ;


signature:
public class PopupMenu { /** * Add an action to the popup menu , with an icon .
 * Note that the menuName is made the NAME value of the action .
 * @ param menuName name of the action on the menu .
 * @ param act the Action . */
public void addAction ( String menuName , ImageIcon icon , Action act ) { } }

implementation: act . putValue ( Action . NAME , menuName ) ; act . putValue ( Action . SMALL_ICON , icon ) ; JMenuItem mi = add ( act ) ; mi . setHorizontalTextPosition ( SwingConstants . LEFT ) ;


signature:
public class PopupMenu { /** * Add an action to the popup menu , using a JCheckBoxMenuItem .
 * Fetch the toggle state using :
 * < pre > Boolean state = ( Boolean ) act . getValue ( BAMutil . STATE ) ; < / pre >
 * @ param menuName name of the action on the menu .
 * @ param act the Action .
 * @ param state : initial state of the checkbox */
public void addActionCheckBox ( String menuName , AbstractAction act , boolean state ) { } }

implementation: JMenuItem mi = new JCheckBoxMenuItem ( menuName , state ) ; mi . addActionListener ( new BAMutil . ActionToggle ( act , mi ) ) ; act . putValue ( BAMutil . STATE , new Boolean ( state ) ) ; add ( mi ) ;


signature:
public class PathMatcher { /** * Find the longest match .
 * @ param path find object with longest match where path . startsWith ( key )
 * @ return the value whose key is the longest that matches path , or null if none */
public Match match ( String path ) { } }

implementation:
SortedMap < String , Match > tail = treeMap . tailMap ( path ) ; if ( tail . isEmpty ( ) ) return null ; String after = tail . firstKey ( ) ; // System . out . println ( " " + path + " ; after = " + afterPath ) ;
if ( path . startsWith ( after ) ) // common case
return treeMap . get ( after ) ; // have to check more , until no common starting chars
for ( String key : tail . keySet ( ) ) { if ( path . startsWith ( key ) ) return treeMap . get ( key ) ; // terminate when there ' s no match at all .
if ( StringUtil2 . match ( path , key ) == 0 ) break ; } return null ;


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

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


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

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


signature:
public class H5iosp { /** * reading */
public void open ( RandomAccessFile raf , ucar . nc2 . NetcdfFile ncfile , ucar . nc2 . util . CancelTask cancelTask ) throws IOException { } }

implementation:
super . open ( raf , ncfile , cancelTask ) ; headerParser = new H5header ( this . raf , ncfile , this ) ; headerParser . read ( null ) ; // check if its an HDF5 - EOS file
Group eosInfo = ncfile . getRootGroup ( ) . findGroup ( HdfEos . HDF5_GROUP ) ; if ( eosInfo != null && useHdfEos ) { isEos = HdfEos . amendFromODL ( ncfile , eosInfo ) ; } ncfile . finish ( ) ;


signature:
public class H5iosp { /** * all the work is here , so can be called recursively */
private Array readData ( ucar . nc2 . Variable v2 , long dataPos , Section wantSection ) throws IOException , InvalidRangeException { } }

implementation:
H5header . Vinfo vinfo = ( H5header . Vinfo ) v2 . getSPobject ( ) ; DataType dataType = v2 . getDataType ( ) ; Object data ; Layout layout ; if ( vinfo . useFillValue ) { // fill value only
Object pa = IospHelper . makePrimitiveArray ( ( int ) wantSection . computeSize ( ) , dataType , vinfo . getFillValue ( ) ) ; if ( dataType == DataType . CHAR ) pa = IospHelper . convertByteToChar ( ( byte [ ] ) pa ) ; return Array . factory ( dataType , wantSection . getShape ( ) , pa ) ; } if ( vinfo . mfp != null ) { // filtered
if ( debugFilter ) System . out . println ( "read variable filtered " + v2 . getFullName ( ) + " vinfo = " + vinfo ) ; assert vinfo . isChunked ; ByteOrder bo = ( vinfo . typeInfo . endian == 0 ) ? ByteOrder . BIG_ENDIAN : ByteOrder . LITTLE_ENDIAN ; layout = new H5tiledLayoutBB ( v2 , wantSection , raf , vinfo . mfp . getFilters ( ) , bo ) ; if ( vinfo . typeInfo . isVString ) { data = readFilteredStringData ( ( LayoutBB ) layout ) ; } else { data = IospHelper . readDataFill ( ( LayoutBB ) layout , v2 . getDataType ( ) , vinfo . getFillValue ( ) ) ; } } else { // normal case
if ( debug ) System . out . println ( "read variable " + v2 . getFullName ( ) + " vinfo = " + vinfo ) ; DataType readDtype = v2 . getDataType ( ) ; int elemSize = v2 . getElementSize ( ) ; Object fillValue = vinfo . getFillValue ( ) ; int endian = vinfo . typeInfo . endian ; // fill in the wantSection
wantSection = Section . fill ( wantSection , v2 . getShape ( ) ) ; if ( vinfo . typeInfo . hdfType == 2 ) { // time
readDtype = vinfo . mdt . timeType ; elemSize = readDtype . getSize ( ) ; fillValue = N3iosp . getFillValueDefault ( readDtype ) ; } else if ( vinfo . typeInfo . hdfType == 8 ) { // enum
H5header . TypeInfo baseInfo = vinfo . typeInfo . base ; readDtype = baseInfo . dataType ; elemSize = readDtype . getSize ( ) ; fillValue = N3iosp . getFillValueDefault ( readDtype ) ; endian = baseInfo . endian ; } else if ( vinfo . typeInfo . hdfType == 9 ) { // vlen
elemSize = vinfo . typeInfo . byteSize ; endian = vinfo . typeInfo . endian ; // wantSection = wantSection . removeVlen ( ) ; / / remove vlen dimension
} if ( vinfo . isChunked ) { layout = new H5tiledLayout ( ( H5header . Vinfo ) v2 . getSPobject ( ) , readDtype , wantSection ) ; } else { layout = new LayoutRegular ( dataPos , elemSize , v2 . getShape ( ) , wantSection ) ; } data = readData ( vinfo , v2 , layout , readDtype , wantSection . getShape ( ) , fillValue , endian ) ; } if ( data instanceof Array ) return ( Array ) data ; else if ( dataType == DataType . STRUCTURE ) return convertStructure ( ( Structure ) v2 , layout , wantSection . getShape ( ) , ( byte [ ] ) data ) ; // LOOK
else return Array . factory ( dataType , wantSection . getShape ( ) , data ) ;


signature:
public class H5iosp { /** * Read data subset from file for a variable , return Array or java primitive array .
 * @ param v the variable to read .
 * @ param layout handles skipping around in the file .
 * @ param dataType dataType of the data to read
 * @ param shape the shape of the output
 * @ param fillValue fill value as a wrapped primitive
 * @ return primitive array or Array with data read in
 * @ throws java . io . IOException if read error
 * @ throws ucar . ma2 . InvalidRangeException if invalid section */
private Object readData ( H5header . Vinfo vinfo , Variable v , Layout layout , DataType dataType , int [ ] shape , Object fillValue , int endian ) throws java . io . IOException , InvalidRangeException { } }

implementation:
H5header . TypeInfo typeInfo = vinfo . typeInfo ; // special processing
if ( typeInfo . hdfType == 2 ) { // time
Object data = IospHelper . readDataFill ( raf , layout , dataType , fillValue , endian , true ) ; Array timeArray = Array . factory ( dataType , shape , data ) ; // now transform into an ISO Date String
String [ ] stringData = new String [ ( int ) timeArray . getSize ( ) ] ; int count = 0 ; while ( timeArray . hasNext ( ) ) { long time = timeArray . nextLong ( ) ; stringData [ count ++ ] = CalendarDate . of ( time ) . toString ( ) ; } return Array . factory ( DataType . STRING , shape , stringData ) ; } if ( typeInfo . hdfType == 8 ) { // enum
Object data = IospHelper . readDataFill ( raf , layout , dataType , fillValue , endian ) ; return Array . factory ( dataType , shape , data ) ; } if ( typeInfo . isVlen ) { // vlen ( not string )
DataType readType = dataType ; if ( typeInfo . base . hdfType == 7 ) // reference
readType = DataType . LONG ; // general case is to read an array of vlen objects
// each vlen generates an Array - so return ArrayObject of Array
// boolean scalar = false ; / / layout . getTotalNelems ( ) = = 1 ; / / if scalar , return just the len Array / / remove 12/25/10 jcaron
Array [ ] data = new Array [ ( int ) layout . getTotalNelems ( ) ] ; int count = 0 ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; if ( chunk == null ) continue ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) { long address = chunk . getSrcPos ( ) + layout . getElemSize ( ) * i ; Array vlenArray = headerParser . getHeapDataArray ( address , readType , endian ) ; data [ count ++ ] = ( typeInfo . base . hdfType == 7 ) ? convertReference ( vlenArray ) : vlenArray ; } } int prefixrank = 0 ; for ( int i = 0 ; i < shape . length ; i ++ ) { // find leftmost vlen
if ( shape [ i ] < 0 ) { prefixrank = i ; break ; } } Array result ; if ( prefixrank == 0 ) // if scalar , return just the singleton vlen array
result = data [ 0 ] ; else { int [ ] newshape = new int [ prefixrank ] ; System . arraycopy ( shape , 0 , newshape , 0 , prefixrank ) ; // result = Array . makeObjectArray ( readType , data [ 0 ] . getClass ( ) , newshape , data ) ;
result = Array . makeVlenArray ( newshape , data ) ; } /* else if ( prefixrank = = 1 ) / / LOOK cant these two cases be combines - just differ in shape ? ?
 result = Array . makeObjectArray ( readType , data [ 0 ] . getClass ( ) , new int [ ] { count } , data ) ;
 else { / / LOOK cant these two cases be combines - just differ in shape ? ?
 / / Otherwise create and fill in an n - dimensional Array Of Arrays
 int [ ] newshape = new int [ prefixrank ] ;
 System . arraycopy ( shape , 0 , newshape , 0 , prefixrank ) ;
 Array ndimarray = Array . makeObjectArray ( readType , Array . class , newshape , null ) ;
 / / Transfer the elements of data into the n - dim arrays
 IndexIterator iter = ndimarray . getIndexIterator ( ) ;
 for ( int i = 0 ; iter . hasNext ( ) ; i + + ) {
 iter . setObjectNext ( data [ i ] ) ;
 result = ndimarray ; */
// return ( scalar ) ? data [ 0 ] : new ArrayObject ( data [ 0 ] . getClass ( ) , shape , data ) ;
// return new ArrayObject ( data [ 0 ] . getClass ( ) , shape , data ) ;
return result ; } if ( dataType == DataType . STRUCTURE ) { // LOOK what about subset ?
int recsize = layout . getElemSize ( ) ; long size = recsize * layout . getTotalNelems ( ) ; byte [ ] byteArray = new byte [ ( int ) size ] ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; if ( chunk == null ) continue ; if ( debugStructure ) System . out . println ( " readStructure " + v . getFullName ( ) + " chunk= " + chunk + " index.getElemSize= " + layout . getElemSize ( ) ) ; // copy bytes directly into the underlying byte [ ] LOOK : assumes contiguous layout ? ?
raf . seek ( chunk . getSrcPos ( ) ) ; raf . readFully ( byteArray , ( int ) chunk . getDestElem ( ) * recsize , chunk . getNelems ( ) * recsize ) ; } // place data into an ArrayStructureBB
return convertStructure ( ( Structure ) v , layout , shape , byteArray ) ; // LOOK
} // normal case
return readDataPrimitive ( layout , dataType , shape , fillValue , endian , true ) ;


signature:
public class H5iosp { /** * recursive */
private boolean convertStructure ( Structure s , StructureMembers sm ) { } }

implementation:
boolean hasHeap = false ; for ( StructureMembers . Member m : sm . getMembers ( ) ) { Variable v2 = s . findVariable ( m . getName ( ) ) ; assert v2 != null ; H5header . Vinfo vm = ( H5header . Vinfo ) v2 . getSPobject ( ) ; // apparently each member may have seperate byte order ( ! ! ! ? ? )
if ( vm . typeInfo . endian >= 0 ) m . setDataObject ( vm . typeInfo . endian == RandomAccessFile . LITTLE_ENDIAN ? ByteOrder . LITTLE_ENDIAN : ByteOrder . BIG_ENDIAN ) ; // vm . dataPos : offset since start of Structure
m . setDataParam ( ( int ) vm . dataPos ) ; // track if there is a heap
if ( v2 . getDataType ( ) == DataType . STRING || v2 . isVariableLength ( ) ) hasHeap = true ; // recurse
if ( v2 instanceof Structure ) { Structure nested = ( Structure ) v2 ; StructureMembers nestSm = nested . makeStructureMembers ( ) ; m . setStructureMembers ( nestSm ) ; hasHeap |= convertStructure ( nested , nestSm ) ; } } return hasHeap ;


signature:
public class H5iosp { /** * public static int setOffsets ( StructureMembers members ) {
 * int offset = 0;
 * for ( StructureMembers . Member m : members . getMembers ( ) ) {
 * m . setDataParam ( offset ) ;
 * offset + = m . getSizeBytes ( ) ;
 * set inner offsets ( starts again at 0)
 * if ( m . getStructureMembers ( ) ! = null )
 * setOffsets ( m . getStructureMembers ( ) ) ;
 * members . setStructureSize ( offset ) ;
 * return offset ; */
void convertHeap ( ArrayStructureBB asbb , int pos , StructureMembers sm ) throws java . io . IOException , InvalidRangeException { } }

implementation:
ByteBuffer bb = asbb . getByteBuffer ( ) ; for ( StructureMembers . Member m : sm . getMembers ( ) ) { if ( m . getDataType ( ) == DataType . STRING ) { m . setDataObject ( ByteOrder . nativeOrder ( ) ) ; // the index is always written in " native order "
int size = m . getSize ( ) ; int destPos = pos + m . getDataParam ( ) ; String [ ] result = new String [ size ] ; for ( int i = 0 ; i < size ; i ++ ) result [ i ] = headerParser . readHeapString ( bb , destPos + i * 16 ) ; // 16 byte " heap ids " are in the ByteBuffer
int index = asbb . addObjectToHeap ( result ) ; bb . order ( ByteOrder . nativeOrder ( ) ) ; // the string index is always written in " native order "
bb . putInt ( destPos , index ) ; // overwrite with the index into the StringHeap
} else if ( m . isVariableLength ( ) ) { int startPos = pos + m . getDataParam ( ) ; bb . order ( ByteOrder . LITTLE_ENDIAN ) ; ByteOrder bo = ( ByteOrder ) m . getDataObject ( ) ; int endian = bo . equals ( ByteOrder . LITTLE_ENDIAN ) ? RandomAccessFile . LITTLE_ENDIAN : RandomAccessFile . BIG_ENDIAN ; // Compute rank and size upto the first ( and ideally last ) VLEN
int [ ] fieldshape = m . getShape ( ) ; int prefixrank = 0 ; int size = 1 ; for ( ; prefixrank < fieldshape . length ; prefixrank ++ ) { if ( fieldshape [ prefixrank ] < 0 ) break ; size *= fieldshape [ prefixrank ] ; } assert size == m . getSize ( ) : "Internal error: field size mismatch" ; Array [ ] fieldarray = new Array [ size ] ; // hold all the vlen instance data
// destPos will point to each vlen instance in turn
// assuming we have ' size ' such instances in a row .
int destPos = startPos ; for ( int i = 0 ; i < size ; i ++ ) { // vlenarray extracts the i ' th vlen contents ( struct not supported ) .
Array vlenArray = headerParser . readHeapVlen ( bb , destPos , m . getDataType ( ) , endian ) ; fieldarray [ i ] = vlenArray ; destPos += VLEN_T_SIZE ; // Apparentlly no way to compute VLEN _ T _ SIZE on the fly
} Array result ; if ( prefixrank == 0 ) // if scalar , return just the singleton vlen array
result = fieldarray [ 0 ] ; else { int [ ] newshape = new int [ prefixrank ] ; System . arraycopy ( fieldshape , 0 , newshape , 0 , prefixrank ) ; // result = Array . makeObjectArray ( m . getDataType ( ) , fieldarray [ 0 ] . getClass ( ) , newshape , fieldarray ) ;
result = Array . makeVlenArray ( newshape , fieldarray ) ; } /* if ( prefixrank = = 1)
 result = Array . makeObjectArray ( m . getDataType ( ) , fieldarray [ 0 ] . getClass ( ) , new int [ ] { size } , fieldarray ) ;
 else {
 / / Otherwise create and fill in an n - dimensional Array Of Arrays
 int [ ] newshape = new int [ prefixrank ] ;
 System . arraycopy ( fieldshape , 0 , newshape , 0 , prefixrank ) ;
 Array ndimarray = Array . makeObjectArray ( m . getDataType ( ) , Array . class , newshape , null ) ;
 / / Transfer the elements of data into the n - dim arrays
 IndexIterator iter = ndimarray . getIndexIterator ( ) ;
 for ( int i = 0 ; iter . hasNext ( ) ; i + + ) {
 iter . setObjectNext ( fieldarray [ i ] ) ;
 result = ndimarray ; */
// Array vlenArray = headerParser . readHeapVlen ( bb , destPos , m . getDataType ( ) , endian ) ;
int index = asbb . addObjectToHeap ( result ) ; bb . order ( ByteOrder . nativeOrder ( ) ) ; bb . putInt ( startPos , index ) ; // overwrite with the index into the Heap
} }


signature:
public class H5iosp { /** * Read data subset from file for a variable , create primitive array .
 * @ param layout handles skipping around in the file .
 * @ param dataType dataType of the variable
 * @ param shape the shape of the output
 * @ param fillValue fill value as a wrapped primitive
 * @ param endian byte order
 * @ return primitive array with data read in
 * @ throws java . io . IOException if read error
 * @ throws ucar . ma2 . InvalidRangeException if invalid section */
Object readDataPrimitive ( Layout layout , DataType dataType , int [ ] shape , Object fillValue , int endian , boolean convertChar ) throws java . io . IOException , InvalidRangeException { } }

implementation:
if ( dataType == DataType . STRING ) { int size = ( int ) layout . getTotalNelems ( ) ; String [ ] sa = new String [ size ] ; int count = 0 ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; if ( chunk == null ) continue ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) { // 16 byte " heap ids "
sa [ count ++ ] = headerParser . readHeapString ( chunk . getSrcPos ( ) + layout . getElemSize ( ) * i ) ; } } return sa ; } if ( dataType == DataType . OPAQUE ) { Array opArray = Array . factory ( DataType . OPAQUE , shape ) ; assert ( new Section ( shape ) . computeSize ( ) == layout . getTotalNelems ( ) ) ; int count = 0 ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; if ( chunk == null ) continue ; int recsize = layout . getElemSize ( ) ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) { byte [ ] pa = new byte [ recsize ] ; raf . seek ( chunk . getSrcPos ( ) + i * recsize ) ; raf . readFully ( pa , 0 , recsize ) ; opArray . setObject ( count ++ , ByteBuffer . wrap ( pa ) ) ; } } return opArray ; } // normal case
return IospHelper . readDataFill ( raf , layout , dataType , fillValue , endian , convertChar ) ;


signature:
public class H5iosp { /** * old way */
private StructureData readStructure ( Structure s , ArrayStructureW asw , long dataPos ) throws IOException , InvalidRangeException { } }

implementation: StructureDataW sdata = new StructureDataW ( asw . getStructureMembers ( ) ) ; if ( debug ) System . out . println ( " readStructure " + s . getFullName ( ) + " dataPos = " + dataPos ) ; for ( Variable v2 : s . getVariables ( ) ) { H5header . Vinfo vinfo = ( H5header . Vinfo ) v2 . getSPobject ( ) ; if ( debug ) System . out . println ( " readStructureMember " + v2 . getFullName ( ) + " vinfo = " + vinfo ) ; Array dataArray = readData ( v2 , dataPos + vinfo . dataPos , v2 . getShapeAsSection ( ) ) ; sdata . setMemberData ( v2 . getShortName ( ) , dataArray ) ; } return sdata ;


signature:
public class ADASConvention { /** * create a NetcdfDataset out of this NetcdfFile , adding coordinates etc . */
public void augmentDataset ( NetcdfDataset ds , CancelTask cancelTask ) throws IOException { } }

implementation:
if ( null != ds . findVariable ( "x" ) ) return ; // check if its already been done - aggregating enhanced datasets .
// old way
Attribute att = ds . findGlobalAttribute ( "MAPPROJ" ) ; int projType = att . getNumericValue ( ) . intValue ( ) ; double lat1 = findAttributeDouble ( ds , "TRUELAT1" , Double . NaN ) ; double lat2 = findAttributeDouble ( ds , "TRUELAT2" , Double . NaN ) ; double lat_origin = lat1 ; double lon_origin = findAttributeDouble ( ds , "TRUELON" , Double . NaN ) ; double false_easting = 0.0 ; double false_northing = 0.0 ; // new way
String projName = ds . findAttValueIgnoreCase ( null , CF . GRID_MAPPING_NAME , null ) ; if ( projName != null ) { projName = projName . trim ( ) ; lat_origin = findAttributeDouble ( ds , "latitude_of_projection_origin" , Double . NaN ) ; lon_origin = findAttributeDouble ( ds , "longitude_of_central_meridian" , Double . NaN ) ; false_easting = findAttributeDouble ( ds , "false_easting" , 0.0 ) ; false_northing = findAttributeDouble ( ds , "false_northing" , 0.0 ) ; Attribute att2 = ds . findGlobalAttributeIgnoreCase ( "standard_parallel" ) ; if ( att2 != null ) { lat1 = att2 . getNumericValue ( ) . doubleValue ( ) ; lat2 = ( att2 . getLength ( ) > 1 ) ? att2 . getNumericValue ( 1 ) . doubleValue ( ) : lat1 ; } } else { if ( projType == 2 ) projName = "lambert_conformal_conic" ; } Variable coord_var = ds . findVariable ( "x_stag" ) ; if ( ! Double . isNaN ( false_easting ) || ! Double . isNaN ( false_northing ) ) { String units = ds . findAttValueIgnoreCase ( coord_var , CDM . UNITS , null ) ; double scalef = 1.0 ; try { scalef = SimpleUnit . getConversionFactor ( units , "km" ) ; } catch ( IllegalArgumentException e ) { log . error ( units + " not convertible to km" ) ; } false_easting *= scalef ; false_northing *= scalef ; } ProjectionImpl proj ; if ( ( projName != null ) && projName . equalsIgnoreCase ( "lambert_conformal_conic" ) ) { proj = new LambertConformal ( lat_origin , lon_origin , lat1 , lat2 , false_easting , false_northing ) ; projCT = new ProjectionCT ( "Projection" , "FGDC" , proj ) ; if ( false_easting == 0.0 ) calcCenterPoints ( ds , proj ) ; // old way
} else { parseInfo . format ( "ERROR: unknown projection type = %s%n" , projName ) ; } if ( debugProj && ( proj != null ) ) { System . out . println ( " using LC " + proj . paramsToString ( ) ) ; double lat_check = findAttributeDouble ( ds , "CTRLAT" , Double . NaN ) ; double lon_check = findAttributeDouble ( ds , "CTRLON" , Double . NaN ) ; LatLonPointImpl lpt0 = new LatLonPointImpl ( lat_check , lon_check ) ; ProjectionPoint ppt0 = proj . latLonToProj ( lpt0 , new ProjectionPointImpl ( ) ) ; System . out . println ( "CTR lpt0= " + lpt0 + " ppt0=" + ppt0 ) ; Variable xstag = ds . findVariable ( "x_stag" ) ; ArrayFloat . D1 xstagData = ( ArrayFloat . D1 ) xstag . read ( ) ; float center_x = xstagData . get ( ( int ) xstag . getSize ( ) - 1 ) ; Variable ystag = ds . findVariable ( "y_stag" ) ; ArrayFloat . D1 ystagData = ( ArrayFloat . D1 ) ystag . read ( ) ; float center_y = ystagData . get ( ( int ) ystag . getSize ( ) - 1 ) ; System . out . println ( "CTR should be x,y= " + center_x / 2000 + ", " + center_y / 2000 ) ; lpt0 = new LatLonPointImpl ( lat_origin , lon_origin ) ; ppt0 = proj . latLonToProj ( lpt0 , new ProjectionPointImpl ( ) ) ; System . out . println ( "ORIGIN lpt0= " + lpt0 + " ppt0=" + ppt0 ) ; lpt0 = new LatLonPointImpl ( lat_origin , lon_origin ) ; ppt0 = proj . latLonToProj ( lpt0 , new ProjectionPointImpl ( ) ) ; System . out . println ( "TRUE ORIGIN lpt0= " + lpt0 + " ppt0=" + ppt0 ) ; } if ( projCT != null ) { VariableDS v = makeCoordinateTransformVariable ( ds , projCT ) ; v . addAttribute ( new Attribute ( _Coordinate . AxisTypes , "GeoX GeoY" ) ) ; ds . addVariable ( null , v ) ; } if ( ds . findVariable ( "x_stag" ) != null ) ds . addCoordinateAxis ( makeCoordAxis ( ds , "x" ) ) ; if ( ds . findVariable ( "y_stag" ) != null ) ds . addCoordinateAxis ( makeCoordAxis ( ds , "y" ) ) ; if ( ds . findVariable ( "z_stag" ) != null ) ds . addCoordinateAxis ( makeCoordAxis ( ds , "z" ) ) ; Variable zsoil = ds . findVariable ( "ZPSOIL" ) ; if ( zsoil != null ) zsoil . addAttribute ( new Attribute ( _Coordinate . AxisType , AxisType . GeoZ . toString ( ) ) ) ; ds . finish ( ) ;


signature:
public class ADASConvention { /** * old */
private void calcCenterPoints ( NetcdfDataset ds , Projection proj ) throws IOException { } }

implementation: double lat_check = findAttributeDouble ( ds , "CTRLAT" , Double . NaN ) ; double lon_check = findAttributeDouble ( ds , "CTRLON" , Double . NaN ) ; LatLonPointImpl lpt0 = new LatLonPointImpl ( lat_check , lon_check ) ; ProjectionPoint ppt0 = proj . latLonToProj ( lpt0 , new ProjectionPointImpl ( ) ) ; System . out . println ( "CTR lpt0= " + lpt0 + " ppt0=" + ppt0 ) ; Variable xstag = ds . findVariable ( "x_stag" ) ; int nxpts = ( int ) xstag . getSize ( ) ; ArrayFloat . D1 xstagData = ( ArrayFloat . D1 ) xstag . read ( ) ; float center_x = xstagData . get ( nxpts - 1 ) ; double false_easting = center_x / 2000 - ppt0 . getX ( ) * 1000.0 ; System . out . println ( "false_easting= " + false_easting ) ; Variable ystag = ds . findVariable ( "y_stag" ) ; int nypts = ( int ) ystag . getSize ( ) ; ArrayFloat . D1 ystagData = ( ArrayFloat . D1 ) ystag . read ( ) ; float center_y = ystagData . get ( nypts - 1 ) ; double false_northing = center_y / 2000 - ppt0 . getY ( ) * 1000.0 ; System . out . println ( "false_northing= " + false_northing ) ; double dx = findAttributeDouble ( ds , "DX" , Double . NaN ) ; double dy = findAttributeDouble ( ds , "DY" , Double . NaN ) ; double w = dx * ( nxpts - 1 ) ; double h = dy * ( nypts - 1 ) ; double startx = ppt0 . getX ( ) * 1000.0 - w / 2 ; double starty = ppt0 . getY ( ) * 1000.0 - h / 2 ; xstag . setValues ( nxpts , startx , dx ) ; ystag . setValues ( nypts , starty , dy ) ;


signature: public class ADASConvention { private CoordinateAxis makeCoordAxis ( NetcdfDataset ds , String axisName ) throws IOException { } }

implementation: Variable stagV = ds . findVariable ( axisName + "_stag" ) ; Array data_stag = stagV . read ( ) ; int n = ( int ) data_stag . getSize ( ) - 1 ; DataType dt = DataType . getType ( data_stag ) ; Array data = Array . factory ( dt , new int [ ] { n } ) ; Index stagIndex = data_stag . getIndex ( ) ; Index dataIndex = data . getIndex ( ) ; for ( int i = 0 ; i < n ; i ++ ) { double val = data_stag . getDouble ( stagIndex . set ( i ) ) + data_stag . getDouble ( stagIndex . set ( i + 1 ) ) ; data . setDouble ( dataIndex . set ( i ) , 0.5 * val ) ; } DataType dtype = DataType . getType ( data ) ; String units = ds . findAttValueIgnoreCase ( stagV , CDM . UNITS , "m" ) ; CoordinateAxis v = new CoordinateAxis1D ( ds , null , axisName , dtype , axisName , units , "synthesized non-staggered " + axisName + " coordinate" ) ; v . setCachedData ( data , true ) ; return v ;


signature:
public class CEAST { /** * Sort specific */
public void addSegment ( CEAST segment ) { } }

implementation: assert sort == Sort . SEGMENT ; if ( subnodes == null ) subnodes = new NodeList ( ) ; subnodes . add ( segment ) ;


signature:
public class ProjectionManager { /** * testing 1-2-3 */
public static void main ( String [ ] args ) { } }

implementation: ProjectionManager d = new ProjectionManager ( null , null ) ; d . setVisible ( ) ;


signature:
public class KMPMatch { /** * Finds the first occurrence of match in data .
 * @ param data search in this byte block
 * @ param start start at data [ start ]
 * @ param max end at data [ start + max ]
 * @ return index into data [ ] of first match , else - 1 if not found . */
public int indexOf ( byte [ ] data , int start , int max ) { } }

implementation: int j = 0 ; if ( data . length == 0 ) return - 1 ; if ( start + max > data . length ) System . out . println ( "HEY KMPMatch" ) ; for ( int i = start ; i < start + max ; i ++ ) { while ( j > 0 && match [ j ] != data [ i ] ) j = failure [ j - 1 ] ; if ( match [ j ] == data [ i ] ) j ++ ; if ( j == match . length ) return i - match . length + 1 ; } return - 1 ;


signature:
public class KMPMatch { /** * Finds the first occurrence of match in data .
 * @ param data search in this byte block
 * @ param start start at data [ start ]
 * @ param max end at data [ start + max ]
 * @ return index into block of first match , else - 1 if not found .
 * public int scan ( InputStream is , int start , int max ) {
 * int j = 0;
 * if ( data . length = = 0 ) return - 1;
 * for ( int i = start ; i < start + max ; i + + ) {
 * while ( j > 0 & & match [ j ] ! = data [ i ] )
 * j = failure [ j - 1 ] ;
 * if ( match [ j ] = = data [ i ] )
 * if ( j = = match . length )
 * return i - match . length + 1;
 * return - 1; */
private int [ ] computeFailure ( byte [ ] match ) { } }

implementation: int [ ] result = new int [ match . length ] ; int j = 0 ; for ( int i = 1 ; i < match . length ; i ++ ) { while ( j > 0 && match [ j ] != match [ i ] ) j = result [ j - 1 ] ; if ( match [ j ] == match [ i ] ) j ++ ; result [ i ] = j ; } return result ;


signature: public class NidsRadialAdapter { public Object isMine ( FeatureType wantFeatureType , NetcdfDataset ncd , Formatter errlog ) throws IOException { } }

implementation: String convention = ncd . findAttValueIgnoreCase ( null , "Conventions" , null ) ; if ( ( null != convention ) && convention . equals ( _Coordinate . Convention ) ) { String format = ncd . findAttValueIgnoreCase ( null , "Format" , null ) ; if ( format != null && format . equals ( "Level3/NIDS" ) ) return this ; } return null ;


signature:
public class PictureCache { /** * this method removes the least popular picture ( s ) in the cache .
 * It first removes those pictures which have been suggested for
 * removal . And then it picks any it can find
 * As many pictures are removed as nescessary untill there are less pictures in the
 * cache than the Settings . maxCache specifies . ( If maxCache is 0 then the
 * Enumeration finds no elements and we don ' t get an endless loop . */
public static synchronized void removeLeastPopular ( ) { } }

implementation:
Tools . log ( "PictureCache.removeLeastPopular:" ) ; // reportCache ( ) ;
Enumeration e = removalQueue . elements ( ) ; while ( ( e . hasMoreElements ( ) ) && ( pictureCache . size ( ) >= maxCache ) ) { String removeElement = ( String ) e . nextElement ( ) ; Tools . log ( "PictureCache.remove: " + removeElement ) ; pictureCache . remove ( removeElement ) ; removalQueue . remove ( removeElement ) ; } e = pictureCache . keys ( ) ; while ( ( pictureCache . size ( ) >= maxCache ) && ( e . hasMoreElements ( ) ) ) { String removeElement = ( String ) e . nextElement ( ) ; Tools . log ( "PictureCache.remove: " + removeElement ) ; pictureCache . remove ( removeElement ) ; }


signature:
public class PictureCache { /** * store an image in the cache
 * @ param urlThe URL of the picture
 * @ param spThe picture to be stored */
public static synchronized void add ( URL url , SourcePicture sp ) { } }

implementation: Tools . log ( "PictureCache.add: " + url . toString ( ) ) ; if ( sp . getSourceBufferedImage ( ) == null ) { Tools . log ( "PictureCache.add: invoked with a null picture! Not cached!" ) ; return ; } if ( ( maxCache < 1 ) ) { Tools . log ( "PictureCache.add: cache is diabled. Not adding picture." ) ; return ; } if ( isInCache ( url ) ) { Tools . log ( "Picture " + url . toString ( ) + " is already in the cache. Not adding again." ) ; return ; } if ( pictureCache . size ( ) >= maxCache ) removeLeastPopular ( ) ; if ( pictureCache . size ( ) < maxCache ) pictureCache . put ( url . toString ( ) , sp ) ; // reportCache ( ) ;


signature:
public class PictureCache { /** * method to inspect the cache */
public static synchronized void reportCache ( ) { } }

implementation:
Tools . log ( "   PictureCache.reportCache: cache contains: " + Integer . toString ( pictureCache . size ( ) ) + " max: " + Integer . toString ( maxCache ) ) ; // Tools . freeMem ( ) ;
Enumeration e = pictureCache . keys ( ) ; while ( e . hasMoreElements ( ) ) { Tools . log ( "   Cache contains: " + ( ( String ) e . nextElement ( ) ) ) ; } Tools . log ( "  End of cache contents" ) ;


signature:
public class PictureCache { /** * method to stop all background loading */
public static void stopBackgroundLoading ( ) { } }

implementation: Enumeration e = cacheLoadsInProgress . elements ( ) ; while ( e . hasMoreElements ( ) ) { ( ( SourcePicture ) e . nextElement ( ) ) . stopLoading ( ) ; }


signature:
public class PictureCache { /** * method to stop all background loading except the indicated file . Returns whether the
 * image is already being loaded . True = loading in progress , False = not in progress . */
public static boolean stopBackgroundLoadingExcept ( URL exemptionURL ) { } }

implementation: SourcePicture sp ; String exemptionURLString = exemptionURL . toString ( ) ; Enumeration e = cacheLoadsInProgress . elements ( ) ; boolean inProgress = false ; while ( e . hasMoreElements ( ) ) { sp = ( ( SourcePicture ) e . nextElement ( ) ) ; if ( ! sp . getUrlString ( ) . equals ( exemptionURLString ) ) sp . stopLoading ( ) ; else { Tools . log ( "PictureCache.stopBackgroundLoading: picture was already loading" ) ; inProgress = true ; } } return inProgress ;


signature:
public class HidableTableColumnModel { /** * listeners will receive columnAdded ( ) / columnRemoved ( ) event */
public void setColumnVisible ( TableColumn column , boolean visible ) { } }

implementation:
if ( isColumnVisible ( column ) == visible ) { return ; // Visibility status did not change .
} if ( ! visible ) { super . removeColumn ( column ) ; } else { // find the visible index of the column :
// iterate through both collections of visible and all columns , counting
// visible columns up to the one that ' s about to be shown again
int noVisibleColumns = tableColumns . size ( ) ; int noInvisibleColumns = allTableColumns . size ( ) ; int visibleIndex = 0 ; for ( int invisibleIndex = 0 ; invisibleIndex < noInvisibleColumns ; ++ invisibleIndex ) { TableColumn visibleColumn = ( visibleIndex < noVisibleColumns ? tableColumns . get ( visibleIndex ) : null ) ; TableColumn testColumn = allTableColumns . get ( invisibleIndex ) ; if ( testColumn == column ) { if ( visibleColumn != column ) { super . addColumn ( column ) ; super . moveColumn ( tableColumns . size ( ) - 1 , visibleIndex ) ; } return ; } if ( testColumn == visibleColumn ) { ++ visibleIndex ; } } }


signature:
public class HidableTableColumnModel { /** * Removes < code > column < / code > from this column model .
 * Posts < code > columnRemoved < / code > event .
 * Will do nothing if the column is not in this model .
 * @ param column the column to be added
 * @ see # addColumn */
@ Override public void removeColumn ( TableColumn column ) { } }

implementation: int allColumnsIndex = allTableColumns . indexOf ( column ) ; if ( allColumnsIndex != - 1 ) { allTableColumns . removeElementAt ( allColumnsIndex ) ; } super . removeColumn ( column ) ;


signature:
public class HidableTableColumnModel { /** * Moves the column from < code > oldIndex < / code > to < code > newIndex < / code > .
 * Posts < code > columnMoved < / code > event .
 * Will not move any columns if < code > oldIndex < / code > equals < code > newIndex < / code > .
 * @ throws IllegalArgumentException if either < code > oldIndex < / code > or
 * < code > newIndex < / code >
 * are not in [ 0 , getColumnCount ( ) - 1]
 * @ param oldIndex index of column to be moved
 * @ param newIndex new index of the column */
@ Override public void moveColumn ( int oldIndex , int newIndex ) { } }

implementation: if ( ( oldIndex < 0 ) || ( oldIndex >= getColumnCount ( ) ) || ( newIndex < 0 ) || ( newIndex >= getColumnCount ( ) ) ) throw new IllegalArgumentException ( "moveColumn() - Index out of range" ) ; TableColumn fromColumn = tableColumns . get ( oldIndex ) ; TableColumn toColumn = tableColumns . get ( newIndex ) ; int allColumnsOldIndex = allTableColumns . indexOf ( fromColumn ) ; int allColumnsNewIndex = allTableColumns . indexOf ( toColumn ) ; if ( oldIndex != newIndex ) { allTableColumns . removeElementAt ( allColumnsOldIndex ) ; allTableColumns . insertElementAt ( fromColumn , allColumnsNewIndex ) ; } super . moveColumn ( oldIndex , newIndex ) ;


signature:
public class HidableTableColumnModel { /** * Returns an < code > Enumeration < / code > of all the columns in the model .
 * @ param onlyVisible if set all invisible columns will be missing from the enumeration .
 * @ return an < code > Enumeration < / code > of the columns in the model */
public Enumeration < TableColumn > getColumns ( boolean onlyVisible ) { } }

implementation: Vector columns = ( onlyVisible ? tableColumns : allTableColumns ) ; return columns . elements ( ) ;


signature:
public class HidableTableColumnModel { /** * Returns the < code > TableColumn < / code > object for the column
 * at < code > columnIndex < / code > .
 * @ param columnIndex the index of the column desired
 * @ param onlyVisible if set columnIndex is meant to be relative to all visible columns only
 * else it is the index in all columns
 * @ return the < code > TableColumn < / code > object for the column
 * at < code > columnIndex < / code > */
public TableColumn getColumn ( int columnIndex , boolean onlyVisible ) { } }

implementation: if ( onlyVisible ) { return tableColumns . elementAt ( columnIndex ) ; } else { return allTableColumns . elementAt ( columnIndex ) ; }


signature:
public class HidableTableColumnModel { /** * Adapted from JTable . createDefaultColumnsFromModel ( ) . */
public void createColumnsFromModel ( TableModel newModel ) { } }

implementation:
if ( newModel != model ) { if ( model != null ) { model . removeTableModelListener ( this ) ; // Stop listening to old model .
} newModel . addTableModelListener ( this ) ; // Start listening to new one .
model = newModel ; } // Removes all current columns including the hidden ones .
// For visible columns that are removed , TableColumnModelEvents get fired .
while ( ! allTableColumns . isEmpty ( ) ) { removeColumn ( allTableColumns . elementAt ( 0 ) ) ; } // Create new columns from the data model info
for ( int modelColumnIndex = 0 ; modelColumnIndex < newModel . getColumnCount ( ) ; modelColumnIndex ++ ) { TableColumn newColumn = new TableColumn ( modelColumnIndex ) ; String columnName = newModel . getColumnName ( modelColumnIndex ) ; newColumn . setHeaderValue ( columnName ) ; addColumn ( newColumn ) ; }


signature:
public class HTTPFactory { /** * Static factory methods for creating HTTPMethod instances */
static public HTTPMethod Get ( HTTPSession session , String legalurl ) throws HTTPException { } }

implementation: return makemethod ( HTTPSession . Methods . Get , session , legalurl ) ;


signature:
public class HTTPFactory { /** * Common method creation code so we can isolate mocking
 * @ param session
 * @ return
 * @ throws HTTPException */
static protected HTTPMethod makemethod ( HTTPSession . Methods m , HTTPSession session , String url ) throws HTTPException { } }

implementation:
HTTPMethod meth = null ; if ( MOCKMETHODCLASS == null ) { // do the normal case
meth = new HTTPMethod ( m , session , url ) ; } else { // ( MOCKMETHODCLASS ! = null )
java . lang . Class methodcl = MOCKMETHODCLASS ; Constructor < HTTPMethod > cons = null ; try { cons = methodcl . getConstructor ( HTTPSession . Methods . class , HTTPSession . class , String . class ) ; } catch ( Exception e ) { throw new HTTPException ( "HTTPFactory: no proper HTTPMethod constructor available" , e ) ; } try { meth = cons . newInstance ( m , session , url ) ; } catch ( Exception e ) { throw new HTTPException ( "HTTPFactory: HTTPMethod constructor failed" , e ) ; } } return meth ;


signature: public class H5diag { public void deflate ( Formatter f , Variable v ) throws IOException { } }

implementation: H5header . Vinfo vinfo = ( H5header . Vinfo ) v . getSPobject ( ) ; DataBTree btree = vinfo . btree ; if ( btree == null || vinfo . useFillValue ) { f . format ( "%s not chunked%n" , v . getShortName ( ) ) ; return ; }


signature:
public class Grib1PartitionBuilderFromIndex { /** * extend Variable {
 * repeated PartitionVariable partition = 100;
 * repeated Parameter vparams = 101 ; / / not used yet */
@ Override protected GribCollectionMutable . VariableIndex readVariableExtensions ( GribCollectionMutable . GroupGC group , GribCollectionProto . Variable proto , GribCollectionMutable . VariableIndex vi ) { } }

implementation:
List < GribCollectionProto . PartitionVariable > pvList = proto . getPartVariableList ( ) ; PartitionCollectionMutable . VariableIndexPartitioned vip = pc . makeVariableIndexPartitioned ( group , vi , pvList . size ( ) ) ; vip . setPartitions ( pvList ) ; // cant put this in the constructor
vip . ndups = vi . ndups ; vip . nrecords = vi . nrecords ; vip . nmissing = vi . nmissing ; return vip ;


signature:
public class Grib1PartitionBuilderFromIndex { /** * message Partition {
 * required string name = 1 ; / / name is used in TDS - eg the subdirectory when generated by TimePartitionCollections
 * required string filename = 2 ; / / the gribCollection . ncx2 file
 * required string directory = 3 ; / / top directory
 * optional uint64 lastModified = 4; */
private PartitionCollectionMutable . Partition makePartition ( GribCollectionProto . Partition proto ) { } }

implementation: long partitionDateMillisecs = proto . getPartitionDate ( ) ; CalendarDate partitionDate = partitionDateMillisecs > 0 ? CalendarDate . of ( partitionDateMillisecs ) : null ; return pc . addPartition ( proto . getName ( ) , proto . getFilename ( ) , proto . getLastModified ( ) , proto . getLength ( ) , null , partitionDate ) ;


signature:
public class RandomValue { /** * return an integer type value ( including long , but not floats ) */
public Object nextInteger ( DapType basetype ) throws DapException { } }

implementation: TypeSort atomtype = basetype . getTypeSort ( ) ; if ( ! atomtype . isIntegerType ( ) ) throw new DapException ( "Unexpected type: " + basetype ) ; boolean unsigned = atomtype . isUnsigned ( ) ; switch ( atomtype ) { case Int8 : return new byte [ ] { ( byte ) ( random . nextInt ( 1 << 8 ) - ( 1 << 7 ) ) } ; case UInt8 : return new byte [ ] { ( byte ) ( random . nextInt ( 1 << 8 ) & 0xFF ) } ; case Int16 : return new short [ ] { ( short ) ( random . nextInt ( 1 << 16 ) - ( 1 << 15 ) ) } ; case UInt16 : return new short [ ] { ( short ) ( random . nextInt ( 1 << 16 ) ) } ; case Int32 : return new int [ ] { random . nextInt ( ) } ; case UInt32 : long l = random . nextLong ( ) ; l = l & 0xFFFFFFFF ; return new int [ ] { ( int ) l } ; case Int64 : return new long [ ] { random . nextLong ( ) } ; case UInt64 : return new long [ ] { new BigInteger ( 64 , random ) . longValue ( ) } ; } throw new DapException ( "Unexpected type: " + basetype ) ;


signature:
public class RandomValue { /** * return a float type value */
public Object nextFloat ( DapType basetype ) throws DapException { } }

implementation: TypeSort atomtype = basetype . getTypeSort ( ) ; switch ( atomtype ) { case Float32 : return new float [ ] { random . nextFloat ( ) } ; case Float64 : return new double [ ] { random . nextDouble ( ) } ; default : break ; } throw new DapException ( "Unexpected type: " + basetype ) ;


signature:
public class RandomValue { /** * Return an integer in range 1 . . max inclusive .
 * @ param max
 * @ return random integer in range
 * @ throws DapException */
public int nextCount ( int max ) throws DapException { } }

implementation:
int min = 1 ; if ( max < min || min < 1 ) throw new DapException ( "bad range" ) ; int range = ( max + 1 ) - min ; // min . . max + 1 - > 0 . . ( max + 1 ) - min
int n = random . nextInt ( range ) ; // 0 . . ( max + 1 ) - min
n = n + min ; // min . . ( max + 1)
if ( DEBUG ) System . err . println ( "RandomValue.nextCount: " + n ) ; return n ;


signature:
public class DapNetcdfFile { /** * Close all resources ( files , sockets , etc ) associated with this file .
 * @ throws java . io . IOException if error when closing */
@ Override public synchronized void close ( ) throws java . io . IOException { } }

implementation:
if ( closed ) return ; closed = true ; // avoid circular calls
dsp = null ; // nodemap = null ; unused ?


signature:
public class DapNetcdfFile { /** * Do a bulk read on a list of Variables and
 * return a corresponding list of Array that contains the results
 * of a full read on each Variable .
 * TODO : optimize to make only a single server call and cache the results .
 * @ param variables List of type Variable
 * @ return List of Array , one for each Variable in the input .
 * @ throws IOException if read error */
@ Override public List < Array > readArrays ( List < Variable > variables ) throws IOException { } }

implementation: List < Array > result = new ArrayList < Array > ( ) ; for ( Variable variable : variables ) { result . add ( variable . read ( ) ) ; } return result ;


signature:
public class DapNetcdfFile { /** * Primary read entry point .
 * This is the primary implementor of Variable . read .
 * @ param cdmvar A top - level variable
 * @ param section the section of databuffer to read .
 * There must be a Range for each Dimension in the variable ,
 * in order . Note : no nulls allowed .
 * @ return An Array object for accessing the databuffer
 * @ throws IOException if read error
 * @ throws InvalidRangeException if invalid section */
@ Override protected Array readData ( Variable cdmvar , Section section ) throws IOException , InvalidRangeException { } }

implementation:
// The section is applied wrt to the DataDMR , so it
// takes into account any constraint used in forming the dataDMR .
// We use the Section to produce a view of the underlying variable array .
assert this . dsp != null ; Array result = arraymap . get ( cdmvar ) ; if ( result == null ) throw new IOException ( "No data for variable: " + cdmvar . getFullName ( ) ) ; if ( section != null ) { if ( cdmvar . getRank ( ) != section . getRank ( ) ) throw new InvalidRangeException ( String . format ( "Section rank != %s rank" , cdmvar . getFullName ( ) ) ) ; List < Range > ranges = section . getRanges ( ) ; // Case out the possibilities
if ( CDMUtil . hasVLEN ( ranges ) ) { ranges = ranges . subList ( 0 , ranges . size ( ) - 1 ) ; // may produce empty list
} if ( ranges . size ( ) > 0 && ! CDMUtil . isWhole ( ranges , cdmvar ) ) result = result . sectionNoReduce ( ranges ) ; } return result ;


signature:
public class DInt32 { /** * Reads data from a < code > DataInputStream < / code > . This method is only used
 * on the client side of the OPeNDAP client / server connection .
 * @ param source a < code > DataInputStream < / code > to read from .
 * @ param sv the < code > ServerVersion < / code > returned by the server .
 * @ param statusUI the < code > StatusUI < / code > object to use for GUI updates
 * and user cancellation notification ( may be null ) .
 * @ throws EOFException if EOF is found before the variable is completely
 * deserialized .
 * @ throws IOException thrown on any other InputStream exception .
 * @ see ClientIO # deserialize ( DataInputStream , ServerVersion , StatusUI ) */
public synchronized void deserialize ( DataInputStream source , ServerVersion sv , StatusUI statusUI ) throws IOException , EOFException { } }

implementation: val = source . readInt ( ) ; if ( statusUI != null ) statusUI . incrementByteCount ( 4 ) ;


signature:
public class RadarServerConfig { /** * filesystem can ' t be re - created either . */
private static FileSystemProvider getProvider ( URI uri ) throws IOException { } }

implementation: if ( fsproviders . containsKey ( uri . getScheme ( ) ) ) { return fsproviders . get ( uri . getScheme ( ) ) ; } else { FileSystem fs ; try { fs = FileSystems . newFileSystem ( uri , new HashMap < String , Object > ( ) , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; } catch ( FileSystemAlreadyExistsException e ) { fs = FileSystems . getFileSystem ( uri ) ; } fsproviders . put ( uri . getScheme ( ) , fs . provider ( ) ) ; return fs . provider ( ) ; }


signature:
public class NexradStationDB { /** * this is the old Gempak table , not as precise */
private static void readStationTable ( ) throws IOException { } }

implementation: stationTableHash = new HashMap < String , Station > ( ) ; ClassLoader cl = Level2VolumeScan . class . getClassLoader ( ) ; InputStream is = cl . getResourceAsStream ( "resources/nj22/tables/nexrad.tbl" ) ; List < TableParser . Record > recs = TableParser . readTable ( is , "3,15,46, 54,60d,67d,73d" , 50000 ) ; for ( TableParser . Record record : recs ) { Station s = new Station ( ) ; s . id = "K" + record . get ( 0 ) ; s . name = record . get ( 2 ) + " " + record . get ( 3 ) ; s . lat = ( Double ) record . get ( 4 ) * .01 ; s . lon = ( Double ) record . get ( 5 ) * .01 ; s . elev = ( Double ) record . get ( 6 ) ; stationTableHash . put ( s . id , s ) ; if ( showStations ) System . out . println ( " station= " + s ) ; }


signature: public class Ghcnm { static private int parseLine ( String line ) throws IOException { } }

implementation: int balony = 0 ; Matcher matcher = dataPattern . matcher ( line ) ; if ( matcher . matches ( ) ) { for ( int i = 1 ; i <= matcher . groupCount ( ) ; i ++ ) { String r = matcher . group ( i ) ; if ( r == null ) continue ; int value = ( int ) Long . parseLong ( r . trim ( ) ) ; balony += value ; } } else { System . out . printf ( "Fail on %s%n" , line ) ; } return balony ;


signature:
public class Ghcnm { /** * debug */
static private NetcdfFile open ( String filename ) throws IOException { } }

implementation: Ghcnm iosp = new Ghcnm ( ) ; RandomAccessFile raf = new RandomAccessFile ( filename , "r" ) ; NetcdfFile ncfile = new NetcdfFileSubclass ( iosp , filename ) ; iosp . open ( raf , ncfile , null ) ; return ncfile ;


signature:
public class VerticalTransformSubset { /** * Get the 1D vertical coordinate array for this time step and point
 * @ param timeIndex the time index . Ignored if ! isTimeDependent ( ) .
 * @ param xIndex the x index
 * @ param yIndex the y index
 * @ return vertical coordinate array
 * @ throws java . io . IOException problem reading data
 * @ throws ucar . ma2 . InvalidRangeException _ more _ */
public D1 getCoordinateArray1D ( int timeIndex , int xIndex , int yIndex ) throws IOException , InvalidRangeException { } }

implementation: ArrayDouble . D3 data = original . getCoordinateArray ( timeIndex ) ; int [ ] origin = new int [ 3 ] ; int [ ] shape = new int [ 3 ] ; shape [ 0 ] = subsetList . get ( 0 ) . length ( ) ; shape [ 1 ] = 1 ; shape [ 2 ] = 1 ; origin [ 0 ] = timeIndex ; if ( isTimeDependent ( ) && ( t_range != null ) ) { origin [ 0 ] = t_range . element ( timeIndex ) ; } origin [ 1 ] = yIndex ; origin [ 2 ] = xIndex ; Array section = data . section ( origin , shape ) ; return ( ArrayDouble . D1 ) section . reduce ( ) ;


signature:
public class CoordinateBuilderImpl { /** * Used by CoordinateND . makeSparseArray ; not used by CoordinateTime2D */
@ Override public int getIndex ( T gr ) { } }

implementation: Integer result = valMap . get ( extract ( gr ) ) ; return ( result == null ) ? 0 : result ;


signature: public class TdsMonitor { public static void main ( String args [ ] ) throws HTTPException { } }

implementation:
// prefs storage
try { String prefStore = ucar . util . prefs . XMLStore . makeStandardFilename ( ".unidata" , "TdsMonitor.xml" ) ; store = ucar . util . prefs . XMLStore . createFromFile ( prefStore , null ) ; prefs = store . getPreferences ( ) ; Debug . setStore ( prefs . node ( "Debug" ) ) ; } catch ( IOException e ) { System . out . println ( "XMLStore Creation failed " + e ) ; } // initializations
BAMutil . setResourcePath ( "/resources/nj22/ui/icons/" ) ; // put UI in a JFrame
frame = new JFrame ( "TDS Monitor" ) ; ui = new TdsMonitor ( prefs , frame ) ; frame . setIconImage ( BAMutil . getImage ( "netcdfUI" ) ) ; frame . addWindowListener ( new WindowAdapter ( ) { public void windowClosing ( WindowEvent e ) { if ( ! done ) ui . exit ( ) ; } } ) ; frame . getContentPane ( ) . add ( ui ) ; Rectangle bounds = ( Rectangle ) prefs . getBean ( FRAME_SIZE , new Rectangle ( 50 , 50 , 800 , 450 ) ) ; frame . setBounds ( bounds ) ; frame . pack ( ) ; frame . setBounds ( bounds ) ; frame . setVisible ( true ) ;


signature:
public class TypedDatasetImpl { /** * reminder for subclasses to set this */
protected void removeDataVariable ( String varName ) { } }

implementation: Iterator iter = dataVariables . iterator ( ) ; while ( iter . hasNext ( ) ) { VariableSimpleIF v = ( VariableSimpleIF ) iter . next ( ) ; if ( v . getShortName ( ) . equals ( varName ) ) iter . remove ( ) ; }


signature:
public class MetarParseReport { /** * convert cloud height to meters */
private String cloud_hgt2_meters ( String height ) { } }

implementation:
if ( height . equals ( "999" ) ) { return "30000" ; } else { // $ meters = 30 * $ height ;
return Integer . toString ( 30 * Integer . parseInt ( height ) ) ; }


signature:
public class BufrTableBViewer { /** * Class , FXY , enElementName , BUFR _ Unit , BUFR _ Scale , BUFR _ ReferenceValue , BUFR _ DataWidth _ Bits , CREX _ Unit , CREX _ Scale , CREX _ DataWidth
 * 20,20009 , General weather indicator ( TAF / METAR ) , Code table , 0,0,4 , Code table , 0,2 */
private void writeDiff ( TableB wmo , TableB t , Formatter out ) { } }

implementation:
out . format ( "#%n# BUFR diff written from %s against %s %n#%n" , t . getName ( ) , wmo . getName ( ) ) ; out . format ( "Class,FXY,enElementName,BUFR_Unit,BUFR_Scale,BUFR_ReferenceValue,BUFR_DataWidth_Bits%n" ) ; List < TableB . Descriptor > listDesc = new ArrayList < > ( t . getDescriptors ( ) ) ; Collections . sort ( listDesc ) ; for ( TableB . Descriptor d1 : listDesc ) { TableB . Descriptor d2 = wmo . getDescriptor ( d1 . getId ( ) ) ; if ( ( d2 == null ) || ( d1 . getScale ( ) != d2 . getScale ( ) ) || ( d1 . getRefVal ( ) != d2 . getRefVal ( ) ) || ( d1 . getDataWidth ( ) != d2 . getDataWidth ( ) ) ) { short fxy = d1 . getId ( ) ; // int f = ( fxy & 0xC000 ) > > 14;
int x = ( fxy & 0x3F00 ) >> 8 ; int y = fxy & 0xFF ; out . format ( "%d,%2d%03d,\"%s\",%s,%d,%d,%d%n" , x , x , y , d1 . getName ( ) , d1 . getUnits ( ) , d1 . getScale ( ) , d1 . getRefVal ( ) , d1 . getDataWidth ( ) ) ; } } out . flush ( ) ;


signature:
public class ProxyReader2D { /** * here is where agg variables get read */
@ Override public Array reallyRead ( Variable mainv , Section section , CancelTask cancelTask ) throws IOException , InvalidRangeException { } }

implementation:
FmrcInvLite . Gridset . Grid gridLite = ( FmrcInvLite . Gridset . Grid ) mainv . getSPobject ( ) ; // read the original type - if its been promoted to a new type , the conversion happens after this read
DataType dtype = ( mainv instanceof VariableDS ) ? ( ( VariableDS ) mainv ) . getOriginalDataType ( ) : mainv . getDataType ( ) ; Array allData = Array . factory ( dtype , section . getShape ( ) ) ; int destPos = 0 ; // assumes the first two dimensions are runtime and time : LOOK : ensemble ? ?
List < Range > ranges = section . getRanges ( ) ; Range runRange = ranges . get ( 0 ) ; Range timeRange = ranges . get ( 1 ) ; List < Range > innerSection = ranges . subList ( 2 , ranges . size ( ) ) ; // keep track of open file - must be local variable for thread safety
HashMap < String , NetcdfDataset > openFilesRead = new HashMap < > ( ) ; try { // iterate over the desired runs
for ( int runIdx : runRange ) { // Date runDate = vstate . runTimes . get ( runIdx ) ;
// iterate over the desired forecast times
for ( int timeIdx : timeRange ) { Array result = null ; // find the inventory for this grid , runtime , and hour
TimeInventory . Instance timeInv = gridLite . getInstance ( runIdx , timeIdx ) ; if ( timeInv != null ) { if ( debugRead ) System . out . printf ( "HIT %d %d " , runIdx , timeIdx ) ; result = read ( timeInv , gridLite . name , innerSection , openFilesRead ) ; // may return null
result = MAMath . convert ( result , dtype ) ; // just in case it need to be converted
} // missing data
if ( result == null ) { int [ ] shape = new Section ( innerSection ) . getShape ( ) ; result = ( ( VariableDS ) mainv ) . getMissingDataArray ( shape ) ; // fill with missing values
if ( debugRead ) System . out . printf ( "MISS %d %d " , runIdx , timeIdx ) ; } if ( debugRead ) System . out . printf ( "%d %d reallyRead %s %d bytes start at %d total size is %d%n" , runIdx , timeIdx , mainv . getFullName ( ) , result . getSize ( ) , destPos , allData . getSize ( ) ) ; Array . arraycopy ( result , 0 , allData , destPos , ( int ) result . getSize ( ) ) ; destPos += result . getSize ( ) ; } } return allData ; } finally { // close any files used during this operation
closeAll ( openFilesRead ) ; }


signature:
public class ColorScale { /** * rest of stuff for construction / deserialization */
private void constructTransient ( ) { } }

implementation: useColors = colors ; edge = new double [ ncolors ] ; hist = new int [ ncolors + 1 ] ; lm = new ListenerManager ( "java.beans.PropertyChangeListener" , "java.beans.PropertyChangeEvent" , "propertyChange" ) ; missingDataColor = Color . white ;


signature:
public class ColorScale { /** * Set the number of colors in the colorscale . */
public void setNumColors ( int n ) { } }

implementation: if ( n != ncolors ) { colors = new Color [ n ] ; int prevn = Math . min ( ncolors , n ) ; System . arraycopy ( useColors , 0 , colors , 0 , prevn ) ; for ( int i = ncolors ; i < n ; i ++ ) colors [ i ] = Color . white ; useColors = colors ; ncolors = n ; edge = new double [ ncolors ] ; hist = new int [ ncolors + 1 ] ; }


signature:
public class ColorScale { /** * / * Get the color at the given index , or the missing data color .
 * @ param i index into color array , or ncolors to get missingDataColor .
 * @ exception IllegalArgumentException if ( i < 0 ) | | ( i > ncolors ) */
public Color getColor ( int i ) { } }

implementation: if ( i >= 0 && i < ncolors ) return useColors [ i ] ; else if ( i == ncolors && hasMissingData ) return missingDataColor ; else throw new IllegalArgumentException ( "Color Scale getColor " + i ) ;


signature:
public class Float64PrimitiveVector { /** * Prints the value of all variables in this vector . This
 * method is primarily intended for debugging OPeNDAP applications and
 * text - based clients such as geturl .
 * @ param os the < code > PrintWriter < / code > on which to print the value .
 * @ param space this value is passed to the < code > printDecl < / code > method ,
 * and controls the leading spaces of the output .
 * @ see BaseType # printVal ( PrintWriter , String , boolean ) */
public void printVal ( PrintWriter os , String space ) { } }

implementation:
int len = vals . length ; for ( int i = 0 ; i < len - 1 ; i ++ ) { os . print ( vals [ i ] ) ; os . print ( ", " ) ; } // print last value , if any , without trailing comma
if ( len > 0 ) os . print ( vals [ len - 1 ] ) ;


signature:
public class Float64PrimitiveVector { /** * Writes data to a < code > DataOutputStream < / code > . This method is used
 * primarily by GUI clients which need to download OPeNDAP data , manipulate
 * it , and then re - save it as a binary file .
 * @ param sink a < code > DataOutputStream < / code > to write to .
 * @ throws IOException thrown on any < code > OutputStream < / code >
 * exception . */
public void externalize ( DataOutputStream sink ) throws IOException { } }

implementation: for ( int i = 0 ; i < vals . length ; i ++ ) { sink . writeDouble ( vals [ i ] ) ; }


signature:
public class ScaledPanel { /** * / * set the bounds of the world coordinates .
 * The point ( world . getX ( ) , world . getY ( ) ) is mapped to the lower left point of the screen .
 * The point ( world . getX ( ) + world . Width ( ) , world . getY ( ) + world . Height ( ) ) is mapped
 * to the upper right corner . Therefore if coords decrease as you go up , world . Height ( )
 * should be negetive . */
public void setWorldBounds ( ScaledPanel . Bounds world ) { } }

implementation: worldBounds . set ( world ) ; transform = null ; if ( debugBounds ) System . out . println ( "  setWorldBounds = " + worldBounds ) ;


signature:
public class ScaledPanel { /** * User must get this Graphics2D and draw into it when panel needs redrawing */
public Graphics2D getBufferedImageGraphics ( ) { } }

implementation:
if ( bImage == null ) return null ; Graphics2D g2 = bImage . createGraphics ( ) ; // set graphics attributes
if ( transform == null ) transform = calcTransform ( screenBounds , worldBounds ) ; g2 . setTransform ( transform ) ; g2 . setStroke ( new BasicStroke ( 0.0f ) ) ; // default stroke size is one pixel
g2 . setRenderingHint ( RenderingHints . KEY_RENDERING , RenderingHints . VALUE_RENDER_SPEED ) ; g2 . setBackground ( backColor ) ; g2 . setClip ( worldBounds . getRect ( ) ) ; return g2 ;


signature:
public class ScaledPanel { /** * System - triggered redraw . */
public void paintComponent ( Graphics g ) { } }

implementation: if ( bImage != null ) g . drawImage ( bImage , 0 , 0 , backColor , imageObs ) ;


signature:
public class ScaledPanel { /** * map world coords to screen coords .
 * @ param world world coordinate rectangle
 * @ param screen screen coordinate rectangle
 * @ return AffineTransform for converting world to screen . */
private AffineTransform calcTransform ( Rectangle2D screen , Bounds world ) { } }

implementation:
// scale to limiting dimension
double xs = screen . getWidth ( ) / ( world . getRight ( ) - world . getLeft ( ) ) ; double ys = screen . getHeight ( ) / ( world . getLower ( ) - world . getUpper ( ) ) ; AffineTransform cat = new AffineTransform ( ) ; cat . setToScale ( xs , ys ) ; cat . translate ( - world . getLeft ( ) , - world . getUpper ( ) ) ; if ( debugTransform ) { System . out . println ( "TPanel calcTransform = " ) ; System . out . println ( "  screen = " + screen ) ; System . out . println ( "  world = " + world ) ; System . out . println ( "  transform = " + cat . getScaleX ( ) + " " + cat . getShearX ( ) + " " + cat . getTranslateX ( ) ) ; System . out . println ( "              " + cat . getShearY ( ) + " " + cat . getScaleY ( ) + " " + cat . getTranslateY ( ) ) ; Point2D src = new Point2D . Double ( world . getLeft ( ) , world . getUpper ( ) ) ; Point2D dst = new Point2D . Double ( 0.0 , 0.0 ) ; System . out . println ( "  upper left pt = " + src ) ; System . out . println ( "  transform = " + cat . transform ( src , dst ) ) ; src = new Point2D . Double ( world . getRight ( ) , world . getLower ( ) ) ; System . out . println ( "  lower right pt = " + src ) ; System . out . println ( "  transform = " + cat . transform ( src , dst ) ) ; } return cat ;


signature:
public class HTTPAuthUtil { /** * Given a session url AuthScope and a Method url AuthScope ,
 * Indicate it the are " compatible " as defined as follows .
 * The method AuthScope is < i > compatible < / i > with the session AuthScope
 * if its host + port is the same as the session ' s host + port and its scheme is
 * compatible , where e . g . http is compatible with https .
 * The scope realm is ignored .
 * @ param ss Session AuthScope
 * @ param ms Method AuthScope
 * @ return */
static boolean authscopeCompatible ( AuthScope ss , AuthScope ms ) { } }

implementation:
assert ( ss . getScheme ( ) != null && ms . getScheme ( ) != null ) ; if ( ! ss . getHost ( ) . equalsIgnoreCase ( ms . getHost ( ) ) ) return false ; if ( ss . getPort ( ) != ms . getPort ( ) ) return false ; String sss = ss . getScheme ( ) . toLowerCase ( ) ; String mss = ms . getScheme ( ) . toLowerCase ( ) ; if ( ! sss . equals ( mss ) ) { // Do some special casing
if ( sss . endsWith ( "s" ) ) sss = sss . substring ( 0 , sss . length ( ) - 1 ) ; if ( mss . endsWith ( "s" ) ) mss = mss . substring ( 0 , mss . length ( ) - 1 ) ; if ( ! sss . equals ( mss ) ) return false ; } return true ;


signature:
public class HTTPAuthUtil { /** * Given a session url AuthScope and a Method url AuthScope ,
 * return a new AuthScope that is the upgrade / merge of the other two .
 * Here , upgrade changes the scheme ( only ) to move http - > https .
 * Assumes authscopeCompatible ( ) is true .
 * @ param ss Session authScope
 * @ param ms Method authScope
 * @ return upgraded AuthScope . */
static AuthScope authscopeUpgrade ( AuthScope ss , AuthScope ms ) { } }

implementation: assert ( HTTPAuthUtil . authscopeCompatible ( ss , ms ) ) ; String sss = ss . getScheme ( ) . toLowerCase ( ) ; String mss = ms . getScheme ( ) . toLowerCase ( ) ; String upgrade = sss ; if ( sss . startsWith ( "http" ) && mss . startsWith ( "http" ) ) { if ( sss . equals ( "https" ) || mss . equals ( "https" ) ) upgrade = "https" ; } AuthScope host = new AuthScope ( ss . getHost ( ) , ss . getPort ( ) , AuthScope . ANY_REALM , upgrade ) ; return host ;


signature:
public class HTTPAuthUtil { /** * Create an AuthScope from a URI ; remove any principal
 * @ param uri to convert
 * @ returns an AuthScope instance */
static AuthScope uriToAuthScope ( URI uri ) { } }

implementation: assert ( uri != null ) ; return new AuthScope ( uri . getHost ( ) , uri . getPort ( ) , AuthScope . ANY_REALM , uri . getScheme ( ) ) ;


signature:
public class GridIndex { /** * compares GDS for duplicates */
public void finish ( ) { } }

implementation: if ( gcs . size ( ) == 1 ) return ; if ( gcs . size ( ) == 2 ) { List hcs = getHorizCoordSys ( ) ; GridDefRecord . compare ( ( GridDefRecord ) hcs . get ( 0 ) , ( GridDefRecord ) hcs . get ( 1 ) ) ; }


signature:
public class Factor { /** * Indicates if this Factor is the reciprocal of another Factor .
 * @ param that
 * The other factor .
 * @ return < code > true < / code > if and only if this Factor is the reciprocal of
 * < code > that < / code > . */
public boolean isReciprocalOf ( final Factor that ) { } }

implementation: return getBase ( ) . equals ( that . getBase ( ) ) && getExponent ( ) == - that . getExponent ( ) ;


signature:
public class NcTVPMeasurementMetadataType { /** * wml2 : defaultPointMetadata / wml2 : DefaultTVPMeasurementMetadata */
public static TVPMeasurementMetadataType initDefaultTVPMeasurementMetadata ( TVPMeasurementMetadataType defaultTVPMeasurementMetadata , VariableSimpleIF dataVar ) { } }

implementation:
// wml2 : uom
UnitReference uom = NcUnitReference . initUom ( defaultTVPMeasurementMetadata . addNewUom ( ) , dataVar ) ; if ( uom == null ) { defaultTVPMeasurementMetadata . unsetUom ( ) ; } // wml2 : interpolationType
NcReferenceType . initInterpolationType ( defaultTVPMeasurementMetadata . addNewInterpolationType ( ) ) ; return defaultTVPMeasurementMetadata ;


signature:
public class Service { /** * See if the service Base is reletive
 * @ return true if the service Base is reletive */
public boolean isRelativeBase ( ) { } }

implementation: if ( getType ( ) == ServiceType . Compound ) return true ; try { URI uri = new java . net . URI ( base ) ; return ! uri . isAbsolute ( ) ; } catch ( java . net . URISyntaxException e ) { throw new IllegalArgumentException ( e . getMessage ( ) ) ; }


signature:
public class UsageLog { /** * Gather context information for the given HTTP request and return
 * a log message appropriate for logging at the start of the request .
 * < p > The following context information is gathered :
 * < ul >
 * < li > " ID " - an identifier for the current thread ; < / li >
 * < li > " host " - the remote host ( IP address or host name ) ; < / li >
 * < li > " userid " - the id of the remote user ; < / li >
 * < li > " startTime " - the system time in millis when this request is started ( i . e . , when this method is called ) ; and < / li >
 * < li > " request " - The HTTP request , e . g . , " GET / index . html HTTP / 1.1 " . < / li >
 * < / ul >
 * < p > Call this method at the start of each HttpServlet doXXX ( ) method
 * ( e . g . , doGet ( ) , doPut ( ) ) or Spring MVC Controller handle ( ) method .
 * @ param req the current request
 * @ return a log message appropriate for the start of the request . */
public static String setupRequestContext ( HttpServletRequest req ) { } }

implementation:
// Setup context .
// HttpSession session = req . getSession ( false ) ;
/* MDC . put ( " host " , req . getRemoteHost ( ) ) ;
 MDC . put ( " ident " , ( session = = null ) ? " - " : session . getId ( ) ) ;
 MDC . put ( " userid " , req . getRemoteUser ( ) ! = null ? req . getRemoteUser ( ) : " - " ) ; */
MDC . put ( "ID" , Long . toString ( logServerAccessId . incrementAndGet ( ) ) ) ; MDC . put ( "startTime" , Long . toString ( System . currentTimeMillis ( ) ) ) ; String query = req . getQueryString ( ) ; query = ( query != null ) ? "?" + query : "" ; Formatter request = new Formatter ( ) ; request . format ( "\"%s %s%s %s\"" , req . getMethod ( ) , req . getRequestURI ( ) , query , req . getProtocol ( ) ) ; MDC . put ( "request" , request . toString ( ) ) ; return "Remote host: " + req . getRemoteHost ( ) + " - Request: " + request . toString ( ) ;


signature:
public class UsageLog { /** * Gather context information for the current non - request thread and
 * return a log message appropriate for logging .
 * < p > The following context information is gathered :
 * < ul >
 * < li > " ID " - an identifier for the current thread ; and < / li >
 * < li > " startTime " - the system time in millis when this method is called . < / li >
 * < / ul >
 * < p > Call this method only for non - request servlet activities , e . g . ,
 * during init ( ) or destroy ( ) .
 * @ return starting log message */
public static String setupNonRequestContext ( ) { } }

implementation:
// Setup context .
MDC . put ( "ID" , Long . toString ( logServerAccessId . incrementAndGet ( ) ) ) ; MDC . put ( "startTime" , Long . toString ( System . currentTimeMillis ( ) ) ) ; return "Non-request thread opening." ;


signature:
public class DapDSR { /** * API */
public String generate ( String dataseturl ) throws IOException { } }

implementation: StringWriter sw = new StringWriter ( ) ; IndentWriter printer = new IndentWriter ( sw ) ; printer . marginPrintln ( "<DatasetServices" ) ; printer . indent ( 2 ) ; printer . marginPrintln ( "xmlns=\"http://xml.opendap.org/ns/DAP/4.0/dataset-services#\">" ) ; printer . outdent ( ) ; printer . marginPrint ( "<DapVersion>" ) ; printer . print ( DapProtocol . X_DAP_VERSION ) ; printer . println ( "</DapVersion>" ) ; printer . marginPrint ( "<ServerSoftwareVersion>" ) ; printer . print ( DapProtocol . X_DAP_SERVER ) ; printer . println ( "</ServerSoftwareVersion>" ) ; printer . marginPrintln ( "<Service title=\"DAP4 Dataset Services\"" ) ; printer . indent ( 3 ) ; printer . marginPrintln ( "role=\"http://services.opendap.org/dap4/dataset-services\">" ) ; printer . outdent ( 3 ) ; printer . indent ( ) ; printer . marginPrint ( "<link type=\"" ) ; printer . print ( DapProtocol . contenttypes . get ( RequestMode . DSR ) . contenttype ) ; printer . println ( "\"" ) ; printer . indent ( 2 ) ; printer . marginPrint ( "href=\"" ) ; printer . print ( dataseturl ) ; printer . println ( "\">" ) ; printer . outdent ( 2 ) ; printer . indent ( ) ; printer . marginPrintln ( "<alt type=\"text/xml\"/>" ) ; printer . outdent ( ) ; printer . marginPrintln ( "</link>" ) ; printer . marginPrintln ( "<link type=\"text/xml\"" ) ; printer . indent ( 2 ) ; printer . marginPrint ( "href=\"" ) ; printer . print ( dataseturl ) ; printer . println ( ".xml\"/>" ) ; printer . outdent ( 2 ) ; printer . outdent ( ) ; printer . marginPrintln ( "</Service>" ) ; printer . marginPrintln ( "<Service title=\"DAP4 Dataset Metadata\"" ) ; printer . indent ( 3 ) ; printer . marginPrintln ( "role=\"http://services.opendap.org/dap4/dataset-metadata\">" ) ; printer . outdent ( 3 ) ; printer . indent ( ) ; printer . marginPrint ( "<link type=\"" ) ; printer . print ( DapProtocol . contenttypes . get ( RequestMode . DMR ) . contenttype ) ; printer . println ( "\"" ) ; printer . indent ( 2 ) ; printer . marginPrint ( "href=\"" ) ; printer . print ( dataseturl ) ; printer . println ( ".dmr\">" ) ; printer . outdent ( 2 ) ; printer . indent ( ) ; printer . marginPrintln ( "<alt type=\"text/xml\"/>" ) ; printer . outdent ( ) ; printer . marginPrintln ( "</link>" ) ; printer . marginPrintln ( "<link type=\"text/xml\"" ) ; printer . indent ( 2 ) ; printer . marginPrint ( "href=\"" ) ; printer . print ( dataseturl ) ; printer . println ( ".dmr.xml\"/>" ) ; printer . outdent ( 2 ) ; printer . outdent ( ) ; printer . marginPrintln ( "</Service>" ) ; printer . marginPrintln ( "<Service title=\"DAP4 Dataset Data\"" ) ; printer . indent ( 2 ) ; printer . marginPrintln ( "role=\"http://services.opendap.org/dap4/data\">" ) ; printer . outdent ( 2 ) ; printer . indent ( ) ; printer . marginPrint ( "<link type=\"" ) ; printer . print ( DapProtocol . contenttypes . get ( RequestMode . DAP ) . contenttype ) ; printer . println ( "\"" ) ; printer . indent ( 2 ) ; printer . marginPrint ( "href=\"" ) ; printer . print ( dataseturl ) ; printer . println ( ".dap\"/>" ) ; printer . outdent ( 2 ) ; printer . outdent ( ) ; printer . marginPrintln ( "</Service>" ) ; printer . outdent ( ) ; printer . marginPrintln ( "</DatasetServices>" ) ; printer . flush ( ) ; printer . close ( ) ; sw . close ( ) ; return sw . toString ( ) ;


signature:
public class DirectoryScanner { /** * Return a catalog for the given directory .
 * @ param directory - the directory to represent as a catalog .
 * @ param filterPattern
 * @ param sortInIncreasingOrder
 * @ return An InvCatalog that represents the given directory of datasets .
 * @ throws NullPointerException if the given directory is null .
 * @ throws IllegalArgumentException if the given directory is not actually a directory or if it is not under the service base URL directory . */
public InvCatalog getDirCatalog ( File directory , String filterPattern , boolean sortInIncreasingOrder , boolean addDatasetSize ) { } }

implementation: return ( this . getDirCatalog ( directory , filterPattern , sortInIncreasingOrder , null , addDatasetSize , null , null , null ) ) ;


signature:
public class SmartArrayInt { /** * Find which index holds the value want
 * @ param want value wanted
 * @ return < 0 if not found , else the index . If duplicates , then return any match */
public int findIdx ( int want ) { } }

implementation:
if ( isConstant ) return ( want == start ) ? 0 : - 1 ; if ( isSequential ) return want - start ; if ( isSorted ) { return Arrays . binarySearch ( raw , want ) ; } // linear search
for ( int i = 0 ; i < raw . length ; i ++ ) if ( raw [ i ] == want ) return i ; return - 1 ;


signature:
public class CatGenConfigMetadataFactory { /** * Create an InvMetadata content object from an XML document at a named URL .
 * The content object is an ArrayList of CatalogGenConfig instances .
 * @ param dataset - the containing dataset
 * @ param urlString - the URL where the XML doc is located .
 * @ return
 * @ throws java . net . MalformedURLException if given URL is malformed .
 * @ throws java . io . IOException if problems reading from given URL */
private Object readMetadataContentFromURL ( InvDataset dataset , String urlString ) throws java . net . MalformedURLException , java . io . IOException { } }

implementation:
// @ todo This isn ' t used anywhere . Remove ?
Document doc ; try { SAXBuilder builder = new SAXBuilder ( true ) ; doc = builder . build ( urlString ) ; } catch ( JDOMException e ) { log . error ( "CatGenConfigMetadataFactory parsing error= \n" + e . getMessage ( ) ) ; throw new java . io . IOException ( "CatGenConfigMetadataFactory parsing error= " + e . getMessage ( ) ) ; } if ( showParsedXML ) { XMLOutputter xmlOut = new XMLOutputter ( Format . getPrettyFormat ( ) ) ; System . out . println ( "*** catalog/showParsedXML = \n" + xmlOut . outputString ( doc ) + "\n*******" ) ; } return ( readMetadataContentJdom ( dataset , doc . getRootElement ( ) ) ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Create an InvMetadata content object from an org . w3c . dom . Element .
 * The content object is an ArrayList of CatalogGenConfig instances .
 * @ param dataset - the containing dataset
 * @ param mdataElement - the metadata element as an org . w3c . dom . Element
 * @ return an object representing the metadata which is an ArrayList of CatalogGenConfig instances . */
public Object readMetadataContent ( InvDataset dataset , org . jdom2 . Element mdataElement ) { } }

implementation:
log . debug ( "readMetadataContent(): ." ) ; // convert to JDOM element
// Element mdataElement = builder . build ( mdataDomElement ) ;
return readMetadataContentJdom ( dataset , mdataElement ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Serialize the InvMetadata content object to a org . w3c . dom . Element
 * @ param mdataJdomElement - add content to this org . w3c . dom . Element
 * @ param contentObject - the content model */
public void addMetadataContent ( org . jdom2 . Element mdataJdomElement , Object contentObject ) { } }

implementation:
// convert to JDOM element
// Element mdataJdomElement = builder . build ( mdataElement ) ;
ArrayList catGenConfigList = ( ArrayList ) contentObject ; Iterator iter = catGenConfigList . iterator ( ) ; while ( iter . hasNext ( ) ) { CatalogGenConfig cgc = ( CatalogGenConfig ) iter . next ( ) ; mdataJdomElement . addContent ( createCatGenConfigElement ( cgc ) ) ; }


signature:
public class CatGenConfigMetadataFactory { /** * Validate the content object . */
public boolean validateMetadataContent ( Object contentObject , StringBuilder out ) { } }

implementation: boolean ok = true ; ArrayList catGenConfigList = ( ArrayList ) contentObject ; Iterator iter = catGenConfigList . iterator ( ) ; while ( iter . hasNext ( ) ) { CatalogGenConfig catGenConf = ( CatalogGenConfig ) iter . next ( ) ; ok &= catGenConf . validate ( out ) ; } return ok ;


signature:
public class CatGenConfigMetadataFactory { /** * Given a metadata JDOM element , return metadata content object
 * ( ArrayList of CatalogGenConfig ) .
 * From the given metadata JDOM element , build ( and return ) an
 * ArrayList of CatalogGenConfig instances . */
private Object readMetadataContentJdom ( InvDataset dataset , Element mdataElement ) { } }

implementation:
Namespace catGenConfigNamespace = null ; ArrayList catGenConfigList = new ArrayList ( ) ; // Get the " catalogGenConfig " children elements with
// CatalogGenConfig namespace first and then with THREDDS namespace .
Iterator iter = mdataElement . getChildren ( "catalogGenConfig" , CATALOG_GEN_CONFIG_NAMESPACE_0_5 ) . iterator ( ) ; if ( ! iter . hasNext ( ) ) iter = mdataElement . getChildren ( "catalogGenConfig" , mdataElement . getNamespace ( ) ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Element catGenConfigElement = ( Element ) iter . next ( ) ; if ( debug ) { log . debug ( "readMetadataContent=" + catGenConfigElement ) ; } catGenConfigList . add ( readCatGenConfigElement ( dataset , catGenConfigElement ) ) ; } return ( catGenConfigList ) ;


signature:
public class CatGenConfigMetadataFactory { /** * Return a CatalogGenConfig when given a ' catalogGenConfig ' JDOM element . */
private CatalogGenConfig readCatGenConfigElement ( InvDataset parentDataset , Element catGenConfElement ) { } }

implementation:
String type = catGenConfElement . getAttributeValue ( "type" ) ; CatalogGenConfig catGenConf = new CatalogGenConfig ( parentDataset , type ) ; // get any datasetSource elements
java . util . List list = catGenConfElement . getChildren ( "datasetSource" , catGenConfElement . getNamespace ( ) ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Element dsSourceElement = ( Element ) list . get ( i ) ; catGenConf . setDatasetSource ( readDatasetSourceElement ( parentDataset , dsSourceElement ) ) ; } // @ todo Start only allowing datasetSource elements in catalogGenConfig elements .
// / / get any datasetNamer elements
// list = catGenConfElement . getChildren ( " datasetNamer " , catGenConfElement . getNamespace ( ) ) ;
// for ( int i = 0 ; i < list . size ( ) ; i + + )
// Element dsNamerElement = ( Element ) list . get ( i ) ;
// catGenConf . addDatasetNamer ( readDatasetNamerElement ( parentDataset ,
// dsNamerElement ) ) ;
return ( catGenConf ) ;