signature:
public class Grib1ParamTableReader { /** * WMO standard table 2 : Version Number 3.
 * Codes and data units for FM 92 - X Ext . GRIB .
 * 001
 * Pressure
 * Pa
 * Pa
 * 002
 * MSL
 * Mean sea level pressure
 * Pa
 * Pa
 * 003
 * None
 * Pressure tendency
 * Pa s * * - 1
 * Pa s * * - 1
 * 004
 * PV
 * Potential vorticity
 * K m * * 2 kg * * - 1 s * * - 1
 * K m * * 2 kg * * - 1 s * * - 1
 * 005
 * None
 * ICAO Standard Atmosphere reference height */
private Map < Integer , Grib1Parameter > readParameterTableEcmwf ( ) throws IOException { } }

implementation:
HashMap < Integer , Grib1Parameter > result = new HashMap < > ( ) ; try ( InputStream is = GribResourceReader . getInputStream ( path ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( is , StandardCharsets . UTF_8 ) ) ) { String line = br . readLine ( ) ; if ( line == null ) { throw new FileNotFoundException ( path + " is empty" ) ; } if ( ! line . startsWith ( "..." ) ) { this . desc = line ; // maybe ? ?
} while ( line != null && ! line . startsWith ( "..." ) ) { line = br . readLine ( ) ; // skip
} while ( true ) { line = br . readLine ( ) ; if ( line == null ) { break ; // done with the file
} if ( ( line . length ( ) == 0 ) || line . startsWith ( "#" ) ) { continue ; } if ( line . startsWith ( "..." ) ) { // . . . may have already been read
line = br . readLine ( ) ; if ( line == null ) { break ; } } String num = line . trim ( ) ; line = br . readLine ( ) ; String name = ( line != null ) ? line . trim ( ) : null ; line = br . readLine ( ) ; String desc = ( line != null ) ? line . trim ( ) : null ; line = br . readLine ( ) ; String units1 = ( line != null ) ? line . trim ( ) : null ; // optional notes
line = br . readLine ( ) ; String notes = ( line == null || line . startsWith ( "..." ) ) ? null : line . trim ( ) ; if ( desc != null && desc . equalsIgnoreCase ( "undefined" ) ) { continue ; // skip
} int p1 ; try { p1 = Integer . parseInt ( num ) ; } catch ( Exception e ) { logger . warn ( "Cant parse " + num + " in file " + path ) ; continue ; } Grib1Parameter parameter = new Grib1Parameter ( this , p1 , name , desc , units1 ) ; result . put ( parameter . getNumber ( ) , parameter ) ; logger . debug ( " %s (%s)%n" , parameter , notes ) ; } return Collections . unmodifiableMap ( result ) ; // all at once - thread safe
}


signature:
public class Grib1ParamTableReader { /** * This method will read in ECMWF grib1 tables . Note that these tables are generated locally by
 * Unidata , and come directly from the ECMWF GRIB - API package localConcepts files . They are
 * generated by :
 * ucar . nc2 . grib . grib1 . tables . EcmwfLocalConcepts
 * The original localConcepts files are located in :
 * grib / src / main / sources / ecmwfEcCodes /
 * Since we write the table file that are ultimately read by CDM , the format is controled and is
 * the following :
 * paramNum shortName [ description ] ( units )
 * for example ,
 * 251 atte [ Adiabatic tendency of temperature ] ( K ) */
private Map < Integer , Grib1Parameter > readParameterTableEcmwfEcCodes ( ) throws IOException { } }

implementation:
HashMap < Integer , Grib1Parameter > result = new HashMap < > ( ) ; try ( InputStream is = GribResourceReader . getInputStream ( path ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( is , StandardCharsets . UTF_8 ) ) ) { String line = br . readLine ( ) ; if ( line == null ) { throw new FileNotFoundException ( path + " is empty" ) ; } // create table name from file name
String [ ] splitPath = path . split ( "/" ) ; String tableNum = splitPath [ splitPath . length - 1 ] . replace ( ".table" , "" ) ; this . desc = "ECMWF GRIB API TABLE " + tableNum ; // skip header
while ( line != null && ! line . startsWith ( "#" ) ) { line = br . readLine ( ) ; // skip
} // keep going until the end of the file is reached ( line = = null )
while ( true ) { // exmaple : 251 atte [ Adiabatic tendency of temperature ] ( K )
line = br . readLine ( ) ; if ( line == null ) { break ; // done with the file
} if ( ( line . length ( ) == 0 ) || line . startsWith ( "#" ) ) { continue ; } // get unit - ( K )
String [ ] tmpUnitArray = line . split ( "\\(" ) ; String tmpUnit = tmpUnitArray [ tmpUnitArray . length - 1 ] ; int lastUnitIndex ; while ( ( lastUnitIndex = tmpUnit . lastIndexOf ( ")" ) ) > 0 ) { tmpUnit = tmpUnit . substring ( 0 , lastUnitIndex ) . trim ( ) ; } String unit = tmpUnit . trim ( ) ; // unit = Util . cleanUnit ( unit ) ; / / fixes some common unit mistakes / / jcaron - just use unit as it is
// get parameter number - 251
String [ ] lineArray = line . trim ( ) . split ( "\\s+" ) ; // all and any white space
String num = lineArray [ 0 ] ; // get shortName - atte
String name = lineArray [ 1 ] . trim ( ) ; // if ( name . equals ( " ~ " ) ) { } ; - todo create name from long name ( ? )
// get description . bracketed by [ ] - [ Adiabatic Tendency of temperature ]
int startDesc = line . indexOf ( "[" ) ; int endDesc = line . indexOf ( "]" ) ; String desc = line . substring ( startDesc , endDesc ) . trim ( ) ; // stuff information into a Grib1Parameter object
int p1 ; try { p1 = Integer . parseInt ( num ) ; } catch ( Exception e ) { logger . warn ( "Cant parse " + num + " in file " + path ) ; continue ; } Grib1Parameter parameter = new Grib1Parameter ( this , p1 , name , desc , unit ) ; result . put ( parameter . getNumber ( ) , parameter ) ; logger . debug ( " %s%n" , parameter ) ; } return Collections . unmodifiableMap ( result ) ; // all at once - thread safe
}


signature:
public class Grib1ParamTableReader { /** * order : num , name , desc , unit */
private Map < Integer , Grib1Parameter > readParameterTableSplit ( String regexp , int [ ] order ) throws IOException { } }

implementation:
HashMap < Integer , Grib1Parameter > result = new HashMap < > ( ) ; try ( InputStream is = GribResourceReader . getInputStream ( path ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( is , StandardCharsets . UTF_8 ) ) ) { // rdg - added the 0 line length check to cover the case of blank lines at the end of the parameter table file .
while ( true ) { String line = br . readLine ( ) ; if ( line == null ) { break ; } if ( ( line . length ( ) == 0 ) || line . startsWith ( "#" ) ) { continue ; } String [ ] flds = line . split ( regexp ) ; int p1 = Integer . parseInt ( flds [ order [ 0 ] ] . trim ( ) ) ; // must have a number
String name = ( order [ 1 ] >= 0 ) ? flds [ order [ 1 ] ] . trim ( ) : null ; String desc = flds [ order [ 2 ] ] . trim ( ) ; String units = ( flds . length > order [ 3 ] ) ? flds [ order [ 3 ] ] . trim ( ) : "" ; Grib1Parameter parameter = new Grib1Parameter ( this , p1 , name , desc , units ) ; result . put ( parameter . getNumber ( ) , parameter ) ; logger . debug ( " %s%n" , parameter ) ; } return Collections . unmodifiableMap ( result ) ; // all at once - thread safe
}


signature:
public class PrefixDBImpl { /** * Adds a prefix to the database by name .
 * @ param name
 * The name of the prefix to be added .
 * @ param value
 * The value of the prefix .
 * @ throws PrefixExistsException
 * Another prefix with the same name or value already exists in
 * the database . */
public void addName ( final String name , final double value ) throws PrefixExistsException { } }

implementation: final Prefix prefix = new PrefixName ( name , value ) ; nameSet . add ( prefix ) ;


signature:
public class PrefixDBImpl { /** * Adds a prefix symbol to the database .
 * @ param symbol
 * The symbol of the prefix to be added .
 * @ param value
 * The value of the prefix .
 * @ throws PrefixExistsException
 * Another prefix with the same symbol or value already exists
 * in the database . */
public void addSymbol ( final String symbol , final double value ) throws PrefixExistsException { } }

implementation: final Prefix prefix = new PrefixSymbol ( symbol , value ) ; symbolSet . add ( prefix ) ; valueMap . put ( new Double ( value ) , prefix ) ;


signature:
public class PrefixDBImpl { /** * Returns the prefix from the given set with the given identifier .
 * @ param string
 * The prefix identifier .
 * @ param set
 * The set to search . */
private static Prefix getPrefix ( final String string , final Set < Prefix > set ) { } }

implementation: for ( final Iterator < Prefix > iter = set . iterator ( ) ; iter . hasNext ( ) ; ) { final Prefix prefix = iter . next ( ) ; final int comp = prefix . compareTo ( string ) ; if ( comp == 0 ) { return prefix ; } if ( comp > 0 ) { break ; } } return null ;


signature:
public class ADNWriter { /** * check its an acceptable form of email */
protected boolean emailOK ( ThreddsMetadata . Source p ) { } }

implementation: String email = p . getEmail ( ) ; return email . indexOf ( '@' ) >= 0 ; // should really do a regexp


signature:
public class ADNWriter { /** * test */
private static void doOne ( InvCatalogFactory fac , String url ) { } }

implementation:
System . out . println ( "***read " + url ) ; try { InvCatalogImpl cat = fac . readXML ( url ) ; StringBuilder buff = new StringBuilder ( ) ; boolean isValid = cat . check ( buff , false ) ; System . out . println ( "catalog <" + cat . getName ( ) + "> " + ( isValid ? "is" : "is not" ) + " valid" ) ; System . out . println ( " validation output=\n" + buff ) ; // System . out . println ( " catalog = \ n " + fac . writeXML ( cat ) ) ;
ADNWriter w = new ADNWriter ( ) ; StringBuilder sbuff = new StringBuilder ( ) ; w . writeDatasetEntries ( cat , "C:/temp/adn3" , sbuff ) ; System . out . println ( " messages=\n" + sbuff ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; }


signature:
public class WKTParser { /** * Peek ahead
 * @ return the char
 * @ throws ParseException problem parsing */
private char peek ( ) throws ParseException { } }

implementation: try { reader . mark ( 10 ) ; int aChar = reader . read ( ) ; reader . reset ( ) ; if ( aChar < 0 ) { return ( char ) 0 ; } else { return ( char ) aChar ; } } catch ( java . io . IOException e1 ) { throw new ParseException ( "Strange io error " + e1 , position ) ; }


signature:
public class WKTParser { /** * _ more _
 * @ return _ more _
 * @ throws ParseException _ more _ */
private char getChar ( ) throws ParseException { } }

implementation: try { int val = reader . read ( ) ; position ++ ; if ( val < 0 ) { throw new ParseException ( "unexpected eof of srtext" , position ) ; } return ( char ) val ; } catch ( java . io . IOException e1 ) { throw new ParseException ( e1 . toString ( ) , position ) ; }


signature:
public class WKTParser { /** * _ more _
 * @ param literal _ more _
 * @ throws ParseException _ more _ */
private void eatLiteral ( String literal ) throws ParseException { } }

implementation: int n = literal . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { char v = getChar ( ) ; if ( v != literal . charAt ( i ) ) { throw new ParseException ( "bad srtext" , position ) ; } }


signature:
public class WKTParser { /** * _ more _
 * @ return _ more _
 * @ throws ParseException _ more _ */
private double eatReal ( ) throws ParseException { } }

implementation: StringBuilder b = new StringBuilder ( ) ; for ( ; ; ) { char t = peek ( ) ; if ( Character . isDigit ( t ) || ( t == 'e' ) || ( t == 'E' ) || ( t == '.' ) || ( t == '-' ) || ( t == '+' ) ) { b . append ( getChar ( ) ) ; } else { break ; } } try { return Double . parseDouble ( b . toString ( ) ) ; } catch ( NumberFormatException e1 ) { throw new ParseException ( "bad number" + e1 , position ) ; }


signature:
public class WKTParser { /** * _ more _
 * @ return _ more _
 * @ throws ParseException _ more _ */
private String eatString ( ) throws ParseException { } }

implementation: StringBuilder b = new StringBuilder ( ) ; if ( getChar ( ) != '"' ) { throw new ParseException ( "expected string" , position ) ; } for ( ; ; ) { char t = getChar ( ) ; if ( t == '"' ) { break ; } b . append ( t ) ; } return b . toString ( ) ;


signature:
public class WKTParser { /** * _ more _
 * @ return _ more _
 * @ throws ParseException _ more _ */
private String eatTerm ( ) throws ParseException { } }

implementation: StringBuilder b = new StringBuilder ( ) ; for ( ; ; ) { char val = peek ( ) ; if ( ! Character . isJavaIdentifierPart ( val ) ) { break ; } b . append ( getChar ( ) ) ; } return b . toString ( ) ;


signature:
public class WKTParser { /** * _ more _
 * @ throws ParseException _ more _ */
private void parseProjcs ( ) throws ParseException { } }

implementation: eatLiteral ( "PROJCS[" ) ; projName = eatString ( ) ; eatComma ( ) ; parseGeogcs ( ) ; for ( ; ; ) { char next = getChar ( ) ; if ( next == ']' ) { break ; } else if ( next != ',' ) { throw new ParseException ( "expected , or ]" , position ) ; } else { String term = eatTerm ( ) ; if ( "PARAMETER" . equals ( term ) ) { eatParameter ( ) ; } else if ( "UNIT" . equals ( term ) ) { eatProjcsUnit ( ) ; } else if ( "PROJECTION" . equals ( term ) ) { eatProjectionType ( ) ; } } }


signature:
public class WKTParser { /** * _ more _
 * @ throws ParseException _ more _ */
private void eatParameter ( ) throws ParseException { } }

implementation: eatOpenBrace ( ) ; String parameterName = eatString ( ) ; eatComma ( ) ; Double value = eatReal ( ) ; eatCloseBrace ( ) ; parameters . put ( parameterName . toLowerCase ( ) , value ) ;


signature:
public class WKTParser { /** * _ more _
 * @ throws ParseException _ more _ */
private void parseGeogcs ( ) throws ParseException { } }

implementation: eatLiteral ( "GEOGCS[" ) ; geogcsName = eatString ( ) ; for ( ; ; ) { char t = getChar ( ) ; if ( t == ']' ) { break ; } else if ( t != ',' ) { throw new ParseException ( "expected , or ]" , position ) ; } else { String term = eatTerm ( ) ; if ( "DATUM" . equals ( term ) ) { eatDatum ( ) ; } else if ( "PRIMEM" . equals ( term ) ) { eatPrimem ( ) ; } else if ( "UNIT" . equals ( term ) ) { eatUnit ( ) ; } } }


signature:
public class WKTParser { /** * _ more _
 * @ throws ParseException _ more _ */
private void eatSpheroid ( ) throws ParseException { } }

implementation: eatLiteral ( "SPHEROID" ) ; eatOpenBrace ( ) ; spheroidName = eatString ( ) ; eatComma ( ) ; majorAxis = eatReal ( ) ; eatComma ( ) ; inverseMinor = eatReal ( ) ; eatCloseBrace ( ) ;


signature:
public class WKTParser { /** * Get the value of the projection parameter . An IllegalArgument exception
 * is thrown if the parameter is not found .
 * @ param name The name of the parameter . Case is ignored .
 * @ return The value of the parameter , as a double . */
public double getParameter ( String name ) { } }

implementation: Double val = ( Double ) parameters . get ( name . toLowerCase ( ) ) ; if ( val == null ) { throw new IllegalArgumentException ( "no parameter called " + name ) ; } return val . doubleValue ( ) ;


signature:
public class WKTParser { /** * Convert OGC spatial reference WKT to a ProjectionImpl .
 * An IllegalArgumentException may be thrown if a parameter is missing .
 * @ param srp The parsed OGC WKT spatial reference text .
 * @ return The ProjectionImpl class .
 * @ throws java . text . ParseException If the OGIS spatial reference text was not parseable . */
public static ProjectionImpl convertWKTToProjection ( WKTParser srp ) { } }

implementation:
if ( ! srp . isPlanarProjection ( ) ) { return new ucar . unidata . geoloc . projection . LatLonProjection ( ) ; } else { String projectionType = srp . getProjectionType ( ) ; double falseEasting = 0 ; double falseNorthing = 0 ; ProjectionImpl proj = null ; if ( srp . hasParameter ( "False_Easting" ) ) { falseEasting = srp . getParameter ( "False_Easting" ) ; } if ( srp . hasParameter ( "False_Northing" ) ) { falseNorthing = srp . getParameter ( "False_Northing" ) ; } if ( ( falseEasting != 0.0 ) || ( falseNorthing != 0.0 ) ) { double scalef = 1.0 ; if ( srp . getProjUnitName ( ) != null ) { try { SimpleUnit unit = SimpleUnit . factoryWithExceptions ( srp . getProjUnitName ( ) ) ; scalef = unit . convertTo ( srp . getProjUnitValue ( ) , SimpleUnit . kmUnit ) ; } catch ( Exception e ) { System . out . println ( srp . getProjUnitValue ( ) + " " + srp . getProjUnitName ( ) + " not convertible to km" ) ; } } falseEasting *= scalef ; falseNorthing *= scalef ; } if ( srp . getProjName ( ) . contains ( "UTM_Zone_" ) ) return processUTM ( srp ) ; if ( "Transverse_Mercator" . equals ( projectionType ) ) { double lat0 = srp . getParameter ( "Latitude_Of_Origin" ) ; double scale = srp . getParameter ( "Scale_Factor" ) ; double tangentLon = srp . getParameter ( "Central_Meridian" ) ; proj = new TransverseMercator ( lat0 , tangentLon , scale , falseEasting , falseNorthing ) ; } else if ( "Lambert_Conformal_Conic" . equals ( projectionType ) ) { double lon0 = srp . getParameter ( "Central_Meridian" ) ; double par1 = srp . getParameter ( "Standard_Parallel_1" ) ; double par2 = par1 ; if ( srp . hasParameter ( "Standard_Parallel_2" ) ) { par2 = srp . getParameter ( "Standard_Parallel_2" ) ; } double lat0 = srp . getParameter ( "Latitude_Of_Origin" ) ; return new LambertConformal ( lat0 , lon0 , par1 , par2 , falseEasting , falseNorthing ) ; } else if ( "Albers" . equals ( projectionType ) ) { double lon0 = srp . getParameter ( "Central_Meridian" ) ; double par1 = srp . getParameter ( "Standard_Parallel_1" ) ; double par2 = par1 ; if ( srp . hasParameter ( "Standard_Parallel_2" ) ) { par2 = srp . getParameter ( "Standard_Parallel_2" ) ; } double lat0 = srp . getParameter ( "Latitude_Of_Origin" ) ; return new AlbersEqualArea ( lat0 , lon0 , par1 , par2 , falseEasting , falseNorthing ) ; } else if ( "Stereographic" . equals ( projectionType ) ) { double lont = srp . getParameter ( "Central_Meridian" ) ; double scale = srp . getParameter ( "Scale_Factor" ) ; double latt = srp . getParameter ( "Latitude_Of_Origin" ) ; return new Stereographic ( latt , lont , scale , falseEasting , falseNorthing ) ; } else if ( "Mercator" . equals ( projectionType ) ) { double lat0 = srp . getParameter ( "Latitude_Of_Origin" ) ; double lon0 = srp . getParameter ( "Central_Meridian" ) ; proj = new Mercator ( lon0 , lat0 , falseEasting , falseNorthing ) ; } else if ( "Universal_Transverse_Mercator" . equals ( projectionType ) ) { // throw new java . text . ParseException (
// " UTM adapter not implemented yet " , 0 ) ;
} return proj ; }


signature:
public class Grib1SectionGridDefinition { /** * Calculate the CRC of the entire byte array
 * @ return CRC of the entire byte array */
public long calcCRC ( ) { } }

implementation: long crc ; if ( rawData == null ) crc = predefinedGridDefinitionCenter << 16 + predefinedGridDefinition ; else { CRC32 crc32 = new CRC32 ( ) ; crc32 . update ( rawData ) ; crc = crc32 . getValue ( ) ; } return crc ;


signature:
public class Grib1SectionGridDefinition { /** * is a " thin " grid
 * @ return if a thin grid */
public final boolean isThin ( ) { } }

implementation: if ( rawData == null ) return false ; int octet5 = getOctet ( 5 ) ; int nv = getOctet ( 4 ) ; return ( octet5 != 255 ) && ( nv == 0 || nv == 255 ) ;


signature:
public class Grib1SectionGridDefinition { /** * Gets the number of points in each line for Quasi / Thin grids
 * " List of numbers of points in each row ( length = NROWS x 2 octets , where NROWS is the
 * total number of rows defined within the grid description ) "
 * @ return number of points in each line as int [ ] */
private int [ ] getNptsInLine ( Grib1Gds gds ) { } }

implementation:
int numPts ; if ( ( gds . getScanMode ( ) & 32 ) == 0 ) { // bit3 = 0 : Adjacent points in i direction are consecutive
numPts = gds . getNy ( ) ; } else { // bit3 = 1 : Adjacent points in j direction are consecutive
numPts = gds . getNx ( ) ; } int [ ] parallels = new int [ numPts ] ; int offset = getOctet ( 5 ) ; for ( int i = 0 ; i < numPts ; i ++ ) { parallels [ i ] = GribNumbers . int2 ( getOctet ( offset ++ ) , getOctet ( offset ++ ) ) ; } return parallels ;


signature: public class Grib1SectionGridDefinition { public boolean hasVerticalCoordinateParameters ( ) { } }

implementation: if ( rawData == null ) return false ; int octet5 = getOctet ( 5 ) ; int nv = getOctet ( 4 ) ; return ( octet5 != 255 ) && ( nv != 0 && nv != 255 ) ;


signature:
public class AbstractCursor { /** * Selected DataCursor API overrides */
@ Override public int fieldIndex ( String name ) throws DapException { } }

implementation: DapStructure ds ; if ( getTemplate ( ) . getSort ( ) . isCompound ( ) ) ds = ( DapStructure ) getTemplate ( ) ; else if ( getTemplate ( ) . getSort ( ) . isVar ( ) && ( ( ( DapVariable ) getTemplate ( ) ) . getBaseType ( ) . getSort ( ) . isCompound ( ) ) ) ds = ( DapStructure ) ( ( DapVariable ) getTemplate ( ) ) . getBaseType ( ) ; else throw new DapException ( "Attempt to get field name on non-compound object" ) ; int i = ds . indexByName ( name ) ; if ( i < 0 ) throw new DapException ( "Unknown field name: " + name ) ; return i ;


signature:
public class AbstractCursor { /** * Utilities */
static public Scheme schemeFor ( DapVariable field ) { } }

implementation: DapType ftype = field . getBaseType ( ) ; Scheme scheme = null ; boolean isscalar = field . getRank ( ) == 0 ; if ( ftype . getTypeSort ( ) . isAtomic ( ) ) scheme = Scheme . ATOMIC ; else { if ( ftype . getTypeSort ( ) . isStructType ( ) ) scheme = Scheme . STRUCTARRAY ; else if ( ftype . getTypeSort ( ) . isSeqType ( ) ) scheme = Scheme . SEQARRAY ; } return scheme ;


signature:
public class CFGridCoverageWriter2 { /** * Returns { @ code true } if we should add 2D latitude & longitude variables to the output file .
 * This method could return { @ code false } for several reasons :
 * < ul >
 * < li > { @ code ! tryToAddLatLon2D } < / li >
 * < li > { @ code subsetDataset . getHorizCoordSys ( ) . isLatLon2D ( ) } < / li >
 * < li > { @ code ! subsetDataset . getHorizCoordSys ( ) . isProjection ( ) } < / li >
 * < li > { @ code subsetDataset . getHorizCoordSys ( ) instanceof LatLonProjection } < / li >
 * < / ul >
 * @ param tryToAddLatLon2D attempt to add 2D lat / lon vars to output file .
 * @ param subsetDataset subsetted version of the original CoverageCollection .
 * @ return { @ code true } if we should add 2D latitude & longitude variables to the output file . */
private boolean shouldAddLatLon2D ( boolean tryToAddLatLon2D , CoverageCollection subsetDataset ) { } }

implementation:
if ( ! tryToAddLatLon2D ) { // We don ' t even want 2D lat / lon vars .
return false ; } HorizCoordSys horizCoordSys = subsetDataset . getHorizCoordSys ( ) ; if ( horizCoordSys . isLatLon2D ( ) ) { // We already have 2D lat / lon vars .
return false ; } if ( ! horizCoordSys . isProjection ( ) ) { // CRS doesn ' t contain a projection , meaning we can ' t calc 2D lat / lon vars .
return false ; } Projection proj = horizCoordSys . getTransform ( ) . getProjection ( ) ; if ( proj instanceof LatLonProjection ) { // Projection is a " fake " ; we already have lat / lon .
return false ; } return true ;


signature:
public class Grib1ParamTime { /** * code table 5 - 2010 edition of WMO manual on codes */
public static String getTimeTypeName ( int timeRangeIndicator ) { } }

implementation:
String timeRange ; switch ( timeRangeIndicator ) { /* Forecast product valid for reference time + P1 ( P1 > 0 ) , or
 Uninitialized analysis product for reference time ( P1 = 0 ) , or
 Image product for reference time ( P1 = 0) */
case 0 : timeRange = "Uninitialized analysis / image product / forecast product valid for RT + P1" ; break ; // Initialized analysis product for reference time ( P1 = 0)
case 1 : timeRange = "Initialized analysis product for reference time" ; break ; // Product with a valid time ranging between reference time + P1 and reference time + P2
case 2 : timeRange = "product valid, interval = (RT + P1) to (RT + P2)" ; break ; // Average ( reference time + P1 to reference time + P2)
case 3 : timeRange = "Average, interval = (RT + P1) to (RT + P2)" ; break ; /* Accumulation ( reference time + P1 to reference time + P2 ) product considered valid at
 reference time + P2 */
case 4 : timeRange = "Accumulation, interval = (RT + P1) to (RT + P2)" ; break ; /* Difference ( reference time + P2 minus reference time + P1 ) product considered valid at
 reference time + P2 */
case 5 : timeRange = "Difference, interval = (RT + P2) - (RT + P1)" ; break ; // Average ( reference time - P1 to reference time - P2)
case 6 : timeRange = "Average, interval = (RT - P1) to (RT - P2)" ; break ; // Average ( reference time - P1 to reference time + P2)
case 7 : timeRange = "Average, interval = (RT - P1) to (RT + P2)" ; break ; // P1 occupies octets 19 and 20 ; product valid at reference time + P1
case 10 : timeRange = "product valid at RT + P1" ; break ; /* Climatological mean value : multiple year averages of quantities which are themselves
 means over some period of time ( P2 ) less than a year . The reference time ( R ) indicates the
 date and time of the start of a period of time , given by R to R + P2 , over which a mean is
 formed ; N indicates the number of such period - means that are averaged together to form
 the climatological value , assuming that the N period - mean fields are separated by one
 year . The reference time indicates the start of the N - year climatology .
 If P1 = 0 then the data averaged in the basic interval P2 are assumed to be continuous , i . e . all available data
 are simply averaged together .
 If P1 = 1 ( the unit of time octet 18 , Code table 4 is not
 relevant here ) then the data averaged together in the basic interval P2 are valid only at the
 time ( hour , minute ) given in the reference time , for all the days included in the P2 period .
 The units of P2 are given by the contents of octet 18 and Code table 4 */
case 51 : timeRange = "Climatological mean values from RT to (RT + P2)" ; // if ( p1 = = 0 ) timeRange + = " continuous " ;
break ; /* Average of N forecasts ( or initialized analyses ) ; each product has forecast period of P1
 ( P1 = 0 for initialized analyses ) ; products have reference times at intervals of P2 , beginning
 at the given reference time */
case 113 : timeRange = "Average of N forecasts, intervals = (refTime + i * P2, refTime + i * P2 + P1)" ; break ; /* Accumulation of N forecasts ( or initialized analyses ) ; each product has forecast period of
 P1 ( P1 = 0 for initialized analyses ) ; products have reference times at intervals of P2,
 beginning at the given reference time */
case 114 : timeRange = "Accumulation of N forecasts, intervals = (refTime + i * P2, refTime + i * P2 + P1)" ; break ; /* Average of N forecasts , all with the same reference time ; the first has a forecast period of
 P1 , the remaining forecasts follow at intervals of P2 */
case 115 : timeRange = "Average of N forecasts, intervals = (refTime, refTime + P1 + i * P2)" ; break ; /* Accumulation of N forecasts , all with the same reference time ; the first has a forecast
 period of P1 , the remaining forecasts follow at intervals of P2 */
case 116 : timeRange = "Accumulation of N forecasts, intervals = (refTime, refTime + P1 + i * P2)" ; break ; /* Average of N forecasts ; the first has a forecast period of P1 , the subsequent ones have
 forecast periods reduced from the previous one by an interval of P2 ; the reference time for
 the first is given in octets 13 to 17 , the subsequent ones have reference times increased
 from the previous one by an interval of P2 . Thus all the forecasts have the same valid time ,
 given by the initial reference time + P1 */
case 117 : timeRange = "Average of N forecasts, intervals = (refTime + i * P2, refTime + P1)" ; break ; /* Temporal variance , or covariance , of N initialized analyses ; each product has forecast
 period of P1 = 0 ; products have reference times at intervals of P2 , beginning at the given
 reference time */
case 118 : timeRange = "Temporal variance or covariance of N initialized analyses, timeCoord = (refTime + i * P2)" ; break ; /* Standard deviation of N forecasts , all with the same reference time with respect to the time
 average of forecasts ; the first forecast has a forecast period of P1 , the remaining forecasts
 follow at intervals of P2 */
case 119 : timeRange = "Standard Deviation of N forecasts, timeCoord = (refTime + P1 + i * P2)" ; break ; // ECMWF " Average of N Forecast " added 11/21/2014 . pretend its WMO standard . maybe should move to ecmwf ? ?
// see " http : / / emoslib . sourcearchive . com / documentation / 000370 . dfsg . 2 / grchk1_8F - source . html "
// C Add Time range indicator = 120 Average of N Forecast . Each product
// C is an accumulation from forecast lenght P1 to forecast
// C lenght P2 , with reference times at intervals P2 - P1
case 120 : timeRange = "Average of N Forecasts (ECMWF), accumulation from forecast P1 to P2, with reference times at intervals P2-P1" ; break ; // Average of N uninitialized analyses , starting at the reference time , at intervals of P2
case 123 : timeRange = "Average of N uninitialized analyses, intervals = (refTime, refTime + i * P2)" ; break ; // Accumulation of N uninitialized analyses , starting at the reference time , at intervals of P2
case 124 : timeRange = "Accumulation of N uninitialized analyses, intervals = (refTime, refTime + i * P2)" ; break ; /* Standard deviation of N forecasts , all with the same reference time with respect to time
 average of the time tendency of forecasts ; the first forecast has a forecast period of P1,
 the remaining forecasts follow at intervals of P2 */
case 125 : timeRange = "Standard deviation of N forecasts, intervals = (refTime, refTime + P1 + i * P2)" ; break ; default : timeRange = "Unknown Time Range Indicator " + timeRangeIndicator ; } return timeRange ;


signature:
public class Grib1ParamTime { /** * A string representation of the time coordinate , whether its an interval or not .
 * @ return string representation of the time coordinate */
public String getTimeCoord ( ) { } }

implementation: if ( isInterval ( ) ) { int [ ] intv = getInterval ( ) ; return intv [ 0 ] + "-" + intv [ 1 ] ; } return Integer . toString ( getForecastTime ( ) ) ;


signature:
public class QueryCapability { /** * Append an error message to the message log . Call check ( ) to get the log when
 * everything is done .
 * @ param message append this message to log
 * @ param fatal true if this is a fatal error . */
public void appendErrorMessage ( String message , boolean fatal ) { } }

implementation: errLog . append ( message ) ; errLog . append ( "\n" ) ; fatalError = fatalError || fatal ;


signature:
public class Parameters { /** * Utilities */
protected String [ ] getparamset ( String key ) throws IOException { } }

implementation: String [ ] values = this . params . get ( key ) ; return ( values == null ? new String [ 0 ] : values ) ;


signature:
public class ArrayStructureBB { /** * Set the offsets , based on m . getSizeBytes ( ) .
 * Also sets members . setStructureSize ( ) .
 * @ param members set offsets for these members
 * @ return the total size */
public static int setOffsets ( StructureMembers members ) { } }

implementation:
int offset = 0 ; for ( StructureMembers . Member m : members . getMembers ( ) ) { m . setDataParam ( offset ) ; offset += m . getSizeBytes ( ) ; // set inner offsets ( starts again at 0)
if ( m . getStructureMembers ( ) != null ) setOffsets ( m . getStructureMembers ( ) ) ; } members . setStructureSize ( offset ) ; return offset ;


signature:
public class CFPolygon { /** * Sets the next polygon which make up the multipolygon which this polygon is a part of .
 * If next is a CFPolygon , automatically connects the other polygon to this polygon as well . */
public void setNext ( Polygon next ) { } }

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


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

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


signature:
public class CFPolygon { /** * Given a dataset , variable and index , automatically sets up a previously constructed polygon .
 * If the specified polygon is not found in the dataset , returns null
 * @ param dataset which the variable is a part of
 * @ param polyvar the variable which has a geometry attribute
 * @ param index of the polygon within the variable */
public Polygon setupPolygon ( NetcdfDataset dataset , Variable polyvar , int index ) { } }

implementation:
this . points . clear ( ) ; Array xPts = null ; Array yPts = null ; Variable nodeCounts = null ; Variable partNodeCounts = null ; Variable interiorRings = null ; List < CoordinateAxis > axes = dataset . getCoordinateAxes ( ) ; CoordinateAxis x = null ; CoordinateAxis y = null ; String [ ] nodeCoords = polyvar . 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 nodeCoStr = polyvar . findAttValueIgnoreCase ( CF . NODE_COUNT , "" ) ; if ( ! nodeCoStr . equals ( "" ) ) { nodeCounts = dataset . findVariable ( nodeCoStr ) ; } else return null ; // Affirm part node counts
String pNodeCoStr = polyvar . findAttValueIgnoreCase ( CF . PART_NODE_COUNT , "" ) ; if ( ! pNodeCoStr . equals ( "" ) ) { partNodeCounts = dataset . findVariable ( pNodeCoStr ) ; } // Affirm interior rings
String interiorRingsStr = polyvar . findAttValueIgnoreCase ( CF . PART_NODE_COUNT , "" ) ; if ( ! interiorRingsStr . equals ( "" ) ) { interiorRings = dataset . findVariable ( interiorRingsStr ) ; } 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 ; this . isInteriorRing = false ; // x and y should have the same shape , will add some handling on this
while ( itrX . hasNext ( ) ) { this . addPoint ( itrX . getDoubleNext ( ) , itrY . getDoubleNext ( ) ) ; } switch ( polyvar . getRank ( ) ) { case 2 : this . setData ( polyvar . read ( CFSimpleGeometryHelper . getSubsetString ( polyvar , index ) ) . reduce ( ) ) ; break ; case 1 : this . setData ( polyvar . 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 { Polygon tail = this ; Array pnc = partNodeCounts . read ( ) ; Array ir = null ; IndexIterator pncItr = pnc . getIndexIterator ( ) ; if ( interiorRings != null ) ir = interiorRings . read ( ) ; // 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 ) ; // Set interior ring if needed
if ( interiorRings != null ) { int interiorRingValue = ir . getInt ( pncInd ) ; switch ( interiorRingValue ) { case 0 : this . setInteriorRing ( false ) ; break ; case 1 : this . setInteriorRing ( true ) ; break ; // will handle default case
} } else this . isInteriorRing = false ; while ( smaller > 0 ) { tail . addPoint ( itrX . getDoubleNext ( ) , itrY . getDoubleNext ( ) ) ; smaller -- ; } // Set data of each
switch ( polyvar . getRank ( ) ) { case 2 : tail . setData ( polyvar . read ( CFSimpleGeometryHelper . getSubsetString ( polyvar , index ) ) . reduce ( ) ) ; break ; case 1 : tail . setData ( polyvar . 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 CFPolygon ( ) ) ; tail = tail . getNext ( ) ; } // Clean up
tail = tail . getPrev ( ) ; if ( tail != null ) tail . setNext ( null ) ; } } catch ( IOException | InvalidRangeException | InvalidDataseriesException e ) { cfpl . error ( e . getMessage ( ) ) ; return null ; } return this ;


signature:
public class InvService { /** * Get named property .
 * @ param name match this name
 * @ return String value of Property or null if not exist . */
public String findProperty ( String name ) { } }

implementation: InvProperty result = null ; for ( InvProperty p : properties ) { if ( p . getName ( ) . equals ( name ) ) result = p ; } return ( result == null ) ? null : result . getValue ( ) ;


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

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


signature:
public class JTableProjection { /** * set current projection if found , else deselect */
public void setCurrentProjection ( ProjectionImpl proj ) { } }

implementation: int row ; if ( 0 <= ( row = model . search ( proj ) ) ) { if ( debug ) System . out . println ( " PTsetCurrentProjection found = " + row ) ; selectedRow = row ; setRowSelectionInterval ( row , row ) ; } else { if ( debug ) System . out . println ( " PTsetCurrentProjection not found = " + row ) ; selectedRow = - 1 ; clearSelection ( ) ; }


signature:
public class TimeOffsetAxis { /** * normal case already handled , this is the case where a time has been specified , and only one runtime */
public Optional < TimeOffsetAxis > subsetFromTime ( SubsetParams params , CalendarDate runDate ) { } }

implementation:
CoordAxisHelper helper = new CoordAxisHelper ( this ) ; CoverageCoordAxisBuilder builder = null ; if ( params . isTrue ( SubsetParams . timePresent ) ) { double offset = getOffsetInTimeUnits ( runDate , CalendarDate . present ( ) ) ; builder = helper . subsetClosest ( offset ) ; } CalendarDate dateWanted = ( CalendarDate ) params . get ( SubsetParams . time ) ; if ( dateWanted != null ) { // convertFrom , convertTo
double offset = getOffsetInTimeUnits ( runDate , dateWanted ) ; builder = helper . subsetClosest ( offset ) ; } Integer stride = ( Integer ) params . get ( SubsetParams . timeStride ) ; if ( stride == null || stride < 0 ) stride = 1 ; CalendarDateRange dateRange = ( CalendarDateRange ) params . get ( SubsetParams . timeRange ) ; if ( dateRange != null ) { double min = getOffsetInTimeUnits ( runDate , dateRange . getStart ( ) ) ; double max = getOffsetInTimeUnits ( runDate , dateRange . getEnd ( ) ) ; Optional < CoverageCoordAxisBuilder > buildero = helper . subset ( min , max , stride ) ; if ( buildero . isPresent ( ) ) builder = buildero . get ( ) ; else return Optional . empty ( buildero . getErrorMessage ( ) ) ; } assert ( builder != null ) ; // all the offsets are reletive to rundate
builder . setReferenceDate ( runDate ) ; return Optional . of ( new TimeOffsetAxis ( builder ) ) ;


signature:
public class NetcdfFile { /** * Register an IOServiceProvider , using its class string name .
 * @ param className Class that implements IOServiceProvider .
 * @ throws IllegalAccessException if class is not accessible .
 * @ throws InstantiationException if class doesnt have a no - arg constructor .
 * @ throws ClassNotFoundException if class not found . */
static public void registerIOProvider ( String className ) throws IllegalAccessException , InstantiationException , ClassNotFoundException { } }

implementation: Class ioClass = NetcdfFile . class . getClassLoader ( ) . loadClass ( className ) ; registerIOProvider ( ioClass ) ;


signature:
public class NetcdfFile { /** * Register an IOServiceProvider . A new instance will be created when one of its files is opened .
 * @ param iospClass Class that implements IOServiceProvider .
 * @ param last true = > insert at the end of the list ; otherwise front
 * @ throws IllegalAccessException if class is not accessible .
 * @ throws InstantiationException if class doesnt have a no - arg constructor .
 * @ throws ClassCastException if class doesnt implement IOServiceProvider interface . */
static public void registerIOProvider ( Class iospClass , boolean last ) throws IllegalAccessException , InstantiationException { } }

implementation:
IOServiceProvider spi ; spi = ( IOServiceProvider ) iospClass . newInstance ( ) ; // fail fast
if ( userLoads && ! last ) registeredProviders . add ( 0 , spi ) ; // put user stuff first
else registeredProviders . add ( spi ) ;


signature:
public class NetcdfFile { /** * Register an IOServiceProvider . A new instance will be created when one of its files is opened .
 * This differs from the above in that it specifically locates the target iosp and inserts
 * the new one in front of it in order to override the target .
 * If the iospclass is already registered , remove it and reinsert .
 * If the target class is not present , then insert at front of the registry
 * @ param iospClass Class that implements IOServiceProvider .
 * @ param target Class to override
 * @ throws IllegalAccessException if class is not accessible .
 * @ throws InstantiationException if class doesnt have a no - arg constructor .
 * @ throws ClassCastException if class doesnt implement IOServiceProvider interface . */
static public void registerIOProviderPreferred ( Class iospClass , Class target ) throws IllegalAccessException , InstantiationException { } }

implementation:
iospDeRegister ( iospClass ) ; // forcibly de - register
int pos = - 1 ; for ( int i = 0 ; i < registeredProviders . size ( ) ; i ++ ) { IOServiceProvider candidate = registeredProviders . get ( i ) ; if ( candidate . getClass ( ) == target ) { if ( pos < i ) pos = i ; break ; // this is where is must be placed
} } if ( pos < 0 ) pos = 0 ; IOServiceProvider spi = ( IOServiceProvider ) iospClass . newInstance ( ) ; // fail fast
registeredProviders . add ( pos , spi ) ; // insert before target


signature:
public class NetcdfFile { /** * See if a specific IOServiceProvider is registered
 * @ param iospClass Class for which to search */
static public boolean iospRegistered ( Class iospClass ) { } }

implementation: for ( IOServiceProvider spi : registeredProviders ) { if ( spi . getClass ( ) == iospClass ) return true ; } return false ;


signature:
public class NetcdfFile { /** * See if a specific IOServiceProvider is registered and if so , remove it .
 * @ param iospClass Class for which to search and remove
 * @ return true if class was present */
static public boolean iospDeRegister ( Class iospClass ) { } }

implementation: for ( int i = 0 ; i < registeredProviders . size ( ) ; i ++ ) { IOServiceProvider spi = registeredProviders . get ( i ) ; if ( spi . getClass ( ) == iospClass ) { registeredProviders . remove ( i ) ; return true ; } } return false ;


signature:
public class NetcdfFile { /** * debugging
 * @ param debugFlag debug flags */
static public void setDebugFlags ( ucar . nc2 . util . DebugFlags debugFlag ) { } }

implementation: debugSPI = debugFlag . isSet ( "NetcdfFile/debugSPI" ) ; debugCompress = debugFlag . isSet ( "NetcdfFile/debugCompress" ) ; debugStructureIterator = debugFlag . isSet ( "NetcdfFile/structureIterator" ) ; N3header . disallowFileTruncation = debugFlag . isSet ( "NetcdfFile/disallowFileTruncation" ) ; N3header . debugHeaderSize = debugFlag . isSet ( "NetcdfFile/debugHeaderSize" ) ; showRequest = debugFlag . isSet ( "NetcdfFile/showRequest" ) ;


signature:
public class NetcdfFile { /** * Open an existing file ( read only ) , with option of cancelling .
 * @ param location location of the file .
 * @ param cancelTask allow task to be cancelled ; may be null .
 * @ return NetcdfFile object , or null if cant find IOServiceProver
 * @ throws IOException if error */
static public NetcdfFile open ( String location , ucar . nc2 . util . CancelTask cancelTask ) throws IOException { } }

implementation: return open ( location , - 1 , cancelTask ) ;


signature:
public class NetcdfFile { /** * Open an existing file ( read only ) , with option of cancelling , setting the RandomAccessFile buffer size for efficiency ,
 * with an optional special object for the iosp .
 * @ param location location of file . This may be a
 * < ol >
 * < li > local netcdf - 3 filename ( with a file : prefix or no prefix )
 * < li > remote netcdf - 3 filename ( with an http : prefix )
 * < li > local netcdf - 4 filename ( with a file : prefix or no prefix )
 * < li > local hdf - 5 filename ( with a file : prefix or no prefix )
 * < li > local iosp filename ( with a file : prefix or no prefix )
 * < / ol > http : / / thredds . ucar . edu / thredds / fileServer / grib / NCEP / GFS / Alaska _ 191km / files / GFS _ Alaska _ 191km _ 20130416_0600 . grib1
 * If file ends with " . Z " , " . zip " , " . gzip " , " . gz " , or " . bz2 " , it will uncompress / unzip and write to new file without the suffix ,
 * then use the uncompressed file . It will look for the uncompressed file before it does any of that . Generally it prefers to
 * place the uncompressed file in the same directory as the original file . If it does not have write permission on that directory ,
 * it will use the directory defined by ucar . nc2 . util . DiskCache class .
 * @ param buffer _ size RandomAccessFile buffer size , if < = 0 , use default size
 * @ param cancelTask allow task to be cancelled ; may be null .
 * @ param iospMessage special iosp tweaking ( sent before open is called ) , may be null
 * @ return NetcdfFile object , or null if cant find IOServiceProver
 * @ throws IOException if error */
static public NetcdfFile open ( String location , int buffer_size , ucar . nc2 . util . CancelTask cancelTask , Object iospMessage ) throws IOException { } }

implementation: ucar . unidata . io . RandomAccessFile raf = getRaf ( location , buffer_size ) ; try { return open ( raf , location , cancelTask , iospMessage ) ; } catch ( Throwable t ) { raf . close ( ) ; throw new IOException ( t ) ; }


signature:
public class NetcdfFile { /** * Find out if the file can be opened , but dont actually open it .
 * Experimental .
 * @ param location same as open
 * @ return true if can be opened
 * @ throws IOException on read error */
static public boolean canOpen ( String location ) throws IOException { } }

implementation: ucar . unidata . io . RandomAccessFile raf = null ; try { raf = getRaf ( location , - 1 ) ; return ( raf != null ) && canOpen ( raf ) ; } finally { if ( raf != null ) raf . close ( ) ; }


signature:
public class NetcdfFile { /** * Open an existing file ( read only ) , specifying which IOSP is to be used .
 * @ param location location of file
 * @ param iospClassName fully qualified class name of the IOSP class to handle this file
 * @ param bufferSize RandomAccessFile buffer size , if < = 0 , use default size
 * @ param cancelTask allow task to be cancelled ; may be null .
 * @ param iospMessage special iosp tweaking ( sent before open is called ) , may be null
 * @ return NetcdfFile object , or null if cant find IOServiceProver
 * @ throws IOException if read error
 * @ throws ClassNotFoundException cannat find iospClassName in thye class path
 * @ throws InstantiationException if class cannot be instantiated
 * @ throws IllegalAccessException if class is not accessible */
static public NetcdfFile open ( String location , String iospClassName , int bufferSize , CancelTask cancelTask , Object iospMessage ) throws ClassNotFoundException , IllegalAccessException , InstantiationException , IOException { } }

implementation:
Class iospClass = NetcdfFile . class . getClassLoader ( ) . loadClass ( iospClassName ) ; IOServiceProvider spi = ( IOServiceProvider ) iospClass . newInstance ( ) ; // fail fast
// send before iosp is opened
if ( iospMessage != null ) spi . sendIospMessage ( iospMessage ) ; if ( bufferSize <= 0 ) bufferSize = default_buffersize ; ucar . unidata . io . RandomAccessFile raf = ucar . unidata . io . RandomAccessFile . acquire ( canonicalizeUriString ( location ) , bufferSize ) ; NetcdfFile result = new NetcdfFile ( spi , raf , location , cancelTask ) ; // send after iosp is opened
if ( iospMessage != null ) spi . sendIospMessage ( iospMessage ) ; return result ;


signature:
public class NetcdfFile { /** * Removes the { @ code " file : " } or { @ code " file : / / " } prefix from the location , if necessary . Also replaces
 * back slashes with forward slashes .
 * @ param location a URI string .
 * @ return a canonical URI string . */
public static String canonicalizeUriString ( String location ) { } }

implementation:
// get rid of file prefix , if any
String uriString = location . trim ( ) ; if ( uriString . startsWith ( "file://" ) ) uriString = uriString . substring ( 7 ) ; else if ( uriString . startsWith ( "file:" ) ) uriString = uriString . substring ( 5 ) ; // get rid of crappy microsnot \ replace with happy /
return StringUtil2 . replace ( uriString , '\\' , "/" ) ;


signature:
public class NetcdfFile { /** * Open an in - memory netcdf file , with a specific iosp .
 * @ param name name of the dataset . Typically use the filename or URI .
 * @ param data in - memory netcdf file
 * @ param iospClassName fully qualified class name of the IOSP class to handle this file
 * @ return NetcdfFile object , or null if cant find IOServiceProver
 * @ throws IOException if read error
 * @ throws ClassNotFoundException cannat find iospClassName in the class path
 * @ throws InstantiationException if class cannot be instantiated
 * @ throws IllegalAccessException if class is not accessible */
public static NetcdfFile openInMemory ( String name , byte [ ] data , String iospClassName ) throws IOException , ClassNotFoundException , IllegalAccessException , InstantiationException { } }

implementation: ucar . unidata . io . InMemoryRandomAccessFile raf = new ucar . unidata . io . InMemoryRandomAccessFile ( name , data ) ; Class iospClass = NetcdfFile . class . getClassLoader ( ) . loadClass ( iospClassName ) ; IOServiceProvider spi = ( IOServiceProvider ) iospClass . newInstance ( ) ; return new NetcdfFile ( spi , raf , name , null ) ;


signature:
public class NetcdfFile { /** * Open an in - memory netcdf file .
 * @ param name name of the dataset . Typically use the filename or URI .
 * @ param data in - memory netcdf file
 * @ return memory - resident NetcdfFile
 * @ throws java . io . IOException if error */
public static NetcdfFile openInMemory ( String name , byte [ ] data ) throws IOException { } }

implementation: ucar . unidata . io . InMemoryRandomAccessFile raf = new ucar . unidata . io . InMemoryRandomAccessFile ( name , data ) ; return open ( raf , name , null , null ) ;


signature:
public class NetcdfFile { /** * Read a local CDM file into memory . All reads are then done from memory .
 * @ param filename location of CDM file , must be a local file .
 * @ return a NetcdfFile , which is completely in memory
 * @ throws IOException if error reading file */
public static NetcdfFile openInMemory ( String filename ) throws IOException { } }

implementation: File file = new File ( filename ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ( int ) file . length ( ) ) ; try ( InputStream in = new BufferedInputStream ( new FileInputStream ( filename ) ) ) { IO . copy ( in , bos ) ; } return openInMemory ( filename , bos . toByteArray ( ) ) ;


signature:
public class NetcdfFile { /** * Read a remote CDM file into memory . All reads are then done from memory .
 * @ param uri location of CDM file , must be accessible through url . toURL ( ) . openStream ( ) .
 * @ return a NetcdfFile , which is completely in memory
 * @ throws IOException if error reading file */
public static NetcdfFile openInMemory ( URI uri ) throws IOException { } }

implementation: URL url = uri . toURL ( ) ; byte [ ] contents = IO . readContentsToByteArray ( url . openStream ( ) ) ; return openInMemory ( uri . toString ( ) , contents ) ;


signature:
public class NetcdfFile { /** * Close all resources ( files , sockets , etc ) associated with this file .
 * If the underlying file was acquired , it will be released , otherwise closed .
 * if isClosed ( ) already , nothing will happen
 * @ throws java . io . IOException if error when closing */
public synchronized void close ( ) throws java . io . IOException { } }

implementation:
if ( cache != null ) { if ( cache . release ( this ) ) return ; } try { if ( null != spi ) { // log . warn ( " NetcdfFile . close called for ncfile = " + this . hashCode ( ) + " for iosp = " + spi . hashCode ( ) ) ;
spi . close ( ) ; } } finally { spi = null ; }


signature:
public class NetcdfFile { /** * Find a Group , with the specified ( full ) name .
 * An embedded " / " is interpreted as separating group names .
 * @ param fullName eg " / group / subgroup / wantGroup " . Null or empty string returns the root group .
 * @ return Group or null if not found . */
public Group findGroup ( String fullName ) { } }

implementation: if ( fullName == null || fullName . length ( ) == 0 ) return rootGroup ; Group g = rootGroup ; StringTokenizer stoke = new StringTokenizer ( fullName , "/" ) ; while ( stoke . hasMoreTokens ( ) ) { String groupName = NetcdfFile . makeNameUnescaped ( stoke . nextToken ( ) ) ; g = g . findGroup ( groupName ) ; if ( g == null ) return null ; } return g ;


signature:
public class NetcdfFile { /** * Find a Variable , with the specified ( escaped full ) name .
 * It may possibly be nested in multiple groups and / or structures .
 * An embedded " . " is interpreted as structure . member .
 * An embedded " / " is interpreted as group / variable .
 * If the name actually has a " . " , you must escape it ( call NetcdfFile . escapeName ( varname ) )
 * Any other chars may also be escaped , as they are removed before testing .
 * @ param fullNameEscaped eg " / group / subgroup / name1 . name2 . name " .
 * @ return Variable or null if not found . */
public Variable findVariable ( String fullNameEscaped ) { } }

implementation:
if ( fullNameEscaped == null || fullNameEscaped . isEmpty ( ) ) { return null ; } Group g = rootGroup ; String vars = fullNameEscaped ; // break into group / group and var . var
int pos = fullNameEscaped . lastIndexOf ( '/' ) ; if ( pos >= 0 ) { String groups = fullNameEscaped . substring ( 0 , pos ) ; vars = fullNameEscaped . substring ( pos + 1 ) ; StringTokenizer stoke = new StringTokenizer ( groups , "/" ) ; while ( stoke . hasMoreTokens ( ) ) { String token = NetcdfFile . makeNameUnescaped ( stoke . nextToken ( ) ) ; g = g . findGroup ( token ) ; if ( g == null ) return null ; } } // heres var . var - tokenize respecting the possible escaped ' . '
List < String > snames = EscapeStrings . tokenizeEscapedName ( vars ) ; if ( snames . size ( ) == 0 ) return null ; String varShortName = NetcdfFile . makeNameUnescaped ( snames . get ( 0 ) ) ; Variable v = g . findVariable ( varShortName ) ; if ( v == null ) return null ; int memberCount = 1 ; while ( memberCount < snames . size ( ) ) { if ( ! ( v instanceof Structure ) ) return null ; String name = NetcdfFile . makeNameUnescaped ( snames . get ( memberCount ++ ) ) ; v = ( ( Structure ) v ) . findVariable ( name ) ; if ( v == null ) return null ; } return v ;


signature:
public class NetcdfFile { /** * Finds a Dimension with the specified full name . It may be nested in multiple groups .
 * An embedded " / " is interpreted as a group separator . A leading slash indicates the root group . That slash may be
 * omitted , but the { @ code fullName } will be treated as if it were there . In other words , the first name token in
 * { @ code fullName } is treated as the short name of a Group or Dimension , relative to the root group .
 * @ param fullName Dimension full name , e . g . " / group / subgroup / dim " .
 * @ return the Dimension or { @ code null } if it wasn ' t found . */
public Dimension findDimension ( String fullName ) { } }

implementation:
if ( fullName == null || fullName . isEmpty ( ) ) { return null ; } Group group = rootGroup ; String dimShortName = fullName ; // break into group / group and dim
int pos = fullName . lastIndexOf ( '/' ) ; if ( pos >= 0 ) { String groups = fullName . substring ( 0 , pos ) ; dimShortName = fullName . substring ( pos + 1 ) ; StringTokenizer stoke = new StringTokenizer ( groups , "/" ) ; while ( stoke . hasMoreTokens ( ) ) { String token = NetcdfFile . makeNameUnescaped ( stoke . nextToken ( ) ) ; group = group . findGroup ( token ) ; if ( group == null ) { return null ; } } } return group . findDimensionLocal ( dimShortName ) ;


signature:
public class NetcdfFile { /** * Look up global Attribute by ( full ) name .
 * @ param name the name of the attribute
 * @ return the attribute , or null if not found */
public Attribute findGlobalAttribute ( String name ) { } }

implementation: for ( Attribute a : gattributes ) { if ( name . equals ( a . getShortName ( ) ) ) return a ; } return null ;


signature:
public class NetcdfFile { /** * Look up global Attribute by name , ignore case .
 * @ param name the name of the attribute
 * @ return the attribute , or null if not found */
public Attribute findGlobalAttributeIgnoreCase ( String name ) { } }

implementation: for ( Attribute a : gattributes ) { if ( name . equalsIgnoreCase ( a . getShortName ( ) ) ) return a ; } return null ;


signature:
public class NetcdfFile { /** * Find an attribute , with the specified ( escaped full ) name .
 * It may possibly be nested in multiple groups and / or structures .
 * An embedded " . " is interpreted as structure . member .
 * An embedded " / " is interpreted as group / group or group / variable .
 * An embedded " @ " is interpreted as variable @ attribute
 * If the name actually has a " . " , you must escape it ( call NetcdfFile . escapeName ( varname ) )
 * Any other chars may also be escaped , as they are removed before testing .
 * @ param fullNameEscaped eg " @ attName " , " / group / subgroup / @ attName " or " / group / subgroup / varname . name2 . name @ attName "
 * @ return Attribute or null if not found . */
public Attribute findAttribute ( String fullNameEscaped ) { } }

implementation:
if ( fullNameEscaped == null || fullNameEscaped . length ( ) == 0 ) { return null ; } int posAtt = fullNameEscaped . indexOf ( '@' ) ; if ( posAtt < 0 || posAtt >= fullNameEscaped . length ( ) - 1 ) return null ; if ( posAtt == 0 ) { return findGlobalAttribute ( fullNameEscaped . substring ( 1 ) ) ; } String path = fullNameEscaped . substring ( 0 , posAtt ) ; String attName = fullNameEscaped . substring ( posAtt + 1 ) ; // find the group
Group g = rootGroup ; int pos = path . lastIndexOf ( '/' ) ; String varName = ( pos > 0 && pos < path . length ( ) - 1 ) ? path . substring ( pos + 1 ) : null ; if ( pos >= 0 ) { String groups = path . substring ( 0 , pos ) ; StringTokenizer stoke = new StringTokenizer ( groups , "/" ) ; while ( stoke . hasMoreTokens ( ) ) { String token = NetcdfFile . makeNameUnescaped ( stoke . nextToken ( ) ) ; g = g . findGroup ( token ) ; if ( g == null ) return null ; } } if ( varName == null ) // group attribute
return g . findAttribute ( attName ) ; // heres var . var - tokenize respecting the possible escaped ' . '
List < String > snames = EscapeStrings . tokenizeEscapedName ( varName ) ; if ( snames . size ( ) == 0 ) return null ; String varShortName = NetcdfFile . makeNameUnescaped ( snames . get ( 0 ) ) ; Variable v = g . findVariable ( varShortName ) ; if ( v == null ) return null ; int memberCount = 1 ; while ( memberCount < snames . size ( ) ) { if ( ! ( v instanceof Structure ) ) return null ; String name = NetcdfFile . makeNameUnescaped ( snames . get ( memberCount ++ ) ) ; v = ( ( Structure ) v ) . findVariable ( name ) ; if ( v == null ) return null ; } return v . findAttribute ( attName ) ;


signature:
public class NetcdfFile { /** * Find a String - valued global or variable Attribute by
 * Attribute name ( ignore case ) , return the Value of the Attribute .
 * If not found return defaultValue
 * @ param v the variable or null for global attribute
 * @ param attName the ( full ) name of the attribute , case insensitive
 * @ param defaultValue return this if attribute not found
 * @ return the attribute value , or defaultValue if not found */
public String findAttValueIgnoreCase ( Variable v , String attName , String defaultValue ) { } }

implementation:
String attValue = null ; Attribute att ; if ( v == null ) att = rootGroup . findAttributeIgnoreCase ( attName ) ; else att = v . findAttributeIgnoreCase ( attName ) ; if ( ( att != null ) && att . isString ( ) ) attValue = att . getStringValue ( ) ; if ( null == attValue ) // not found , use default
attValue = defaultValue ; return attValue ;


signature:
public class NetcdfFile { /** * CDL representation of Netcdf header info , non strict */
public String toNcML ( String url ) throws IOException { } }

implementation: NcMLWriter ncmlWriter = new NcMLWriter ( ) ; ncmlWriter . setWriteVariablesPredicate ( NcMLWriter . writeNoVariablesPredicate ) ; Element netcdfElement = ncmlWriter . makeNetcdfElement ( this , url ) ; return ncmlWriter . writeToString ( netcdfElement ) ;


signature:
public class NetcdfFile { /** * Write CDL representation to OutputStream .
 * @ param out write to this OutputStream
 * @ param strict if true , make it stricly CDL , otherwise , add a little extra info */
public void writeCDL ( OutputStream out , boolean strict ) { } }

implementation: PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( out , CDM . utf8Charset ) ) ; toStringStart ( pw , strict ) ; toStringEnd ( pw ) ; pw . flush ( ) ;


signature:
public class NetcdfFile { /** * Write CDL representation to PrintWriter .
 * @ param pw write to this PrintWriter
 * @ param strict if true , make it stricly CDL , otherwise , add a little extra info */
public void writeCDL ( PrintWriter pw , boolean strict ) { } }

implementation: toStringStart ( pw , strict ) ; toStringEnd ( pw ) ; pw . flush ( ) ;


signature:
public class NetcdfFile { /** * the actual work is here */
protected void writeCDL ( Formatter f , Indent indent , boolean strict ) { } }

implementation: toStringStart ( f , indent , strict ) ; f . format ( "%s}%n" , indent ) ;


signature:
public class NetcdfFile { /** * Write the NcML representation : dont show coodinate values
 * @ param os : write to this OutputStream . Will be closed at end of the method .
 * @ param uri use this for the url attribute ; if null use getLocation ( ) . / / ? ?
 * @ throws IOException if error
 * @ see NcMLWriter # writeToStream */
public void writeNcML ( java . io . OutputStream os , String uri ) throws IOException { } }

implementation: NcMLWriter ncmlWriter = new NcMLWriter ( ) ; Element netcdfElem = ncmlWriter . makeNetcdfElement ( this , uri ) ; ncmlWriter . writeToStream ( netcdfElem , os ) ;


signature:
public class NetcdfFile { /** * Write the NcML representation : dont show coodinate values
 * @ param writer : write to this Writer , should have encoding of UTF - 8 if applicable . Will be closed at end of the
 * method .
 * @ param uri use this for the url attribute ; if null use getLocation ( ) .
 * @ throws IOException if error
 * @ see NcMLWriter # writeToWriter */
public void writeNcML ( java . io . Writer writer , String uri ) throws IOException { } }

implementation: NcMLWriter ncmlWriter = new NcMLWriter ( ) ; Element netcdfElem = ncmlWriter . makeNetcdfElement ( this , uri ) ; ncmlWriter . writeToWriter ( netcdfElem , writer ) ;


signature:
public class NetcdfFile { /** * Check if file has changed , and reread metadata if needed .
 * All previous object references ( variables , dimensions , etc ) may become invalid - you must re - obtain .
 * DO NOT USE THIS ROUTINE YET - NOT FULLY TESTED
 * @ return true if file was changed .
 * @ throws IOException if error
 * public boolean sync ( ) throws IOException {
 * unlocked = false ;
 * return ( spi ! = null ) & & spi . sync ( ) ; */
@ Override public long getLastModified ( ) { } }

implementation: if ( spi != null && spi instanceof AbstractIOServiceProvider ) { AbstractIOServiceProvider aspi = ( AbstractIOServiceProvider ) spi ; return aspi . getLastModified ( ) ; } return 0 ;


signature:
public class NetcdfFile { /** * Add an attribute to a group .
 * @ param parent add to this group . If group is null , use root group
 * @ param att add this attribute
 * @ return the attribute that was added */
public Attribute addAttribute ( Group parent , Attribute att ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( parent == null ) parent = rootGroup ; parent . addAttribute ( att ) ; return att ;


signature:
public class NetcdfFile { /** * Add optional String attribute to a group .
 * @ param parent add to this group . If group is null , use root group
 * @ param name attribute name , may not be null
 * @ param value attribute value , may be null , in which case , do not addd
 * @ return the attribute that was added */
public Attribute addAttribute ( Group parent , String name , String value ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( value == null ) return null ; if ( parent == null ) parent = rootGroup ; Attribute att = new Attribute ( name , value ) ; parent . addAttribute ( att ) ; return att ;


signature:
public class NetcdfFile { /** * Add a group to the parent group .
 * @ param parent add to this group . If group is null , use root group
 * @ param g add this group
 * @ return the group that was added */
public Group addGroup ( Group parent , Group g ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( parent == null ) parent = rootGroup ; parent . addGroup ( g ) ; return g ;


signature:
public class NetcdfFile { /** * Add a shared Dimension to a Group .
 * @ param parent add to this group . If group is null , use root group
 * @ param d add this Dimension
 * @ return the dimension that was added */
public Dimension addDimension ( Group parent , Dimension d ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( parent == null ) parent = rootGroup ; parent . addDimension ( d ) ; return d ;


signature:
public class NetcdfFile { /** * Remove a shared Dimension from a Group by name .
 * @ param g remove from this group . If group is null , use root group
 * @ param dimName name of Dimension to remove .
 * @ return true if found and removed . */
public boolean removeDimension ( Group g , String dimName ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( g == null ) g = rootGroup ; return g . removeDimension ( dimName ) ;


signature:
public class NetcdfFile { /** * Add a Variable to the given group .
 * @ param g add to this group . If group is null , use root group
 * @ param v add this Variable
 * @ return the variable that was added */
public Variable addVariable ( Group g , Variable v ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( g == null ) g = rootGroup ; if ( v != null ) g . addVariable ( v ) ; return v ;


signature:
public class NetcdfFile { /** * Create a new Variable , and add to the given group .
 * @ param g add to this group . If group is null , use root group
 * @ param shortName short name of the Variable
 * @ param dtype data type of the Variable
 * @ param dims list of dimension names
 * @ return the new Variable */
public Variable addVariable ( Group g , String shortName , DataType dtype , String dims ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( g == null ) g = rootGroup ; Variable v = new Variable ( this , g , null , shortName ) ; v . setDataType ( dtype ) ; v . setDimensions ( dims ) ; g . addVariable ( v ) ; return v ;


signature:
public class NetcdfFile { /** * Create a new Variable of type Datatype . CHAR , and add to the given group .
 * @ param g add to this group . If group is null , use root group
 * @ param shortName short name of the Variable
 * @ param dims list of dimension names
 * @ param strlen dimension length of the inner ( fastest changing ) dimension
 * @ return the new Variable */
public Variable addStringVariable ( Group g , String shortName , String dims , int strlen ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( g == null ) g = rootGroup ; String dimName = shortName + "_strlen" ; addDimension ( g , new Dimension ( dimName , strlen ) ) ; Variable v = new Variable ( this , g , null , shortName ) ; v . setDataType ( DataType . CHAR ) ; v . setDimensions ( dims + " " + dimName ) ; g . addVariable ( v ) ; return v ;


signature:
public class NetcdfFile { /** * Remove a Variable from the given group by name .
 * @ param g remove from this group . If group is null , use root group
 * @ param varName name of variable to remove .
 * @ return true is variable found and removed */
public boolean removeVariable ( Group g , String varName ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; if ( g == null ) g = rootGroup ; return g . removeVariable ( varName ) ;


signature:
public class NetcdfFile { /** * Generic way to send a " message " to the underlying IOSP .
 * This message is sent after the file is open . To affect the creation of the file , you must send into the factory method .
 * @ param message iosp specific message
 * Special : < ul >
 * < li > NetcdfFile . IOSP _ MESSAGE _ ADD _ RECORD _ STRUCTURE : tells Netcdf - 3 files to make record ( unlimited ) variables into a structure .
 * return true if it has a Nectdf - 3 record structure
 * < / ul >
 * @ return iosp specific return , may be null */
public Object sendIospMessage ( Object message ) { } }

implementation: if ( null == message ) return null ; if ( message == IOSP_MESSAGE_ADD_RECORD_STRUCTURE ) { Variable v = rootGroup . findVariable ( "record" ) ; boolean gotit = ( v != null ) && ( v instanceof Structure ) ; return gotit || makeRecordStructure ( ) ; } else if ( message == IOSP_MESSAGE_REMOVE_RECORD_STRUCTURE ) { Variable v = rootGroup . findVariable ( "record" ) ; boolean gotit = ( v != null ) && ( v instanceof Structure ) ; if ( gotit ) { rootGroup . remove ( v ) ; variables . remove ( v ) ; removeRecordStructure ( ) ; } return ( gotit ) ; } if ( spi != null ) return spi . sendIospMessage ( message ) ; return null ;


signature:
public class NetcdfFile { /** * If there is an unlimited dimension , make all variables that use it into a Structure .
 * A Variable called " record " is added .
 * You can then access these through the record structure .
 * @ return true if it has a Nectdf - 3 record structure */
protected Boolean makeRecordStructure ( ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; Boolean didit = false ; if ( ( spi != null ) && ( spi instanceof N3iosp ) && hasUnlimitedDimension ( ) ) { didit = ( Boolean ) spi . sendIospMessage ( IOSP_MESSAGE_ADD_RECORD_STRUCTURE ) ; } return didit ;


signature:
public class NetcdfFile { /** * Make this immutable .
 * @ return this */
public NetcdfFile setImmutable ( ) { } }

implementation: if ( immutable ) return this ; immutable = true ; setImmutable ( rootGroup ) ; variables = Collections . unmodifiableList ( variables ) ; dimensions = Collections . unmodifiableList ( dimensions ) ; gattributes = Collections . unmodifiableList ( gattributes ) ; return this ;


signature:
public class NetcdfFile { /** * Completely empty the objects in the netcdf file .
 * Used for rereading the file on a sync ( ) . */
public void empty ( ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; variables = new ArrayList < > ( ) ; gattributes = new ArrayList < > ( ) ; dimensions = new ArrayList < > ( ) ; rootGroup = makeRootGroup ( ) ; // addedRecordStructure = false ;


signature:
public class NetcdfFile { /** * Finish constructing the object model .
 * This construsts the " global " variables , attributes and dimensions .
 * It also looks for coordinate variables . */
public void finish ( ) { } }

implementation: if ( immutable ) throw new IllegalStateException ( "Cant modify" ) ; variables = new ArrayList < > ( ) ; dimensions = new ArrayList < > ( ) ; gattributes = new ArrayList < > ( ) ; finishGroup ( rootGroup ) ;


signature:
public class NetcdfFile { /** * Do not call this directly , use Variable . read ( ) ! !
 * Ranges must be filled ( no nulls ) */
protected Array readData ( ucar . nc2 . Variable v , Section ranges ) throws IOException , InvalidRangeException { } }

implementation:
long start = 0 ; if ( showRequest ) { log . info ( "Data request for variable: {} section {}..." , v . getFullName ( ) , ranges ) ; start = System . currentTimeMillis ( ) ; } /* if ( unlocked ) {
 String info = cache . getInfo ( this ) ;
 throw new IllegalStateException ( " File is unlocked - cannot use \ n " + info ) ; */
if ( spi == null ) { throw new IOException ( "spi is null, perhaps file has been closed. Trying to read variable " + v . getFullName ( ) ) ; } Array result = spi . readData ( v , ranges ) ; if ( showRequest ) { long took = System . currentTimeMillis ( ) - start ; log . info ( " ...took= {} msecs" , took ) ; } return result ;


signature:
public class NetcdfFile { /** * Read a variable using the given section specification .
 * The result is always an array of the type of the innermost variable .
 * Its shape is the accumulation of all the shapes of its parent structures .
 * @ param variableSection the constraint expression .
 * @ return data requested
 * @ throws IOException if error
 * @ throws InvalidRangeException if variableSection is invalid
 * @ see < a href = " http : / / www . unidata . ucar . edu / software / netcdf - java / reference / SectionSpecification . html " > SectionSpecification < / a > */
public Array readSection ( String variableSection ) throws IOException , InvalidRangeException { } }

implementation:
/* if ( unlocked )
 throw new IllegalStateException ( " File is unlocked - cannot use " ) ; */
ParsedSectionSpec cer = ParsedSectionSpec . parseVariableSection ( this , variableSection ) ; if ( cer . child == null ) { return cer . v . read ( cer . section ) ; } if ( spi == null ) return IospHelper . readSection ( cer ) ; else // allow iosp to optimize
return spi . readSection ( cer ) ;


signature:
public class NetcdfFile { /** * Read data from a top level Variable and send data to a WritableByteChannel . Experimental .
 * @ param v a top - level Variable
 * @ param section the section of data to read .
 * There must be a Range for each Dimension in the variable , in order .
 * Note : no nulls allowed . IOSP may not modify .
 * @ param wbc write data to this WritableByteChannel
 * @ return the number of bytes written to the channel
 * @ throws java . io . IOException if read error
 * @ throws ucar . ma2 . InvalidRangeException if invalid section */
protected long readToByteChannel ( ucar . nc2 . Variable v , Section section , WritableByteChannel wbc ) throws java . io . IOException , ucar . ma2 . InvalidRangeException { } }

implementation:
// if ( unlocked )
// throw new IllegalStateException ( " File is unlocked - cannot use " ) ;
if ( ( spi == null ) || v . hasCachedData ( ) ) return IospHelper . copyToByteChannel ( v . read ( section ) , wbc ) ; return spi . readToByteChannel ( v , section , wbc ) ;


signature:
public class NetcdfFile { /** * Do a bulk read on a list of Variables and
 * return a corresponding list of Array that contains the results
 * of a full read on each Variable .
 * This is mostly here so DODSNetcdf can override it with one call to the server .
 * @ param variables List of type Variable
 * @ return List of Array , one for each Variable in the input .
 * @ throws IOException if read error */
public java . util . List < Array > readArrays ( java . util . List < Variable > variables ) throws IOException { } }

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


signature:
public class NetcdfFile { /** * Read a variable using the given section specification .
 * @ param variableSection the constraint expression .
 * @ param flatten MUST BE TRUE
 * @ return Array data read .
 * @ throws IOException if error
 * @ throws InvalidRangeException if variableSection is invalid
 * @ see < a href = " http : / / www . unidata . ucar . edu / software / netcdf - java / reference / SectionSpecification . html " > SectionSpecification < / a >
 * @ deprecated use readSection ( ) , flatten = false no longer supported */
public Array read ( String variableSection , boolean flatten ) throws IOException , InvalidRangeException { } }

implementation: if ( ! flatten ) throw new UnsupportedOperationException ( "NetdfFile.read(String variableSection, boolean flatten=false)" ) ; return readSection ( variableSection ) ;


signature:
public class NetcdfFile { /** * debugging - do not use */
public static void main ( String [ ] arg ) throws Exception { } }

implementation:
// NetcdfFile . registerIOProvider ( ucar . nc2 . grib . GribServiceProvider . class ) ;
int wide = 20 ; Formatter f = new Formatter ( System . out ) ; f . format ( " %" + wide + "s %n" , "test" ) ; f . format ( " %20s %n" , "asiuasdipuasiud" ) ; /* try {
 String filename = " R : / testdata2 / hdf5 / npoess / ExampleFiles / AVAFO _ NPP _ d2003125 _ t10109 _ e101038 _ b9 _ c2005829155458 _ devl _ Tst . h5 " ;
 NetcdfFile ncfile = NetcdfFile . open ( filename ) ;
 / / Thread . currentThread ( ) . sleep ( 60 * 60 * 1000 ) ; / / pause to examine in profiler
 ncfile . close ( ) ;
 } catch ( Exception e ) {
 e . printStackTrace ( ) ; */


signature:
public class NetcdfFile { /** * Create a valid CDM object name .
 * Control chars ( < 0x20 ) are not allowed .
 * Trailing and leading blanks are not allowed and are stripped off .
 * A space is converted into an underscore " _ " .
 * A forward slash " / " is converted into an underscore " _ " .
 * @ param shortName from this name
 * @ return valid CDM object name */
static public String makeValidCdmObjectName ( String shortName ) { } }

implementation: if ( shortName == null ) return null ; return StringUtil2 . makeValidCdmObjectName ( shortName ) ;


signature:
public class NetcdfFile { /** * Given a CDMNode , create its full name with
 * appropriate backslash escaping of the specified characters .
 * @ param node the cdm node
 * @ param reservedChars the set of characters to escape
 * @ return full name */
static protected String makeFullName ( CDMNode node , String reservedChars ) { } }

implementation:
Group parent = node . getParentGroup ( ) ; if ( ( ( parent == null ) || parent . isRoot ( ) ) && ! node . isMemberOfStructure ( ) ) // common case ?
return EscapeStrings . backslashEscape ( node . getShortName ( ) , reservedChars ) ; StringBuilder sbuff = new StringBuilder ( ) ; appendGroupName ( sbuff , parent , reservedChars ) ; appendStructureName ( sbuff , node , reservedChars ) ; return sbuff . toString ( ) ;


signature:
public class NetcdfFile { /** * Create a synthetic full name from a group plus a string
 * @ param parent parent group
 * @ param name synthetic name string
 * @ return synthetic name */
protected String makeFullNameWithString ( Group parent , String name ) { } }

implementation:
name = makeValidPathName ( name ) ; // escape for use in full name
StringBuilder sbuff = new StringBuilder ( ) ; appendGroupName ( sbuff , parent , null ) ; sbuff . append ( name ) ; return sbuff . toString ( ) ;


signature:
public class CompositeMFileFilter { /** * inclusion is an OR */
private boolean include ( MFile mfile ) { } }

implementation: if ( includeFilters == null ) return true ; for ( MFileFilter filter : includeFilters ) { if ( filter . accept ( mfile ) ) return true ; } return false ;


signature:
public class CompositeMFileFilter { /** * exclusion is an AND */
private boolean exclude ( MFile mfile ) { } }

implementation: if ( excludeFilters == null ) return false ; for ( MFileFilter filter : excludeFilters ) { if ( filter . accept ( mfile ) ) return true ; } return false ;


signature:
public class CompositeMFileFilter { /** * all AND filters must be satisfied */
private boolean andFilter ( MFile mfile ) { } }

implementation: if ( andFilters == null ) return true ; for ( MFileFilter filter : andFilters ) { if ( ! filter . accept ( mfile ) ) return false ; } return true ;


signature:
public class NodeMap { /** * Accessors */
public DAP_T get ( CDM_T cdm ) { } }

implementation: cdm = ( CDM_T ) CDMNode . unwrap ( cdm ) ; int lh = cdm . localhash ( ) ; return dapmap . get ( lh ) ;


signature:
public class NodeMap { /** * Given a CDM _ T < - > DAP _ T pair , insert
 * into the maps
 * @ param cdm
 * @ param dap */
public void put ( CDM_T cdm , DAP_T dap ) { } }

implementation: assert ( dap != null && cdm != null ) ; cdm = ( CDM_T ) CDMNode . unwrap ( cdm ) ; int lh = cdm . localhash ( ) ; dapmap . put ( lh , dap ) ; cdmmap . put ( dap , cdm ) ;


signature:
public class NodeMap { /** * Given a DAP _ T < - > CDM _ T pair , remove
 * from the maps
 * @ param cdm
 * @ param dap */
public void remove ( CDM_T cdm , DAP_T dap ) { } }

implementation: assert ( dap != null && cdm != null ) ; cdm = ( CDM_T ) CDMNode . unwrap ( cdm ) ; dapmap . remove ( cdm . localhash ( ) ) ; cdmmap . remove ( dap ) ;


signature:
public class Attribute { /** * Returns the attribute type as a < code > String < / code > .
 * @ return the attribute type < code > String < / code > . */
public final String getTypeString ( ) { } }

implementation:
switch ( type ) { case CONTAINER : return "Container" ; case ALIAS : return "Alias" ; case BYTE : return "Byte" ; case INT16 : return "Int16" ; case UINT16 : return "UInt16" ; case INT32 : return "Int32" ; case UINT32 : return "UInt32" ; case FLOAT32 : return "Float32" ; case FLOAT64 : return "Float64" ; case STRING : return "String" ; case URL : return "Url" ; // case BOOLEAN : return " Boolean " ;
default : return "" ; }


signature:
public class Attribute { /** * Returns the attribute type as a < code > String < / code > .
 * @ return the attribute type < code > String < / code > . */
public static final int getTypeVal ( String s ) { } }

implementation: if ( s . equalsIgnoreCase ( "Container" ) ) return CONTAINER ; else if ( s . equalsIgnoreCase ( "Byte" ) ) return BYTE ; else if ( s . equalsIgnoreCase ( "Int16" ) ) return INT16 ; else if ( s . equalsIgnoreCase ( "UInt16" ) ) return UINT16 ; else if ( s . equalsIgnoreCase ( "Int32" ) ) return INT32 ; else if ( s . equalsIgnoreCase ( "UInt32" ) ) return UINT32 ; else if ( s . equalsIgnoreCase ( "Float32" ) ) return FLOAT32 ; else if ( s . equalsIgnoreCase ( "Float64" ) ) return FLOAT64 ; else if ( s . equalsIgnoreCase ( "String" ) ) return STRING ; else if ( s . equalsIgnoreCase ( "URL" ) ) return URL ; else return UNKNOWN ;


signature:
public class Attribute { /** * Returns the attribute value at < code > index < / code > .
 * @ param index the index of the attribute value to return .
 * @ return the attribute < code > String < / code > at < code > index < / code > . */
public String getValueAt ( int index ) throws NoSuchAttributeException { } }

implementation: checkVectorUsage ( ) ; return ( String ) ( ( Vector ) attr ) . elementAt ( index ) ;


signature:
public class Attribute { /** * Returns the attribute value at < code > index < / code > .
 * @ param index the index of the attribute value to return .
 * @ return the attribute < code > String < / code > at < code > index < / code > , or null if a container . . */
public String getValueAtN ( int index ) { } }

implementation: if ( ! ( attr instanceof Vector ) ) return null ; return ( String ) ( ( Vector ) attr ) . elementAt ( index ) ;


signature:
public class Attribute { /** * Append a value to this attribute .
 * @ param value the attribute < code > String < / code > to add .
 * @ param check if true , check the validity of he attribute ' s value , if
 * false don ' t .
 * @ throws AttributeBadValueException thrown if the value is not a legal
 * member of type */
public void appendValue ( String value , boolean check ) throws NoSuchAttributeException , AttributeBadValueException { } }

implementation: checkVectorUsage ( ) ; if ( check ) value = forceValue ( type , value ) ; ( ( Vector ) attr ) . addElement ( value ) ;


signature:
public class Attribute { /** * Check if the value is legal for a given type .
 * @ param type the type of the value .
 * @ param value the value < code > String < / code > .
 * @ throws AttributeBadValueException if the value is not a legal
 * member of type */
private static void dispatchCheckValue ( int type , String value ) throws AttributeBadValueException { } }

implementation:
switch ( type ) { case BYTE : if ( ! checkByte ( value ) ) throw new AttributeBadValueException ( "`" + value + "' is not a Byte value." ) ; break ; case INT16 : if ( ! checkShort ( value ) ) throw new AttributeBadValueException ( "`" + value + "' is not an Int16 value." ) ; break ; case UINT16 : if ( ! checkUShort ( value ) ) throw new AttributeBadValueException ( "`" + value + "' is not an UInt16 value." ) ; break ; case INT32 : if ( ! checkInt ( value ) ) throw new AttributeBadValueException ( "`" + value + "' is not an Int32 value." ) ; break ; case UINT32 : if ( ! checkUInt ( value ) ) throw new AttributeBadValueException ( "`" + value + "' is not an UInt32 value." ) ; break ; case FLOAT32 : if ( ! checkFloat ( value ) ) throw new AttributeBadValueException ( "`" + value + "' is not a Float32 value." ) ; break ; case FLOAT64 : if ( ! checkDouble ( value ) ) throw new AttributeBadValueException ( "`" + value + "' is not a Float64 value." ) ; break ; // case BOOLEAN :
// if ( ! checkBoolean ( value ) )
// throw new AttributeBadValueException ( " ` " + value + " ' is not a Boolean value . " ) ;
// break ;
default : // Assume UNKNOWN , CONTAINER , STRING , and URL are okay .
}


signature:
public class Attribute { /** * Check if the value is legal for a given type
 * and try to convert to specified type .
 * @ param type the type of the value .
 * @ param value the value < code > String < / code > .
 * @ return original or converted value
 * @ throws AttributeBadValueException if the value is not a legal
 * member of type */
private static String forceValue ( int type , String value ) throws AttributeBadValueException { } }

implementation:
try { dispatchCheckValue ( type , value ) ; } catch ( AttributeBadValueException abe ) { if ( type == BYTE ) { // Try again : allow e . g . negative byte values
short val = Short . parseShort ( value ) ; if ( val > 255 && val < - 128 ) throw new AttributeBadValueException ( "Cannot convert to byte: " + value ) ; value = Integer . toString ( ( val & 0xFF ) ) ; } } return value ;


signature:
public class Attribute { /** * Check if string is a valid Byte .
 * @ param s the < code > String < / code > to check .
 * @ return true if the value is legal . */
private static final boolean checkByte ( String s ) throws AttributeBadValueException { } }

implementation:
try { // Byte . parseByte ( ) can ' t be used because values > 127 are allowed
short val = Short . parseShort ( s ) ; if ( DebugValueChecking ) { log . debug ( "Attribute.checkByte() - string: '" + s + "'   value: " + val ) ; } if ( val > 0xFF || val < 0 ) return false ; else return true ; } catch ( NumberFormatException e ) { throw new AttributeBadValueException ( "`" + s + "' is not a Byte value." ) ; }


signature:
public class Attribute { /** * Check if string is a valid Int16.
 * @ param s the < code > String < / code > to check .
 * @ return true if the value is legal . */
private static final boolean checkShort ( String s ) { } }

implementation: try { short val = Short . parseShort ( s ) ; if ( DebugValueChecking ) { DAPNode . log . debug ( "Attribute.checkShort() - string: '" + s + "'   value: " + val ) ; } return true ; } catch ( NumberFormatException e ) { return false ; }


signature:
public class Attribute { /** * Check if string is a valid Int32.
 * @ param s the < code > String < / code > to check .
 * @ return true if the value is legal . */
private static final boolean checkInt ( String s ) { } }

implementation:
try { // Coverity [ FB . DLS _ DEAD _ LOCAL _ STORE ]
int val = Integer . parseInt ( s ) ; if ( DebugValueChecking ) { DAPNode . log . debug ( "Attribute.checkInt() - string: '" + s + "'   value: " + val ) ; } return true ; } catch ( NumberFormatException e ) { return false ; }


signature:
public class Attribute { /** * Check if string is a valid UInt32.
 * @ param s the < code > String < / code > to check .
 * @ return true if the value is legal . */
private static final boolean checkUInt ( String s ) { } }

implementation:
// Note : Because there is no Unsigned class in Java , use Long instead .
try { long val = Long . parseLong ( s ) ; if ( DebugValueChecking ) { DAPNode . log . debug ( "Attribute.checkUInt() - string: '" + s + "'   value: " + val ) ; } if ( val > 0xFFFFFFFFL ) return false ; else return true ; } catch ( NumberFormatException e ) { return false ; }


signature:
public class Attribute { /** * Check if string is a valid Float32.
 * @ param s the < code > String < / code > to check .
 * @ return true if the value is legal . */
private static final boolean checkFloat ( String s ) { } }

implementation:
try { // Coverity [ FB . DLS _ DEAD _ LOCAL _ STORE ] =
float val = Float . parseFloat ( s ) ; if ( DebugValueChecking ) { DAPNode . log . debug ( "Attribute.checkFloat() - string: '" + s + "'   value: " + val ) ; } return true ; } catch ( NumberFormatException e ) { if ( s . equalsIgnoreCase ( "nan" ) || s . equalsIgnoreCase ( "inf" ) ) return true ; return false ; }


signature:
public class Attribute { /** * Check if string is a valid Float64.
 * @ param s the < code > String < / code > to check .
 * @ return true if the value is legal . */
private static final boolean checkDouble ( String s ) { } }

implementation:
try { // Coverity [ FB . DLS _ DEAD _ LOCAL _ STORE ]
double val = Double . parseDouble ( s ) ; if ( DebugValueChecking ) { DAPNode . log . debug ( "Attribute.checkDouble() - string: '" + s + "'   value: " + val ) ; } return true ; } catch ( NumberFormatException e ) { if ( s . equalsIgnoreCase ( "nan" ) || s . equalsIgnoreCase ( "inf" ) ) return true ; return false ; }


signature:
public class Attribute { /** * Returns a clone of this < code > Attribute < / code > .
 * See DAPNode . cloneDag ( )
 * @ param map track previously cloned nodes
 * @ return a clone of this < code > Attribute < / code > . */
public DAPNode cloneDAG ( CloneMap map ) throws CloneNotSupportedException { } }

implementation:
Attribute a = ( Attribute ) super . cloneDAG ( map ) ; // assume type , is _ alias , and aliased _ to have been cloned already
if ( type == CONTAINER ) a . attr = ( AttributeTable ) cloneDAG ( map , ( ( AttributeTable ) attr ) ) ; else a . attr = ( ( Vector ) attr ) . clone ( ) ; // ok , attr is a vector of strings
return a ;


signature:
public class EnhanceScaleMissingUnsignedImpl { /** * Get the data type of an attribute . Make it unsigned if the variable is unsigned . */
private DataType getAttributeDataType ( Attribute attribute ) { } }

implementation:
DataType dataType = attribute . getDataType ( ) ; if ( signedness == Signedness . UNSIGNED ) { // If variable is unsigned , make its integral attributes unsigned too .
dataType = dataType . withSignedness ( signedness ) ; } return dataType ;


signature:
public class EnhanceScaleMissingUnsignedImpl { /** * Returns a distinct integer for each of the { @ link DataType # isNumeric ( ) numeric } data types that can be used to
 * ( roughly ) order them by the range of the DataType . { @ code BYTE < UBYTE < SHORT < USHORT < INT < UINT <
 * LONG < ULONG < FLOAT < DOUBLE } . { @ code - 1 } will be returned for all non - numeric data types .
 * @ param dataType a numeric data type .
 * @ return a distinct integer for each of the numeric data types that can be used to ( roughly ) order them by size . */
public static int rank ( DataType dataType ) { } }

implementation: if ( dataType == null ) { return - 1 ; } switch ( dataType ) { case BYTE : return 0 ; case UBYTE : return 1 ; case SHORT : return 2 ; case USHORT : return 3 ; case INT : return 4 ; case UINT : return 5 ; case LONG : return 6 ; case ULONG : return 7 ; case FLOAT : return 8 ; case DOUBLE : return 9 ; default : return - 1 ; }


signature:
public class EnhanceScaleMissingUnsignedImpl { /** * Returns the data type that is the largest among the arguments . Relative sizes of data types are determined via
 * { @ link # rank ( DataType ) } .
 * @ param dataTypes an array of numeric data types .
 * @ return the data type that is the largest among the arguments . */
public static DataType largestOf ( DataType ... dataTypes ) { } }

implementation: DataType widest = null ; for ( DataType dataType : dataTypes ) { if ( widest == null ) { widest = dataType ; } else if ( rank ( dataType ) > rank ( widest ) ) { widest = dataType ; } } return widest ;


signature:
public class EnhanceScaleMissingUnsignedImpl { /** * Returns the smallest numeric data type that :
 * < ol >
 * < li > can hold a larger integer than { @ code dataType } can < / li >
 * < li > if integral , has the same signedness as { @ code dataType } < / li >
 * < / ol >
 * The relative sizes of data types are determined in a manner consistent with { @ link # rank ( DataType ) } .
 * < table border = " 1 " >
 * < tr > < th > Argument < / th > < th > Result < / th > < / tr >
 * < tr > < td > BYTE < / td > < td > SHORT < / td > < / tr >
 * < tr > < td > UBYTE < / td > < td > USHORT < / td > < / tr >
 * < tr > < td > SHORT < / td > < td > INT < / td > < / tr >
 * < tr > < td > USHORT < / td > < td > UINT < / td > < / tr >
 * < tr > < td > INT < / td > < td > LONG < / td > < / tr >
 * < tr > < td > UINT < / td > < td > ULONG < / td > < / tr >
 * < tr > < td > LONG < / td > < td > DOUBLE < / td > < / tr >
 * < tr > < td > ULONG < / td > < td > DOUBLE < / td > < / tr >
 * < tr >
 * < td > Any other data type < / td >
 * < td > Just return argument < / td >
 * < / tr >
 * < / table >
 * The returned type is intended to be just big enough to hold the result of performing an unsigned conversion of a
 * value of the smaller type . For example , the { @ code byte } value { @ code - 106 } equals { @ code 150 } when interpreted
 * as unsigned . That won ' t fit in a ( signed ) { @ code byte } , but it will fit in a { @ code short } .
 * @ param dataType an integral data type .
 * @ return the next larger type . */
public static DataType nextLarger ( DataType dataType ) { } }

implementation: switch ( dataType ) { case BYTE : return SHORT ; case UBYTE : return USHORT ; case SHORT : return INT ; case USHORT : return UINT ; case INT : return LONG ; case UINT : return ULONG ; case LONG : return DOUBLE ; case ULONG : return DOUBLE ; default : return dataType ; }


signature:
public class Godiva3Viewer { /** * Returns true if this is a gridded dataset that is accessible via WMS . */
@ Override public boolean isViewable ( Dataset ds ) { } }

implementation: Access access = ds . getAccess ( ServiceType . WMS ) ; return access != null && ( ThreddsConfig . getBoolean ( "WMS.allow" , false ) ) ;


signature:
public class StringValidateEncodeUtils { /** * Return true if the given String is a valid single - line String .
 * < p > A string will be considered a valid single - line string if it does not
 * contain any characters from these Unicode general categories :
 * < ul >
 * < li > Cc - Other , Control < / li >
 * < li > Cf - Other , Format < / li >
 * < li > Cs - Other , Surrogate < / li >
 * < li > Co - Other , Private Use < / li >
 * < li > Cn - Other , Not Assigned < / li >
 * < li > Zl - Separator , Line < / li >
 * < li > Zp - Separator , Paragraph < / li >
 * < / ul >
 * < p > Or , in other words , allow : Letters , Numbers , Marks , Punctuation ,
 * Symbols , and Space separators .
 * @ param singleLineString the String to validate
 * @ return true if the given String is a valid single - line String . */
public static boolean validSingleLineString ( String singleLineString ) { } }

implementation: if ( singleLineString == null ) return false ; Matcher m = INVALID_CHARACTERS_FOR_SINGLE_LINE_STRING_PATTERN . matcher ( singleLineString ) ; return ! m . find ( ) ;


signature:
public class StringValidateEncodeUtils { /** * Return true if the given String is a valid path .
 * A String is considered a valid path if :
 * < ul >
 * < li > when passed to validSingleLineString ( String ) true is returned , and
 * < li > it does not contain any parent path segments ( " . . / " ) . < / li >
 * < / li >
 * < / ul >
 * @ param path the String to validate
 * @ return true if the given String is a valid path .
 * @ see # validSingleLineString ( String ) */
@ SuppressWarnings ( { } }

implementation:
"SimplifiableIfStatement" } ) public static boolean validPath ( String path ) { if ( path == null ) return false ; // Don ' t allow " . . " directories in path .
if ( path . indexOf ( "/../" ) != - 1 || path . equals ( ".." ) || path . startsWith ( "../" ) || path . endsWith ( "/.." ) ) return false ; return validSingleLineString ( path ) ;


signature:
public class StringValidateEncodeUtils { /** * Return true if the given String is a valid File path .
 * A String is considered a valid File path if :
 * < ul >
 * < li > when passed to validPath ( String ) true is returned ; and < / li >
 * < li > it does not contain the Java File path separator
 * ( java . io . File . pathSeparatorChar ) which is system dependant . < / li >
 * < / ul >
 * @ param path the String to validate
 * @ return true if the given String is a valid File path .
 * @ see # validPath ( String ) */
@ SuppressWarnings ( { } }

implementation: "SimplifiableIfStatement" } ) public static boolean validFilePath ( String path ) { if ( path == null ) return false ; if ( path . indexOf ( File . pathSeparatorChar ) != - 1 ) return false ; return validPath ( path ) ;