signature:
public class DTSServlet { /** * Handler for OPeNDAP status requests ; not publically available ,
 * used only for debugging
 * @ param rs The client ' s < code > ReqState < / code >
 * @ see GetHTMLInterfaceHandler */
public void doGetStatus ( ReqState rs ) throws Exception { } }

implementation:
rs . getResponse ( ) . setHeader ( "XDODS-Server" , getServerVersion ( ) ) ; rs . getResponse ( ) . setContentType ( "text/html" ) ; rs . getResponse ( ) . setHeader ( "Content-Description" , "dods-status" ) ; PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( rs . getResponse ( ) . getOutputStream ( ) , Util . UTF8 ) ) ; pw . println ( "<title>Server Status</title>" ) ; pw . println ( "
" ) ; printStatus ( pw ) ; pw . println ( "
" ) ; pw . flush ( ) ; rs . getResponse ( ) . setStatus ( HttpServletResponse . SC_OK ) ;


signature:
public class DTSServlet { /** * to be overridden by servers that implement status report */
protected void printStatus ( PrintWriter os ) { } }

implementation:
os . println ( "
Server version = " + getServerVersion ( ) + "
" ) ; os . println ( "
Number of Requests Received = " + HitCounter + "
" ) ; if ( track ) { int n = prArr . size ( ) ; int pending = 0 ; StringBuilder preqs = new StringBuilder ( ) ; for ( int i = 0 ; i < n ; i ++ ) { ReqState rs = ( ReqState ) prArr . get ( i ) ; RequestDebug reqD = ( RequestDebug ) rs . getUserObject ( ) ; if ( ! reqD . done ) { preqs . append ( "
-----------------------\n" ) ; preqs . append ( "Request[" ) ; preqs . append ( reqD . reqno ) ; preqs . append ( "](" ) ; preqs . append ( reqD . threadDesc ) ; preqs . append ( ") is pending.\n" ) ; preqs . append ( rs . toString ( ) ) ; preqs . append ( "
" ) ; pending ++ ; } } os . println ( "
" + pending + " Pending Request(s)
" ) ; os . println ( preqs . toString ( ) ) ; }


signature:
public class DTSServlet { /** * This is a bit of instrumentation that I kept around to let me look at the
 * state of the incoming < code > HttpServletRequest < / code > from the client .
 * This method calls the < code > get * < / code > methods of the request and prints
 * the results to standard out .
 * @ param ps The < code > PrintStream < / code > to send output .
 * @ param rs The < code > ReqState < / code > object to probe . */
public void probeRequest ( PrintStream ps , ReqState rs ) { } }

implementation:
Enumeration e ; int i ; HttpServletRequest request = rs . getRequest ( ) ; ps . println ( "####################### PROBE ##################################" ) ; ps . println ( "The HttpServletRequest object is actually a: " + request . getClass ( ) . getName ( ) ) ; ps . println ( "" ) ; ps . println ( "HttpServletRequest Interface:" ) ; ps . println ( "    getAuthType:           " + request . getAuthType ( ) ) ; ps . println ( "    getMethod:             " + request . getMethod ( ) ) ; ps . println ( "    getPathInfo:           " + request . getPathInfo ( ) ) ; ps . println ( "    getPathTranslated:     " + request . getPathTranslated ( ) ) ; ps . println ( "    getRequestURL:         " + request . getRequestURL ( ) ) ; ps . println ( "    getQueryString:        " + request . getQueryString ( ) ) ; ps . println ( "    getRemoteUser:         " + request . getRemoteUser ( ) ) ; ps . println ( "    getRequestedSessionId: " + request . getRequestedSessionId ( ) ) ; ps . println ( "    getRequestURI:         " + request . getRequestURI ( ) ) ; ps . println ( "    getServletPath:        " + request . getServletPath ( ) ) ; ps . println ( "    isRequestedSessionIdFromCookie: " + request . isRequestedSessionIdFromCookie ( ) ) ; ps . println ( "    isRequestedSessionIdValid:      " + request . isRequestedSessionIdValid ( ) ) ; ps . println ( "    isRequestedSessionIdFromURL:    " + request . isRequestedSessionIdFromURL ( ) ) ; ps . println ( "" ) ; i = 0 ; e = request . getHeaderNames ( ) ; ps . println ( "    Header Names:" ) ; while ( e . hasMoreElements ( ) ) { i ++ ; String s = ( String ) e . nextElement ( ) ; ps . print ( "        Header[" + i + "]: " + s ) ; ps . println ( ": " + request . getHeader ( s ) ) ; } ps . println ( "" ) ; ps . println ( "ServletRequest Interface:" ) ; ps . println ( "    getCharacterEncoding:  " + request . getCharacterEncoding ( ) ) ; ps . println ( "    getContentType:        " + request . getContentType ( ) ) ; ps . println ( "    getContentLength:      " + request . getContentLength ( ) ) ; ps . println ( "    getProtocol:           " + request . getProtocol ( ) ) ; ps . println ( "    getScheme:             " + request . getScheme ( ) ) ; ps . println ( "    getServerName:         " + request . getServerName ( ) ) ; ps . println ( "    getServerPort:         " + request . getServerPort ( ) ) ; ps . println ( "    getRemoteAddr:         " + request . getRemoteAddr ( ) ) ; ps . println ( "    getRemoteHost:         " + request . getRemoteHost ( ) ) ; // ps . println ( " getRealPath : " + request . getRealPath ( ) ) ;
ps . println ( "............................." ) ; ps . println ( "" ) ; i = 0 ; e = request . getAttributeNames ( ) ; ps . println ( "    Attribute Names:" ) ; while ( e . hasMoreElements ( ) ) { i ++ ; String s = ( String ) e . nextElement ( ) ; ps . print ( "        Attribute[" + i + "]: " + s ) ; ps . println ( " Type: " + request . getAttribute ( s ) ) ; } ps . println ( "............................." ) ; ps . println ( "" ) ; i = 0 ; e = request . getParameterNames ( ) ; ps . println ( "    Parameter Names:" ) ; while ( e . hasMoreElements ( ) ) { i ++ ; String s = ( String ) e . nextElement ( ) ; ps . print ( "        Parameter[" + i + "]: " + s ) ; ps . println ( " Value: " + request . getParameter ( s ) ) ; } ps . println ( "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" ) ; ps . println ( " . . . . . . . . . Servlet Infomation API  . . . . . . . . . . . . . ." ) ; ps . println ( "" ) ; ps . println ( "Servlet Context:" ) ; ps . println ( "" ) ; i = 0 ; e = servletContext . getAttributeNames ( ) ; ps . println ( "    Attribute Names:" ) ; while ( e . hasMoreElements ( ) ) { i ++ ; String s = ( String ) e . nextElement ( ) ; ps . print ( "        Attribute[" + i + "]: " + s ) ; ps . println ( " Type: " + servletContext . getAttribute ( s ) ) ; } ps . println ( "    ServletContext.getRealPath(\".\"): " + servletContext . getRealPath ( "." ) ) ; ps . println ( "    ServletContext.getMajorVersion(): " + servletContext . getMajorVersion ( ) ) ; // ps . println ( " ServletContext . getMimeType ( ) : " + sc . getMimeType ( ) ) ;
ps . println ( "    ServletContext.getMinorVersion(): " + servletContext . getMinorVersion ( ) ) ; // ps . println ( " ServletContext . getRealPath ( ) : " + sc . getRealPath ( ) ) ;
ps . println ( "............................." ) ; ps . println ( "Servlet Config:" ) ; ps . println ( "" ) ; ServletConfig scnfg = getServletConfig ( ) ; i = 0 ; e = scnfg . getInitParameterNames ( ) ; ps . println ( "    InitParameters:" ) ; while ( e . hasMoreElements ( ) ) { String p = ( String ) e . nextElement ( ) ; ps . print ( "        InitParameter[" + i + "]: " + p ) ; ps . println ( " Value: " + scnfg . getInitParameter ( p ) ) ; i ++ ; } ps . println ( "" ) ; ps . println ( "######################## END PROBE ###############################" ) ; ps . println ( "" ) ;


signature:
public class DTSServlet { /** * Handles incoming requests from clients . Parses the request and determines
 * what kind of OPeNDAP response the client is requesting . If the request is
 * understood , then the appropriate handler method is called , otherwise
 * an error is returned to the client .
 * This method is the entry point for < code > DTSServlet < / code > .
 * @ param request The client ' s < code > HttpServletRequest < / code > request
 * object .
 * @ param response The server ' s < code > HttpServletResponse < / code > response
 * object .
 * @ see opendap . servlet . ReqState */
public void doGet ( HttpServletRequest request , HttpServletResponse response ) { } }

implementation:
log . debug ( "DTS doGet()" ) ; long tid = Thread . currentThread ( ) . getId ( ) ; log . debug ( "thread=" + tid ) ; // setHeader ( " Last - Modified " , ( new Date ( ) ) . toString ( ) ) ;
boolean isDebug = false ; ReqState rs = null ; RequestDebug reqD = null ; try { // if ( Debug . isSet ( " probeRequest " ) )
// probeRequest ( System . out , rs ) ;
rs = getRequestState ( request , response ) ; assert ( rs != null ) ; if ( rs != null ) { String ds = rs . getDataSet ( ) ; String suff = rs . getRequestSuffix ( ) ; isDebug = ( ( ds != null ) && ds . equals ( "debug" ) && ( suff != null ) && suff . equals ( "" ) ) ; } synchronized ( syncLock ) { if ( ! isDebug ) { long reqno = HitCounter ++ ; if ( track ) { reqD = new RequestDebug ( reqno , Thread . currentThread ( ) . toString ( ) ) ; rs . setUserObject ( reqD ) ; if ( prArr == null ) prArr = new ArrayList ( 10000 ) ; prArr . add ( ( int ) reqno , rs ) ; } if ( Debug . isSet ( "showRequest" ) ) { log . debug ( "-------------------------------------------" ) ; log . debug ( "Server: " + getServerName ( ) + "   Request #" + reqno ) ; log . debug ( "Client: " + request . getRemoteHost ( ) ) ; log . debug ( rs . toString ( ) ) ; log . debug ( "Request dataset: '" + rs . getDataSet ( ) + "' suffix: '" + rs . getRequestSuffix ( ) + "' CE: '" + rs . getConstraintExpression ( ) + "'" ) ; } } } // synch
if ( rs != null ) { String dataSet = rs . getDataSet ( ) ; String requestSuffix = rs . getRequestSuffix ( ) ; rs . getResponse ( ) . setHeader ( "XDODS-Server" , getServerVersion ( ) ) ; // Make sure always set
if ( dataSet == null || dataSet . equals ( "/" ) || dataSet . equals ( "" ) ) { doGetDIR ( rs ) ; } else if ( dataSet . equalsIgnoreCase ( "/version" ) || dataSet . equalsIgnoreCase ( "/version/" ) ) { doGetVER ( rs ) ; } else if ( dataSet . equalsIgnoreCase ( "/help" ) || dataSet . equalsIgnoreCase ( "/help/" ) ) { doGetHELP ( rs ) ; } else if ( dataSet . equalsIgnoreCase ( "/" + requestSuffix ) ) { doGetHELP ( rs ) ; } else if ( requestSuffix . equalsIgnoreCase ( "dds" ) ) { doGetDDS ( rs ) ; } else if ( requestSuffix . equalsIgnoreCase ( "das" ) ) { doGetDAS ( rs ) ; } else if ( requestSuffix . equalsIgnoreCase ( "ddx" ) ) { doGetDDX ( rs ) ; } else if ( requestSuffix . equalsIgnoreCase ( "blob" ) ) { doGetBLOB ( rs ) ; } else if ( requestSuffix . equalsIgnoreCase ( "dods" ) ) { doGetDAP2Data ( rs ) ; } else if ( requestSuffix . equalsIgnoreCase ( "asc" ) || requestSuffix . equalsIgnoreCase ( "ascii" ) ) { doGetASC ( rs ) ; } else if ( requestSuffix . equalsIgnoreCase ( "info" ) ) { doGetINFO ( rs ) ; } else if ( requestSuffix . equalsIgnoreCase ( "html" ) || requestSuffix . equalsIgnoreCase ( "htm" ) ) { doGetHTML ( rs ) ; } else if ( requestSuffix . equalsIgnoreCase ( "ver" ) || requestSuffix . equalsIgnoreCase ( "version" ) ) { doGetVER ( rs ) ; } else if ( requestSuffix . equalsIgnoreCase ( "help" ) ) { doGetHELP ( rs ) ; /* JC added
 } else if ( dataSet . equalsIgnoreCase ( " catalog " ) & & requestSuffix . equalsIgnoreCase ( " xml " ) ) {
 doGetCatalog ( rs ) ;
 } else if ( dataSet . equalsIgnoreCase ( " status " ) ) {
 doGetStatus ( rs ) ;
 } else if ( dataSet . equalsIgnoreCase ( " systemproperties " ) ) {
 doGetSystemProps ( rs ) ;
 } else if ( isDebug ) {
 doDebug ( rs ) ; */
} else if ( requestSuffix . equals ( "" ) ) { badURL ( request , response ) ; } else { badURL ( request , response ) ; } } else { // rs = = null
badURL ( request , response ) ; } if ( reqD != null ) reqD . done = true ; } catch ( Throwable e ) { anyExceptionHandler ( e , rs ) ; }


signature: public class DTSServlet { void showMemUsed ( String from ) { } }

implementation:
long totalMemory = Runtime . getRuntime ( ) . totalMemory ( ) ; long freeMemory = Runtime . getRuntime ( ) . freeMemory ( ) ; // long maxMemory = Runtime . getRuntime ( ) . maxMemory ( ) ;
long usedMemory = ( totalMemory - freeMemory ) ; log . debug ( "****showMemUsed " + from ) ; log . debug ( " totalMemory " + totalMemory ) ; log . debug ( " freeMemory " + freeMemory ) ; // log . debug ( " maxMemory " + maxMemory ) ;
log . debug ( " usedMemory " + usedMemory ) ;


signature:
public class DTSServlet { /** * Prints the Bad URL Page page to the passed PrintWriter
 * @ param pw PrintWriter stream to which to dump the bad URL page . */
private void printBadURLPage ( PrintWriter pw ) { } }

implementation:
pw . println ( "
Error in URL
" ) ; pw . println ( "The URL extension did not match any that are known by this" ) ; pw . println ( "server. Below is a list of the five extensions that are be recognized by" ) ; pw . println ( "all OPeNDAP servers. If you think that the server is broken (that the URL you" ) ; pw . println ( "submitted should have worked), then please contact the" ) ; pw . println ( "OPeNDAP user support coordinator at: " ) ; pw . println ( "support@unidata.ucar.edu
" ) ;


signature:
public class Grib2SectionIdentification { /** * reference reference or base time as Dare .
 * @ return baseTime */
public CalendarDate getReferenceDate ( ) { } }

implementation: return CalendarDate . of ( null , year , month , day , hour , minute , second ) ;


signature:
public class XMLEntityResolver { /** * Add an entity for resolution . Specify a local resource , and / or a URL . Look
 * for the local Resource first .
 * @ param entityName name of entity , eg the namespace String
 * @ param resourceName resolve using this Resource , found on the class path
 * @ param urlName resolve using this Resource , found on the class path */
static public void initEntity ( String entityName , String resourceName , String urlName ) { } }

implementation:
String entity = null ; try ( InputStream is = ucar . nc2 . util . IO . getFileResource ( resourceName ) ) { // try to read from local file resource , eg from catalog . jar
ByteArrayOutputStream sbuff = new ByteArrayOutputStream ( 3000 ) ; if ( is != null ) { IO . copy ( is , sbuff ) ; entity = new String ( sbuff . toByteArray ( ) , CDM . utf8Charset ) ; logger . debug ( " *** entity " + entityName + " mapped to local resource at " + resourceName ) ; } else if ( urlName != null ) { // otherwise , get from network
entity = IO . readURLcontentsWithException ( urlName ) ; logger . debug ( " *** entity " + entityName + " mapped to remote URL at " + urlName ) ; } } catch ( IOException e ) { System . out . println ( " *** FAILED to map entity " + entityName + " locally at " + resourceName + " or remotely at " + urlName ) ; // e . printStackTrace ( ) ;
} entityHash . put ( entityName , entity ) ; entityHash . put ( urlName , entity ) ; // also map it to the remote URL


signature:
public class XMLEntityResolver { /** * we read the DTD / schema locally if we can . */
public org . xml . sax . InputSource resolveEntity ( String publicId , String systemId ) throws SAXException , IOException { } }

implementation: logger . debug ( "  publicId=" + publicId + " systemId=" + systemId ) ; String entity = entityHash . get ( systemId ) ; if ( entity != null ) { logger . debug ( " *** resolved  with local copy" ) ; return new MyInputSource ( entity ) ; } if ( systemId . contains ( "InvCatalog.0.6.dtd" ) ) { entity = entityHash . get ( "http://www.unidata.ucar.edu/schemas/thredds/InvCatalog.0.6.dtd" ) ; if ( entity != null ) { logger . debug ( " *** resolved2 with local copy" ) ; return new MyInputSource ( entity ) ; } } logger . debug ( " *** not resolved" ) ; return null ;


signature:
public class NcStreamIosp { /** * lOOK probably desnt work */
private Array readVlenData ( Variable v , Section section , DataStorage dataStorage ) throws IOException , InvalidRangeException { } }

implementation:
raf . seek ( dataStorage . filePos ) ; int nelems = readVInt ( raf ) ; Array [ ] result = new Array [ nelems ] ; for ( int elem = 0 ; elem < nelems ; elem ++ ) { int dsize = readVInt ( raf ) ; byte [ ] data = new byte [ dsize ] ; raf . readFully ( data ) ; Array dataArray = Array . factory ( v . getDataType ( ) , ( int [ ] ) null , ByteBuffer . wrap ( data ) ) ; result [ elem ] = dataArray ; } // return Array . makeObjectArray ( v . getDataType ( ) , result [ 0 ] . getClass ( ) , new int [ ] { nelems } , result ) ;
return Array . makeVlenArray ( new int [ ] { nelems } , result ) ; // return dataArray . section ( section . getRanges ( ) ) ;


signature:
public class NcStreamIosp { /** * optionally read in all messages , return as List < NcMess > */
public void openDebug ( RandomAccessFile raf , NetcdfFile ncfile , List < NcsMess > ncm ) throws IOException { } }

implementation:
raf . seek ( 0 ) ; long pos = raf . getFilePointer ( ) ; if ( ! readAndTest ( raf , NcStream . MAGIC_START ) ) { if ( ncm != null ) { ncm . add ( new NcsMess ( pos , 0 , "MAGIC_START missing - abort" ) ) ; return ; } throw new IOException ( "Data corrupted on " + raf . getLocation ( ) ) ; } if ( ncm != null ) ncm . add ( new NcsMess ( pos , 4 , "MAGIC_START" ) ) ; pos = raf . getFilePointer ( ) ; if ( ! readAndTest ( raf , NcStream . MAGIC_HEADER ) ) { if ( ncm != null ) { ncm . add ( new NcsMess ( pos , 0 , "MAGIC_HEADER missing - abort" ) ) ; return ; } throw new IOException ( "Data corrupted on " + ncfile . getLocation ( ) ) ; } if ( ncm != null ) ncm . add ( new NcsMess ( pos , 4 , "MAGIC_HEADER" ) ) ; // assume for the moment it always starts with one header message
pos = raf . getFilePointer ( ) ; int msize = readVInt ( raf ) ; byte [ ] m = new byte [ msize ] ; raf . readFully ( m ) ; NcStreamProto . Header proto = NcStreamProto . Header . parseFrom ( m ) ; if ( ncm != null ) ncm . add ( new NcsMess ( pos , msize , proto ) ) ; version = proto . getVersion ( ) ; NcStreamProto . Group root = proto . getRoot ( ) ; NcStream . readGroup ( root , ncfile , ncfile . getRootGroup ( ) ) ; ncfile . finish ( ) ; // then we have a stream of data messages with a final END or ERR
while ( ! raf . isAtEndOfFile ( ) ) { pos = raf . getFilePointer ( ) ; byte [ ] b = new byte [ 4 ] ; raf . readFully ( b ) ; if ( test ( b , NcStream . MAGIC_END ) ) { if ( ncm != null ) ncm . add ( new NcsMess ( pos , 4 , "MAGIC_END" ) ) ; break ; } if ( test ( b , NcStream . MAGIC_ERR ) ) { int esize = readVInt ( raf ) ; byte [ ] dp = new byte [ esize ] ; raf . readFully ( dp ) ; NcStreamProto . Error error = NcStreamProto . Error . parseFrom ( dp ) ; if ( ncm != null ) ncm . add ( new NcsMess ( pos , esize , error . getMessage ( ) ) ) ; break ; // assume broken now ?
} if ( ! test ( b , NcStream . MAGIC_DATA ) ) { if ( ncm != null ) ncm . add ( new NcsMess ( pos , 4 , "MAGIC_DATA missing - abort" ) ) ; break ; } if ( ncm != null ) ncm . add ( new NcsMess ( pos , 4 , "MAGIC_DATA" ) ) ; // data messages
pos = raf . getFilePointer ( ) ; int psize = readVInt ( raf ) ; byte [ ] dp = new byte [ psize ] ; raf . readFully ( dp ) ; NcStreamProto . Data dproto = NcStreamProto . Data . parseFrom ( dp ) ; ByteOrder bo = NcStream . decodeDataByteOrder ( dproto ) ; // LOOK not using bo ! !
Variable v = ncfile . findVariable ( dproto . getVarName ( ) ) ; if ( v == null ) { System . out . printf ( " ERR cant find var %s%n%s%n" , dproto . getVarName ( ) , dproto ) ; } if ( debug ) System . out . printf ( " dproto = %s for %s%n" , dproto , v . getShortName ( ) ) ; if ( ncm != null ) ncm . add ( new NcsMess ( pos , psize , dproto ) ) ; List < DataStorage > storage ; if ( v != null ) { storage = ( List < DataStorage > ) v . getSPobject ( ) ; // LOOK could be an in memory Rtree using section
if ( storage == null ) { storage = new ArrayList < > ( ) ; v . setSPobject ( storage ) ; } } else storage = new ArrayList < > ( ) ; // barf
// version < 3
if ( dproto . getDataType ( ) == NcStreamProto . DataType . STRUCTURE ) { pos = raf . getFilePointer ( ) ; msize = readVInt ( raf ) ; m = new byte [ msize ] ; raf . readFully ( m ) ; NcStreamProto . StructureData sdata = NcStreamProto . StructureData . parseFrom ( m ) ; DataStorage dataStorage = new DataStorage ( msize , pos , dproto ) ; dataStorage . sdata = sdata ; if ( ncm != null ) ncm . add ( new NcsMess ( dataStorage . filePos , msize , sdata ) ) ; storage . add ( dataStorage ) ; } else if ( dproto . getVdata ( ) ) { DataStorage dataStorage = new DataStorage ( 0 , raf . getFilePointer ( ) , dproto ) ; int nelems = readVInt ( raf ) ; int totalSize = 0 ; for ( int i = 0 ; i < nelems ; i ++ ) { int dsize = readVInt ( raf ) ; totalSize += dsize ; raf . skipBytes ( dsize ) ; } dataStorage . nelems = nelems ; dataStorage . size = totalSize ; if ( ncm != null ) ncm . add ( new NcsMess ( dataStorage . filePos , totalSize , dataStorage ) ) ; storage . add ( dataStorage ) ; } else { // regular data
int dsize = readVInt ( raf ) ; DataStorage dataStorage = new DataStorage ( dsize , raf . getFilePointer ( ) , dproto ) ; if ( ncm != null ) ncm . add ( new NcsMess ( dataStorage . filePos , dsize , dataStorage ) ) ; storage . add ( dataStorage ) ; raf . skipBytes ( dsize ) ; } }


signature:
public class NcmlCollectionReader { /** * Read an NcML file from a String , and construct a NcmlCollectionReader from its scan or scanFmrc element .
 * @ param ncmlString the NcML to construct the reader from
 * @ param errlog put error messages here
 * @ return the resulting NetcdfDataset
 * @ throws IOException on read error , or bad referencedDatasetUri URI */
static public NcmlCollectionReader readNcML ( String ncmlString , Formatter errlog ) throws IOException { } }

implementation: StringReader reader = new StringReader ( ncmlString ) ; org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; if ( debugURL ) System . out . println ( " NetcdfDataset NcML String = <" + ncmlString + ">" ) ; doc = builder . build ( new StringReader ( ncmlString ) ) ; } catch ( JDOMException e ) { throw new IOException ( e . getMessage ( ) ) ; } if ( debugXML ) System . out . println ( " SAXBuilder done" ) ; return readXML ( doc , errlog , null ) ;


signature:
public class NcmlCollectionReader { /** * Read an NcML file from a URL location , and construct a NcmlCollectionReader from its scan or scanFmrc element .
 * @ param ncmlLocation the URL location string of the NcML document
 * @ param errlog put error messages here
 * @ return the resulting NetcdfDataset
 * @ throws IOException on read error , or bad referencedDatasetUri URI */
static public NcmlCollectionReader open ( String ncmlLocation , Formatter errlog ) throws IOException { } }

implementation: if ( ! ncmlLocation . startsWith ( "http:" ) && ! ncmlLocation . startsWith ( "file:" ) ) ncmlLocation = "file:" + ncmlLocation ; URL url = new URL ( ncmlLocation ) ; org . jdom2 . Document doc ; try { SAXBuilder builder = new SAXBuilder ( ) ; if ( debugURL ) System . out . println ( " NetcdfDataset URL = <" + url + ">" ) ; doc = builder . build ( url ) ; } catch ( JDOMException e ) { throw new IOException ( e . getMessage ( ) ) ; } if ( debugXML ) System . out . println ( " SAXBuilder done" ) ; return readXML ( doc , errlog , ncmlLocation ) ;


signature:
public class StringUtil2 { /** * Replace any char not alphanumeric or in allowChars by replaceChar .
 * @ param x operate on this string
 * @ param allowChars these are ok .
 * @ param replaceChar thar char to replace
 * @ return resulting string . */
static public String allow ( String x , String allowChars , char replaceChar ) { } }

implementation:
boolean ok = true ; for ( int pos = 0 ; pos < x . length ( ) ; pos ++ ) { char c = x . charAt ( pos ) ; if ( ! ( Character . isLetterOrDigit ( c ) || ( 0 <= allowChars . indexOf ( c ) ) ) ) { ok = false ; break ; } } if ( ok ) return x ; // gotta do it
StringBuilder sb = new StringBuilder ( x ) ; for ( int pos = 0 ; pos < sb . length ( ) ; pos ++ ) { char c = sb . charAt ( pos ) ; if ( Character . isLetterOrDigit ( c ) || ( 0 <= allowChars . indexOf ( c ) ) ) { continue ; } sb . setCharAt ( pos , replaceChar ) ; } return sb . toString ( ) ;


signature:
public class StringUtil2 { /** * Break the given text into lines , respecting word boundaries ( blank space ) .
 * @ param text The text to convert
 * @ param insert break to insert
 * @ param lineSize line size to insert at
 * @ return The text with added br tags . */
public static String breakTextAtWords ( String text , String insert , int lineSize ) { } }

implementation: StringBuilder buff = new StringBuilder ( ) ; StringTokenizer stoker = new StringTokenizer ( text ) ; int lineCount = 0 ; while ( stoker . hasMoreTokens ( ) ) { String tok = stoker . nextToken ( ) ; if ( tok . length ( ) + lineCount >= lineSize ) { buff . append ( insert ) ; lineCount = 0 ; } buff . append ( tok ) ; buff . append ( " " ) ; lineCount += tok . length ( ) + 1 ; } return buff . toString ( ) ;


signature:
public class StringUtil2 { /** * Delete any non - printable characters
 * @ param h byte array
 * @ return cleaned up string */
public static String cleanup ( byte [ ] h ) { } }

implementation: byte [ ] bb = new byte [ h . length ] ; int count = 0 ; for ( byte b : h ) { if ( b >= 32 && b < 127 ) bb [ count ++ ] = b ; } return new String ( bb , 0 , count , CDM . utf8Charset ) ;


signature:
public class StringUtil2 { /** * Remove any char not alphanumeric or in okChars .
 * @ param x filter this string
 * @ param okChars these are ok .
 * @ return filtered string . */
static public String filter ( String x , String okChars ) { } }

implementation:
boolean ok = true ; for ( int pos = 0 ; pos < x . length ( ) ; pos ++ ) { char c = x . charAt ( pos ) ; if ( ! ( Character . isLetterOrDigit ( c ) || ( 0 <= okChars . indexOf ( c ) ) ) ) { ok = false ; break ; } } if ( ok ) { return x ; } // gotta do it
StringBuilder sb = new StringBuilder ( x . length ( ) ) ; for ( int pos = 0 ; pos < x . length ( ) ; pos ++ ) { char c = x . charAt ( pos ) ; if ( Character . isLetterOrDigit ( c ) || ( 0 <= okChars . indexOf ( c ) ) ) { sb . append ( c ) ; } } return sb . toString ( ) ;


signature:
public class StringUtil2 { /** * Remove all but printable ascii
 * @ param s filter this string
 * @ return filtered string . */
static public String filter7bits ( String s ) { } }

implementation: if ( s == null ) return null ; char [ ] bo = new char [ s . length ( ) ] ; int count = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( ( c < 128 ) && ( c > 31 ) || ( ( c == '\n' ) || ( c == '\t' ) ) ) { bo [ count ++ ] = c ; } } return new String ( bo , 0 , count ) ;


signature:
public class StringUtil2 { /** * transform embedded space to " _ " */
static public String makeValidCdmObjectName ( String name ) { } }

implementation:
name = name . trim ( ) ; // common case no change
boolean ok = true ; for ( int i = 0 ; i < name . length ( ) ; i ++ ) { int c = name . charAt ( i ) ; if ( c < 0x20 ) ok = false ; if ( c == '/' ) ok = false ; if ( c == ' ' ) ok = false ; if ( ! ok ) break ; } if ( ok ) return name ; StringBuilder sbuff = new StringBuilder ( name . length ( ) ) ; for ( int i = 0 , len = name . length ( ) ; i < len ; i ++ ) { int c = name . charAt ( i ) ; if ( ( c == '/' ) || ( c == ' ' ) ) sbuff . append ( '_' ) ; else if ( c >= 0x20 ) sbuff . append ( ( char ) c ) ; } return sbuff . toString ( ) ;


signature:
public class StringUtil2 { /** * Count number of chars that match in two strings , starting from front .
 * @ param s1 compare this string
 * @ param s2 compare this string
 * @ return number of matching chars , starting from first char */
static public int match ( String s1 , String s2 ) { } }

implementation: int i = 0 ; while ( ( i < s1 . length ( ) ) && ( i < s2 . length ( ) ) ) { if ( s1 . charAt ( i ) != s2 . charAt ( i ) ) { break ; } i ++ ; } return i ;


signature:
public class StringUtil2 { /** * Pad the given string with padString on the left up to the given length .
 * @ param s String to pad
 * @ param desiredLength ending length
 * @ param padString String to pad with ( e . g , " " )
 * @ return padded String */
public static String padLeft ( String s , int desiredLength , String padString ) { } }

implementation: while ( s . length ( ) < desiredLength ) { s = padString + s ; } return s ;


signature:
public class StringUtil2 { /** * Pad the given string with padString on the right up to the given length .
 * @ param s String to pad
 * @ param desiredLength ending length
 * @ param padString String to pad with ( e . g , " " )
 * @ return padded String */
public static String padRight ( String s , int desiredLength , String padString ) { } }

implementation: StringBuilder ret = new StringBuilder ( s ) ; while ( ret . length ( ) < desiredLength ) { ret . append ( padString ) ; } return ret . toString ( ) ;


signature:
public class StringUtil2 { /** * Remove all occurrences of the substring sub in the string s .
 * @ param s operate on this string
 * @ param sub remove all occurrences of this substring .
 * @ return result with substrings removed */
static public String remove ( String s , String sub ) { } }

implementation: int len = sub . length ( ) ; int pos ; while ( 0 <= ( pos = s . indexOf ( sub ) ) ) { s = s . substring ( 0 , pos ) + s . substring ( pos + len ) ; } return s ;


signature:
public class StringUtil2 { /** * Remove all occurrences of the character c in the string s .
 * @ param s operate on this string
 * @ param c remove all occurrences of this character .
 * @ return result with any character c removed */
static public String remove ( String s , int c ) { } }

implementation:
if ( 0 > s . indexOf ( c ) ) { // none
return s ; } StringBuilder buff = new StringBuilder ( s ) ; int i = 0 ; while ( i < buff . length ( ) ) { if ( buff . charAt ( i ) == c ) { buff . deleteCharAt ( i ) ; } else { i ++ ; } } return buff . toString ( ) ;


signature:
public class StringUtil2 { /** * Remove all occurrences of the character c at the end of s .
 * @ param s operate on this string
 * @ param c remove all occurrences of this character that are at the end of the string .
 * @ return result with any character c removed */
static public String removeFromEnd ( String s , int c ) { } }

implementation:
if ( 0 > s . indexOf ( c ) ) // none
return s ; int len = s . length ( ) ; while ( ( s . charAt ( len - 1 ) == c ) && ( len > 0 ) ) len -- ; if ( len == s . length ( ) ) return s ; return s . substring ( 0 , len ) ;


signature:
public class StringUtil2 { /** * Remove any whitespace ( ie . , Character . isWhitespace ) from the input string .
 * @ param inputString The string to remove the whitespace .
 * @ return The whitespaceless result . */
public static String removeWhitespace ( String inputString ) { } }

implementation: StringBuilder sb = new StringBuilder ( ) ; char [ ] chars = inputString . toCharArray ( ) ; for ( char c : chars ) { if ( Character . isWhitespace ( c ) ) { continue ; } sb . append ( c ) ; } return sb . toString ( ) ;


signature:
public class StringUtil2 { /** * Collapse continuous whitespace into one single " " .
 * @ param s operate on this string
 * @ return result with collapsed whitespace */
static public String collapseWhitespace ( String s ) { } }

implementation:
int len = s . length ( ) ; StringBuilder b = new StringBuilder ( len ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = s . charAt ( i ) ; if ( ! Character . isWhitespace ( c ) ) { b . append ( c ) ; } else { b . append ( ' ' ) ; while ( ( i + 1 < len ) && Character . isWhitespace ( s . charAt ( i + 1 ) ) ) { i ++ ; // / skip further whitespace
} } } return b . toString ( ) ;


signature:
public class StringUtil2 { /** * Replace any char " out " in s with " in " .
 * @ param s string to replace
 * @ param out replace this character
 * @ param in with this string
 * @ return modified string if needed */
static public String replace ( String s , char out , String in ) { } }

implementation:
if ( s . indexOf ( out ) < 0 ) { return s ; } // gotta do it
StringBuilder sb = new StringBuilder ( s ) ; replace ( sb , out , in ) ; return sb . toString ( ) ;


signature:
public class StringUtil2 { /** * Replace all occurrences of any char in replaceChar with corresponding String in replaceWith
 * @ param x operate on this string
 * @ param replaceChar get rid of these
 * @ param replaceWith replace with these
 * @ return resulting string */
static public String replace ( String x , char [ ] replaceChar , String [ ] replaceWith ) { } }

implementation:
// common case no replacement
boolean ok = true ; for ( char aReplaceChar : replaceChar ) { int pos = x . indexOf ( aReplaceChar ) ; ok = ( pos < 0 ) ; if ( ! ok ) break ; } if ( ok ) return x ; // gotta do it
StringBuilder sb = new StringBuilder ( x ) ; for ( int i = 0 ; i < replaceChar . length ; i ++ ) { int pos = x . indexOf ( replaceChar [ i ] ) ; if ( pos >= 0 ) { replace ( sb , replaceChar [ i ] , replaceWith [ i ] ) ; } } return sb . toString ( ) ;


signature:
public class StringUtil2 { /** * Replaces all occurrences of " pattern " in " string " with " value "
 * @ param string string to munge
 * @ param pattern pattern to replace
 * @ param value replacement value
 * @ return munged string */
public static String replace ( String string , String pattern , String value ) { } }

implementation:
if ( pattern . length ( ) == 0 ) return string ; if ( ! string . contains ( pattern ) ) return string ; // ok gotta do it
StringBuilder returnValue = new StringBuilder ( ) ; int patternLength = pattern . length ( ) ; while ( true ) { int idx = string . indexOf ( pattern ) ; if ( idx < 0 ) break ; returnValue . append ( string . substring ( 0 , idx ) ) ; if ( value != null ) returnValue . append ( value ) ; string = string . substring ( idx + patternLength ) ; } returnValue . append ( string ) ; return returnValue . toString ( ) ;


signature:
public class StringUtil2 { /** * Replace all occurrences of orgReplace with orgChar ; inverse of replace ( ) .
 * @ param x operate on this string
 * @ param orgReplace get rid of these
 * @ param orgChar replace with these
 * @ return resulting string */
static public String unreplace ( String x , String [ ] orgReplace , char [ ] orgChar ) { } }

implementation:
// common case no replacement
boolean ok = true ; for ( String anOrgReplace : orgReplace ) { int pos = x . indexOf ( anOrgReplace ) ; ok = ( pos < 0 ) ; if ( ! ok ) break ; } if ( ok ) return x ; // gotta do it
StringBuilder result = new StringBuilder ( x ) ; for ( int i = 0 ; i < orgReplace . length ; i ++ ) { int pos = result . indexOf ( orgReplace [ i ] ) ; if ( pos >= 0 ) { unreplace ( result , orgReplace [ i ] , orgChar [ i ] ) ; } } return result . toString ( ) ;


signature:
public class StringUtil2 { /** * Find all occurrences of the " match " in original , and substitute the " subst " string .
 * @ param original starting string
 * @ param match string to match
 * @ param subst string to substitute
 * @ return a new string with substitutions */
static public String substitute ( String original , String match , String subst ) { } }

implementation: String s = original ; int pos ; while ( 0 <= ( pos = s . indexOf ( match ) ) ) { StringBuilder sb = new StringBuilder ( s ) ; s = sb . replace ( pos , pos + match . length ( ) , subst ) . toString ( ) ; } return s ;


signature:
public class StringUtil2 { /** * Escape any char not alphanumeric or in okChars .
 * Escape by replacing char with % xx ( hex ) .
 * @ param x escape this string
 * @ param okChars these are ok .
 * @ return equivilent escaped string . */
static public String escape ( String x , String okChars ) { } }

implementation: StringBuilder newname = new StringBuilder ( ) ; for ( char c : x . toCharArray ( ) ) { if ( c == '%' ) { newname . append ( "%%" ) ; } else if ( ! Character . isLetterOrDigit ( c ) && okChars . indexOf ( c ) < 0 ) { newname . append ( '%' ) ; newname . append ( Integer . toHexString ( ( 0xFF & ( int ) c ) ) ) ; } else newname . append ( c ) ; } return newname . toString ( ) ;


signature:
public class StringUtil2 { /** * This finds any ' % xx ' and converts to the equivalent char . Inverse of
 * escape ( ) .
 * @ param x operate on this String
 * @ return original String . */
static public String unescape ( String x ) { } }

implementation:
if ( x . indexOf ( '%' ) < 0 ) { return x ; } // gotta do it
char [ ] b = new char [ 2 ] ; StringBuilder sb = new StringBuilder ( x ) ; for ( int pos = 0 ; pos < sb . length ( ) ; pos ++ ) { char c = sb . charAt ( pos ) ; if ( c != '%' ) { continue ; } if ( pos >= sb . length ( ) - 2 ) { // malformed - should be % xx
return x ; } b [ 0 ] = sb . charAt ( pos + 1 ) ; b [ 1 ] = sb . charAt ( pos + 2 ) ; int value ; try { value = Integer . parseInt ( new String ( b ) , 16 ) ; } catch ( NumberFormatException e ) { continue ; // not a hex number
} c = ( char ) value ; sb . setCharAt ( pos , c ) ; sb . delete ( pos + 1 , pos + 3 ) ; } return sb . toString ( ) ;


signature:
public class StringUtil2 { /** * Find all occurences of match strings in original , and substitute the corresponding
 * subst string .
 * @ param original starting string
 * @ param match array of strings to match
 * @ param subst array of strings to substitute
 * @ return a new string with substitutions */
static public String substitute ( String original , String [ ] match , String [ ] subst ) { } }

implementation:
boolean ok = true ; for ( String aMatch : match ) { if ( original . contains ( aMatch ) ) { ok = false ; break ; } } if ( ok ) { return original ; } // gotta do it ;
StringBuilder sb = new StringBuilder ( original ) ; for ( int i = 0 ; i < match . length ; i ++ ) { substitute ( sb , match [ i ] , subst [ i ] ) ; } return sb . toString ( ) ;


signature:
public class StringUtil2 { /** * Remove any of the characters in out from sb
 * @ param sb the StringBuilder
 * @ param out get rid of any of these characters */
static public void remove ( StringBuilder sb , String out ) { } }

implementation: int i = 0 ; while ( i < sb . length ( ) ) { int c = sb . charAt ( i ) ; boolean ok = true ; for ( int j = 0 ; j < out . length ( ) ; j ++ ) { if ( out . charAt ( j ) == c ) { sb . delete ( i , i + 1 ) ; ok = false ; break ; } } if ( ok ) i ++ ; }


signature:
public class StringUtil2 { /** * Replace any String " out " in sb with char " in " .
 * @ param sb StringBuilder to replace
 * @ param out repalce this String
 * @ param in with this char */
static public void unreplace ( StringBuilder sb , String out , char in ) { } }

implementation: int pos ; while ( 0 <= ( pos = sb . indexOf ( out ) ) ) { sb . setCharAt ( pos , in ) ; sb . delete ( pos + 1 , pos + out . length ( ) ) ; }


signature:
public class StringUtil2 { /** * Replace any of the characters from out with corresponding character from in
 * @ param sb the StringBuilder
 * @ param out get rid of any of these characters
 * @ param in replacing with the character at same index */
static public void replace ( StringBuilder sb , String out , String in ) { } }

implementation: for ( int i = 0 ; i < sb . length ( ) ; i ++ ) { int c = sb . charAt ( i ) ; for ( int j = 0 ; j < out . length ( ) ; j ++ ) { if ( out . charAt ( j ) == c ) sb . setCharAt ( i , in . charAt ( j ) ) ; } }


signature:
public class StringUtil2 { /** * Find all occurences of the " match " in original , and substitute the " subst " string ,
 * directly into the original .
 * @ param sbuff starting string buffer
 * @ param match string to match
 * @ param subst string to substitute */
static public void substitute ( StringBuilder sbuff , String match , String subst ) { } }

implementation:
int pos , fromIndex = 0 ; int substLen = subst . length ( ) ; int matchLen = match . length ( ) ; while ( 0 <= ( pos = sbuff . indexOf ( match , fromIndex ) ) ) { sbuff . replace ( pos , pos + matchLen , subst ) ; fromIndex = pos + substLen ; // make sure dont get into an infinite loop
}


signature:
public class StringUtil2 { /** * Remove bad char from beginning or end of string
 * @ param s operate on this
 * @ return trimmed string */
static public String trim ( String s , int bad ) { } }

implementation: int len = s . length ( ) ; int st = 0 ; while ( ( st < len ) && ( s . charAt ( st ) == bad ) ) { st ++ ; } while ( ( st < len ) && ( s . charAt ( len - 1 ) == bad ) ) { len -- ; } return ( ( st > 0 ) || ( len < s . length ( ) ) ) ? s . substring ( st , len ) : s ;


signature:
public class InvDatasetFeatureCollection { /** * old school : used by FMRC and Point */
protected void makeCollection ( ) { } }

implementation: Formatter errlog = new Formatter ( ) ; datasetCollection = new MFileCollectionManager ( config , errlog , logger ) ; topDirectory = datasetCollection . getRoot ( ) ; String errs = errlog . toString ( ) ; if ( errs . length ( ) > 0 ) logger . warn ( "MFileCollectionManager parse error = {} " , errs ) ;


signature:
public class InvDatasetFeatureCollection { /** * called by eventBus , this is where the trigger comes in */
@ Subscribe public void processEvent ( CollectionUpdateEvent event ) { } }

implementation:
if ( ! config . collectionName . equals ( event . getCollectionName ( ) ) ) return ; // not for me
try { update ( event . getType ( ) ) ; } catch ( IOException e ) { logger . error ( "Error processing event" , e ) ; }


signature: public class InvDatasetFeatureCollection { public void showStatus ( Formatter f ) { } }

implementation: try { checkState ( ) ; _showStatus ( f , false , null ) ; } catch ( Throwable t ) { StringWriter sw = new StringWriter ( 5000 ) ; t . printStackTrace ( new PrintWriter ( sw ) ) ; f . format ( sw . toString ( ) ) ; }


signature:
public class InvDatasetFeatureCollection { /** * A request has come in , check that the state has been initialized .
 * this is called from the request thread .
 * @ return a copy of the State */
protected State checkState ( ) throws IOException { } }

implementation:
State localState ; synchronized ( lock ) { if ( first ) { firstInit ( ) ; updateCollection ( state , config . updateConfig . updateType ) ; // makeDatasetTop ( state ) ;
first = false ; } localState = state . copy ( ) ; } return localState ;


signature:
public class InvDatasetFeatureCollection { /** * Collection was changed , update internal objects .
 * called by CollectionUpdater , trigger via handleCollectionEvent , so in a quartz scheduler thread
 * @ param force update type */
protected void update ( CollectionUpdateType force ) throws IOException { } }

implementation:
// this may be called from a background thread , or from checkState ( ) request thread
State localState ; synchronized ( lock ) { if ( first ) { state = checkState ( ) ; state . lastInvChange = System . currentTimeMillis ( ) ; return ; } // do the update in a local object
localState = state . copy ( ) ; } updateCollection ( localState , force ) ; // makeDatasetTop ( localState ) ;
localState . lastInvChange = System . currentTimeMillis ( ) ; // switch to live
synchronized ( lock ) { state = localState ; }


signature: public class InvDatasetFeatureCollection { protected String makeFullName ( DatasetNode ds ) { } }

implementation: if ( ds . getParent ( ) == null ) return ds . getName ( ) ; String parentName = makeFullName ( ds . getParent ( ) ) ; if ( parentName == null || parentName . length ( ) == 0 ) return ds . getName ( ) ; return parentName + "/" + ds . getName ( ) ;


signature:
public class InvDatasetFeatureCollection { /** * Make the containing catalog of this feature collection
 * " http : / / server : port / thredds / catalog / path / catalog . xml "
 * @ param catURI base URI of the request
 * @ param localState current state to use
 * @ return the top FMRC catalog
 * @ throws java . io . IOException on I / O error
 * @ throws java . net . URISyntaxException if path is misformed */
protected CatalogBuilder makeCatalogTop ( URI catURI , State localState ) throws IOException , URISyntaxException { } }

implementation:
Catalog parentCatalog = parent . getParentCatalog ( ) ; CatalogBuilder topCatalog = new CatalogBuilder ( ) ; topCatalog . setName ( makeFullName ( parent ) ) ; topCatalog . setVersion ( parentCatalog . getVersion ( ) ) ; topCatalog . setBaseURI ( catURI ) ; DatasetBuilder top = makeDatasetTop ( catURI , localState ) ; topCatalog . addDataset ( top ) ; // topCatalog . addService ( StandardServices . latest . getService ( ) ) ; / / in case its needed
topCatalog . addService ( virtualService ) ; return topCatalog ;


signature:
public class InvDatasetFeatureCollection { /** * this catalog lists the individual files comprising the collection . */
protected CatalogBuilder makeCatalogFiles ( URI catURI , State localState , List < String > filenames , boolean addLatest ) throws IOException { } }

implementation:
Catalog parentCatalog = parent . getParentCatalog ( ) ; CatalogBuilder result = new CatalogBuilder ( ) ; result . setName ( makeFullName ( parent ) ) ; result . setVersion ( parentCatalog . getVersion ( ) ) ; result . setBaseURI ( catURI ) ; result . addService ( orgService ) ; DatasetBuilder top = new DatasetBuilder ( null ) ; top . transferInheritedMetadata ( parent ) ; // make all inherited metadata local
top . setName ( FILES ) ; // add Variables , GeospatialCoverage , TimeCoverage
ThreddsMetadata tmi = top . getInheritableMetadata ( ) ; tmi . set ( Dataset . TimeCoverage , null ) ; // LOOK
if ( localState . coverage != null ) { tmi . set ( Dataset . GeospatialCoverage , localState . coverage ) ; } tmi . set ( Dataset . ServiceName , orgService . getName ( ) ) ; result . addDataset ( top ) ; if ( addLatest ) { DatasetBuilder latest = new DatasetBuilder ( top ) ; latest . setName ( getLatestFileName ( ) ) ; latest . put ( Dataset . UrlPath , LATEST_DATASET_CATALOG ) ; latest . put ( Dataset . Id , LATEST_DATASET_CATALOG ) ; latest . put ( Dataset . ServiceName , latestService . getName ( ) ) ; latest . addServiceToCatalog ( latestService ) ; top . addDataset ( latest ) ; } // sort copy of files
List < String > sortedFilenames = new ArrayList < > ( filenames ) ; Collections . sort ( sortedFilenames , String . CASE_INSENSITIVE_ORDER ) ; // if not increasing ( i . e . we WANT newest file listed first ) , reverse sort
if ( ! this . config . getSortFilesAscending ( ) ) { Collections . reverse ( sortedFilenames ) ; } for ( String f : sortedFilenames ) { if ( ! f . startsWith ( topDirectory ) ) logger . warn ( "File {} doesnt start with topDir {}" , f , topDirectory ) ; DatasetBuilder ds = new DatasetBuilder ( top ) ; String fname = f . substring ( topDirectory . length ( ) + 1 ) ; ds . setName ( fname ) ; String lpath = this . configPath + "/" + FILES + "/" + fname ; // String lpath = getPath ( ) + " / " + FILES + " / " + fname ;
ds . put ( Dataset . UrlPath , lpath ) ; ds . put ( Dataset . Id , lpath ) ; ds . put ( Dataset . VariableMapLinkURI , new ThreddsMetadata . UriResolved ( makeMetadataLink ( lpath , VARIABLES ) , catURI ) ) ; File file = new File ( f ) ; ds . put ( Dataset . DataSize , file . length ( ) ) ; top . addDataset ( ds ) ; } return result ;


signature:
public class InvDatasetFeatureCollection { /** * Get the associated Grid Dataset , if any . called by DatasetHandler . openGridDataset ( )
 * @ param matchPath match . remaining
 * @ return Grid Dataset , or null if n / a
 * @ throws IOException on error */
public ucar . nc2 . dt . grid . GridDataset getGridDataset ( String matchPath ) throws IOException { } }

implementation: return null ;


signature:
public class InvDatasetFeatureCollection { /** * Get the dataset named by the path .
 * called by DatasetHandler . getNetcdfFile ( )
 * @ param matchPath remaining path from match
 * @ return requested dataset
 * @ throws IOException if read error */
public NetcdfDataset getNetcdfDataset ( String matchPath ) throws IOException { } }

implementation:
int pos = matchPath . indexOf ( '/' ) ; String type = ( pos > - 1 ) ? matchPath . substring ( 0 , pos ) : matchPath ; String name = ( pos > - 1 ) ? matchPath . substring ( pos + 1 ) : "" ; // this assumes that these are files . also might be remote datasets from a catalog
if ( type . equalsIgnoreCase ( FILES ) ) { if ( topDirectory == null ) return null ; String filename = new StringBuilder ( topDirectory ) . append ( topDirectory . endsWith ( "/" ) ? "" : "/" ) . append ( name ) . toString ( ) ; DatasetUrl durl = new DatasetUrl ( null , filename ) ; return NetcdfDataset . acquireDataset ( null , durl , null , - 1 , null , null ) ; // no enhancement
} GridDataset gds = getGridDataset ( matchPath ) ; // LOOK cant be right
return ( gds == null ) ? null : ( NetcdfDataset ) gds . getNetcdfFile ( ) ;


signature:
public class InvDatasetFeatureCollection { /** * this says that a File URL has to be topDirectory + [ FILES / + ] + match . remaining */
public File getFile ( String remaining ) { } }

implementation: if ( null == topDirectory ) return null ; int pos = remaining . indexOf ( FILES ) ; StringBuilder fname = new StringBuilder ( topDirectory ) ; if ( ! topDirectory . endsWith ( "/" ) ) fname . append ( "/" ) ; fname . append ( ( pos > - 1 ) ? remaining . substring ( pos + FILES . length ( ) + 1 ) : remaining ) ; return new File ( fname . toString ( ) ) ;


signature:
public class Grib2ReportPanel { /** * http : / / www . unidata . ucar . edu / software / netcdf / docs / BestPractices . html
 * Packed Data Values
 * Packed data is stored in a netCDF file by limiting precision and using a smaller data type than the original data , for example , packing double - precision ( 64 - bit ) values into short ( 16 - bit ) integers . The C - based netCDF libraries do not do the packing and unpacking . ( The netCDF Java library will do automatic unpacking when the VariableEnhanced Interface is used . For details see EnhancedScaleMissing ) .
 * Each variable with packed data has two attributes called scale _ factor and add _ offset , so that the packed data may be read and unpacked using the formula :
 * unpacked _ data _ value = packed _ data _ value * scale _ factor + add _ offset
 * The type of the stored variable is the packed data type , typically byte , short or int .
 * The type of the scale _ factor and add _ offset attributes should be the type that you want the unpacked data to be , typically float or double .
 * To avoid introducing a bias into the unpacked values due to truncation when packing , the data provider should round to the nearest integer rather than just truncating towards zero before writing the data :
 * packed _ data _ value = nint ( ( unpacked _ data _ value - add _ offset ) / scale _ factor )
 * Depending on whether the packed data values are intended to be interpreted by the reader as signed or unsigned integers , there are alternative ways for the data provider to compute the scale _ factor and add _ offset attributes . In either case , the formulas above apply for unpacking and packing the data .
 * A conventional way to indicate whether a byte , short , or int variable is meant to be interpreted as unsigned , even for the netCDF - 3 classic model that has no external unsigned integer type , is by providing the special variable attribute _ Unsigned with value " true " . However , most existing data for which packed values are intended to be interpreted as unsigned are stored without this attribute , so readers must be aware of packing assumptions in this case . In the enhanced netCDF - 4 data model , packed integers may be declared to be of the appropriate unsigned type .
 * Let n be the number of bits in the packed type , and assume dataMin and dataMax are the minimum and maximum values that will be used for a variable to be packed .
 * If the packed values are intended to be interpreted as signed integers ( the default assumption for classic model data ) , you may use :
 * scale _ factor = ( dataMax - dataMin ) / ( 2 ^ n - 1)
 * add _ offset = dataMin + 2n - 1 * scale _ factor
 * If the packed values are intended to be interpreted as unsigned ( for example , when read in the C interface using the nc _ get _ var _ uchar ( ) function ) , use :
 * scale _ factor = ( dataMax - dataMin ) / ( 2 ^ n - 1)
 * add _ offset = dataMin
 * In either the signed or unsigned case , an alternate formula may be used for the add _ offset and scale _ factor packing parameters that reserves a packed value for a special value , such as an indicator of missing data . For example , to reserve the minimum packed value ( - 2n - 1 ) for use as a special value in the case of signed packed values :
 * scale _ factor = ( dataMax - dataMin ) / ( 2 ^ n - 2)
 * add _ offset = ( dataMax + dataMin ) / 2
 * If the packed values are unsigned , then the analogous formula that reserves 0 as the packed form of a special value would be :
 * scale _ factor = ( dataMax - dataMin ) / ( 2 ^ n - 2)
 * add _ offset = dataMin - scale _ factor
 * Example , packing 32 - bit floats into 16 - bit shorts :
 * variables :
 * short data ( z , y , x ) ;
 * data : scale _ offset = 34.02f ;
 * data : add _ offset = 1.54f ;
 * The units attribute applies to unpacked values . */
private void doCopyCompress ( Formatter f , ucar . nc2 . grib . grib2 . Grib2Record gr , RandomAccessFile raf , OutputStream out , Counters counters ) throws IOException { } }

implementation:
float [ ] data = gr . readData ( raf ) ; Grib2SectionDataRepresentation drss = gr . getDataRepresentationSection ( ) ; drss . getDrs ( raf ) ; // calc scale / offset
GribData . Info info = gr . getBinaryDataInfo ( raf ) ; int nbits = info . numberOfBits ; counters . count ( "Nbits" , nbits ) ; int width = ( 2 << ( nbits - 1 ) ) - 1 ; // f . format ( " nbits = % d % n " , nbits ) ;
// f . format ( " width = % d ( 0x % s ) % n " , width2 , Long . toHexString ( width2 ) ) ;
float dataMin = Float . MAX_VALUE ; float dataMax = - Float . MAX_VALUE ; for ( float fd : data ) { dataMin = Math . min ( dataMin , fd ) ; dataMax = Math . max ( dataMax , fd ) ; } // f . format ( " dataMin = % f % n " , dataMin ) ;
// f . format ( " dataMax = % f % n " , dataMax ) ;
// f . format ( " range = % f % n " , ( dataMax - dataMin ) ) ;
// scale _ factor = ( dataMax - dataMin ) / ( 2 ^ n - 1)
// add _ offset = dataMin + 2 ^ ( n - 1 ) * scale _ factor
// float scale _ factor = ( dataMax - dataMin ) / width2;
// float add _ offset = dataMin + width2 * scale _ factor / 2;
float scale_factor = ( dataMax - dataMin ) / ( width - 2 ) ; float add_offset = dataMin - scale_factor ; // f . format ( " scale _ factor = % f % n " , scale _ factor ) ;
// f . format ( " add _ offset = % f % n " , add _ offset ) ;
// unpacked _ data _ value = packed _ data _ value * scale _ factor + add _ offset
// packed _ data _ value = nint ( ( unpacked _ data _ value - add _ offset ) / scale _ factor )
/* compressedSize = out . size ( ) ;
 f . format ( " compressedSize = % d % n " , compressedSize ) ;
 f . format ( " compressedRatio = % f % n " , ( float ) compressedSize / ( n * nbits / 8 ) ) ;
 f . format ( " ratio with grib = % f % n " , ( float ) compressedSize / bean1 . getDataLength ( ) ) ; */


signature: public class Grib2ReportPanel { private void doCheckTables ( Formatter f , MCollection dcm , boolean useIndex ) throws IOException { } }

implementation: f . format ( "Check Grib-2 Parameter Tables%n" ) ; int [ ] accum = new int [ 4 ] ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { f . format ( "%n %s%n" , mfile . getPath ( ) ) ; doCheckTables ( mfile , f , accum ) ; } f . format ( "%nGrand total=%d not operational = %d local = %d missing = %d%n" , accum [ 0 ] , accum [ 1 ] , accum [ 2 ] , accum [ 3 ] ) ;


signature: public class Grib2ReportPanel { private void doLocalUseSection ( Formatter f , MCollection dcm , boolean useIndex ) throws IOException { } }

implementation: f . format ( "Show Local Use Section%n" ) ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { f . format ( " %s%n" , mfile . getPath ( ) ) ; doLocalUseSection ( mfile , f , useIndex ) ; }


signature:
public class Grib2ReportPanel { /** * Look through the collection and find what GDS and PDS templates are used . */
private void doUniqueTemplates ( Formatter f , MCollection dcm , boolean useIndex ) throws IOException { } }

implementation: f . format ( "Show Unique GDS and PDS templates%n" ) ; Map < Integer , FileList > gdsSet = new HashMap < > ( ) ; Map < Integer , FileList > pdsSet = new HashMap < > ( ) ; Map < Integer , FileList > drsSet = new HashMap < > ( ) ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { f . format ( " %s%n" , mfile . getPath ( ) ) ; doUniqueTemplates ( mfile , gdsSet , pdsSet , drsSet , f ) ; } List < FileList > sorted = new ArrayList < > ( gdsSet . values ( ) ) ; Collections . sort ( sorted ) ; for ( FileList gdsl : sorted ) { f . format ( "%nGDS %s template= %d %n" , gdsl . name , gdsl . template ) ; for ( FileCount fc : gdsl . fileList ) { f . format ( "  %5d %s %n" , fc . countRecords , fc . f . getPath ( ) ) ; } } List < FileList > sortedPds = new ArrayList < > ( pdsSet . values ( ) ) ; Collections . sort ( sortedPds ) ; for ( FileList pdsl : sortedPds ) { f . format ( "%n===================================================%n" ) ; f . format ( "%nPDS %s template= %d %n" , pdsl . name , pdsl . template ) ; for ( FileCount fc : pdsl . fileList ) { f . format ( "  %5d %s %n" , fc . countRecords , fc . f . getPath ( ) ) ; } } List < FileList > sortedDrs = new ArrayList < > ( drsSet . values ( ) ) ; Collections . sort ( sortedDrs ) ; for ( FileList pdsl : sortedDrs ) { f . format ( "%n===================================================%n" ) ; f . format ( "%nDRS %s template= %d %n" , pdsl . name , pdsl . template ) ; for ( FileCount fc : pdsl . fileList ) { f . format ( "  %5d %s %n" , fc . countRecords , fc . f . getPath ( ) ) ; } }


signature: public class Grib2ReportPanel { private void doPdsSummary ( Formatter f , MCollection dcm , boolean eachFile ) throws IOException { } }

implementation: Counters countersAll = new Counters ( ) ; countersAll . add ( "template" ) ; countersAll . add ( "timeUnit" ) ; countersAll . add ( "timeOffset" ) ; countersAll . add ( "timeIntervalSize" ) ; countersAll . add ( "levelType" ) ; countersAll . add ( "genProcessType" ) ; countersAll . add ( "genProcessId" ) ; countersAll . add ( "levelScale" ) ; countersAll . add ( "nExtraCoords" ) ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { f . format ( "---%s%n" , mfile . getPath ( ) ) ; doPdsSummary ( f , mfile , countersAll ) ; if ( eachFile ) { countersAll . show ( f ) ; countersAll . reset ( ) ; } } f . format ( "PdsSummary - all files%n" ) ; if ( ! eachFile ) countersAll . show ( f ) ;


signature: public class Grib2ReportPanel { private void doIdProblems ( Formatter f , MCollection dcm , boolean useIndex ) throws IOException { } }

implementation: f . format ( "Look for ID Problems%n" ) ; Counters countersAll = new Counters ( ) ; countersAll . add ( "discipline" ) ; countersAll . add ( "masterTable" ) ; countersAll . add ( "localTable" ) ; countersAll . add ( "centerId" ) ; countersAll . add ( "subcenterId" ) ; countersAll . add ( "genProcess" ) ; countersAll . add ( "backProcess" ) ; countersAll . add ( "significanceOfReference" ) ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { f . format ( " %s%n" , mfile . getPath ( ) ) ; doIdProblems ( f , mfile , useIndex , countersAll ) ; } countersAll . show ( f ) ;


signature: public class Grib2ReportPanel { private void doDrsSummary ( Formatter f , MCollection dcm , boolean useIndex , boolean eachFile , boolean extra ) throws IOException { } }

implementation: f . format ( "Show Unique DRS Templates%n" ) ; Counters countersAll = new Counters ( ) ; countersAll . add ( "DRS_template" ) ; countersAll . add ( "BMS indicator" ) ; countersAll . add ( "DRS template 40 signed problem" ) ; countersAll . add ( "Number_of_Bits" ) ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { f . format ( "------- %s%n" , mfile . getPath ( ) ) ; if ( useIndex ) doDrsSummaryIndex ( f , mfile , extra , countersAll ) ; else doDrsSummaryScan ( f , mfile , extra , countersAll ) ; if ( eachFile ) { countersAll . show ( f ) ; f . format ( "%n" ) ; countersAll . reset ( ) ; } } if ( ! eachFile ) countersAll . show ( f ) ;


signature: public class Grib2ReportPanel { private void doGdsSummary ( Formatter f , MCollection dcm , boolean extra ) throws IOException { } }

implementation: f . format ( "Show Unique GDS Templates%n" ) ; Counters counters = new Counters ( ) ; counters . add ( "template" ) ; counters . add ( "scanMode" ) ; counters . add ( "scanModeDifference" ) ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { f . format ( " %s%n" , mfile . getPath ( ) ) ; doGdsSummary ( f , mfile , counters , extra ) ; } counters . show ( f ) ;


signature: public class Grib2ReportPanel { private void doTimeCoord ( Formatter f , MCollection dcm , boolean useIndex ) throws IOException { } }

implementation: Counters counters = new Counters ( ) ; counters . add ( "template" ) ; counters . add ( "timeUnit" ) ; counters . add ( "statType" ) ; counters . add ( "NumberTimeIntervals" ) ; counters . add ( "TimeIntervalsDiffer" ) ; counters . add ( "TimeIntervalsLength" ) ; int count = 0 ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { f . format ( " %s%n" , mfile . getPath ( ) ) ; count += doTimeCoord ( f , mfile , counters ) ; } f . format ( "total records = %d%n" , count ) ; counters . show ( f ) ;


signature: public class Grib2ReportPanel { private void doRename ( Formatter f , MCollection dcm , boolean useIndex ) throws IOException { } }

implementation:
f . format ( "CHECK Grib-2 Names: Old vs New for collection %s%n" , dcm . getCollectionName ( ) ) ; List < VarName > varNames = new ArrayList < > ( 3000 ) ; Map < String , List < String > > gridsAll = new HashMap < > ( 1000 ) ; // old - > list < new >
int countExactMatch = 0 ; int countExactMatchIg = 0 ; int countOldVars = 0 ; for ( MFile mfile : dcm . getFilesSorted ( ) ) { f . format ( "%n%s%n" , mfile . getPath ( ) ) ; Map < Integer , GridMatch > gridsNew = getGridsNew ( mfile , f ) ; Map < Integer , GridMatch > gridsOld = getGridsOld ( mfile , f ) ; // look for exact match on name
Set < String > namesNew = new HashSet < > ( gridsNew . size ( ) ) ; for ( GridMatch gm : gridsNew . values ( ) ) namesNew . add ( gm . grid . getFullName ( ) ) ; for ( GridMatch gm : gridsOld . values ( ) ) { if ( namesNew . contains ( gm . grid . getFullName ( ) ) ) countExactMatch ++ ; countOldVars ++ ; } // look for exact match on hashcode
for ( GridMatch gm : gridsNew . values ( ) ) { GridMatch match = gridsOld . get ( gm . hashCode ( ) ) ; if ( match != null ) { gm . match = match ; match . match = gm ; } } // look for alternative match
for ( GridMatch gm : gridsNew . values ( ) ) { if ( gm . match == null ) { GridMatch match = altMatch ( gm , gridsOld . values ( ) ) ; if ( match != null ) { gm . match = match ; match . match = gm ; } } } // print out match
f . format ( "%n" ) ; List < GridMatch > listNew = new ArrayList < > ( gridsNew . values ( ) ) ; Collections . sort ( listNew ) ; for ( GridMatch gm : listNew ) { f . format ( " %s%n" , gm . grid . findAttributeIgnoreCase ( Grib . VARIABLE_ID_ATTNAME ) ) ; f . format ( " %s (%d)%n" , gm . grid . getFullName ( ) , gm . hashCode ( ) ) ; if ( gm . match != null ) { boolean exact = gm . match . grid . getFullName ( ) . equals ( gm . grid . getFullName ( ) ) ; boolean exactIg = ! exact && gm . match . grid . getFullName ( ) . equalsIgnoreCase ( gm . grid . getFullName ( ) ) ; if ( exactIg ) countExactMatchIg ++ ; String status = exact ? " " : exactIg ? "**" : " *" ; f . format ( "%s%s (%d)%n" , status , gm . match . grid . getFullName ( ) , gm . match . hashCode ( ) ) ; } f . format ( "%n" ) ; } // print out missing
f . format ( "%nMISSING MATCHES IN NEW%n" ) ; List < GridMatch > list = new ArrayList < > ( gridsNew . values ( ) ) ; Collections . sort ( list ) ; for ( GridMatch gm : list ) { if ( gm . match == null ) f . format ( " %s (%s) == %s%n" , gm . grid . getFullName ( ) , gm . show ( ) , gm . grid . getDescription ( ) ) ; } f . format ( "%nMISSING MATCHES IN OLD%n" ) ; List < GridMatch > listOld = new ArrayList < > ( gridsOld . values ( ) ) ; Collections . sort ( listOld ) ; for ( GridMatch gm : listOld ) { if ( gm . match == null ) f . format ( " %s (%s)%n" , gm . grid . getFullName ( ) , gm . show ( ) ) ; } // add to gridsAll to track old - > new mapping
for ( GridMatch gmOld : listOld ) { String key = gmOld . grid . getShortName ( ) ; List < String > newGrids = gridsAll . get ( key ) ; if ( newGrids == null ) { newGrids = new ArrayList < > ( ) ; gridsAll . put ( key , newGrids ) ; } if ( gmOld . match != null ) { String keyNew = gmOld . match . grid . getShortName ( ) ; if ( ! newGrids . contains ( keyNew ) ) newGrids . add ( keyNew ) ; } } // add matches to VarNames
for ( GridMatch gmOld : listOld ) { if ( gmOld . match == null ) { f . format ( "MISSING %s (%s)%n" , gmOld . grid . getFullName ( ) , gmOld . show ( ) ) ; continue ; } Attribute att = gmOld . match . grid . findAttributeIgnoreCase ( Grib . VARIABLE_ID_ATTNAME ) ; String varId = att == null ? "" : att . getStringValue ( ) ; varNames . add ( new VarName ( mfile . getName ( ) , gmOld . grid . getShortName ( ) , gmOld . match . grid . getShortName ( ) , varId ) ) ; } } // show old - > new mapping
f . format ( "%nOLD -> NEW MAPPINGS%n" ) ; List < String > keys = new ArrayList < > ( gridsAll . keySet ( ) ) ; int total = keys . size ( ) ; int dups = 0 ; Collections . sort ( keys ) ; for ( String key : keys ) { f . format ( " OLD %s%n" , key ) ; List < String > newGrids = gridsAll . get ( key ) ; Collections . sort ( newGrids ) ; if ( newGrids . size ( ) > 1 ) dups ++ ; for ( String newKey : newGrids ) f . format ( " NEW %s%n" , newKey ) ; f . format ( "%n" ) ; } f . format ( "Exact matches=%d  Exact ignore case=%d  totalOldVars=%d%n" , countExactMatch , countExactMatchIg , countOldVars ) ; f . format ( "Number with more than one map=%d total=%d%n" , dups , total ) ; // old - > new mapping xml table
if ( ! useIndex ) { Element rootElem = new Element ( "gribVarMap" ) ; Document doc = new Document ( rootElem ) ; rootElem . setAttribute ( "collection" , dcm . getCollectionName ( ) ) ; String currentDs = null ; Element dsElem = null ; for ( VarName vn : varNames ) { if ( ! vn . dataset . equals ( currentDs ) ) { dsElem = new Element ( "dataset" ) ; rootElem . addContent ( dsElem ) ; dsElem . setAttribute ( "name" , vn . dataset ) ; currentDs = vn . dataset ; } Element param = new Element ( "param" ) ; dsElem . addContent ( param ) ; param . setAttribute ( "oldName" , vn . oldVar ) ; param . setAttribute ( "newName" , vn . newVar ) ; param . setAttribute ( "varId" , vn . varId ) ; } FileOutputStream fout = new FileOutputStream ( "C:/tmp/grib2VarMap.xml" ) ; XMLOutputter fmt = new XMLOutputter ( Format . getPrettyFormat ( ) ) ; fmt . output ( doc , fout ) ; fout . close ( ) ; } /* old - > new mapping xml table
 if ( ! useIndex ) {
 Element rootElem = new Element ( " gribVarMap " ) ;
 Document doc = new Document ( rootElem ) ;
 rootElem . setAttribute ( " collection " , dcm . getCollectionName ( ) ) ;
 for ( String key : keys ) {
 Element param = new Element ( " param " ) ;
 rootElem . addContent ( param ) ;
 param . setAttribute ( " oldName " , key ) ;
 List < String > newGrids = gridsAll . get ( key ) ;
 Collections . sort ( newGrids ) ;
 for ( String newKey : newGrids )
 param . addContent ( new Element ( " newName " ) . addContent ( newKey ) ) ;
 FileOutputStream fout = new FileOutputStream ( " C : / tmp / gribVarMap . xml " ) ;
 XMLOutputter fmt = new XMLOutputter ( Format . getPrettyFormat ( ) ) ;
 fmt . output ( doc , fout ) ;
 fout . close ( ) ; */
} private GridMatch altMatch ( GridMatch want , Collection < GridMatch > test ) { // look for scale factor errors in prob
for ( GridMatch gm : test ) { if ( gm . match != null ) continue ; // already matched
if ( gm . altMatch ( want ) ) { // gm . altMatch ( want ) ; / / debug
return gm ; } } // give up matching the prob
for ( GridMatch gm : test ) { if ( gm . match != null ) continue ; // already matched
if ( gm . altMatchNoProb ( want ) ) { // gm . altMatchNoProb ( want ) ; / / debug
return gm ; } } return null ;


signature:
public class InvCatalogRef { /** * Get a list of all the nested datasets .
 * @ return Datasets . This triggers a read of the referenced catalog the first time its called . */
@ Override public java . util . List < InvDataset > getDatasets ( ) { } }

implementation: read ( ) ; return useProxy ? proxy . getDatasets ( ) : super . getDatasets ( ) ;


signature:
public class InvCatalogRef { /** * Release resources - undo the read of the catalog . This is needed when crawling large catalogs .
 * For modest catalogs that you will repeatedly examine , do not use this method . */
public void release ( ) { } }

implementation: datasets = new java . util . ArrayList < > ( ) ; proxy = null ; useProxy = false ; init = false ;


signature:
public class InvCatalogRef { /** * Read the referenced catalog asynchronously , if the catalog factory supports it .
 * If it doesnt , this method will work equivilently to read ( ) , which is called the first time
 * getDatasets ( ) is called . If the catalog is already read in , the callback will be called
 * immediately , before this method exits .
 * @ param factory : use this catalog factory
 * @ param caller when catalog is read
 * @ see CatalogSetCallback */
public synchronized void readAsynch ( InvCatalogFactory factory , CatalogSetCallback caller ) { } }

implementation:
if ( init ) { caller . setCatalog ( ( InvCatalogImpl ) getParentCatalog ( ) ) ; return ; } // may be reletive
String hrefResolved ; try { java . net . URI uri = getParentCatalog ( ) . resolveUri ( href ) ; hrefResolved = uri . toString ( ) ; } catch ( java . net . URISyntaxException e ) { // this is to display an error message
proxy = new InvDatasetImpl ( null , "HREF ERROR" ) ; if ( debug ) System . out . println ( "HREF ERROR =\n  " + href + " err= " + e . getMessage ( ) ) ; proxy . addProperty ( new InvProperty ( "HREF ERROR" , href ) ) ; datasets . add ( proxy ) ; return ; } // open and read the referenced catalog XML asynchronously
// setCatalog will be called when ready
try { if ( debug ) System . out . println ( " InvCatalogRef readXMLasynch " + getFullName ( ) + "  hrefResolved = " + hrefResolved ) ; factory . readXMLasynch ( hrefResolved , new Callback ( caller ) ) ; } catch ( Exception e ) { // this is to display an error message
proxy = new InvDatasetImpl ( null , "HREF ERROR" ) ; if ( debug ) System . out . println ( "HREF ERROR =\n  " + href + " err= " + e . getMessage ( ) ) ; proxy . addProperty ( new InvProperty ( "HREF ERROR" , href ) ) ; datasets . add ( proxy ) ; }


signature:
public class InvCatalogRef { /** * / / proxy */
@ Override public thredds . catalog . InvDatasetImpl findDatasetByName ( java . lang . String p0 ) { } }

implementation: return ! useProxy ? super . findDatasetByName ( p0 ) : proxy . findDatasetByName ( p0 ) ;


signature:
public class InvCatalogRef { /** * / * LOOK
 * public thredds . catalog . InvCatalog getParentCatalog ( ) {
 * return ! useProxy ? super . getParentCatalog ( ) : proxy . getParentCatalog ( ) ; */
@ Override public java . util . List < ThreddsMetadata . Vocab > getProjects ( ) { } }

implementation: return ! useProxy ? super . getProjects ( ) : proxy . getProjects ( ) ;


signature:
public class RangeSelector { /** * / * public void setLevels ( ucar . nc2 . dataset . grid . GridCoordSys gcs , int current ) {
 * this . zAxis = gcs . getVerticalAxis ( ) ;
 * if ( zAxis = = null ) {
 * slider . setEnabled ( false ) ;
 * return ;
 * set up the slider and conversion
 * slider . setEnabled ( true ) ;
 * slider . setInverted ( ! gcs . isZPositive ( ) ) ;
 * slider . setToolTipText ( zAxis . getUnitString ( ) ) ;
 * setSelectedIndex ( current ) ;
 * int n = ( int ) zAxis . getSize ( ) ;
 * min = Math . min ( zAxis . getCoordEdge ( 0 ) , zAxis . getCoordEdge ( n ) ) ;
 * max = Math . max ( zAxis . getCoordEdge ( 0 ) , zAxis . getCoordEdge ( n ) ) ;
 * setLabels ( ) ;
 * slider . setPaintLabels ( true ) ;
 * private void setLabels ( ) {
 * Rectangle bounds = slider . getBounds ( ) ;
 * if ( debugEvent ) System . out . println ( " setLevels Bounds = " + bounds ) ;
 * double h = ( bounds . getHeight ( ) > 0 ) ? bounds . getHeight ( ) : 100.0;
 * double wh = ( max - min ) > 0.0 ? ( max - min ) : 1.0;
 * scale = 100.0 / wh ;
 * double slider2pixel = h / 100.0;
 * Font font = slider . getFont ( ) ;
 * FontMetrics fontMetrics = Toolkit . getDefaultToolkit ( ) . getFontMetrics ( font ) ;
 * if ( fontMetrics ! = null )
 * incrY = fontMetrics . getAscent ( ) ; / / + fontMetrics . getDescent ( ) ;
 * if ( debugEvent ) System . out . println ( " scale = " + scale + " incrY = " + incrY ) ;
 * java . util . Hashtable labelTable = new java . util . Hashtable ( ) ;
 * if ( zAxis = = null ) return ;
 * int n = ( int ) zAxis . getSize ( ) ;
 * int last = world2slider ( zAxis . getCoordValue ( n - 1 ) ) ; / / always
 * labelTable . put ( new Integer ( last ) , new JLabel ( zAxis . getCoordName ( n - 1 ) ) ) ; / / always
 * int next = world2slider ( zAxis . getCoordValue ( 0 ) ) ;
 * labelTable . put ( new Integer ( next ) , new JLabel ( zAxis . getCoordName ( 0 ) ) ) ; / / always
 * if ( debugLevels ) System . out . println ( " level = " + slider2pixel * next + " " + zAxis . getCoordName ( 0 ) + " added " ) ;
 * for ( int i = 1 ; i < n - 1 ; i + + ) {
 * int ival = world2slider ( zAxis . getCoordValue ( i ) ) ;
 * if ( debugLevels ) System . out . println ( " level = " + slider2pixel * ival + " " + zAxis . getCoordName ( i ) ) ;
 * if ( ( slider2pixel * Math . abs ( ival - last ) > incrY ) & &
 * ( slider2pixel * Math . abs ( ival - next ) > incrY ) ) {
 * labelTable . put ( new Integer ( ival ) , new JLabel ( zAxis . getCoordName ( i ) ) ) ;
 * next = ival ;
 * if ( debugLevels ) System . out . println ( " added " ) ;
 * if ( debugLevels ) System . out . println ( " level = " + slider2pixel * last + " " + zAxis . getCoordName ( n - 1 ) + " added " ) ;
 * slider . setLabelTable ( labelTable ) ;
 * private void setSelectedByName ( String name ) {
 * if ( zAxis = = null ) return ;
 * for ( int i = 0 ; i < zAxis . getSize ( ) ; i + + )
 * if ( name . equals ( zAxis . getCoordName ( i ) ) ) {
 * setSelectedIndex ( i ) ;
 * return ;
 * System . out . println ( " ERROR VertScaleSlider cant find = " + name ) ;
 * set current value - no event
 * private void setSelectedIndex ( int idx ) {
 * if ( zAxis = = null )
 * return ;
 * eventOK = false ;
 * currentIdx = idx ;
 * slider . setValue ( world2slider ( zAxis . getCoordValue ( currentIdx ) ) ) ;
 * eventOK = true ; */
private int calcFracDigits ( String d ) { } }

implementation: int pos = d . indexOf ( "." ) ; if ( pos < 0 ) return 0 ; return d . length ( ) - pos - 1 ;


signature:
public class GetInfoHandler { /** * Default handler for OPeNDAP info requests . Returns an html document
 * describing the contents of the servers datasets .
 * The " INFOcache " & lt ; init - param & gt ; element in the web . xml file
 * specifies the designated location for :
 * < ul >
 * < li > " . info " response override files . < / li >
 * < li > Server specific HTML * files . < / li >
 * < li > Dataset specific HTML * files . < / li >
 * < / ul >
 * The server specific HTML * files must be named # servlet # . html
 * where # servlet # is the name of the servlet that is running as
 * the OPeNDAP server in question . This name is determined at run time
 * by using the class called Class ( this . getClass ( ) . getName ( ) ) .
 * < p > In the C + + code the analogy is the per - cgi file names . < / p >
 * The dataset specific HTML * files are located by catenating ` . html '
 * to # name # , where # name # is the name of the dataset . If the filename part
 * of # name # is of the form [ A - Za - z ] + [ 0-9 ] * . * then this function also looks
 * for a file whose name is [ A - Za - z ] . html For example , if # name # is
 * . . . / data / fnoc1 . nc this function first looks for . . . / data / fnoc1 . nc . html .
 * However , if that does not exist it will look for . . . / data / fnoc . html . This
 * allows one ` per - dataset ' file to be used for a collection of files with
 * the same root name .
 * NB : An HTML * file contains HTML without the < html > , < head > or < body > tags
 * ( my own notation ) .
 * < h3 > Look for the user supplied Server - and dataset - specific HTML * documents . < / h3 >
 * @ param pw The PrintStream to which the output should be written .
 * @ param gds The thread safe dataset .
 * @ param rs The ReqState object for theis client request .
 * @ see GuardedDataset
 * @ see ReqState */
public void sendINFO ( PrintWriter pw , GuardedDataset gds , ReqState rs ) throws DAP2Exception , ParseException { } }

implementation:
if ( _Debug ) System . out . println ( "opendap.servlet.GetInfoHandler.sendINFO() reached." ) ; String responseDoc = null ; ServerDDS myDDS = null ; DAS myDAS = null ; myDDS = gds . getDDS ( ) ; myDAS = gds . getDAS ( ) ; infoDir = rs . getINFOCache ( rs . getRootPath ( ) ) ; responseDoc = loadOverrideDoc ( infoDir , rs . getDataSet ( ) ) ; if ( responseDoc != null ) { if ( _Debug ) System . out . println ( "override document: " + responseDoc ) ; pw . print ( responseDoc ) ; } else { String user_html = get_user_supplied_docs ( rs . getServerClassName ( ) , rs . getDataSet ( ) ) ; String global_attrs = buildGlobalAttributes ( myDAS , myDDS ) ; String variable_sum = buildVariableSummaries ( myDAS , myDDS ) ; // Send the document back to the client .
pw . println ( "<title>Dataset Information</title>" ) ; pw . println ( "" ) ; pw . println ( "" ) ; pw . println ( "" ) ; if ( global_attrs . length ( ) > 0 ) { pw . println ( global_attrs ) ; pw . println ( "
" ) ; } pw . println ( variable_sum ) ; pw . println ( "
" ) ; pw . println ( user_html ) ; pw . println ( "" ) ; // Flush the output buffer .
pw . flush ( ) ; }


signature:
public class GetInfoHandler { /** * Checks the info directory for user supplied override documents for the
 * passed dataset name . If there are overridedocuments present then the
 * contents are read and returned to the caller as a string .
 * @ param dataSet The name of the dataset . */
public String loadOverrideDoc ( String infoDir , String dataSet ) throws DAP2Exception { } }

implementation:
StringBuilder userDoc = new StringBuilder ( ) ; String overrideFile = dataSet + ".ovr" ; // Try to open and read the override file for this dataset .
try { File fin = new File ( infoDir + overrideFile ) ; try ( BufferedReader svIn = new BufferedReader ( new InputStreamReader ( new FileInputStream ( fin ) , Util . UTF8 ) ) ; ) { boolean done = false ; while ( ! done ) { String line = svIn . readLine ( ) ; if ( line == null ) { done = true ; } else { userDoc . append ( line ) ; userDoc . append ( "\n" ) ; } } } } catch ( FileNotFoundException fnfe ) { userDoc . append ( "
No Could Not Open Override Document.

" ) ; return ( null ) ; } catch ( IOException ioe ) { throw ( new DAP2Exception ( opendap . dap . DAP2Exception . UNKNOWN_ERROR , ioe . getMessage ( ) ) ) ; } return ( userDoc . toString ( ) ) ;


signature: public class GetInfoHandler { private String buildGlobalAttributes ( DAS das , ServerDDS dds ) { } }

implementation:
boolean found = false ; StringBuilder ga = new StringBuilder ( ) ; ga . append ( "
Dataset Information
\n
\n" ) ; Enumeration edas = das . getNames ( ) ; while ( edas . hasMoreElements ( ) ) { String name = ( String ) edas . nextElement ( ) ; if ( ! dasTools . nameInKillFile ( name ) && ( dasTools . nameIsGlobal ( name ) || ! dasTools . nameInDDS ( name , dds ) ) ) { try { AttributeTable attr = das . getAttributeTable ( name ) ; if ( attr != null ) { Enumeration e = attr . getNames ( ) ; while ( e . hasMoreElements ( ) ) { String aName = ( String ) e . nextElement ( ) ; Attribute a = attr . getAttribute ( aName ) ; found = true ; ga . append ( "\n
" ) ; ga . append ( aName + ":	\n" ) ; ga . append ( "" ) ; Enumeration es = a . getValues ( ) ; while ( es . hasMoreElements ( ) ) { String val = ( String ) es . nextElement ( ) ; ga . append ( val ) ; ga . append ( "
" ) ; } ga . append ( "
\n" ) ; } } } catch ( NoSuchAttributeException nsae ) { } } } ga . append ( "
\n
\n" ) ; if ( ! found ) ga . setLength ( 0 ) ; return ( ga . toString ( ) ) ;


signature: public class GetInfoHandler { private String buildVariableSummaries ( DAS das , ServerDDS dds ) { } }

implementation:
StringBuilder vs = new StringBuilder ( ) ; vs . append ( "
Variables in this Dataset
\n
\n" ) ; Enumeration e = dds . getVariables ( ) ; while ( e . hasMoreElements ( ) ) { BaseType bt = ( BaseType ) e . nextElement ( ) ; vs . append ( "
" ) ; vs . append ( summarizeVariable ( bt , das ) ) ; vs . append ( "
" ) ; } vs . append ( "
\n
\n" ) ; return ( vs . toString ( ) ) ;


signature:
public class StructureDataDeep { /** * Make deep copy from sdata to another StructureData object whose data is self contained
 * @ param sdata original sdata
 * @ param members the StructureData members . a reference is kept to this object
 * @ return StructureData with all data self contained */
static public StructureDataDeep copy ( StructureData sdata , StructureMembers members ) { } }

implementation: ArrayStructureBB abb = copyToArrayBB ( sdata , members , ByteOrder . BIG_ENDIAN ) ; return new StructureDataDeep ( abb ) ;


signature:
public class StructureDataDeep { /** * Make deep copy from an ArrayStructure to a ArrayStructureBB whose data is contained in a ByteBuffer
 * @ param as original ArrayStructure
 * @ param bo what byte order to use ? ( null for any )
 * @ param canonical packing must be canonical
 * @ return ArrayStructureBB with all data self contained */
static public ArrayStructureBB copyToArrayBB ( ArrayStructure as , ByteOrder bo , boolean canonical ) throws IOException { } }

implementation:
if ( ! canonical && as . getClass ( ) . equals ( ArrayStructureBB . class ) ) { // no subclasses , LOOK detect already canonical later
ArrayStructureBB abb = ( ArrayStructureBB ) as ; ByteBuffer bb = abb . getByteBuffer ( ) ; if ( bo == null || bo . equals ( bb . order ( ) ) ) return abb ; } StructureMembers smo = as . getStructureMembers ( ) ; StructureMembers sm = new StructureMembers ( smo ) ; ArrayStructureBB abb = new ArrayStructureBB ( sm , as . getShape ( ) ) ; ArrayStructureBB . setOffsets ( sm ) ; // this makes the packing canonical
if ( bo != null ) { ByteBuffer bb = abb . getByteBuffer ( ) ; bb . order ( bo ) ; } try ( StructureDataIterator iter = as . getStructureDataIterator ( ) ) { while ( iter . hasNext ( ) ) copyToArrayBB ( iter . next ( ) , abb ) ; } return abb ;


signature:
public class StructureDataDeep { /** * Make deep copy to an ArrayStructureBB whose data is contained in a ByteBuffer .
 * Use the order of the members in the given Structure ; skip copying any not in the Structure
 * @ param s list of structure members come from here ; must be compatible with ArrayStructure ' s data
 * @ param as original ArrayStructure
 * @ param bo what byte order to use ? ( null for default )
 * @ return ArrayStructureBB with all data self contained */
static public ArrayStructureBB copyToArrayBB ( Structure s , ArrayStructure as , ByteOrder bo ) throws IOException { } }

implementation: StructureMembers sm = s . makeStructureMembers ( ) ; ArrayStructureBB abb = new ArrayStructureBB ( sm , as . getShape ( ) ) ; ArrayStructureBB . setOffsets ( sm ) ; if ( bo != null ) { ByteBuffer bb = abb . getByteBuffer ( ) ; bb . order ( bo ) ; } try ( StructureDataIterator iter = as . getStructureDataIterator ( ) ) { while ( iter . hasNext ( ) ) copyToArrayBB ( iter . next ( ) , abb ) ; } return abb ;


signature:
public class StructureDataDeep { /** * Make deep copy from a StructureData to a ArrayStructureBB whose data is contained in a ByteBuffer .
 * @ param sdata original ArrayStructure .
 * @ return ArrayStructureBB with all data self contained */
static public ArrayStructureBB copyToArrayBB ( StructureData sdata ) { } }

implementation: return copyToArrayBB ( sdata , new StructureMembers ( sdata . getStructureMembers ( ) ) , ByteOrder . BIG_ENDIAN ) ;


signature:
public class StructureDataDeep { /** * Make deep copy from a StructureData to a ArrayStructureBB whose data is contained in a ByteBuffer
 * @ param sdata original ArrayStructure
 * @ param sm the StructureData members . a reference is kept to this object
 * @ param bo Byte Order of the ByteBuffer
 * @ return ArrayStructureBB with all data self contained */
static public ArrayStructureBB copyToArrayBB ( StructureData sdata , StructureMembers sm , ByteOrder bo ) { } }

implementation:
int size = sm . getStructureSize ( ) ; ByteBuffer bb = ByteBuffer . allocate ( size ) ; // default is big endian
bb . order ( bo ) ; ArrayStructureBB abb = new ArrayStructureBB ( sm , new int [ ] { 1 } , bb , 0 ) ; ArrayStructureBB . setOffsets ( sm ) ; copyToArrayBB ( sdata , abb ) ; return abb ;


signature:
public class StructureDataDeep { /** * Make deep copy from a StructureData into the given ArrayStructureBB
 * @ param sdata original data from here
 * @ param abb copy data into this ArrayStructureBB , starting from wherever the ByteBuffer current position is
 * @ return number of bytes copied */
static public int copyToArrayBB ( StructureData sdata , ArrayStructureBB abb ) { } }

implementation:
// StructureMembers sm = sdata . getStructureMembers ( ) ;
ByteBuffer bb = abb . getByteBuffer ( ) ; int start = bb . limit ( ) ; for ( StructureMembers . Member wantMember : abb . getMembers ( ) ) { StructureMembers . Member m = sdata . findMember ( wantMember . getName ( ) ) ; assert m != null ; assert m . getDataType ( ) == wantMember . getDataType ( ) ; DataType dtype = m . getDataType ( ) ; // System . out . printf ( " do % s ( % s ) = % d % n " , m . getName ( ) , m . getDataType ( ) , bb . position ( ) ) ;
if ( m . isScalar ( ) ) { switch ( dtype ) { case STRING : bb . putInt ( abb . addObjectToHeap ( sdata . getScalarString ( m ) ) ) ; break ; case FLOAT : bb . putFloat ( sdata . getScalarFloat ( m ) ) ; break ; case DOUBLE : bb . putDouble ( sdata . getScalarDouble ( m ) ) ; break ; case INT : case UINT : case ENUM4 : bb . putInt ( sdata . getScalarInt ( m ) ) ; break ; case SHORT : case USHORT : case ENUM2 : bb . putShort ( sdata . getScalarShort ( m ) ) ; break ; case BYTE : case UBYTE : case ENUM1 : bb . put ( sdata . getScalarByte ( m ) ) ; break ; case CHAR : bb . put ( ( byte ) sdata . getScalarChar ( m ) ) ; break ; case LONG : case ULONG : bb . putLong ( sdata . getScalarLong ( m ) ) ; break ; case STRUCTURE : StructureData sd = sdata . getScalarStructure ( m ) ; ArrayStructureBB out_abb = new ArrayStructureBB ( sd . getStructureMembers ( ) , new int [ ] { 1 } , bb , 0 ) ; copyToArrayBB ( sd , out_abb ) ; break ; default : throw new IllegalStateException ( "scalar " + dtype . toString ( ) ) ; /* case BOOLEAN :
 break ;
 case SEQUENCE :
 break ;
 case OPAQUE :
 break ; */
} } else { int n = m . getSize ( ) ; switch ( dtype ) { case STRING : String [ ] ss = sdata . getJavaArrayString ( m ) ; bb . putInt ( abb . addObjectToHeap ( ss ) ) ; // stored as String [ ] on the heap
break ; case FLOAT : float [ ] fdata = sdata . getJavaArrayFloat ( m ) ; for ( int i = 0 ; i < n ; i ++ ) bb . putFloat ( fdata [ i ] ) ; break ; case DOUBLE : double [ ] ddata = sdata . getJavaArrayDouble ( m ) ; for ( int i = 0 ; i < n ; i ++ ) bb . putDouble ( ddata [ i ] ) ; break ; case INT : case ENUM4 : int [ ] idata = sdata . getJavaArrayInt ( m ) ; for ( int i = 0 ; i < n ; i ++ ) bb . putInt ( idata [ i ] ) ; break ; case SHORT : case ENUM2 : short [ ] shdata = sdata . getJavaArrayShort ( m ) ; for ( int i = 0 ; i < n ; i ++ ) bb . putShort ( shdata [ i ] ) ; break ; case BYTE : case ENUM1 : byte [ ] bdata = sdata . getJavaArrayByte ( m ) ; for ( int i = 0 ; i < n ; i ++ ) bb . put ( bdata [ i ] ) ; break ; case CHAR : char [ ] cdata = sdata . getJavaArrayChar ( m ) ; bb . put ( IospHelper . convertCharToByte ( cdata ) ) ; break ; case LONG : long [ ] ldata = sdata . getJavaArrayLong ( m ) ; for ( int i = 0 ; i < n ; i ++ ) bb . putLong ( ldata [ i ] ) ; break ; default : throw new IllegalStateException ( "array " + dtype . toString ( ) ) ; /* case BOOLEAN :
 break ;
 case OPAQUE :
 break ;
 case STRUCTURE :
 break ; / / */
case SEQUENCE : break ; // skip
} } } return bb . limit ( ) - start ;


signature:
public class NwsMetDevTables { /** * Only use in GribVariable to decide on variable identity when intvMerge = false .
 * By returning a constant , we dont intvMerge = false .
 * Problem is we cant reconstruct interval length without reference time , which is not in the pds . */
@ Override public double getForecastTimeIntervalSizeInHours ( Grib2Pds pds ) { } }

implementation:
Grib2Pds . PdsInterval pdsIntv = ( Grib2Pds . PdsInterval ) pds ; // override here only if timeRangeUnit = 255
boolean needOverride = false ; for ( Grib2Pds . TimeInterval ti : pdsIntv . getTimeIntervals ( ) ) { needOverride = ( ti . timeRangeUnit == 255 ) ; } if ( ! needOverride ) return super . getForecastTimeIntervalSizeInHours ( pds ) ; return 12.0 ;


signature:
public class CoordinateAxis1D { /** * Create a new CoordinateAxis1D as a section of this CoordinateAxis1D .
 * @ param r the section range
 * @ return a new CoordinateAxis1D as a section of this CoordinateAxis1D
 * @ throws InvalidRangeException if IllegalRange */
public CoordinateAxis1D section ( Range r ) throws InvalidRangeException { } }

implementation:
Section section = new Section ( ) . appendRange ( r ) ; CoordinateAxis1D result = ( CoordinateAxis1D ) section ( section ) ; int len = r . length ( ) ; // deal with the midpoints , bounds
if ( isNumeric ( ) ) { double [ ] new_mids = new double [ len ] ; for ( int idx = 0 ; idx < len ; idx ++ ) { int old_idx = r . element ( idx ) ; new_mids [ idx ] = coords [ old_idx ] ; } result . coords = new_mids ; if ( isInterval ) { double [ ] new_bound1 = new double [ len ] ; double [ ] new_bound2 = new double [ len ] ; double [ ] new_edge = new double [ len + 1 ] ; for ( int idx = 0 ; idx < len ; idx ++ ) { int old_idx = r . element ( idx ) ; new_bound1 [ idx ] = bound1 [ old_idx ] ; new_bound2 [ idx ] = bound2 [ old_idx ] ; new_edge [ idx ] = bound1 [ old_idx ] ; new_edge [ idx + 1 ] = bound2 [ old_idx ] ; // all but last are overwritten
} result . bound1 = new_bound1 ; result . bound2 = new_bound2 ; result . edge = new_edge ; } else { double [ ] new_edge = new double [ len + 1 ] ; for ( int idx = 0 ; idx < len ; idx ++ ) { int old_idx = r . element ( idx ) ; new_edge [ idx ] = edge [ old_idx ] ; new_edge [ idx + 1 ] = edge [ old_idx + 1 ] ; // all but last are overwritten
} result . edge = new_edge ; } } if ( names != null ) { String [ ] new_names = new String [ len ] ; for ( int idx = 0 ; idx < len ; idx ++ ) { int old_idx = r . element ( idx ) ; new_names [ idx ] = names [ old_idx ] ; } result . names = new_names ; } result . wasCalcRegular = false ; result . calcIsRegular ( ) ; return result ;


signature:
public class ImprovedFileChooser { /** * / / / / / JFileChooser / / / / / */
@ Override public int showDialog ( Component parent , String approveButtonText ) throws HeadlessException { } }

implementation:
int returnValue = super . showDialog ( parent , approveButtonText ) ; this . dialog = null ; // dialog was disposed in super - method . Null out so we don ' t try to use it .
return returnValue ;


signature:
public class TableAnalyzer { /** * Find a TableConfigurer for this dataset , if there is one .
 * @ param wantFeatureType want this FeatureType
 * @ param ds for this dataset
 * @ return TableConfigurer or null if not found
 * @ throws IOException on read error */
static public TableConfigurer getTableConfigurer ( FeatureType wantFeatureType , NetcdfDataset ds ) throws IOException { } }

implementation:
String convUsed = null ; // search for the Conventions attribute
String convName = ds . findAttValueIgnoreCase ( null , CDM . CONVENTIONS , null ) ; if ( convName == null ) convName = ds . findAttValueIgnoreCase ( null , "Convention" , null ) ; // now search for TableConfigurer using that Convention
Configurator anal = null ; if ( convName != null ) { convName = convName . trim ( ) ; // search for Convention parsing class
anal = matchConfigurator ( convName ) ; if ( anal != null ) { convUsed = convName ; if ( debug ) System . out . println ( "  TableConfigurer found using convName " + convName ) ; } // now search for comma or semicolon or / delimited list
if ( anal == null ) { List < String > names = new ArrayList < > ( ) ; if ( ( convName . indexOf ( ',' ) > 0 ) || ( convName . indexOf ( ';' ) > 0 ) ) { StringTokenizer stoke = new StringTokenizer ( convName , ",;" ) ; while ( stoke . hasMoreTokens ( ) ) { String name = stoke . nextToken ( ) ; names . add ( name . trim ( ) ) ; } } else if ( ( convName . indexOf ( '/' ) > 0 ) ) { StringTokenizer stoke = new StringTokenizer ( convName , "/" ) ; while ( stoke . hasMoreTokens ( ) ) { String name = stoke . nextToken ( ) ; names . add ( name . trim ( ) ) ; } } if ( names . size ( ) > 0 ) { // search the registered conventions , in order
for ( Configurator conv : conventionList ) { for ( String name : names ) { if ( name . equalsIgnoreCase ( conv . convName ) ) { anal = conv ; convUsed = name ; if ( debug ) System . out . println ( "  TableConfigurer found using convName " + convName ) ; } } if ( anal != null ) break ; } } } } // search for ones that dont use Convention attribute , in order added .
// call method isMine ( ) using reflection .
if ( anal == null ) { for ( Configurator conv : conventionList ) { Class c = conv . confClass ; Method isMineMethod ; try { isMineMethod = c . getMethod ( "isMine" , new Class [ ] { FeatureType . class , NetcdfDataset . class } ) ; } catch ( NoSuchMethodException ex ) { continue ; } try { Boolean result = ( Boolean ) isMineMethod . invoke ( conv . confInstance , wantFeatureType , ds ) ; if ( debug ) System . out . println ( "  TableConfigurer.isMine " + c . getName ( ) + " result = " + result ) ; if ( result ) { anal = conv ; convUsed = conv . convName ; break ; } } catch ( Exception ex ) { System . out . println ( "ERROR: Class " + c . getName ( ) + " Exception invoking isMine method%n" + ex ) ; } } } // Instantiate a new TableConfigurer object
TableConfigurer tc = null ; if ( anal != null ) { try { tc = ( TableConfigurer ) anal . confClass . newInstance ( ) ; tc . setConvName ( convName ) ; tc . setConvUsed ( convUsed ) ; } catch ( InstantiationException | IllegalAccessException e ) { log . error ( "TableConfigurer create failed" , e ) ; } } return tc ;


signature:
public class TableAnalyzer { /** * Create a TableAnalyser for this dataset with the given TableConfigurer
 * @ param tc TableConfigurer , may be null .
 * @ param wantFeatureType want this FeatureType
 * @ param ds for this dataset
 * @ return TableAnalyser
 * @ throws IOException on read error */
static public TableAnalyzer factory ( TableConfigurer tc , FeatureType wantFeatureType , NetcdfDataset ds ) throws IOException { } }

implementation:
// Create a TableAnalyzer with this TableConfigurer ( may be null )
TableAnalyzer analyzer = new TableAnalyzer ( ds , tc ) ; if ( tc != null ) { if ( tc . getConvName ( ) == null ) analyzer . userAdvice . format ( " No 'Conventions' global attribute.%n" ) ; else analyzer . userAdvice . format ( " Conventions global attribute = %s %n" , tc . getConvName ( ) ) ; // add the convention name used
if ( tc . getConvUsed ( ) != null ) { analyzer . setConventionUsed ( tc . getConvUsed ( ) ) ; if ( ! tc . getConvUsed ( ) . equals ( tc . getConvName ( ) ) ) analyzer . userAdvice . format ( " TableConfigurer used = " + tc . getConvUsed ( ) + ".%n" ) ; } } else { analyzer . userAdvice . format ( " No TableConfigurer found, using default analysis.%n" ) ; } // construct the nested table object
analyzer . analyze ( wantFeatureType ) ; return analyzer ;


signature:
public class TableAnalyzer { /** * for debugging messages */
public FeatureType getFirstFeatureType ( ) { } }

implementation: for ( NestedTable nt : leaves ) { if ( nt . hasCoords ( ) ) return nt . getFeatureType ( ) ; } return null ;


signature:
public class TableAnalyzer { /** * Make a NestedTable object for the dataset .
 * @ param wantFeatureType want this FeatureType
 * @ throws IOException on read error */
private void analyze ( FeatureType wantFeatureType ) throws IOException { } }

implementation:
// for netcdf - 3 files , convert record dimension to structure
// LOOK may be problems when served via opendap
boolean structAdded = ( Boolean ) ds . sendIospMessage ( NetcdfFile . IOSP_MESSAGE_ADD_RECORD_STRUCTURE ) ; if ( tc == null ) { makeTablesDefault ( structAdded ) ; makeNestedTables ( ) ; } else { configResult = tc . getConfig ( wantFeatureType , ds , errlog ) ; if ( configResult != null ) addTableRecurse ( configResult ) ; // kinda stupid
else { // use default
makeTablesDefault ( structAdded ) ; makeNestedTables ( ) ; } } // find the leaves
for ( TableConfig config : tableSet ) { if ( config . children == null ) { // its a leaf
NestedTable flatTable = new NestedTable ( ds , config , errlog ) ; leaves . add ( flatTable ) ; } } if ( PointDatasetStandardFactory . showTables ) getDetailInfo ( new Formatter ( System . out ) ) ;