signature:
public class IospHelper { /** * Copy data to a channel . Used by ncstream . Not doing Structures correctly yet .
 * @ param data copy from here
 * @ param channel copy to here
 * @ return number of bytes copied
 * @ throws java . io . IOException on write error */
public static long copyToByteChannel ( Array data , WritableByteChannel channel ) throws java . io . IOException { } }

implementation:
Class classType = data . getElementType ( ) ; /* if ( data instanceof ArrayStructure ) { / / use NcStream encoding
 DataOutputStream os = new DataOutputStream ( Channels . newOutputStream ( channel ) ) ;
 return NcStream . encodeArrayStructure ( ( ArrayStructure ) data , null , os ) ; */
DataOutputStream outStream = new DataOutputStream ( Channels . newOutputStream ( channel ) ) ; IndexIterator iterA = data . getIndexIterator ( ) ; if ( classType == double . class ) { while ( iterA . hasNext ( ) ) outStream . writeDouble ( iterA . getDoubleNext ( ) ) ; } else if ( classType == float . class ) { while ( iterA . hasNext ( ) ) outStream . writeFloat ( iterA . getFloatNext ( ) ) ; } else if ( classType == long . class ) { while ( iterA . hasNext ( ) ) outStream . writeLong ( iterA . getLongNext ( ) ) ; } else if ( classType == int . class ) { while ( iterA . hasNext ( ) ) outStream . writeInt ( iterA . getIntNext ( ) ) ; } else if ( classType == short . class ) { while ( iterA . hasNext ( ) ) outStream . writeShort ( iterA . getShortNext ( ) ) ; } else if ( classType == char . class ) { // LOOK why are we using chars anyway ?
byte [ ] pa = convertCharToByte ( ( char [ ] ) data . get1DJavaArray ( DataType . CHAR ) ) ; outStream . write ( pa , 0 , pa . length ) ; } else if ( classType == byte . class ) { while ( iterA . hasNext ( ) ) outStream . writeByte ( iterA . getByteNext ( ) ) ; } else if ( classType == boolean . class ) { while ( iterA . hasNext ( ) ) outStream . writeBoolean ( iterA . getBooleanNext ( ) ) ; } else if ( classType == String . class ) { long size = 0 ; while ( iterA . hasNext ( ) ) { String s = ( String ) iterA . getObjectNext ( ) ; size += NcStream . writeVInt ( outStream , s . length ( ) ) ; byte [ ] b = s . getBytes ( CDM . utf8Charset ) ; outStream . write ( b ) ; size += b . length ; } return size ; } else if ( classType == ByteBuffer . class ) { // OPAQUE
long size = 0 ; while ( iterA . hasNext ( ) ) { ByteBuffer bb = ( ByteBuffer ) iterA . getObjectNext ( ) ; size += NcStream . writeVInt ( outStream , bb . limit ( ) ) ; bb . rewind ( ) ; channel . write ( bb ) ; size += bb . limit ( ) ; } return size ; } else if ( data instanceof ArrayObject ) { // vlen
long size = 0 ; // size + = NcStream . writeVInt ( outStream , ( int ) data . getSize ( ) ) ; / / nelems already written
while ( iterA . hasNext ( ) ) { Array row = ( Array ) iterA . getObjectNext ( ) ; ByteBuffer bb = row . getDataAsByteBuffer ( ) ; byte [ ] result = bb . array ( ) ; size += NcStream . writeVInt ( outStream , result . length ) ; // size in bytes
outStream . write ( result ) ; // array
size += result . length ; } return size ; } else throw new UnsupportedOperationException ( "Class type = " + classType . getName ( ) ) ; return data . getSizeBytes ( ) ;


signature:
public class IospHelper { /** * Create 1D primitive array of the given size and type
 * @ param size the size of the array to create
 * @ param dataType dataType of the variable
 * @ return primitive array with data read in */
static public Object makePrimitiveArray ( int size , DataType dataType ) { } }

implementation: Object arr = null ; if ( ( dataType . getPrimitiveClassType ( ) == byte . class ) || ( dataType == DataType . CHAR ) || ( dataType == DataType . OPAQUE ) || ( dataType == DataType . STRUCTURE ) ) { arr = new byte [ size ] ; } else if ( dataType . getPrimitiveClassType ( ) == short . class ) { arr = new short [ size ] ; } else if ( dataType . getPrimitiveClassType ( ) == int . class ) { arr = new int [ size ] ; } else if ( dataType . getPrimitiveClassType ( ) == long . class ) { arr = new long [ size ] ; } else if ( dataType == DataType . FLOAT ) { arr = new float [ size ] ; } else if ( dataType == DataType . DOUBLE ) { arr = new double [ size ] ; } else if ( dataType == DataType . STRING ) { arr = new String [ size ] ; } return arr ;


signature:
public class IospHelper { /** * Create 1D primitive array of the given size and type , fill it with the given value
 * @ param size the size of the array to create
 * @ param dataType dataType of the variable
 * @ param fillValue must be Number if dataType . isNumeric ( ) , or String for STRING , byte [ ] for Structure , or null for none
 * @ return primitive array with data read in */
static public Object makePrimitiveArray ( int size , DataType dataType , Object fillValue ) { } }

implementation:
if ( dataType . getPrimitiveClassType ( ) == byte . class || ( dataType == DataType . CHAR ) ) { byte [ ] pa = new byte [ size ] ; byte val = ( ( Number ) fillValue ) . byteValue ( ) ; if ( val != 0 ) for ( int i = 0 ; i < size ; i ++ ) pa [ i ] = val ; // if ( dataType = = DataType . CHAR ) return convertByteToChar ( pa ) ;
return pa ; } else if ( dataType == DataType . OPAQUE ) { return new byte [ size ] ; } else if ( dataType . getPrimitiveClassType ( ) == short . class ) { short [ ] pa = new short [ size ] ; short val = ( ( Number ) fillValue ) . shortValue ( ) ; if ( val != 0 ) for ( int i = 0 ; i < size ; i ++ ) pa [ i ] = val ; return pa ; } else if ( dataType . getPrimitiveClassType ( ) == int . class ) { int [ ] pa = new int [ size ] ; int val = ( ( Number ) fillValue ) . intValue ( ) ; if ( val != 0 ) for ( int i = 0 ; i < size ; i ++ ) pa [ i ] = val ; return pa ; } else if ( dataType . getPrimitiveClassType ( ) == long . class ) { long [ ] pa = new long [ size ] ; long val = ( ( Number ) fillValue ) . longValue ( ) ; if ( val != 0 ) for ( int i = 0 ; i < size ; i ++ ) pa [ i ] = val ; return pa ; } else if ( dataType == DataType . FLOAT ) { float [ ] pa = new float [ size ] ; float val = ( ( Number ) fillValue ) . floatValue ( ) ; if ( val != 0.0 ) for ( int i = 0 ; i < size ; i ++ ) pa [ i ] = val ; return pa ; } else if ( dataType == DataType . DOUBLE ) { double [ ] pa = new double [ size ] ; double val = ( ( Number ) fillValue ) . doubleValue ( ) ; if ( val != 0.0 ) for ( int i = 0 ; i < size ; i ++ ) pa [ i ] = val ; return pa ; } else if ( dataType == DataType . STRING ) { String [ ] pa = new String [ size ] ; for ( int i = 0 ; i < size ; i ++ ) pa [ i ] = ( String ) fillValue ; return pa ; } else if ( dataType == DataType . STRUCTURE ) { byte [ ] pa = new byte [ size ] ; if ( fillValue != null ) { byte [ ] val = ( byte [ ] ) fillValue ; int count = 0 ; while ( count < size ) for ( byte aVal : val ) pa [ count ++ ] = aVal ; } return pa ; } throw new IllegalStateException ( ) ;


signature:
public class IospHelper { /** * convert byte array to char array , assuming UTF - 8 encoding */
static public char [ ] convertByteToCharUTF ( byte [ ] byteArray ) { } }

implementation: Charset c = CDM . utf8Charset ; CharBuffer output = c . decode ( ByteBuffer . wrap ( byteArray ) ) ; return output . array ( ) ;


signature:
public class IospHelper { /** * convert char array to byte array , assuming UTF - 8 encoding */
static public byte [ ] convertCharToByteUTF ( char [ ] from ) { } }

implementation: Charset c = CDM . utf8Charset ; ByteBuffer output = c . encode ( CharBuffer . wrap ( from ) ) ; return output . array ( ) ;


signature:
public class IospHelper { /** * convert byte array to char array */
static public char [ ] convertByteToChar ( byte [ ] byteArray ) { } }

implementation:
int size = byteArray . length ; char [ ] cbuff = new char [ size ] ; for ( int i = 0 ; i < size ; i ++ ) cbuff [ i ] = ( char ) DataType . unsignedByteToShort ( byteArray [ i ] ) ; // NOTE : not Unicode !
return cbuff ; } // convert char array to byte array
static public byte [ ] convertCharToByte ( char [ ] from ) { byte [ ] to = null ; if ( from != null ) { int size = from . length ; to = new byte [ size ] ; for ( int i = 0 ; i < size ; i ++ ) to [ i ] = ( byte ) from [ i ] ; // LOOK wrong , convert back to unsigned byte ? ? ?
} return to ;


signature:
public class IospHelper { /** * section reading for member data */
static public ucar . ma2 . Array readSection ( ParsedSectionSpec cer ) throws IOException , InvalidRangeException { } }

implementation:
Variable inner = null ; List < Range > totalRanges = new ArrayList < > ( ) ; ParsedSectionSpec current = cer ; while ( current != null ) { totalRanges . addAll ( current . section . getRanges ( ) ) ; inner = current . v ; current = current . child ; } assert inner != null ; Section total = new Section ( totalRanges ) ; Array result = Array . factory ( inner . getDataType ( ) , total . getShape ( ) ) ; // must be a Structure
Structure outer = ( Structure ) cer . v ; Structure outerSubset = outer . select ( cer . child . v . getShortName ( ) ) ; // allows IOSPs to optimize for this case
ArrayStructure outerData = ( ArrayStructure ) outerSubset . read ( cer . section ) ; extractSection ( cer . child , outerData , result . getIndexIterator ( ) ) ; return result ;


signature:
public class IospHelper { /** * LOOK could be used in createView ? ? */
static private ArrayStructure sectionArrayStructure ( ParsedSectionSpec child , ArrayStructure innerData , StructureMembers . Member m ) throws IOException , InvalidRangeException { } }

implementation:
StructureMembers membersw = new StructureMembers ( m . getStructureMembers ( ) ) ; // no data arrays get propagated
ArrayStructureW result = new ArrayStructureW ( membersw , child . section . getShape ( ) ) ; int count = 0 ; Section . Iterator iter = child . section . getIterator ( child . v . getShape ( ) ) ; while ( iter . hasNext ( ) ) { int recno = iter . next ( null ) ; StructureData sd = innerData . getStructureData ( recno ) ; result . setStructureData ( sd , count ++ ) ; } return result ;


signature:
public class CDMArrayStructure { /** * / * package */
void add ( long recno , int fieldno , Array field ) { } }

implementation: FieldArrays fs = records [ ( int ) recno ] ; if ( fs == null ) records [ ( int ) recno ] = ( fs = new FieldArrays ( this . nmembers ) ) ; fs . fields [ fieldno ] = field ;


signature:
public class CDMArrayStructure { /** * Get the index ' th StructureData ( StructureDataA ) object
 * We need instances of StructureData to give to the user .
 * We use StructureDataA so we can centralize everything
 * in this class . The total number of StructureData objects
 * is dimsize .
 * @ param index
 * @ return */
@ Override public StructureData getStructureData ( int index ) { } }

implementation: assert ( super . sdata != null ) ; if ( index < 0 || index >= this . dimsize ) throw new IllegalArgumentException ( index + " >= " + super . sdata . length ) ; assert ( super . sdata [ index ] != null ) ; return super . sdata [ index ] ;


signature:
public class CDMArrayStructure { /** * Get member databuffer of type String or char .
 * @ param recnum get databuffer from the recnum - th StructureData of the ArrayStructure . Must be less than getSize ( ) ;
 * @ param m get databuffer from this StructureMembers . Member . Must be of type String or char .
 * @ return scalar String value */
public String getScalarString ( int recnum , StructureMembers . Member m ) { } }

implementation: Array data = m . getDataArray ( ) ; return ( String ) data . getObject ( recnum ) . toString ( ) ;


signature:
public class CDMArrayStructure { /** * Non - atomic cases */
public StructureData getScalarStructure ( int index , StructureMembers . Member m ) { } }

implementation: if ( m . getDataType ( ) != DataType . STRUCTURE ) throw new ForbiddenConversionException ( "Atomic field cannot be converted to Structure" ) ; Array ca = memberArray ( index , memberIndex ( m ) ) ; if ( ca . getDataType ( ) != DataType . STRUCTURE && ca . getDataType ( ) != DataType . SEQUENCE ) throw new ForbiddenConversionException ( "Attempt to access non-structure member" ) ; CDMArrayStructure as = ( CDMArrayStructure ) ca ; return as . getStructureData ( 0 ) ;


signature:
public class CDMArrayStructure { /** * Key interface method coming in from StructureDataA .
 * @ param recno The instance # of the array of Structure instances
 * @ param m The member of interest in the Structure instance
 * @ return The ucar . ma2 . Array instance corresponding to the instance .
 * Hidden : friend of StructureDataA */
@ Override public ucar . ma2 . Array getArray ( int recno , StructureMembers . Member m ) { } }

implementation: return ( ucar . ma2 . Array ) memberArray ( recno , memberIndex ( m ) ) ;


signature:
public class CDMArrayStructure { /** * Utilities */
@ Override protected StructureData makeStructureData ( ArrayStructure as , int index ) { } }

implementation: if ( super . sdata [ index ] == null ) super . sdata [ index ] = new StructureDataA ( as , index ) ; return super . sdata [ index ] ;


signature:
public class CDMArrayStructure { /** * Compute the StructureMembers object
 * from a DapStructure . May need to recurse
 * if a field is itself a Structure
 * @ param var The DapVariable to use to construct
 * a StructureMembers object .
 * @ return The StructureMembers object for the given DapStructure */
static StructureMembers computemembers ( DapVariable var ) { } }

implementation:
DapStructure ds = ( DapStructure ) var . getBaseType ( ) ; StructureMembers sm = new StructureMembers ( ds . getShortName ( ) ) ; List < DapVariable > fields = ds . getFields ( ) ; for ( int i = 0 ; i < fields . size ( ) ; i ++ ) { DapVariable field = fields . get ( i ) ; DapType dt = field . getBaseType ( ) ; DataType cdmtype = CDMTypeFcns . daptype2cdmtype ( dt ) ; StructureMembers . Member m = sm . addMember ( field . getShortName ( ) , "" , null , cdmtype , CDMUtil . computeEffectiveShape ( field . getDimensions ( ) ) ) ; m . setDataParam ( i ) ; // So we can index into various lists
// recurse if this field is itself a structure
if ( dt . getTypeSort ( ) . isStructType ( ) ) { StructureMembers subsm = computemembers ( field ) ; m . setStructureMembers ( subsm ) ; } } return sm ;


signature:
public class DUInt32 { /** * Prints the value of the variable , with its declaration . This
 * function is primarily intended for debugging OPeNDAP applications and
 * text - based clients such as geturl .
 * @ param os the < 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 .
 * @ param print _ decl _ p a boolean value controlling whether the
 * variable declaration is printed as well as the value .
 * @ see BaseType # printVal ( PrintWriter , String , boolean ) */
public void printVal ( PrintWriter os , String space , boolean print_decl_p ) { } }

implementation:
// to print properly , cast to long and convert unsigned to signed
long tempVal = ( ( long ) getValue ( ) ) & 0xFFFFFFFFL ; if ( print_decl_p ) { printDecl ( os , space , false ) ; os . println ( " = " + tempVal + ";" ) ; } else os . print ( tempVal ) ;


signature:
public class GridEnsembleCoord { /** * Add this as a dimension to a netCDF file
 * @ param ncfile the netCDF file
 * @ param g the group in the file */
public void addDimensionsToNetcdfFile ( NetcdfFile ncfile , Group g ) { } }

implementation: ncfile . addDimension ( g , new Dimension ( getName ( ) , getNEnsembles ( ) , true ) ) ;


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

implementation:
JFrame frame = new JFrame ( "Test prefs Field" ) ; frame . addWindowListener ( new WindowAdapter ( ) { public void windowClosing ( WindowEvent e ) { System . exit ( 0 ) ; } } ) ; PrefPanel . Dialog d = new PrefPanel . Dialog ( frame , false , "title" , null , null ) ; PrefPanel pp = d . getPrefPanel ( ) ; final Field . Text tf = pp . addTextField ( "text" , "text" , "defValue" ) ; pp . setCursor ( 1 , 0 ) ; pp . addTextField ( "text2" , "text2" , "text2" ) ; // final Field . Int intf = pp . addIntField ( " int " , " int " , 66 ) ;
tf . setText ( "better value" ) ; d . finish ( ) ; d . show ( ) ; JPanel main = new JPanel ( new FlowLayout ( ) ) ; frame . getContentPane ( ) . add ( main ) ; main . setPreferredSize ( new Dimension ( 200 , 200 ) ) ; frame . pack ( ) ; frame . setLocation ( 300 , 300 ) ; frame . setVisible ( true ) ; pp . addActionListener ( e -> { String text = tf . getText ( ) ; tf . setText ( text + "1" ) ; } ) ;


signature:
public class CrawlableDatasetFactory { /** * Construct a CrawlableDataset for the given path using the
 * CrawlableDataset implementation indicated by the given class name .
 * The class given by className is used to instantiate the requested
 * CrawlableDataset and so must be an implementation of
 * thredds . crawlabledataset . CrawlableDataset . The given class must also
 * supply a public constructor with a single String argument . The String
 * argument is the path for the CrawlableDataset being constructed .
 * If className is null , thredds . crawlabledataset . CrawlableDatasetFile will
 * be used .
 * If the path is an alias containing wildcard characters ( " * " ) ,
 * the class thredds . crawlabledataset . CrawlableDatasetAlias will be used to
 * expand the alias into a collection of CrawlableDatasets of the type given
 * by className .
 * @ param path the path of the CrawlableDataset .
 * @ param className the class name of the CrawlableDataset implementation to instantiate .
 * @ param configObj
 * @ return a CrawlableDataset for the given path and of the type given by the class name .
 * @ throws IOException if a CrawlableDataset cannot be created due to IO problems .
 * @ throws ClassNotFoundException if the given CrawlableDataset implementation was not found .
 * @ throws NoSuchMethodException if the given CrawlableDataset implementation does not have a constructor with a single String parameter which is required .
 * @ throws IllegalAccessException if the constructor is inaccessible due to Java language access control .
 * @ throws InvocationTargetException if the constructor throws an exception .
 * @ throws InstantiationException if the given CrawlableDataset implementation is an abstract class .
 * @ throws NullPointerException if the given path is null .
 * @ throws IllegalArgumentException if the given class name is not an implementation of CrawlableDataset . */
public static CrawlableDataset createCrawlableDataset ( String path , String className , Object configObj ) throws IOException , ClassNotFoundException , NoSuchMethodException , IllegalAccessException , InvocationTargetException , InstantiationException , IllegalArgumentException , NullPointerException // throws CrDsException , IllegalArgumentException
{ } }

implementation:
if ( path == null ) throw new NullPointerException ( "Given path must not be null." ) ; String tmpClassName = ( className == null ? defaultClassName : className ) ; // @ todo Remove alias until sure how to handle things like " . scour * " being a regular file .
// if ( CrawlableDatasetAlias . isAlias ( tmpPath ) )
// return new CrawlableDatasetAlias ( tmpPath , tmpClassName , configObj ) ;
// Get the Class instance for desired CrawlableDataset implementation .
Class crDsClass = Class . forName ( tmpClassName ) ; // Check that the Class is a CrawlableDataset .
if ( ! CrawlableDataset . class . isAssignableFrom ( crDsClass ) ) { throw new IllegalArgumentException ( "Requested class <" + className + "> not an implementation of thredds.crawlabledataset.CrawlableDataset." ) ; } // Instantiate the desired CrawlableDataset .
Class [ ] argTypes = { String . class , Object . class } ; Object [ ] args = { path , configObj } ; Constructor constructor = crDsClass . getDeclaredConstructor ( argTypes ) ; try { return ( CrawlableDataset ) constructor . newInstance ( args ) ; } catch ( InvocationTargetException e ) { if ( IOException . class . isAssignableFrom ( e . getCause ( ) . getClass ( ) ) ) throw ( IOException ) e . getCause ( ) ; else throw e ; }


signature:
public class CrawlableDatasetFactory { /** * Normalize the given path so that it can be used in the creation of a CrawlableDataset .
 * This method can be used on absolute or relative paths .
 * Normal uses slashes ( " / " ) as path seperator , not backslashes ( " \ " ) , and does
 * not use trailing slashes . This function allows users to specify Windows
 * pathnames and UNC pathnames in there normal manner .
 * @ param path the path to be normalized .
 * @ return the normalized path .
 * @ throws NullPointerException if path is null . */
public static String normalizePath ( String path ) { } }

implementation:
// Replace any occurance of a backslash ( " \ " ) with a slash ( " / " ) .
// NOTE : Both String and Pattern escape backslash , so need four backslashes to find one .
// NOTE : No longer replace multiple backslashes with one slash , which allows for UNC pathnames ( Windows LAN addresses ) .
// Was path . replaceAll ( " \ \ \ \ + " , " / " ) ;
String newPath = path . replaceAll ( "\\\\" , "/" ) ; // Remove trailing slashes .
while ( newPath . endsWith ( "/" ) && ! newPath . equals ( "/" ) ) newPath = newPath . substring ( 0 , newPath . length ( ) - 1 ) ; return newPath ;


signature:
public class ContourFeature { /** * implement GisFeature methods : */
public java . awt . geom . Rectangle2D getBounds2D ( ) { } }

implementation:
// Get the bounding box for this feature . from java . awt . geom . Rectangle2D
double x0 = ( ( ( ContourLine ) ( lines . get ( 0 ) ) ) . getX ( ) ) [ 0 ] ; double y0 = ( ( ( ContourLine ) ( lines . get ( 0 ) ) ) . getY ( ) ) [ 0 ] ; double xMaxInd = x0 , xmin = x0 , yMaxInd = y0 , ymin = y0 ; for ( int i = 0 ; i < lines . size ( ) ; i ++ ) { GisPart cline = ( ContourLine ) ( lines . get ( i ) ) ; double [ ] xpts = cline . getX ( ) ; double [ ] ypts = cline . getY ( ) ; for ( int j = 0 ; j < cline . getNumPoints ( ) ; j ++ ) { if ( xpts [ j ] < xmin ) xmin = xpts [ j ] ; else if ( xpts [ j ] > xMaxInd ) xMaxInd = xpts [ j ] ; if ( ypts [ j ] < ymin ) ymin = ypts [ j ] ; else if ( ypts [ j ] > yMaxInd ) yMaxInd = ypts [ j ] ; } } // Rectangle2D . Double ( double x , double y , double width , double height )
Rectangle2D . Double rect = new Rectangle2D . Double ( xmin , ymin , xMaxInd - xmin , yMaxInd - ymin ) ; return rect ;


signature:
public class Aggregation { /** * this is where persist ( ) reads / writes files */
static public void setPersistenceCache ( DiskCache2 dc ) { } }

implementation: diskCache2 = dc ; if ( diskCache2 != null ) diskCache2 . setAlwaysUseCache ( true ) ; // the persistence cache file has same name as the ncml - must put it into the cache else clobber ncml 7/31/2014


signature:
public class Aggregation { /** * Add a nested dataset , specified by an explicit netcdf element .
 * enhance is handled by the reader , so its always false here .
 * @ param cacheName a unique name to use for caching
 * @ param location attribute " location " on the netcdf element
 * @ param id attribute " id " on the netcdf element
 * @ param ncoordS attribute " ncoords " on the netcdf element
 * @ param coordValueS attribute " coordValue " on the netcdf element
 * @ param sectionSpec attribute " section " on the netcdf element
 * @ param reader factory for reading this netcdf dataset */
public void addExplicitDataset ( String cacheName , String location , String id , String ncoordS , String coordValueS , String sectionSpec , ucar . nc2 . util . cache . FileFactory reader ) { } }

implementation: Dataset nested = makeDataset ( cacheName , location , id , ncoordS , coordValueS , sectionSpec , null , reader ) ; explicitDatasets . add ( nested ) ;


signature:
public class Aggregation { /** * Add a dataset scan
 * @ param crawlableDatasetElement defines a CrawlableDataset , or null
 * @ param dirName scan this directory
 * @ param suffix filter on this suffix ( may be null )
 * @ param regexpPatternString include if full name matches this regular expression ( may be null )
 * @ param dateFormatMark create dates from the filename ( may be null )
 * @ param enhanceMode how should files be enhanced
 * @ param subdirs equals " false " if should not descend into subdirectories
 * @ param olderThan files must be older than this time ( now - lastModified > = olderThan ) ; must be a time unit , may ne bull */
public void addDatasetScan ( Element crawlableDatasetElement , String dirName , String suffix , String regexpPatternString , String dateFormatMark , Set < NetcdfDataset . Enhance > enhanceMode , String subdirs , String olderThan ) { } }

implementation:
datasetManager . addDirectoryScan ( dirName , suffix , regexpPatternString , subdirs , olderThan , enhanceMode ) ; this . dateFormatMark = dateFormatMark ; if ( dateFormatMark != null ) { isDate = true ; if ( type == Type . joinExisting ) type = Type . joinExistingOne ; // tricky
DateExtractor dateExtractor = new DateExtractorFromName ( dateFormatMark , true ) ; datasetManager . setDateExtractor ( dateExtractor ) ; }


signature:
public class Aggregation { /** * experimental */
public void addCollection ( String spec , String olderThan ) throws IOException { } }

implementation: datasetManager = MFileCollectionManager . open ( spec , spec , olderThan , new Formatter ( ) ) ;


signature:
public class Aggregation { /** * all elements are processed , finish construction */
public void finish ( CancelTask cancelTask ) throws IOException { } }

implementation:
datasetManager . scan ( true ) ; // Make the list of Datasets , by scanning if needed .
cacheDirty = true ; makeDatasets ( cancelTask ) ; // ucar . unidata . io . RandomAccessFile . setDebugAccess ( true ) ;
buildNetcdfDataset ( cancelTask ) ; // ucar . unidata . io . RandomAccessFile . setDebugAccess ( false ) ;


signature:
public class Aggregation { /** * Make the list of Datasets , from explicit and scans .
 * @ param cancelTask user can cancel
 * @ throws IOException on i / o error */
protected void makeDatasets ( CancelTask cancelTask ) throws IOException { } }

implementation:
// heres where the results will go
datasets = new ArrayList < > ( ) ; for ( MFile cd : datasetManager . getFilesSorted ( ) ) { datasets . add ( makeDataset ( cd ) ) ; } // sort using Aggregation . Dataset as Comparator .
// Sort by date if it exists , else filename .
Collections . sort ( datasets ) ; /* optionally extract the date
 String dateCoordS = null ;
 if ( null ! = dateFormatMark ) {
 String filename = myf . getName ( ) ; / / LOOK operates on name , not path
 Date dateCoord = DateFromString . getDateUsingDemarkatedCount ( filename , dateFormatMark , ' # ' ) ;
 dateCoordS = formatter . toDateTimeStringISO ( dateCoord ) ;
 if ( debugDateParse ) System . out . println ( " adding " + myf . getPath ( ) + " date = " + dateCoordS ) ;
 } else {
 if ( debugDateParse ) System . out . println ( " adding " + myf . getPath ( ) ) ;
 String location = myf . getPath ( ) ;
 Aggregation . Dataset ds = makeDataset ( location , location , null , null , dateCoordS , null , enhance , null ) ;
 datasets . add ( ds ) ;
 / / Sort by date if it exists , else filename .
 Collections . sort ( datasets , new Comparator < Aggregation . Dataset > ( ) {
 public int compare ( Aggregation . Dataset ds1 , Aggregation . Dataset ds2 ) {
 if ( ds1 . cd = = null )
 return ds1 . getLocation ( ) . compareTo ( ds2 . getLocation ( ) ) ;
 if ( ds1 . cd . dateCoord ! = null ) / / LOOK can we generalize
 return ds1 . cd . dateCoord . compareTo ( ds2 . cd . dateCoord ) ;
 else
 return ds1 . cd . file . getName ( ) . compareTo ( ds2 . cd . file . getName ( ) ) ; */
// add the explicit datasets - these need to be kept in order
// LOOK - should they be before or after scanned ? Does it make sense to mix scan and explicit ?
// AggFmrcSingle sets explicit datasets - the scan is empty
for ( Aggregation . Dataset dataset : explicitDatasets ) { datasets . add ( dataset ) ; } // Remove unreadable files ( i . e . due to permissions ) from the aggregation .
// LOOK : Is this logic we should install " upstream " , perhaps in MFileCollectionManager ?
// It would affect other collections than just NcML aggregation in that case .
for ( Iterator < Dataset > datasetsIter = datasets . iterator ( ) ; datasetsIter . hasNext ( ) ; ) { Dataset dataset = datasetsIter . next ( ) ; Path datasetPath ; if ( dataset . getMFile ( ) instanceof MFileOS ) { datasetPath = ( ( MFileOS ) dataset . getMFile ( ) ) . getFile ( ) . toPath ( ) ; } else if ( dataset . getMFile ( ) instanceof MFileOS7 ) { datasetPath = ( ( MFileOS7 ) dataset . getMFile ( ) ) . getNioPath ( ) ; } else { continue ; } if ( ! Files . isReadable ( datasetPath ) ) { // File . canRead ( ) is broken on Windows , but the JDK7 methods work .
logger . warn ( "Aggregation member isn't readable (permissions issue?). Skipping: " + datasetPath ) ; datasetsIter . remove ( ) ; } } // check for duplicate location
Set < String > dset = new HashSet < > ( 2 * datasets . size ( ) ) ; for ( Aggregation . Dataset dataset : datasets ) { if ( dset . contains ( dataset . cacheLocation ) ) logger . warn ( "Duplicate dataset in aggregation = " + dataset . cacheLocation ) ; dset . add ( dataset . cacheLocation ) ; } if ( datasets . size ( ) == 0 ) { throw new IllegalStateException ( "There are no datasets in the aggregation " + datasetManager ) ; }


signature:
public class Aggregation { /** * Open one of the nested datasets as a template for the aggregation dataset .
 * @ return a typical Dataset
 * @ throws IOException if there are no datasets */
protected Dataset getTypicalDataset ( ) throws IOException { } }

implementation:
List < Dataset > nestedDatasets = getDatasets ( ) ; int n = nestedDatasets . size ( ) ; if ( n == 0 ) throw new FileNotFoundException ( "No datasets in this aggregation" ) ; int select ; if ( typicalDatasetMode == TypicalDataset . LATEST ) select = n - 1 ; else if ( typicalDatasetMode == TypicalDataset . PENULTIMATE ) select = ( n < 2 ) ? 0 : n - 2 ; else if ( typicalDatasetMode == TypicalDataset . FIRST ) select = 0 ; else { // random is default
if ( r == null ) r = new Random ( ) ; select = ( n < 2 ) ? 0 : r . nextInt ( n ) ; } return nestedDatasets . get ( select ) ;


signature:
public class Aggregation { /** * Dataset factory , so subclasses can override
 * @ param cacheName a unique name to use for caching
 * @ param location attribute " location " on the netcdf element
 * @ param id attribute " id " on the netcdf element
 * @ param ncoordS attribute " ncoords " on the netcdf element
 * @ param coordValueS attribute " coordValue " on the netcdf element
 * @ param sectionSpec attribute " sectionSpec " on the netcdf element
 * @ param enhance open dataset in enhance mode NOT USED
 * @ param reader factory for reading this netcdf dataset
 * @ return a Aggregation . Dataset */
protected Dataset makeDataset ( String cacheName , String location , String id , String ncoordS , String coordValueS , String sectionSpec , EnumSet < NetcdfDataset . Enhance > enhance , ucar . nc2 . util . cache . FileFactory reader ) { } }

implementation: return new Dataset ( cacheName , location , id , enhance , reader ) ; // overridden in OuterDim , tiled


signature:
public class Aggregation { /** * All non - agg variables use a proxy to acquire the file before reading .
 * If the variable is caching , read data into cache now .
 * If not caching , VariableEnhanced . setProxyReader ( ) is called .
 * @ param typicalDataset read from a " typical dataset "
 * @ param newds containing dataset
 * @ throws IOException on i / o error */
protected void setDatasetAcquireProxy ( Dataset typicalDataset , NetcdfDataset newds ) throws IOException { } }

implementation: DatasetProxyReader proxy = new DatasetProxyReader ( typicalDataset ) ; setDatasetAcquireProxy ( proxy , newds . getRootGroup ( ) ) ;


signature:
public class DatasetTrackerInMem { /** * This tracks Dataset elements that have resource control attributes
 * @ param ds the dataset */
void putResourceControl ( Dataset ds ) { } }

implementation:
if ( logger . isDebugEnabled ( ) ) logger . debug ( "putResourceControl " + ds . getRestrictAccess ( ) + " for " + ds . getName ( ) ) ; resourceControlHash . put ( ds . getUrlPath ( ) , ds . getRestrictAccess ( ) ) ; // resourceControl is inherited , but no guarentee that children paths are related , unless its a
// DatasetScan or InvDatasetFmrc . So we keep track of all datasets that have a ResourceControl , including children
// DatasetScan and InvDatasetFmrc must use a PathMatcher , others can use exact match ( hash )
/* if ( ds instanceof DatasetScan ) {
 DatasetScan scan = ( DatasetScan ) ds ;
 if ( debugResourceControl )
 System . out . println ( " putResourceControl " + ds . getRestrictAccess ( ) + " for datasetScan " + scan . getPath ( ) ) ;
 resourceControlMatcher . put ( scan . getPath ( ) , ds . getRestrictAccess ( ) ) ;
 } else { / / dataset
 if ( debugResourceControl )
 System . out . println ( " putResourceControl " + ds . getRestrictAccess ( ) + " for dataset " + ds . getUrlPath ( ) ) ;
 / / LOOK : seems like you only need to add if InvAccess . InvService . isReletive
 / / LOOK : seems like we should use resourceControlMatcher to make sure we match . dods , etc
 for ( Access access : ds . getAccess ( ) ) {
 if ( access . getService ( ) . isRelativeBase ( ) )
 resourceControlHash . put ( access . getUrlPath ( ) , ds . getRestrictAccess ( ) ) ; */
hasResourceControl = true ;


signature:
public class CFLine { /** * Add a point to the end of the line . */
public void addPoint ( double x , double y ) { } }

implementation: Point ptPrev = null ; if ( points . size ( ) > 0 ) { ptPrev = points . get ( points . size ( ) - 1 ) ; } this . points . add ( new CFPoint ( x , y , ptPrev , null , null ) ) ;


signature:
public class CFLine { /** * Sets the previous line which makes up the multiline which this line is a part of .
 * If prev is a CFLine , automatically connect the other line to this line as well . */
public void setNext ( Line next ) { } }

implementation: if ( next instanceof CFLine ) { setNext ( ( CFLine ) next ) ; } else this . next = next ;


signature:
public class CFLine { /** * Sets the previous line which makes up the multiline which this line is a part of .
 * If prev is a CFLine , automatically connect the other line to this line as well . */
public void setPrev ( Line prev ) { } }

implementation: if ( prev instanceof CFLine ) { setPrev ( ( CFLine ) prev ) ; } else this . prev = prev ;


signature:
public class CFLine { /** * Given a dataset , variable , and index , automatically populates this Line and
 * returns it . If not found , returns null .
 * @ param dataset which the variable is a part of
 * @ param var the variable which has a geometry attribute
 * @ param index of the line within the variable
 * @ return return a line */
public Line setupLine ( NetcdfDataset dataset , Variable var , int index ) { } }

implementation:
this . points . clear ( ) ; Array xPts = null ; Array yPts = null ; Variable nodeCounts = null ; Variable partNodeCounts = null ; List < CoordinateAxis > axes = dataset . getCoordinateAxes ( ) ; CoordinateAxis x = null ; CoordinateAxis y = null ; String [ ] nodeCoords = var . findAttributeIgnoreCase ( CF . NODE_COORDINATES ) . getStringValue ( ) . split ( " " ) ; // Look for x and y
for ( CoordinateAxis ax : axes ) { if ( ax . getFullName ( ) . equals ( nodeCoords [ 0 ] ) ) x = ax ; if ( ax . getFullName ( ) . equals ( nodeCoords [ 1 ] ) ) y = ax ; } // Affirm node counts
String node_c_str = var . findAttValueIgnoreCase ( CF . NODE_COUNT , "" ) ; if ( ! node_c_str . equals ( "" ) ) { nodeCounts = dataset . findVariable ( node_c_str ) ; } else return null ; // Affirm part node counts
String pNodeCoStr = var . findAttValueIgnoreCase ( CF . PART_NODE_COUNT , "" ) ; if ( ! pNodeCoStr . equals ( "" ) ) { partNodeCounts = dataset . findVariable ( pNodeCoStr ) ; } SimpleGeometryIndexFinder indexFinder = new SimpleGeometryIndexFinder ( nodeCounts ) ; // Get beginning and ending indicies for this polygon
int lower = indexFinder . getBeginning ( index ) ; int upper = indexFinder . getEnd ( index ) ; try { xPts = x . read ( lower + ":" + upper ) . reduce ( ) ; yPts = y . read ( lower + ":" + upper ) . reduce ( ) ; IndexIterator itrX = xPts . getIndexIterator ( ) ; IndexIterator itrY = yPts . getIndexIterator ( ) ; // No multipolygons just read in the whole thing
if ( partNodeCounts == null ) { this . next = null ; this . prev = null ; // x and y should have the same shape , will add some handling on this
while ( itrX . hasNext ( ) ) { this . addPoint ( itrX . getDoubleNext ( ) , itrY . getDoubleNext ( ) ) ; } switch ( var . getRank ( ) ) { case 2 : this . setData ( var . read ( CFSimpleGeometryHelper . getSubsetString ( var , index ) ) . reduce ( ) ) ; break ; case 1 : this . setData ( var . read ( "" + index ) ) ; break ; default : throw new InvalidDataseriesException ( InvalidDataseriesException . RANK_MISMATCH ) ; // currently do not support anything but dataseries and scalar associations
} } // If there are multipolygons then take the upper and lower of it and divy it up
else { Line tail = this ; Array pnc = partNodeCounts . read ( ) ; IndexIterator pncItr = pnc . getIndexIterator ( ) ; // In part node count search for the right index to begin looking for " part node counts "
int pncInd = 0 ; int pncEnd = 0 ; while ( pncEnd < lower ) { pncEnd += pncItr . getIntNext ( ) ; pncInd ++ ; } // Now the index is found , use part node count and the index to find each part node count of each individual part
while ( lower < upper ) { int smaller = pnc . getInt ( pncInd ) ; while ( smaller > 0 ) { tail . addPoint ( itrX . getDoubleNext ( ) , itrY . getDoubleNext ( ) ) ; smaller -- ; } // Set data of each
switch ( var . getRank ( ) ) { case 2 : tail . setData ( var . read ( CFSimpleGeometryHelper . getSubsetString ( var , index ) ) . reduce ( ) ) ; break ; case 1 : tail . setData ( var . read ( "" + index ) ) ; break ; default : throw new InvalidDataseriesException ( InvalidDataseriesException . RANK_MISMATCH ) ; // currently do not support anything but dataseries and scalar associations
} lower += tail . getPoints ( ) . size ( ) ; pncInd ++ ; tail . setNext ( new CFLine ( ) ) ; tail = tail . getNext ( ) ; } // Clean up
tail = tail . getPrev ( ) ; if ( tail != null ) tail . setNext ( null ) ; } } catch ( IOException | InvalidRangeException | InvalidDataseriesException e ) { cfl . error ( e . getMessage ( ) ) ; ; return null ; } return this ;


signature:
public class CFLine { /** * Gets the upper bounding box coordinate on the line .
 * @ return double array = ( x , y ) */
public double [ ] getBBUpper ( ) { } }

implementation:
double [ ] bbUpper = new double [ 2 ] ; List < Point > ptList = this . getPoints ( ) ; if ( ptList . isEmpty ( ) ) return null ; bbUpper [ 0 ] = ptList . get ( 0 ) . getY ( ) ; bbUpper [ 1 ] = ptList . get ( 0 ) . getY ( ) ; for ( Point pt : this . getPoints ( ) ) { if ( bbUpper [ 0 ] < pt . getX ( ) ) { bbUpper [ 0 ] = pt . getX ( ) ; } if ( bbUpper [ 1 ] < pt . getY ( ) ) { bbUpper [ 1 ] = pt . getY ( ) ; } } // Got maximum points , add some padding .
bbUpper [ 0 ] += 10 ; bbUpper [ 1 ] += 10 ; return bbUpper ;


signature:
public class CFLine { /** * Gets the lower bounding box coordinate on the line .
 * @ return double array = ( x , y ) */
public double [ ] getBBLower ( ) { } }

implementation:
double [ ] bbLower = new double [ 2 ] ; List < Point > ptList = this . getPoints ( ) ; if ( ptList . isEmpty ( ) ) return null ; bbLower [ 0 ] = ptList . get ( 0 ) . getY ( ) ; bbLower [ 1 ] = ptList . get ( 0 ) . getY ( ) ; for ( Point pt : this . getPoints ( ) ) { if ( bbLower [ 0 ] > pt . getX ( ) ) { bbLower [ 0 ] = pt . getX ( ) ; } if ( bbLower [ 1 ] > pt . getY ( ) ) { bbLower [ 1 ] = pt . getY ( ) ; } } // Got minimum points , add some padding .
bbLower [ 0 ] -= 10 ; bbLower [ 1 ] -= 10 ; return bbLower ;


signature:
public class DatasetFilter { /** * Validate this DatasetFilter object . Return true if valid , false if invalid .
 * @ param out StringBuffer with validation messages .
 * @ return boolean true if valid , false if invalid */
boolean validate ( StringBuilder out ) { } }

implementation:
this . isValid = true ; // If log from construction has content , append to validation output msg .
if ( this . log . length ( ) > 0 ) { out . append ( this . log ) ; } // Validity check : ' name ' cannot be null . ( Though , ' name '
// can be an empty string . )
if ( this . getName ( ) == null ) { isValid = false ; out . append ( " ** DatasetFilter (4): null value for name is not valid." ) ; } // Check that type is not null .
if ( this . getType ( ) == null ) { isValid = false ; out . append ( " ** DatasetFilter (5): null value for type is not valid (set with bad string?)." ) ; } // Validity check : ' matchPattern ' must be null if ' type ' value
// is not ' RegExp ' .
if ( this . type == DatasetFilter . Type . REGULAR_EXPRESSION && this . matchPattern == null ) { isValid = false ; out . append ( " ** DatasetFilter (6): null value for matchPattern not valid when type is 'RegExp'." ) ; } if ( this . type != DatasetFilter . Type . REGULAR_EXPRESSION && this . type != null && this . matchPattern != null ) { isValid = false ; out . append ( " ** DatasetFilter (7): matchPattern value (" + this . matchPattern + ") must be null if type is not 'RegExp'." ) ; } return ( this . isValid ) ;


signature:
public class DatasetFilter { /** * Test whether the given dataset matches the filter criteria .
 * @ param dataset - the dataset to be tested .
 * @ return true if and only if the dataset matches the filter criteria . */
private boolean match ( InvDataset dataset ) { } }

implementation:
// Check whether this filter applies to the given dataset .
if ( this . getParentDatasetSource ( ) . isCollection ( dataset ) && ! this . applyToCollectionDatasets ) return ( false ) ; if ( ( ! this . getParentDatasetSource ( ) . isCollection ( dataset ) ) && ! this . applyToAtomicDatasets ) return ( false ) ; // Set the default matchPatternTarget so old versions still work .
if ( this . matchPatternTarget == null ) { if ( this . getParentDatasetSource ( ) . isCollection ( dataset ) ) { this . setMatchPatternTarget ( "name" ) ; } else { this . setMatchPatternTarget ( "urlPath" ) ; } } if ( this . type == DatasetFilter . Type . REGULAR_EXPRESSION ) { boolean isMatch ; if ( this . getMatchPatternTarget ( ) . equals ( "name" ) ) { java . util . regex . Matcher matcher = this . regExpPattern . matcher ( dataset . getName ( ) ) ; isMatch = matcher . find ( ) ; } else if ( this . getMatchPatternTarget ( ) . equals ( "urlPath" ) ) { java . util . regex . Matcher matcher = this . regExpPattern . matcher ( ( ( InvDatasetImpl ) dataset ) . getUrlPath ( ) ) ; isMatch = matcher . find ( ) ; } else { // ToDo deal with any matchPatternTarget ( XPath - ish )
isMatch = false ; } // / / Invert the meaning of a match ( accept things that don ' t match ) .
// if ( this . isRejectMatchingDatasets ( ) )
// / / If match , return false .
// return ( regExpMatch = = null ? true : false ) ;
// / / Don ' t invert ( a match is a match ) .
// else
// If match , return true .
return ( isMatch ) ; } else { System . err . println ( "WARNING -- DatasetFilter.accept(): unsupported type" + " <" + this . type . toString ( ) + ">." ) ; return ( false ) ; // @ todo think about exceptions .
// throw new java . lang . Exception ( " DatasetFilter . accept ( ) : " +
// " unsupported type < " + this . type . toString ( ) + " > . " ) ;
}


signature:
public class DatasetFilter { /** * Given a dataset and a group of filters , return true if the group of
 * filters indicates that the dataset should be accepted , false if it
 * should be rejected .
 * To make filtering out a set of datasets as easy as allowing a set of
 * datasets , DatasetFilter provides a dataset reject mode as well as a
 * dataset accept mode . Rejection of a dataset by any filter overrides
 * acceptance by any number of filters . Therefore , to be accepted by the
 * group a dataset needs to be accepted by at least one filter , however ,
 * rejection by a single filter will cause rejection by the group .
 * If the filter group is empty , the dataset will be accepted .
 * @ param filters - the group of filters to apply to the dataset .
 * @ param dataset - the dataset on which to apply the filter group .
 * @ param isCollectionDataset
 * @ return true if the group of filters indicates that the dataset should be accepted , false otherwise .
 * @ throws NullPointerException if the filter list or the dataset is null . */
public static boolean acceptDatasetByFilterGroup ( List filters , InvDataset dataset , boolean isCollectionDataset ) { } }

implementation:
if ( filters == null ) throw new NullPointerException ( "Given null list of filters." ) ; if ( dataset == null ) throw new NullPointerException ( "Given null dataset." ) ; // If not filters , accept all datasets .
if ( filters . isEmpty ( ) ) return ( true ) ; // Loop through DatasetFilter list to check if current dataset should be accepted .
// @ todo If none of the filters apply to directories , accept all directories .
boolean accept = false ; boolean anyApplyToAtomic = false ; boolean anyApplyToCollection = false ; for ( Iterator it = filters . iterator ( ) ; it . hasNext ( ) ; ) { DatasetFilter curFilter = ( DatasetFilter ) it . next ( ) ; anyApplyToAtomic |= curFilter . isApplyToAtomicDatasets ( ) ; anyApplyToCollection |= curFilter . isApplyToCollectionDatasets ( ) ; if ( curFilter . isAcceptMatchingDatasets ( ) ) { if ( curFilter . accept ( dataset ) ) { accept = true ; // Dataset accepted by current DatasetFilter .
} } else // if ( ! curFilter . isAcceptMatchingDatasets ( ) )
{ if ( curFilter . reject ( dataset ) ) { return ( false ) ; // Rejection takes precedence over accpetance
} } } // At least one filter accepted ( and none rejected ) , so accept .
if ( accept ) return ( true ) ; // Check if any filters apply to dataset . If none apply , accept the dataset .
if ( isCollectionDataset ) { if ( ! anyApplyToCollection ) return ( true ) ; // Collection ds , no collection filters .
} else { if ( ! anyApplyToAtomic ) return ( true ) ; // Atomic ds , no atomic filters .
} // Dataset not accepted or rejected by any DatasetFilter ( so reject ) .
return ( false ) ;


signature:
public class SortingStationPointFeatureCache { /** * fdPoint remains open . */
public void addAll ( FeatureDatasetPoint fdPoint ) throws IOException { } }

implementation: try ( PointFeatureIterator pointFeatIter = new FlattenedDatasetPointCollection ( fdPoint ) . getPointFeatureIterator ( ) ) { while ( pointFeatIter . hasNext ( ) ) { StationPointFeature pointFeat = ( StationPointFeature ) pointFeatIter . next ( ) ; add ( pointFeat ) ; } }


signature:
public class SortingStationPointFeatureCache { /** * Double - check idiom for lazy initialization of instance fields . See Effective Java 2nd Ed , p . 283. */
private StationFeatureCopyFactory getStationFeatureCopyFactory ( StationPointFeature proto ) throws IOException { } }

implementation: if ( stationFeatCopyFactory == null ) { synchronized ( this ) { if ( stationFeatCopyFactory == null ) { stationFeatCopyFactory = createStationFeatureCopyFactory ( proto ) ; } } } assert stationFeatCopyFactory != null : "We screwed this up." ; return stationFeatCopyFactory ;


signature:
public class CEEvaluator { /** * Parse a constraint expression . Variables in the projection are marked
 * as such in the CEEvaluator ' s ServerDDS instance . The selection
 * subexpression is then parsed and a list of Clause objects is built .
 * The parser is located in opendap . servers . parsers . CeParser .
 * @ param constraint The constraint expression to parse .
 * @ throws ParseException
 * @ throws NoSuchVariableException
 * @ throws NoSuchFunctionException
 * @ throws InvalidOperatorException
 * @ throws InvalidParameterException
 * @ throws SBHException */
public void parseConstraint ( String constraint , String urlencoded ) throws ParseException , opendap . dap . DAP2Exception , NoSuchVariableException , NoSuchFunctionException , InvalidOperatorException , InvalidParameterException , SBHException , WrongTypeException { } }

implementation:
if ( clauseFactory == null ) { clauseFactory = new ClauseFactory ( ) ; } // Parses constraint expression ( duh . . . ) and sets the
// projection flag for each member of the CE ' s ServerDDS
// instance . This also builds the list of clauses .
try { CeParser . constraint_expression ( this , _dds . getFactory ( ) , clauseFactory , constraint , urlencoded ) ; } catch ( ConstraintException ce ) { // convert to a DAP2Exception
ce . printStackTrace ( ) ; throw new DAP2Exception ( ce ) ; } if ( _Debug ) { int it = 0 ; Enumeration ec = getClauses ( ) ; System . out . println ( "Results of clause parsing:" ) ; if ( ! ec . hasMoreElements ( ) ) System . out . println ( "    No Clauses Found." ) ; while ( ec . hasMoreElements ( ) ) { it ++ ; System . out . println ( "    Clause " + it + ": " + ec . nextElement ( ) ) ; } }


signature:
public class CEEvaluator { /** * Convenience wrapper for parseConstraint .
 * @ param rs
 * @ throws ParseException
 * @ throws opendap . dap . DAP2Exception
 * @ throws NoSuchVariableException
 * @ throws NoSuchFunctionException
 * @ throws InvalidOperatorException
 * @ throws InvalidParameterException
 * @ throws SBHException
 * @ throws WrongTypeException */
public void parseConstraint ( ReqState rs ) throws ParseException , opendap . dap . DAP2Exception , NoSuchVariableException , NoSuchFunctionException , InvalidOperatorException , InvalidParameterException , SBHException , WrongTypeException { } }

implementation: parseConstraint ( rs . getConstraintExpression ( ) , rs . getRequestURL ( ) . toString ( ) ) ;


signature:
public class CEEvaluator { /** * This function sends the variables described in the constrained DDS to
 * the output described by < code > sink < / code > . This function calls
 * < code > parse _ constraint ( ) < / code > , < code > BaseType : : read ( ) < / code > , and
 * < code > ServerIO : : serialize ( ) < / code > .
 * @ param dataset The name of the dataset to send .
 * @ param sink A pointer to the output buffer for the data .
 * @ param specialO An < code > Object < / code > passed by the server . This is typically used by server implementations
 * to deliver needed functionaliy or information to the read methods of each < code > BaseType < / code > .
 * @ see # parseConstraint
 * @ see ServerMethods # serialize ( String , DataOutputStream ,
 * CEEvaluator , Object ) ServerMethods . serialize ( ) */
public void send ( String dataset , OutputStream sink , Object specialO ) throws NoSuchVariableException , DAP2ServerSideException , IOException { } }

implementation:
Enumeration e = _dds . getVariables ( ) ; while ( e . hasMoreElements ( ) ) { ServerMethods s = ( ServerMethods ) e . nextElement ( ) ; if ( _Debug ) System . out . println ( "Sending variable: " + ( ( BaseType ) s ) . getEncodedName ( ) ) ; if ( s . isProject ( ) ) { if ( _Debug ) System . out . println ( "Calling " + ( ( BaseType ) s ) . getTypeName ( ) + ".serialize() (Name: " + ( ( BaseType ) s ) . getEncodedName ( ) + ")" ) ; // System . out . printf ( " serialize % s ( % s ) start = % d % n " , ( ( BaseType ) s ) . getName ( ) , ( ( BaseType ) s ) . getTypeName ( ) ,
// ( ( DataOutputStream ) sink ) . size ( ) ) ;
s . serialize ( dataset , ( DataOutputStream ) sink , this , specialO ) ; } } // System . out . printf ( " serialize total size = % d % n " , ( ( DataOutputStream ) sink ) . size ( ) ) ;


signature:
public class CEEvaluator { /** * Evaluate all of the Clauses in the Clause vector .
 * @ param specialO That special Object that can be passed down
 * through the < code > DDS . send ( ) < / code > method .
 * @ return True if all the Clauses evaluate to true , false otherwise . */
public boolean evalClauses ( Object specialO ) throws NoSuchVariableException , DAP2ServerSideException , IOException { } }

implementation:
boolean result = true ; Enumeration ec = getClauses ( ) ; while ( ec . hasMoreElements ( ) && result == true ) { Object o = ec . nextElement ( ) ; if ( _Debug ) { System . out . println ( "Evaluating clause: " + ec . nextElement ( ) ) ; } result = ( ( TopLevelClause ) o ) . evaluate ( ) ; } // Hack : pop the projections of all DArrayDimensions that
// have been pushed .
return ( result ) ;


signature:
public class CEEvaluator { /** * Mark all the variables in the DDS either as part of the current
 * projection ( when < code > state < / code > is true ) or not
 * ( < code > state < / code > is false ) . This is a convenience function that
 * provides a way to clear or set an entire dataset described by a DDS
 * with respect to its projection .
 * @ param state true if the variables should all be projected , false is
 * no variable should be projected . */
public void markAll ( boolean state ) throws DAP2Exception , NoSuchVariableException , SBHException { } }

implementation:
// For all the Variables in the DDS
Enumeration e = _dds . getVariables ( ) ; while ( e . hasMoreElements ( ) ) { // Get the thing
Object o = e . nextElement ( ) ; // - Clip this to stop marking all dimensions of Grids and Arrays
// If we are marking all for true , then we need to make sure
// we get all the parts of each array and grid
// This code should probably be moved into SDArray and SDGrid .
// There we should add a resetProjections ( ) method that changes
// the current projection to be the entire array . 11/18/99 jhrg
if ( state ) { if ( o instanceof SDArray ) { // Is this thing a SDArray ?
SDArray SDA = ( SDArray ) o ; // Get it ' s DArrayDimensions
Enumeration eSDA = SDA . getDimensions ( ) ; while ( eSDA . hasMoreElements ( ) ) { DArrayDimension dad = ( DArrayDimension ) eSDA . nextElement ( ) ; // Tweak it ' s projection state
dad . setProjection ( 0 , 1 , dad . getSize ( ) - 1 ) ; } } else if ( o instanceof SDGrid ) { // Is this thing a SDGrid ?
SDGrid SDG = ( SDGrid ) o ; SDArray sdgA = ( SDArray ) SDG . getVar ( 0 ) ; // Get it ' s internal SDArray .
// Get it ' s DArrayDimensions
Enumeration eSDA = sdgA . getDimensions ( ) ; while ( eSDA . hasMoreElements ( ) ) { DArrayDimension dad = ( DArrayDimension ) eSDA . nextElement ( ) ; // Tweak it ' s projection state
dad . setProjection ( 0 , 1 , dad . getSize ( ) - 1 ) ; } } } // - - - - - End Clip - - - - -
ServerMethods s = ( ServerMethods ) o ; s . setProject ( state ) ; }


signature:
public class CEEvaluator { /** * Print all of the Clauses in the Clause vector . */
public void printConstraint ( PrintWriter pw ) { } }

implementation: Enumeration ec = getClauses ( ) ; boolean first = true ; while ( ec . hasMoreElements ( ) ) { Clause cl = ( Clause ) ec . nextElement ( ) ; if ( ! first ) pw . print ( " & " ) ; cl . printConstraint ( pw ) ; first = false ; } pw . flush ( ) ;


signature:
public class HdfEos { /** * Amend the given NetcdfFile with metadata from HDF - EOS structMetadata .
 * All Variables named StructMetadata . n , where n = 1 , 2 , 3 . . . are read in and their contents concatenated
 * to make the structMetadata String .
 * @ param ncfile Amend this file
 * @ param eosGroup the group containing variables named StructMetadata . *
 * @ return true if HDF - EOS info was found
 * @ throws IOException on read error */
static public boolean amendFromODL ( NetcdfFile ncfile , Group eosGroup ) throws IOException { } }

implementation: String smeta = getStructMetadata ( eosGroup ) ; if ( smeta == null ) { return false ; } HdfEos fixer = new HdfEos ( ) ; fixer . fixAttributes ( ncfile . getRootGroup ( ) ) ; fixer . amendFromODL ( ncfile , smeta ) ; return true ;


signature:
public class HdfEos { /** * Amend the given NetcdfFile with metadata from HDF - EOS structMetadata
 * @ param ncfile Amend this file
 * @ param structMetadata structMetadata as String
 * @ throws IOException on read error */
private void amendFromODL ( NetcdfFile ncfile , String structMetadata ) throws IOException { } }

implementation:
Group rootg = ncfile . getRootGroup ( ) ; ODLparser parser = new ODLparser ( ) ; Element root = parser . parseFromString ( structMetadata ) ; // now we have the ODL in JDOM elements
FeatureType featureType = null ; // SWATH
Element swathStructure = root . getChild ( "SwathStructure" ) ; if ( swathStructure != null ) { List < Element > swaths = swathStructure . getChildren ( ) ; for ( Element elemSwath : swaths ) { Element swathNameElem = elemSwath . getChild ( "SwathName" ) ; if ( swathNameElem == null ) { log . warn ( "No SwathName element in {} {} " , elemSwath . getName ( ) , ncfile . getLocation ( ) ) ; continue ; } String swathName = NetcdfFile . makeValidCdmObjectName ( swathNameElem . getText ( ) . trim ( ) ) ; Group swathGroup = findGroupNested ( rootg , swathName ) ; // if ( swathGroup = = null )
// swathGroup = findGroupNested ( rootg , H4header . createValidObjectName ( swathName ) ) ;
if ( swathGroup != null ) { featureType = amendSwath ( ncfile , elemSwath , swathGroup ) ; } else { log . warn ( "Cant find swath group {} {}" , swathName , ncfile . getLocation ( ) ) ; } } } // GRID
Element gridStructure = root . getChild ( "GridStructure" ) ; if ( gridStructure != null ) { List < Element > grids = gridStructure . getChildren ( ) ; for ( Element elemGrid : grids ) { Element gridNameElem = elemGrid . getChild ( "GridName" ) ; if ( gridNameElem == null ) { log . warn ( "No GridName element in {} {} " , elemGrid . getName ( ) , ncfile . getLocation ( ) ) ; continue ; } String gridName = NetcdfFile . makeValidCdmObjectName ( gridNameElem . getText ( ) . trim ( ) ) ; Group gridGroup = findGroupNested ( rootg , gridName ) ; // if ( gridGroup = = null )
// gridGroup = findGroupNested ( rootg , H4header . createValidObjectName ( gridName ) ) ;
if ( gridGroup != null ) { featureType = amendGrid ( elemGrid , ncfile , gridGroup , ncfile . getLocation ( ) ) ; } else { log . warn ( "Cant find Grid group {} {}" , gridName , ncfile . getLocation ( ) ) ; } } } // POINT - NOT DONE YET
Element pointStructure = root . getChild ( "PointStructure" ) ; if ( pointStructure != null ) { List < Element > pts = pointStructure . getChildren ( ) ; for ( Element elem : pts ) { Element nameElem = elem . getChild ( "PointName" ) ; if ( nameElem == null ) { log . warn ( "No PointName element in {} {}" , elem . getName ( ) , ncfile . getLocation ( ) ) ; continue ; } String name = nameElem . getText ( ) . trim ( ) ; Group ptGroup = findGroupNested ( rootg , name ) ; // if ( ptGroup = = null )
// ptGroup = findGroupNested ( rootg , H4header . createValidObjectName ( name ) ) ;
if ( ptGroup != null ) { featureType = FeatureType . POINT ; } else { log . warn ( "Cant find Point group {} {}" , name , ncfile . getLocation ( ) ) ; } } } if ( featureType != null ) { if ( showWork ) { log . debug ( "***EOS featureType= {}" , featureType . toString ( ) ) ; } rootg . addAttribute ( new Attribute ( CF . FEATURE_TYPE , featureType . toString ( ) ) ) ; // rootg . addAttribute ( new Attribute ( CDM . CONVENTIONS , " HDFEOS " ) ) ;
}


signature:
public class HdfEos { /** * convert to shared dimensions */
private void setSharedDimensions ( Variable v , List < Element > values , List < Dimension > unknownDims , String location ) { } }

implementation:
if ( values . size ( ) == 0 ) { return ; } // remove the " scalar " dumbension
Iterator < Element > iter = values . iterator ( ) ; while ( iter . hasNext ( ) ) { Element value = iter . next ( ) ; String dimName = value . getText ( ) . trim ( ) ; if ( dimName . equalsIgnoreCase ( "scalar" ) ) { iter . remove ( ) ; } } // gotta have same number of dimensions
List < Dimension > oldDims = v . getDimensions ( ) ; if ( oldDims . size ( ) != values . size ( ) ) { log . error ( "Different number of dimensions for {} {}" , v , location ) ; return ; } List < Dimension > newDims = new ArrayList < > ( ) ; Group group = v . getParentGroup ( ) ; for ( int i = 0 ; i < values . size ( ) ; i ++ ) { Element value = values . get ( i ) ; String dimName = value . getText ( ) . trim ( ) ; dimName = NetcdfFile . makeValidCdmObjectName ( dimName ) ; Dimension dim = group . findDimension ( dimName ) ; Dimension oldDim = oldDims . get ( i ) ; if ( dim == null ) { dim = checkUnknownDims ( dimName , unknownDims , oldDim , location ) ; } if ( dim == null ) { log . error ( "Unknown Dimension= {} for variable = {} {} " , dimName , v . getFullName ( ) , location ) ; return ; } if ( dim . getLength ( ) != oldDim . getLength ( ) ) { log . error ( "Shared dimension ({}) has different length than data dimension ({}) shared={} org={} for {} {}" , dim . getShortName ( ) , oldDim . getShortName ( ) , dim . getLength ( ) , oldDim . getLength ( ) , v , location ) ; return ; } newDims . add ( dim ) ; } v . setDimensions ( newDims ) ; if ( showWork ) { log . debug ( " set shared dimensions for {}" , v . getNameAndDimensions ( ) ) ; }


signature:
public class HdfEos { /** * look if the wanted dimension is in the unknownDims list . */
private Dimension checkUnknownDims ( String wantDim , List < Dimension > unknownDims , Dimension oldDim , String location ) { } }

implementation:
for ( Dimension dim : unknownDims ) { if ( dim . getShortName ( ) . equals ( wantDim ) ) { int len = oldDim . getLength ( ) ; if ( len == 0 ) { dim . setUnlimited ( true ) ; // allow zero length dimension ! !
} dim . setLength ( len ) ; // use existing ( anon ) dimension
Group parent = dim . getGroup ( ) ; parent . addDimensionIfNotExists ( dim ) ; // add to the parent
unknownDims . remove ( dim ) ; // remove from list LOOK is this ok ?
log . warn ( "unknownDim {} length set to {}{}" , wantDim , oldDim . getLength ( ) , location ) ; return dim ; } } return null ;


signature:
public class HdfEos { /** * look for a group with the given name . recurse into subgroups if needed . breadth first */
private Group findGroupNested ( Group parent , String name ) { } }

implementation: for ( Group g : parent . getGroups ( ) ) { if ( g . getShortName ( ) . equals ( name ) ) { return g ; } } for ( Group g : parent . getGroups ( ) ) { Group result = findGroupNested ( g , name ) ; if ( result != null ) { return result ; } } return null ;


signature:
public class Documentation { /** * Get inline content as a string , else null if there is none
 * @ return inline content as a string , else null */
public String readXlinkContent ( ) throws java . io . IOException { } }

implementation:
if ( uri == null ) return "" ; URL url = uri . toURL ( ) ; InputStream is = url . openStream ( ) ; ByteArrayOutputStream os = new ByteArrayOutputStream ( is . available ( ) ) ; // copy to string
byte [ ] buffer = new byte [ 1024 ] ; while ( true ) { int bytesRead = is . read ( buffer ) ; if ( bytesRead == - 1 ) break ; os . write ( buffer , 0 , bytesRead ) ; } is . close ( ) ; return new String ( os . toByteArray ( ) , CDM . utf8Charset ) ;


signature:
public class InvAccess { /** * Get the standard URL , with resolution if the URL is reletive .
 * catalog . resolveURI ( getUnresolvedUrlName ( ) )
 * @ return URL string , or null if error . */
public String getStandardUrlName ( ) { } }

implementation: URI uri = getStandardUri ( ) ; if ( uri == null ) return null ; return uri . toString ( ) ;


signature:
public class InvAccess { /** * Construct the standard THREDDS access URI for this dataset access method ,
 * resolve if the URI is relative .
 * @ return the standard fully resolved THREDDS access URI for this dataset access method , or null if error . */
public URI getStandardUri ( ) { } }

implementation: try { InvCatalog cat = dataset . getParentCatalog ( ) ; if ( cat == null ) return new URI ( getUnresolvedUrlName ( ) ) ; return cat . resolveUri ( getUnresolvedUrlName ( ) ) ; } catch ( java . net . URISyntaxException e ) { logger . warn ( "Error parsing URL= " + getUnresolvedUrlName ( ) ) ; return null ; }


signature:
public class iniFile { /** * Parse the . ini file indicated by the < code > private String iniFile < / code > . */
private void parseFile ( ) { } }

implementation:
try { try ( BufferedReader fp = new BufferedReader ( new InputStreamReader ( new FileInputStream ( iniFile ) , Charset . forName ( "UTF-8" ) ) ) ; ) { boolean done = false ; while ( ! done ) { String thisLine = fp . readLine ( ) ; if ( thisLine != null && thisLine . trim ( ) . length ( ) == 0 ) thisLine = null ; if ( thisLine != null ) { if ( Debug ) System . out . println ( "Read: \"" + thisLine + "\"" ) ; if ( thisLine . startsWith ( ";" ) || thisLine . equalsIgnoreCase ( "" ) ) { // Do nothing , it ' s a comment
if ( Debug ) System . out . println ( "Ignoring comment or blank line..." ) ; } else { int cindx = thisLine . indexOf ( ";" ) ; if ( cindx > 0 ) thisLine = thisLine . substring ( 0 , cindx ) . trim ( ) ; if ( Debug ) System . out . println ( "Comments removed: \"" + thisLine + "\"" ) ; if ( thisLine . startsWith ( "[" ) && thisLine . endsWith ( "]" ) ) { String sname = thisLine . substring ( 1 , thisLine . length ( ) - 1 ) . trim ( ) ; if ( Debug ) System . out . println ( "Found Section Name: " + sname ) ; if ( sectionNames == null ) sectionNames = new Vector ( ) ; sectionNames . add ( sname ) ; if ( sectionProperties == null ) sectionProperties = new Vector ( ) ; sectionProperties . add ( new Vector ( ) ) ; } else if ( sectionNames != null && sectionProperties != null ) { int eqidx = thisLine . indexOf ( "=" ) ; if ( eqidx != - 1 ) { String pair [ ] = new String [ 2 ] ; pair [ 0 ] = thisLine . substring ( 0 , eqidx ) . trim ( ) ; pair [ 1 ] = thisLine . substring ( eqidx + 1 , thisLine . length ( ) ) . trim ( ) ; if ( Debug ) System . out . println ( "pair[0]: \"" + pair [ 0 ] + "\"   pair[1]: \"" + pair [ 1 ] + "\"" ) ; // Add the pair to the current property list , which is the
// last element in the sectionProperties vector .
( ( Vector ) sectionProperties . lastElement ( ) ) . add ( pair ) ; } } } } else { done = true ; } } } } catch ( FileNotFoundException e ) { System . err . println ( "Could Not Find ini File: \"" + iniFile + "\"" ) ; } catch ( IOException e ) { System . err . println ( "Could Not Read ini File: \"" + iniFile + "\"" ) ; }


signature:
public class iniFile { /** * Get the list of properties for the section < code > sectionName < / code > .
 * @ param sectionName A < code > String < / code > containing the name of the
 * section whose property list is desired .
 * @ return An enumeration of the properties in the < code > sectionName < / code >
 * Returns < code > null < / code > if the section name doesn ' t exist or there are
 * no properties for the section . */
public Enumeration getPropList ( String sectionName ) { } }

implementation: if ( sectionNames == null ) { System . err . println ( errMsg ) ; return ( null ) ; } int sectionIndex = 0 ; Enumeration e = sectionNames . elements ( ) ; boolean done = false ; while ( ! done && e . hasMoreElements ( ) ) { String thisName = ( String ) e . nextElement ( ) ; if ( sectionName . equalsIgnoreCase ( thisName ) ) done = true ; else sectionIndex ++ ; } if ( ! done ) return ( null ) ; return ( ( ( Vector ) sectionProperties . elementAt ( sectionIndex ) ) . elements ( ) ) ;


signature:
public class iniFile { /** * Get the named property from the current section .
 * @ param propertyName The name of the desired property .
 * @ return A < code > String < / code > containing the value of property of the
 * passed property name . Returns null if the property name doesn ' t exist
 * or is not set . */
public String getProperty ( String propertyName ) { } }

implementation: if ( currentSection < 0 ) { String msg = "You must use the setSection() method before you can use getProperty()." ; System . err . println ( msg ) ; return ( msg ) ; } String pair [ ] = null ; Enumeration e = ( ( Vector ) sectionProperties . elementAt ( currentSection ) ) . elements ( ) ; boolean done = false ; while ( ! done && e . hasMoreElements ( ) ) { pair = ( String [ ] ) e . nextElement ( ) ; if ( pair [ 0 ] . equalsIgnoreCase ( propertyName ) ) done = true ; } if ( done ) return ( pair [ 1 ] ) ; return ( null ) ;


signature:
public class iniFile { /** * Prints the iniFile .
 * @ param ps The < code > PrintStream < / code > to which to print . */
public void printProps ( PrintStream ps ) { } }

implementation: Enumeration se = getSectionList ( ) ; if ( se == null ) { ps . println ( errMsg ) ; } else { while ( se . hasMoreElements ( ) ) { String sname = ( String ) se . nextElement ( ) ; setSection ( sname ) ; ps . println ( "[" + sname + "]" ) ; Enumeration pe = getPropList ( sname ) ; while ( pe != null && pe . hasMoreElements ( ) ) { String pair [ ] = ( String [ ] ) pe . nextElement ( ) ; String prop = pair [ 0 ] ; String valu = getProperty ( prop ) ; ps . println ( "    \"" + prop + "\" = \"" + valu + "\"" ) ; } } }


signature:
public class iniFile { /** * Set the section of the iniFile that you wish to work with . This is
 * persistent for the life of the object , or until it ' s set again .
 * @ param sectionName A < code > String < / code > containing the name of the
 * section that is desired .
 * @ return true if the section exists and the operation was successful ,
 * false otherwise . */
public boolean setSection ( String sectionName ) { } }

implementation: if ( sectionNames == null ) { System . err . println ( errMsg ) ; return ( false ) ; } int sectionIndex = 0 ; Enumeration e = sectionNames . elements ( ) ; boolean done = false ; while ( ! done && e . hasMoreElements ( ) ) { String thisName = ( String ) e . nextElement ( ) ; if ( sectionName . equalsIgnoreCase ( thisName ) ) done = true ; else sectionIndex ++ ; } if ( ! done ) return ( false ) ; currentSection = sectionIndex ; return ( true ) ;


signature:
public class ProjectionParamPanel { /** * construct input fields based on Projection Class */
public void setProjection ( ProjectionManager . ProjectionClass pc ) { } }

implementation:
// clear out any fields
removeAll ( ) ; for ( ProjectionManager . ProjectionParam pp : pc . paramList ) { // construct the label
JPanel thisPanel = new JPanel ( ) ; thisPanel . add ( new JLabel ( pp . name + ": " ) ) ; // text input field
JTextField tf = new JTextField ( ) ; pp . setTextField ( tf ) ; tf . setColumns ( 12 ) ; thisPanel . add ( tf ) ; add ( thisPanel ) ; } revalidate ( ) ;


signature:
public class wwwOutPut { /** * Changed 4/28/10 dmh : legal dods names are not same as legal javascript names , so translate . */
public static String nameForJsCode ( String dodsName ) { } }

implementation: StringBuilder buf = new StringBuilder ( dodsName ) ; for ( int i = 0 ; i < buf . length ( ) ; i ++ ) { char c = buf . charAt ( i ) ; if ( c == '-' ) buf . replace ( i , i + 1 , "_" ) ; else if ( legal_javascript_id_chars . indexOf ( c ) < 0 ) { String s = "_" + String . valueOf ( ( int ) c ) + "_" ; buf . replace ( i , i + 1 , s ) ; } } return "dods_" + buf . toString ( ) ;


signature:
public class wwwOutPut { /** * void
 * WWWOutput : : write _ variable _ entries ( DAS & das , DDS & dds )
 * This writes the text ` Variables : ' and then sets up the table so that
 * the first variable ' s section is written into column two .
 * _ os < < \
 * < tr >
 * < td align = \ " right \ " valign = \ " top \ " >
 * < h3 > < a href = \ " dods _ form _ help . html # dataset _ variables \ " > Variables : < / a > < / h3 >
 * < td > " ;
 * for ( Pix p = dds . first _ var ( ) ; p ; dds . next _ var ( p ) ) {
 * dds . var ( p ) - > print _ val ( _ os ) ;
 * write _ variable _ attributes ( dds . var ( p ) , das ) ;
 * _ os < < " \ n < p > < p > \ n \ n " ; / / End the current var ' s section
 * _ os < < " < tr > < td > < td > \ n \ n " ; / / Start the next var in column two */
public void writeVariableEntries ( DAS das , DDS dds ) { } }

implementation:
// This writes the text ` Variables : ' and then sets up the table
// so that the first variable ' s section is written into column two .
pWrt . print ( "
\n" + "\n" + "
Variables:
\n" + "
\n" ) ; Enumeration e = dds . getVariables ( ) ; while ( e . hasMoreElements ( ) ) { BaseType bt = ( BaseType ) e . nextElement ( ) ; ( ( BrowserForm ) bt ) . printBrowserForm ( pWrt , das ) ; writeVariableAttributes ( bt , das ) ; pWrt . print ( "\n

\n\n" ) ; // End the current var ' s section
pWrt . print ( "
\n\n" ) ; // Start the next var in column two
}


signature:
public class wwwOutPut { /** * void
 * WWWOutput : : write _ variable _ attributes ( BaseType * btp , DAS & das )
 * AttrTable * attr = das . get _ table ( btp - > name ( ) ) ;
 * Don ' t write anything if there are no attributes .
 * if ( ! attr )
 * return ;
 * _ os < < " < textarea name = \ " " < < btp - > name ( ) < < " _ attr " < < " \ " rows = "
 * < < _ attr _ rows < < " cols = " < < _ attr _ cols < < " > \ n " ;
 * write _ attributes ( attr ) ;
 * _ os < < " < / textarea > \ n \ n " ; */
public void writeVariableAttributes ( BaseType bt , DAS das ) { } }

implementation: try { AttributeTable attr = das . getAttributeTable ( bt . getEncodedName ( ) ) ; if ( attr != null ) { pWrt . print ( "<textarea name=\"" + bt . getLongName ( ) . replace ( '.' , '_' ) + "_attr" + "\" rows=" + _attrRows + " cols=" + _attrCols + ">\n" ) ; writeAttributes ( attr ) ; pWrt . print ( "</textarea>\n\n" ) ; } } catch ( NoSuchAttributeException nsae ) { }


signature:
public class NcShapeType { /** * wml2 : Collection / wml2 : observationMember / om : OM _ Observation / om : featureOfInterest / wml2 : MonitoringPoint / sams : shape */
public static ShapeType initShape ( ShapeType shape , StationTimeSeriesFeature stationFeat ) { } }

implementation:
// gml : Point
PointDocument pointDoc = PointDocument . Factory . newInstance ( ) ; NcPointType . initPoint ( pointDoc . addNewPoint ( ) , stationFeat ) ; shape . set ( pointDoc ) ; return shape ;


signature:
public class LayoutM { /** * Adds the specified component to the layout , using the specified
 * constraint object .
 * @ param comp the component to be added
 * @ param constraint where / how the component is added to the layout . */
public void addLayoutComponent ( Component comp , Object constraint ) { } }

implementation: if ( debug ) System . out . println ( name + " addLayoutComponent= " + comp . getClass ( ) . getName ( ) + " " + comp . hashCode ( ) + " " + constraint ) ; if ( ! ( constraint instanceof Constraint ) ) throw new IllegalArgumentException ( "MySpringLayout must be Constraint" ) ; constraintMap . put ( comp , constraint ) ; globalBounds = null ;


signature:
public class LayoutM { /** * Invalidates the layout , indicating that if the layout manager
 * has cached information it should be discarded . */
public void invalidateLayout ( Container target ) { } }

implementation:
if ( debug ) System . out . println ( name + " invalidateLayout " ) ; globalBounds = null ; // this probably need to be scheduled later ? ?
// layoutContainer ( target ) ;


signature:
public class LayoutM { /** * Removes the specified component from the layout .
 * @ param comp the component to be removed */
public void removeLayoutComponent ( Component comp ) { } }

implementation: if ( debug ) System . out . println ( "removeLayoutComponent" ) ; constraintMap . remove ( comp ) ; globalBounds = null ;


signature:
public class LayoutM { /** * Calculates the preferred size dimensions for the specified
 * container , given the components it contains .
 * @ param parent the container to be laid out
 * @ see # minimumLayoutSize */
public Dimension preferredLayoutSize ( Container parent ) { } }

implementation: if ( globalBounds == null ) layoutContainer ( parent ) ; if ( debug ) System . out . println ( name + " preferredLayoutSize " + globalBounds . getSize ( ) + " " + parent . getInsets ( ) ) ; return globalBounds . getSize ( ) ;


signature:
public class LayoutM { /** * Calculates the minimum size dimensions for the specified
 * container , given the components it contains .
 * @ param parent the component to be laid out
 * @ see # preferredLayoutSize */
public Dimension minimumLayoutSize ( Container parent ) { } }

implementation: if ( debug ) System . out . println ( "minimumLayoutSize" ) ; if ( globalBounds == null ) layoutContainer ( parent ) ; return globalBounds . getSize ( ) ;


signature:
public class LayoutM { /** * Lays out the specified container .
 * @ param target the container to be laid out */
public void layoutContainer ( Container target ) { } }

implementation:
synchronized ( target . getTreeLock ( ) ) { if ( debug ) System . out . println ( name + " layoutContainer " ) ; // first layout any nested LayoutM components
// it seems that generally Swing laysout from outer to inner ? ? ?
int n = target . getComponentCount ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Component comp = target . getComponent ( i ) ; if ( comp instanceof Container ) { Container c = ( Container ) comp ; LayoutManager m = c . getLayout ( ) ; if ( m instanceof LayoutM ) m . layoutContainer ( c ) ; } } // now layout this container
reset ( target ) ; globalBounds = new Rectangle ( 0 , 0 , 0 , 0 ) ; while ( ! layoutPass ( target ) ) target . setPreferredSize ( globalBounds . getSize ( ) ) ; }


signature:
public class RadialCoordSys { /** * Determine if this CoordinateSystem can be made into a RadialCoordSys .
 * @ param parseInfo put debug information into this Formatter ; may be null .
 * @ param cs the CoordinateSystem to test
 * @ return true if it can be made into a RadialCoordSys . */
public static boolean isRadialCoordSys ( Formatter parseInfo , CoordinateSystem cs ) { } }

implementation: return ( cs . getAzimuthAxis ( ) != null ) && ( cs . getRadialAxis ( ) != null ) && ( cs . getElevationAxis ( ) != null ) ;


signature:
public class RadialCoordSys { /** * Determine if the CoordinateSystem cs can be made into a GridCoordSys for the Variable v .
 * @ param parseInfo put debug information into this StringBuffer ; may be null .
 * @ param cs CoordinateSystem to check .
 * @ param v Variable to check .
 * @ return the RadialCoordSys made from cs , else null . */
public static RadialCoordSys makeRadialCoordSys ( Formatter parseInfo , CoordinateSystem cs , VariableEnhanced v ) { } }

implementation: if ( parseInfo != null ) { parseInfo . format ( " " ) ; v . getNameAndDimensions ( parseInfo , true , false ) ; parseInfo . format ( " check CS " + cs . getName ( ) ) ; } if ( isRadialCoordSys ( parseInfo , cs ) ) { RadialCoordSys rcs = new RadialCoordSys ( cs ) ; if ( cs . isComplete ( v ) ) { if ( parseInfo != null ) parseInfo . format ( " OK%n" ) ; return rcs ; } else { if ( parseInfo != null ) parseInfo . format ( " NOT complete%n" ) ; } } return null ;


signature:
public class RadialCoordSys { /** * Get the maximum radial distance , in km . */
public double getMaximumRadial ( ) { } }

implementation:
if ( maxRadial == 0.0 ) { try { Array radialData = getRadialAxisDataCached ( ) ; maxRadial = MAMath . getMaximum ( radialData ) ; String units = getRadialAxis ( ) . getUnitsString ( ) ; SimpleUnit radialUnit = SimpleUnit . factory ( units ) ; maxRadial = radialUnit . convertTo ( maxRadial , SimpleUnit . kmUnit ) ; // convert to km
} catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( IllegalArgumentException e ) { e . printStackTrace ( ) ; } } return maxRadial ;


signature:
public class RadialCoordSys { /** * Get the units of Calendar time .
 * To get a Date , from a time value , call DateUnit . getStandardDate ( double value ) .
 * To get units as a String , call DateUnit . getUnitsString ( ) . */
public ucar . nc2 . units . DateUnit getTimeUnits ( ) throws Exception { } }

implementation: if ( null == dateUnit ) { dateUnit = new DateUnit ( timeAxis . getUnitsString ( ) ) ; } return dateUnit ;


signature:
public class RadialCoordSys { /** * debug */
static public void main ( String [ ] args ) { } }

implementation: System . out . println ( "1 Deg=" + Math . toDegrees ( 1000 * 111.0 / Earth . getRadius ( ) ) ) ;


signature:
public class GridAsPointDataset { /** * Reads data for the given point ( earthlocation ) and if bounded is true returns data for the closest point within the grid , for points outside of the grid
 * @ param grid read data from here
 * @ param date at this time
 * @ param location EarthLocation , if altitude is NaN assume that is 2D point
 * @ param bounded if bounded , location must be in grid cell ; otherwise get nearest grid point to location
 * @ return the location and data value
 * @ throws java . io . IOException on bad stuff */
public Point readData ( GridDatatype grid , CalendarDate date , EarthLocation location , boolean bounded ) throws java . io . IOException { } }

implementation:
if ( ! bounded ) { if ( Double . isNaN ( location . getAltitude ( ) ) ) { return readData ( grid , date , location . getLatitude ( ) , location . getLongitude ( ) ) ; } else { return readData ( grid , date , location . getAltitude ( ) , location . getLatitude ( ) , location . getLongitude ( ) ) ; } } // Bounded - - > Read closest data
GridCoordSystem gcs = grid . getCoordinateSystem ( ) ; int tidx = findTimeIndexForCalendarDate ( gcs , date ) ; int [ ] xy = gcs . findXYindexFromLatLonBounded ( location . getLatitude ( ) , location . getLongitude ( ) , null ) ; LatLonPoint latlon = gcs . getLatLon ( xy [ 0 ] , xy [ 1 ] ) ; Point p = new Point ( ) ; p . lat = latlon . getLatitude ( ) ; p . lon = latlon . getLongitude ( ) ; int zidx = - 1 ; if ( ! Double . isNaN ( location . getAltitude ( ) ) ) { CoordinateAxis1D zAxis = gcs . getVerticalAxis ( ) ; zidx = zAxis . findCoordElement ( location . getAltitude ( ) ) ; p . z = zAxis . getCoordValue ( zidx ) ; } Array data = grid . readDataSlice ( tidx , zidx , xy [ 1 ] , xy [ 0 ] ) ; p . dataValue = data . getDouble ( data . getIndex ( ) ) ; return p ;


signature:
public class URLDumpPane { /** * Uses apache HttpComponents
 * private void openClient ( String urlString , Command cmd ) {
 * HttpEntity entity = null ;
 * try {
 * org . apache . http . client . HttpClient httpclient = new DefaultHttpClient ( ) ;
 * request
 * HttpGet httpget = new HttpGet ( urlString ) ;
 * appendLine ( " Request : " + httpget . getRequestLine ( ) ) ;
 * HttpParams params = httpget . getParams ( ) ;
 * appendLine ( " Params : " ) ;
 * showParameter ( CoreProtocolPNames . HTTP _ CONTENT _ CHARSET , params ) ;
 * showParameter ( CoreProtocolPNames . HTTP _ ELEMENT _ CHARSET , params ) ;
 * showParameter ( CoreProtocolPNames . ORIGIN _ SERVER , params ) ;
 * showParameter ( CoreProtocolPNames . PROTOCOL _ VERSION , params ) ;
 * showParameter ( CoreProtocolPNames . STRICT _ TRANSFER _ ENCODING , params ) ;
 * showParameter ( CoreProtocolPNames . USE _ EXPECT _ CONTINUE , params ) ;
 * showParameter ( CoreProtocolPNames . USER _ AGENT , params ) ;
 * showParameter ( CoreProtocolPNames . WAIT _ FOR _ CONTINUE , params ) ;
 * response
 * BasicHttpContext localContext = new BasicHttpContext ( ) ;
 * HttpResponse response = httpclient . execute ( httpget , localContext ) ;
 * appendLine ( " \ nHttpContext : " + localContext ) ;
 * showAtribute ( ExecutionContext . HTTP _ CONNECTION , localContext ) ;
 * showAtribute ( ExecutionContext . HTTP _ PROXY _ HOST , localContext ) ;
 * showAtribute ( ExecutionContext . HTTP _ REQ _ SENT , localContext ) ;
 * showAtribute ( ExecutionContext . HTTP _ REQUEST , localContext ) ;
 * showAtribute ( ExecutionContext . HTTP _ RESPONSE , localContext ) ;
 * showAtribute ( ExecutionContext . HTTP _ TARGET _ HOST , localContext ) ;
 * HttpRequest req = ( HttpRequest ) localContext . getAttribute ( ExecutionContext . HTTP _ REQUEST ) ;
 * appendLine ( " \ nRequest Headers : " ) ;
 * HeaderIterator it = req . headerIterator ( ) ;
 * while ( it . hasNext ( ) ) {
 * appendLine ( " " + it . next ( ) . toString ( ) ) ;
 * appendLine ( " \ nResponse Headers : " ) ;
 * it = response . headerIterator ( ) ;
 * while ( it . hasNext ( ) ) {
 * appendLine ( " " + it . next ( ) . toString ( ) ) ;
 * content
 * entity = response . getEntity ( ) ;
 * if ( entity ! = null ) {
 * String contents = EntityUtils . toString ( entity ) ;
 * if ( contents . length ( ) > 50 * 1000)
 * contents = contents . substring ( 0 , 50 * 1000 ) ;
 * appendLine ( " \ nContent : " ) ;
 * appendLine ( contents ) ;
 * } catch ( Exception e ) {
 * ByteArrayOutputStream bos = new ByteArrayOutputStream ( 5000 ) ;
 * e . printStackTrace ( new PrintStream ( bos ) ) ;
 * appendLine ( bos . toString ( ) ) ;
 * } finally {
 * if ( entity ! = null ) try {
 * entity . consumeContent ( ) ;
 * } catch ( IOException e ) {
 * ByteArrayOutputStream bos = new ByteArrayOutputStream ( 5000 ) ;
 * e . printStackTrace ( new PrintStream ( bos ) ) ;
 * appendLine ( bos . toString ( ) ) ;
 * private void showAtribute ( String key , HttpContext localContext ) {
 * Object value = localContext . getAttribute ( key ) ;
 * if ( null ! = value )
 * appendLine ( " " + key + " : " + value ) ;
 * private void showParameter ( String key , HttpParams params ) {
 * Object value = params . getParameter ( key ) ;
 * if ( null ! = value )
 * appendLine ( " " + key + " : " + value ) ; */
private HTTPMethod processMethod ( HTTPSession httpclient , String url , Command cmd ) throws HTTPException , UnsupportedEncodingException { } }

implementation:
HTTPMethod m = null ; if ( cmd == Command . GET ) m = HTTPFactory . Get ( httpclient , url ) ; else if ( cmd == Command . HEAD ) m = HTTPFactory . Head ( httpclient , url ) ; else if ( cmd == Command . OPTIONS ) m = HTTPFactory . Options ( httpclient , url ) ; else if ( cmd == Command . PUT ) { m = HTTPFactory . Put ( httpclient , url ) ; m . setRequestContent ( new StringEntity ( ta . getText ( ) ) ) ; // was setRequestContentAsString ( ta . getText ( ) ) ;
} return m ;


signature:
public class URLDumpPane { /** * Uses apache commons HttpClient */
@ Urlencoded private void openURL2 ( String urlString , Command cmd ) { } }

implementation:
HTTPMethod m ; try ( HTTPSession httpclient = HTTPFactory . newSession ( urlString ) ) { /* you might think this works , but it doesnt :
 URI raw = new URI ( urlString . trim ( ) ) ;
 appendLine ( " raw scheme = " + raw . getScheme ( ) + " \ n auth = " + raw . getRawAuthority ( ) + " \ n path = " + raw . getRawPath ( ) +
 " \ n query = " + raw . getRawQuery ( ) + " \ n fragment = " + raw . getRawFragment ( ) + " \ n " ) ;
 URI url = new URI ( raw . getScheme ( ) , raw . getRawAuthority ( ) ,
 URIUtil . encodePath ( raw . getRawPath ( ) ) ,
 URIUtil . encodeQuery ( raw . getRawQuery ( ) ) ,
 raw . getRawFragment ( ) ) ;
 appendLine ( " encoded scheme = " + url . getScheme ( ) + " \ n auth = " + url . getAuthority ( ) + " \ n path = " + url . getPath ( ) +
 " \ n query = " + url . getQuery ( ) + " \ n fragment = " + url . getFragment ( ) + " \ n " ) ;
 urlString = url . toString ( ) ; */
// urlString = URLnaming . escapeQuery ( urlString ) ;
if ( cmd == Command . GET ) m = HTTPFactory . Get ( httpclient , urlString ) ; else if ( cmd == Command . HEAD ) m = HTTPFactory . Head ( httpclient , urlString ) ; else if ( cmd == Command . OPTIONS ) m = HTTPFactory . Options ( httpclient , urlString ) ; else if ( cmd == Command . PUT ) { m = HTTPFactory . Put ( httpclient , urlString ) ; m . setRequestContent ( new StringEntity ( ta . getText ( ) ) ) ; // was setRequestContentAsString ( ta . getText ( ) ) ;
} else { throw new IOException ( "Unsupported command: " + cmd ) ; } m . setCompression ( "gzip,deflate" ) ; /* FIX
 appendLine ( " HttpClient " + m . getName ( ) + " " + urlString ) ;
 appendLine ( " do Authentication = " + m . getDoAuthentication ( ) ) ;
 appendLine ( " follow Redirects = " + m . getFollowRedirects ( ) ) ;
 appendLine ( " cookie policy = " + p . getCookiePolicy ( ) ) ;
 appendLine ( " http version = " + p . getVersion ( ) . toString ( ) ) ;
 appendLine ( " timeout ( msecs ) = " + p . getSoTimeout ( ) ) ;
 appendLine ( " virtual host = " + p . getVirtualHost ( ) ) ; */
printHeaders ( "Request Headers = " , m . getRequestHeaders ( ) ) ; appendLine ( " " ) ; m . execute ( ) ; printHeaders ( "Request Headers2 = " , m . getRequestHeaders ( ) ) ; appendLine ( " " ) ; appendLine ( "Status = " + m . getStatusCode ( ) + " " + m . getStatusText ( ) ) ; appendLine ( "Status Line = " + m . getStatusLine ( ) ) ; printHeaders ( "Response Headers = " , m . getResponseHeaders ( ) ) ; if ( cmd == Command . GET ) { appendLine ( "\nResponseBody---------------" ) ; String charset = m . getResponseCharSet ( ) ; if ( charset == null ) charset = CDM . UTF8 ; String contents = null ; // check for deflate and gzip compression
Header h = m . getResponseHeader ( "content-encoding" ) ; String encoding = ( h == null ) ? null : h . getValue ( ) ; if ( encoding != null && encoding . equals ( "deflate" ) ) { byte [ ] body = m . getResponseAsBytes ( ) ; if ( body != null ) { InputStream is = new BufferedInputStream ( new InflaterInputStream ( new ByteArrayInputStream ( body ) ) , 10000 ) ; contents = IO . readContents ( is , charset ) ; double ratio = ( double ) contents . length ( ) / body . length ; appendLine ( "  deflate encoded=" + body . length + " decoded=" + contents . length ( ) + " ratio= " + ratio ) ; } } else if ( encoding != null && encoding . equals ( "gzip" ) ) { byte [ ] body = m . getResponseAsBytes ( ) ; if ( body != null ) { InputStream is = new BufferedInputStream ( new GZIPInputStream ( new ByteArrayInputStream ( body ) ) , 10000 ) ; contents = IO . readContents ( is , charset ) ; double ratio = ( double ) contents . length ( ) / body . length ; appendLine ( "  gzip encoded=" + body . length + " decoded=" + contents . length ( ) + " ratio= " + ratio ) ; } } else { byte [ ] body = m . getResponseAsBytes ( 50 * 1000 ) ; // max 50 Kbytes
contents = ( body == null ) ? "" : new String ( body , charset ) ; } if ( contents != null ) { if ( contents . length ( ) > 50 * 1000 ) // limit contents
contents = contents . substring ( 0 , 50 * 1000 ) ; appendLine ( contents ) ; } } else if ( cmd == Command . OPTIONS ) printSet ( "AllowedMethods = " , HTTPFactory . getAllowedMethods ( ) ) ; } catch ( IOException e ) { StringWriter sw = new StringWriter ( 5000 ) ; e . printStackTrace ( new PrintWriter ( sw ) ) ; appendLine ( sw . toString ( ) ) ; }


signature:
public class URLDumpPane { /** * Uses java . net */
private void openURL ( String urlString , Command command ) { } }

implementation:
try { // Open the URLConnection for reading
URL u = new URL ( urlString ) ; currentConnection = ( HttpURLConnection ) u . openConnection ( ) ; currentConnection . setRequestMethod ( command . toString ( ) ) ; // GET or HEAD
currentConnection . setAllowUserInteraction ( true ) ; clear ( ) ; appendLine ( command + " request for " + urlString ) ; // request headers
Map < String , List < String > > reqs = currentConnection . getRequestProperties ( ) ; for ( Map . Entry < String , List < String > > ent : reqs . entrySet ( ) ) { append ( " " + ent . getKey ( ) + ": " ) ; for ( String v : ent . getValue ( ) ) append ( v + " " ) ; appendLine ( "" ) ; } appendLine ( "" ) ; appendLine ( "getFollowRedirects=" + HttpURLConnection . getFollowRedirects ( ) ) ; appendLine ( "getInstanceFollowRedirects=" + currentConnection . getInstanceFollowRedirects ( ) ) ; appendLine ( "AllowUserInteraction=" + currentConnection . getAllowUserInteraction ( ) ) ; appendLine ( "" ) ; int code = currentConnection . getResponseCode ( ) ; String response = currentConnection . getResponseMessage ( ) ; // response headers
appendLine ( " HTTP/1.x " + code + " " + response ) ; appendLine ( " content-length: " + currentConnection . getContentLength ( ) ) ; appendLine ( " content-encoding: " + currentConnection . getContentEncoding ( ) ) ; appendLine ( " content-type: " + currentConnection . getContentType ( ) ) ; appendLine ( "\nHeaders: " ) ; for ( int j = 1 ; true ; j ++ ) { String header = currentConnection . getHeaderField ( j ) ; String key = currentConnection . getHeaderFieldKey ( j ) ; if ( header == null || key == null ) break ; appendLine ( " " + key + ": " + header ) ; } appendLine ( "" ) ; appendLine ( "contents:" ) ; // read it
java . io . InputStream is = currentConnection . getInputStream ( ) ; ByteArrayOutputStream bout = new ByteArrayOutputStream ( 200000 ) ; IO . copy ( is , bout ) ; is . close ( ) ; append ( new String ( bout . toByteArray ( ) , CDM . utf8Charset ) ) ; appendLine ( "end contents" ) ; } catch ( MalformedURLException e ) { append ( urlString + " is not a parseable URL" ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; }


signature:
public class GEOSTransform { /** * Transform geographic Earth coordinates to satellite view angle coordinate system
 * also known as the " intermediate " coordinate system in CGMS Normalized Geostationary Projection .
 * @ param geographic _ lon longitude , units : degrees
 * @ param geographic _ lat latitude , units : degrees
 * @ return ( lamda , theta ) units : radian . This is the ( x , y ) or ( East - West , North _ South ) view angle . */
public double [ ] earthToSat ( double geographic_lon , double geographic_lat ) { } }

implementation:
geographic_lat = geographic_lat * DEG_TO_RAD ; geographic_lon = geographic_lon * DEG_TO_RAD ; double geocentric_lat = Math . atan ( ( ( r_pol * r_pol ) / ( r_eq * r_eq ) ) * Math . tan ( geographic_lat ) ) ; double r_earth = r_pol / Math . sqrt ( 1.0 - ( ( r_eq * r_eq - r_pol * r_pol ) / ( r_eq * r_eq ) ) * Math . cos ( geocentric_lat ) * Math . cos ( geocentric_lat ) ) ; double r_1 = h - r_earth * Math . cos ( geocentric_lat ) * Math . cos ( geographic_lon - sub_lon ) ; double r_2 = - r_earth * Math . cos ( geocentric_lat ) * Math . sin ( geographic_lon - sub_lon ) ; double r_3 = r_earth * Math . sin ( geocentric_lat ) ; if ( r_1 > h ) { // often two geoid intersect points , use the closer one .
return new double [ ] { Double . NaN , Double . NaN } ; } double lamda_sat = Double . NaN ; double theta_sat = Double . NaN ; if ( scan_geom . equals ( GEOS ) ) { // GEOS ( eg . SEVIRI , MSG ) CGMS 03 , 4.4.3.2 , Normalized Geostationary Projection
lamda_sat = Math . atan ( - r_2 / r_1 ) ; theta_sat = Math . asin ( r_3 / Math . sqrt ( r_1 * r_1 + r_2 * r_2 + r_3 * r_3 ) ) ; } else if ( scan_geom . equals ( GOES ) ) { // GOES ( eg . GOES - R ABI )
lamda_sat = Math . asin ( - r_2 / Math . sqrt ( r_1 * r_1 + r_2 * r_2 + r_3 * r_3 ) ) ; theta_sat = Math . atan ( r_3 / r_1 ) ; } return new double [ ] { lamda_sat , theta_sat } ;


signature:
public class GEOSTransform { /** * Transform satellite view angle coordinates , known as the " intermeidate " coordinates in the
 * CGMS Normalized Geostationary Projection , to geographic Earth coordinates .
 * @ param x is lamda ( East - West ) angle , units : radians
 * @ param y is theta ( Norht - South ) angle , units : radians
 * @ return ( Longitude , Latitude ) , units degrees */
public double [ ] satToEarth ( double x , double y ) { } }

implementation:
if ( scan_geom . equals ( GOES ) ) { // convert from GOES to GEOS for transfrom below
double [ ] lambda_theta_geos = GOES_to_GEOS ( x , y ) ; x = lambda_theta_geos [ 0 ] ; y = lambda_theta_geos [ 1 ] ; } double c1 = ( h * Math . cos ( x ) * Math . cos ( y ) ) * ( h * Math . cos ( x ) * Math . cos ( y ) ) ; double c2 = ( Math . cos ( y ) * Math . cos ( y ) + fp * Math . sin ( y ) * Math . sin ( y ) ) * d ; if ( c1 < c2 ) { return new double [ ] { Double . NaN , Double . NaN } ; } double s_d = Math . sqrt ( c1 - c2 ) ; double s_n = ( h * Math . cos ( x ) * Math . cos ( y ) - s_d ) / ( Math . cos ( y ) * Math . cos ( y ) + fp * Math . sin ( y ) * Math . sin ( y ) ) ; double s_1 = h - s_n * Math . cos ( x ) * Math . cos ( y ) ; double s_2 = s_n * Math . sin ( x ) * Math . cos ( y ) ; double s_3 = - s_n * Math . sin ( y ) ; double s_xy = Math . sqrt ( s_1 * s_1 + s_2 * s_2 ) ; double geographic_lon = Math . atan ( s_2 / s_1 ) + sub_lon ; double geographic_lat = Math . atan ( - fp * ( s_3 / s_xy ) ) ; double lonDegrees = RAD_TO_DEG * geographic_lon ; double latDegrees = RAD_TO_DEG * geographic_lat ; // force output longitude to - 180 to 180 range
if ( lonDegrees < - 180.0 ) lonDegrees += 360.0 ; if ( lonDegrees > 180.0 ) lonDegrees -= 360.0 ; return new double [ ] { lonDegrees , latDegrees } ;


signature:
public class GEOSTransform { /** * Transform view angle coordinates in the GOES scan geometry frame to view angle coordinates
 * in the GEOS scan geometry frame . */
public double [ ] GOES_to_GEOS ( double lamda_goes , double theta_goes ) { } }

implementation: double theta_geos = Math . asin ( Math . sin ( theta_goes ) * Math . cos ( lamda_goes ) ) ; double lamda_geos = Math . atan ( Math . tan ( lamda_goes ) / Math . cos ( theta_goes ) ) ; return new double [ ] { lamda_geos , theta_geos } ;


signature:
public class GEOSTransform { /** * Transform fractional FGF coordinates to ( longitude , latitude ) .
 * @ param fgf _ x fractional FGF coordinate , zero - based
 * @ param fgf _ y fractional FGF coordinate , zero - based
 * @ param scale _ x scaleFactor from the x coordinate variable
 * @ param offset _ x addOffset from the x coordinate variable
 * @ param scale _ y scaleFactor from the y coordinate variable
 * @ param offset _ y addOffset from the y coordinate variable
 * @ return ( Longitude , Latitude ) , units : degrees */
public double [ ] FGFtoEarth ( double fgf_x , double fgf_y , double scale_x , double offset_x , double scale_y , double offset_y ) { } }

implementation: double [ ] xy = FGFtoSat ( fgf_x , fgf_y , scale_x , offset_x , scale_y , offset_y ) ; return satToEarth ( xy [ 0 ] , xy [ 1 ] ) ;


signature:
public class GEOSTransform { /** * Transform fractional FGF coordinates to ( lamda , theta ) radians .
 * @ param fgf _ x fractional FGF coordinate , zero - based
 * @ param fgf _ y fractional FGF coordinate , zero - based
 * @ param scale _ x scaleFactor from the x coordinate variable
 * @ param offset _ x addOffset from the x coordinate variable
 * @ param scale _ y scaleFactor from the y coordinate variable
 * @ param offset _ y addOffset from the y coordinate variable
 * @ return ( lamda , theta ) , units : radians */
public double [ ] FGFtoSat ( double fgf_x , double fgf_y , double scale_x , double offset_x , double scale_y , double offset_y ) { } }

implementation: double x = fgf_x * scale_x + offset_x ; double y = fgf_y * scale_y + offset_y ; return new double [ ] { x , y } ;


signature:
public class GEOSTransform { /** * Transform integer FGF coordinates to ( longitude , latitude ) of pixel center
 * The ( i , j ) pixel , zero - based , refers to the pixel center .
 * @ param scale _ x scaleFactor from the x coordinate variable
 * @ param offset _ x addOffset from the x coordinate variable
 * @ param scale _ y scaleFactor from the y coordinate variable
 * @ param offset _ y addOffset from the y coordinate variable
 * @ return ( Longitude , Latitude ) , units : degrees , of FGF ( i , j ) pixel center */
public double [ ] elemLineToEarth ( int elem , int line , double scale_x , double offset_x , double scale_y , double offset_y ) { } }

implementation: return FGFtoEarth ( ( double ) elem , ( double ) line , scale_x , offset_x , scale_y , offset_y ) ;