signature:
public class Rules { /** * Try the rules from the hostname , domain name , metadata and global scopes
 * in this order . Returns true if the URL should be removed , false
 * otherwise . The value returns the value of the first matching rule , be it
 * positive or negative .
 * @ throws MalformedURLException */
public boolean filter ( String url , Metadata metadata ) throws MalformedURLException { } }

implementation:
URL u = new URL ( url ) ; // first try the full hostname
String hostname = u . getHost ( ) ; if ( checkScope ( hostNameRules . get ( hostname ) , u ) ) { return true ; } // then on the various components of the domain
String [ ] domainParts = hostname . split ( "\\." ) ; String domain = null ; for ( int i = domainParts . length - 1 ; i >= 0 ; i -- ) { domain = domainParts [ i ] + ( domain == null ? "" : "." + domain ) ; if ( checkScope ( domainRules . get ( domain ) , u ) ) { return true ; } } // check on parent ' s URL metadata
for ( MDScope scope : metadataRules ) { String [ ] vals = metadata . getValues ( scope . getKey ( ) ) ; if ( vals == null ) { continue ; } for ( String v : vals ) { if ( v . equalsIgnoreCase ( scope . getValue ( ) ) ) { FastURLFilter . LOG . debug ( "Filtering {} matching metadata {}:{}" , url , scope . getKey ( ) , scope . getValue ( ) ) ; if ( checkScope ( scope , u ) ) { return true ; } } } } if ( checkScope ( globalRules , u ) ) { return true ; } return false ;


signature:
public class RegexURLNormalizer { /** * This function does the replacements by iterating through all the regex
 * patterns . It accepts a string url as input and returns the altered
 * string . If the normalized url is an empty string , the function will
 * return null . */
@ Override public String filter ( URL sourceUrl , Metadata sourceMetadata , String urlString ) { } }

implementation: Iterator < Rule > i = rules . iterator ( ) ; while ( i . hasNext ( ) ) { Rule r = i . next ( ) ; Matcher matcher = r . pattern . matcher ( urlString ) ; urlString = matcher . replaceAll ( r . substitution ) ; } if ( urlString . equals ( "" ) ) { urlString = null ; } return urlString ;


signature:
public class RegexURLNormalizer { /** * Populates a List of Rules off of JsonNode . */
private List < Rule > readRules ( ArrayNode rulesList ) { } }

implementation: List < Rule > rules = new ArrayList < > ( ) ; for ( JsonNode regexNode : rulesList ) { if ( regexNode == null || regexNode . isNull ( ) ) { LOG . warn ( "bad config: 'regex' element is null" ) ; continue ; } JsonNode patternNode = regexNode . get ( "pattern" ) ; JsonNode substitutionNode = regexNode . get ( "substitution" ) ; String substitutionValue = "" ; if ( substitutionNode != null ) { substitutionValue = substitutionNode . asText ( ) ; } if ( patternNode != null && StringUtils . isNotBlank ( patternNode . asText ( ) ) ) { Rule rule = createRule ( patternNode . asText ( ) , substitutionValue ) ; if ( rule != null ) { rules . add ( rule ) ; } } } if ( rules . size ( ) == 0 ) { rules = EMPTY_RULES ; } return rules ;


signature:
public class RegexURLNormalizer { /** * Reads the configuration file and populates a List of Rules . */
private List < Rule > readRules ( String rulesFile ) { } }

implementation: try { InputStream regexStream = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( rulesFile ) ; Reader reader = new InputStreamReader ( regexStream , StandardCharsets . UTF_8 ) ; return readConfiguration ( reader ) ; } catch ( Exception e ) { LOG . error ( "Error loading rules from file: {}" , e ) ; return EMPTY_RULES ; }


signature:
public class BasicURLNormalizer { /** * Basic filter to remove query parameters from urls so parameters that
 * don ' t change the content of the page can be removed . An example would be
 * a google analytics query parameter like " utm _ campaign " which might have
 * several different values for a url that points to the same content . This
 * is also called when removing attributes where the value is a hash . */
private String processQueryElements ( String urlToFilter ) { } }

implementation:
try { // Handle illegal characters by making a url first
// this will clean illegal characters like |
URL url = new URL ( urlToFilter ) ; String query = url . getQuery ( ) ; String path = url . getPath ( ) ; // check if the last element of the path contains parameters
// if so convert them to query elements
if ( path . contains ( ";" ) ) { String [ ] pathElements = path . split ( "/" ) ; String last = pathElements [ pathElements . length - 1 ] ; // replace last value by part without params
int semicolon = last . indexOf ( ";" ) ; if ( semicolon != - 1 ) { pathElements [ pathElements . length - 1 ] = last . substring ( 0 , semicolon ) ; String params = last . substring ( semicolon + 1 ) . replaceAll ( ";" , "&" ) ; if ( query == null ) { query = params ; } else { query += "&" + params ; } // rebuild the path
StringBuilder newPath = new StringBuilder ( ) ; for ( String p : pathElements ) { if ( StringUtils . isNotBlank ( p ) ) { newPath . append ( "/" ) . append ( p ) ; } } path = newPath . toString ( ) ; } } if ( StringUtils . isEmpty ( query ) ) { return urlToFilter ; } List < NameValuePair > pairs = URLEncodedUtils . parse ( query , StandardCharsets . UTF_8 ) ; Iterator < NameValuePair > pairsIterator = pairs . iterator ( ) ; while ( pairsIterator . hasNext ( ) ) { NameValuePair param = pairsIterator . next ( ) ; if ( queryElementsToRemove . contains ( param . getName ( ) ) ) { pairsIterator . remove ( ) ; } else if ( removeHashes && param . getValue ( ) != null ) { Matcher m = thirtytwobithash . matcher ( param . getValue ( ) ) ; if ( m . matches ( ) ) { pairsIterator . remove ( ) ; } } } StringBuilder newFile = new StringBuilder ( ) ; if ( StringUtils . isNotBlank ( path ) ) { newFile . append ( path ) ; } if ( ! pairs . isEmpty ( ) ) { Collections . sort ( pairs , comp ) ; String newQueryString = URLEncodedUtils . format ( pairs , StandardCharsets . UTF_8 ) ; newFile . append ( '?' ) . append ( newQueryString ) ; } if ( url . getRef ( ) != null ) { newFile . append ( '#' ) . append ( url . getRef ( ) ) ; } return new URL ( url . getProtocol ( ) , url . getHost ( ) , url . getPort ( ) , newFile . toString ( ) ) . toString ( ) ; } catch ( MalformedURLException e ) { LOG . warn ( "Invalid urlToFilter {}. {}" , urlToFilter , e ) ; return null ; }


signature:
public class BasicURLNormalizer { /** * A common error to find is a query string that starts with an & instead of
 * a ? This will fix that error . So http : / / foo . com & a = b will be changed to
 * http : / / foo . com ? a = b .
 * @ param urlToFilter
 * @ return corrected url */
private String unmangleQueryString ( String urlToFilter ) { } }

implementation: int firstAmp = urlToFilter . indexOf ( '&' ) ; if ( firstAmp > 0 ) { int firstQuestionMark = urlToFilter . indexOf ( '?' ) ; if ( firstQuestionMark == - 1 ) { return urlToFilter . replaceFirst ( "&" , "?" ) ; } } return urlToFilter ;


signature:
public class BasicURLNormalizer { /** * Remove % encoding from path segment in URL for characters which should be
 * unescaped according to < a
 * href = " https : / / tools . ietf . org / html / rfc3986 # section - 2.2 " > RFC3986 < / a > as
 * well as non - standard implementations of percent encoding , see
 * < https : / / en .
 * wikipedia . org / wiki / Percent - encoding # Non - standard _ implementations > . */
private String unescapePath ( String path ) { } }

implementation:
Matcher matcher = illegalEscapePattern . matcher ( path ) ; StringBuilder sb = null ; int end = 0 ; while ( matcher . find ( ) ) { if ( sb == null ) { sb = new StringBuilder ( ) ; } // Append everything up to this group
sb . append ( path . substring ( end , matcher . start ( ) ) ) ; String group = matcher . group ( 1 ) ; int letter = Integer . valueOf ( group , 16 ) ; sb . append ( ( char ) letter ) ; end = matcher . end ( ) ; } // we got a replacement
if ( sb != null ) { // append whatever is left
sb . append ( path . substring ( end ) ) ; path = sb . toString ( ) ; end = 0 ; } matcher = unescapeRulePattern . matcher ( path ) ; if ( ! matcher . find ( ) ) { return path ; } sb = new StringBuilder ( ) ; // Traverse over all encoded groups
do { // Append everything up to this group
sb . append ( path . substring ( end , matcher . start ( ) ) ) ; // Get the integer representation of this hexadecimal encoded
// character
int letter = Integer . valueOf ( matcher . group ( 1 ) , 16 ) ; if ( letter < 128 && unescapedCharacters [ letter ] ) { // character should be unescaped in URLs
sb . append ( ( char ) letter ) ; } else { // Append the whole sequence as uppercase
sb . append ( matcher . group ( ) . toUpperCase ( Locale . ROOT ) ) ; } end = matcher . end ( ) ; } while ( matcher . find ( ) ) ; // Append the rest if there ' s anything left
sb . append ( path . substring ( end ) ) ; return sb . toString ( ) ;


signature:
public class BasicURLNormalizer { /** * Convert path segment of URL from Unicode to UTF - 8 and escape all
 * characters which should be escaped according to < a
 * href = " https : / / tools . ietf . org / html / rfc3986 # section - 2.2 " > RFC3986 < / a > . . */
private String escapePath ( String path ) { } }

implementation:
StringBuilder sb = new StringBuilder ( path . length ( ) ) ; // Traverse over all bytes in this URL
for ( byte b : path . getBytes ( utf8 ) ) { // Is this a control character ?
if ( b < 33 || b == 91 || b == 92 || b == 93 || b == 124 ) { // Start escape sequence
sb . append ( '%' ) ; // Get this byte ' s hexadecimal representation
String hex = Integer . toHexString ( b & 0xFF ) . toUpperCase ( Locale . ROOT ) ; // Do we need to prepend a zero ?
if ( hex . length ( ) % 2 != 0 ) { sb . append ( '0' ) ; sb . append ( hex ) ; } else { // No , append this hexadecimal representation
sb . append ( hex ) ; } } else { // No , just append this character as - is
sb . append ( ( char ) b ) ; } } return sb . toString ( ) ;


signature:
public class AbstractS3CacheBolt { /** * Returns an S3 client given the configuration * */
public static AmazonS3Client getS3Client ( Map conf ) { } }

implementation: AWSCredentialsProvider provider = new DefaultAWSCredentialsProviderChain ( ) ; AWSCredentials credentials = provider . getCredentials ( ) ; ClientConfiguration config = new ClientConfiguration ( ) ; AmazonS3Client client = new AmazonS3Client ( credentials , config ) ; String regionName = ConfUtils . getString ( conf , REGION ) ; if ( StringUtils . isNotBlank ( regionName ) ) { client . setRegion ( RegionUtils . getRegion ( regionName ) ) ; } String endpoint = ConfUtils . getString ( conf , ENDPOINT ) ; if ( StringUtils . isNotBlank ( endpoint ) ) { client . setEndpoint ( endpoint ) ; } return client ;


signature:
public class NavigationFilters { /** * Loads and configure the NavigationFilters based on the storm config if
 * there is one otherwise returns an emptyNavigationFilters . */
@ SuppressWarnings ( "rawtypes" ) public static NavigationFilters fromConf ( Map stormConf ) { } }

implementation: String configfile = ConfUtils . getString ( stormConf , "navigationfilters.config.file" ) ; if ( StringUtils . isNotBlank ( configfile ) ) { try { return new NavigationFilters ( stormConf , configfile ) ; } catch ( IOException e ) { String message = "Exception caught while loading the NavigationFilters from " + configfile ; LOG . error ( message ) ; throw new RuntimeException ( message , e ) ; } } return NavigationFilters . emptyNavigationFilters ;


signature:
public class GzipHdfsBolt { /** * Add an additional record format at given position */
public GzipHdfsBolt addRecordFormat ( RecordFormat format , int position ) { } }

implementation: MultipleRecordFormat formats ; if ( this . format == null ) { formats = new MultipleRecordFormat ( format ) ; this . format = formats ; } else { if ( this . format instanceof MultipleRecordFormat ) { formats = ( MultipleRecordFormat ) this . format ; } else { formats = new MultipleRecordFormat ( this . format ) ; this . format = formats ; } formats . addFormat ( new GzippedRecordFormat ( format ) , position ) ; } return this ;


signature:
public class AbstractQueryingSpout { /** * Returns the amount of time to wait if the backend was queried too
 * recently and needs throttling or - 1 if the backend can be queried
 * straight away . */
private long throttleQueries ( ) { } }

implementation:
if ( timeLastQuerySent != 0 ) { // check that we allowed some time between queries
long difference = System . currentTimeMillis ( ) - timeLastQuerySent ; if ( difference < minDelayBetweenQueries ) { return minDelayBetweenQueries - difference ; } } return - 1 ;


signature:
public class AbstractQueryingSpout { /** * Indicates whether enough time has elapsed since receiving the results of
 * the previous query so that a new one can be sent even if the buffer is
 * not empty . Applies to asynchronous clients only . */
private boolean triggerQueries ( ) { } }

implementation:
if ( timeLastQueryReceived != 0 && maxDelayBetweenQueries > 0 ) { // check that we allowed some time between queries
long difference = System . currentTimeMillis ( ) - timeLastQueryReceived ; if ( difference > maxDelayBetweenQueries ) { return true ; } } return false ;


signature:
public class ParseFilters { /** * Loads and configure the ParseFilters based on the storm config if there
 * is one otherwise returns an emptyParseFilter . */
@ SuppressWarnings ( "rawtypes" ) public static ParseFilters fromConf ( Map stormConf ) { } }

implementation: String parseconfigfile = ConfUtils . getString ( stormConf , "parsefilters.config.file" ) ; if ( StringUtils . isNotBlank ( parseconfigfile ) ) { try { return new ParseFilters ( stormConf , parseconfigfile ) ; } catch ( IOException e ) { String message = "Exception caught while loading the ParseFilters from " + parseconfigfile ; LOG . error ( message ) ; throw new RuntimeException ( message , e ) ; } } return ParseFilters . emptyParseFilter ;


signature:
public class DOMBuilder { /** * Append a node to the current container .
 * @ param newNode
 * New node to append */
protected void append ( Node newNode ) throws org . xml . sax . SAXException { } }

implementation:
Node currentNode = m_currentNode ; if ( null != currentNode ) { currentNode . appendChild ( newNode ) ; // System . out . println ( newNode . getNodeName ( ) ) ;
} else if ( null != m_docFrag ) { m_docFrag . appendChild ( newNode ) ; } else { boolean ok = true ; short type = newNode . getNodeType ( ) ; if ( type == Node . TEXT_NODE ) { String data = newNode . getNodeValue ( ) ; if ( ( null != data ) && ( data . trim ( ) . length ( ) > 0 ) ) { throw new org . xml . sax . SAXException ( "Warning: can't output text before document element!  Ignoring..." ) ; } ok = false ; } else if ( type == Node . ELEMENT_NODE ) { if ( m_doc . getDocumentElement ( ) != null ) { throw new org . xml . sax . SAXException ( "Can't have more than one root on a DOM!" ) ; } } if ( ok ) { m_doc . appendChild ( newNode ) ; } }


signature:
public class DOMBuilder { /** * Receive notification of ignorable whitespace in element content .
 * Validating Parsers must use this method to report each chunk of ignorable
 * whitespace ( see the W3C XML 1.0 recommendation , section 2.10 ) :
 * non - validating parsers may also use this method if they are capable of
 * parsing and using content models .
 * SAX parsers may return all contiguous whitespace in a single chunk , or
 * they may split it into several chunks ; however , all of the characters in
 * any single event must come from the same external entity , so that the
 * Locator provides useful information .
 * The application must not attempt to read from the array outside of the
 * specified range .
 * @ param ch
 * The characters from the XML document .
 * @ param start
 * The start position in the array .
 * @ param length
 * The number of characters to read from the array .
 * @ see # characters */
@ Override public void ignorableWhitespace ( char ch [ ] , int start , int length ) throws org . xml . sax . SAXException { } }

implementation:
if ( isOutsideDocElem ( ) ) { return ; // avoid DOM006 Hierarchy request error
} String s = new String ( ch , start , length ) ; append ( m_doc . createTextNode ( s ) ) ;


signature:
public class DOMBuilder { /** * Receive notification of a processing instruction .
 * The Parser will invoke this method once for each processing instruction
 * found : note that processing instructions may occur before or after the
 * main document element .
 * A SAX parser should never report an XML declaration ( XML 1.0 , section
 * 2.8 ) or a text declaration ( XML 1.0 , section 4.3.1 ) using this method .
 * @ param target
 * The processing instruction target .
 * @ param data
 * The processing instruction data , or null if none was supplied . */
@ Override public void processingInstruction ( String target , String data ) throws org . xml . sax . SAXException { } }

implementation: append ( m_doc . createProcessingInstruction ( target , data ) ) ;


signature:
public class DOMBuilder { /** * Report an XML comment anywhere in the document .
 * This callback will be used for comments inside or outside the document
 * element , including comments in the external DTD subset ( if read ) .
 * @ param ch
 * An array holding the characters in the comment .
 * @ param start
 * The starting position in the array .
 * @ param length
 * The number of characters to use from the array . */
@ Override public void comment ( char ch [ ] , int start , int length ) throws org . xml . sax . SAXException { } }

implementation:
// tagsoup sometimes submits invalid values here
if ( ch == null || start < 0 || length >= ( ch . length - start ) || length < 0 ) { return ; } append ( m_doc . createComment ( new String ( ch , start , length ) ) ) ;


signature:
public class DOMBuilder { /** * Receive notification of cdata .
 * The Parser will call this method to report each chunk of character data .
 * SAX parsers may return all contiguous character data in a single chunk ,
 * or they may split it into several chunks ; however , all of the characters
 * in any single event must come from the same external entity , so that the
 * Locator provides useful information .
 * The application must not attempt to read from the array outside of the
 * specified range .
 * Note that some parsers will report whitespace using the
 * ignorableWhitespace ( ) method rather than this one ( validating parsers
 * must do so ) .
 * @ param ch
 * The characters from the XML document .
 * @ param start
 * The start position in the array .
 * @ param length
 * The number of characters to read from the array .
 * @ see # ignorableWhitespace
 * @ see org . xml . sax . Locator */
public void cdata ( char ch [ ] , int start , int length ) { } }

implementation:
if ( isOutsideDocElem ( ) && XMLCharacterRecognizer . isWhiteSpace ( ch , start , length ) ) { return ; // avoid DOM006 Hierarchy request error
} String s = new String ( ch , start , length ) ; // XXX ab @ apache . org : modified from the original , to accomodate TagSoup .
Node n = m_currentNode . getLastChild ( ) ; if ( n instanceof CDATASection ) { ( ( CDATASection ) n ) . appendData ( s ) ; } else if ( n instanceof Comment ) { ( ( Comment ) n ) . appendData ( s ) ; }


signature:
public class DOMBuilder { /** * Report the start of DTD declarations , if any .
 * Any declarations are assumed to be in the internal subset unless
 * otherwise indicated .
 * @ param name
 * The document type name .
 * @ param publicId
 * The declared public identifier for the external DTD subset , or
 * null if none was declared .
 * @ param systemId
 * The declared system identifier for the external DTD subset , or
 * null if none was declared .
 * @ see # endDTD
 * @ see # startEntity */
@ Override public void startDTD ( String name , String publicId , String systemId ) throws org . xml . sax . SAXException { } }

implementation: // Do nothing for now .


signature:
public class DOMBuilder { /** * Begin the scope of a prefix - URI Namespace mapping .
 * The information from this event is not necessary for normal Namespace
 * processing : the SAX XML reader will automatically replace prefixes for
 * element and attribute names when the
 * http : / / xml . org / sax / features / namespaces feature is true ( the default ) .
 * There are cases , however , when applications need to use prefixes in
 * character data or in attribute values , where they cannot safely be
 * expanded automatically ; the start / endPrefixMapping event supplies the
 * information to the application to expand prefixes in those contexts
 * itself , if necessary .
 * Note that start / endPrefixMapping events are not guaranteed to be properly
 * nested relative to each - other : all startPrefixMapping events will occur
 * before the corresponding startElement event , and all endPrefixMapping
 * events will occur after the corresponding endElement event , but their
 * order is not guaranteed .
 * @ param prefix
 * The Namespace prefix being declared .
 * @ param uri
 * The Namespace URI the prefix is mapped to .
 * @ see # endPrefixMapping
 * @ see # startElement */
@ Override public void startPrefixMapping ( String prefix , String uri ) throws org . xml . sax . SAXException { } }

implementation:
/* * / / Not sure if this is needed or wanted / / Also , it fails in the
 * stree . if ( ( null ! = m _ currentNode ) & & ( m _ currentNode . getNodeType ( ) = =
 * Node . ELEMENT _ NODE ) ) { String qname ; if ( ( ( null ! = prefix ) & &
 * ( prefix . length ( ) = = 0 ) ) | | ( null = = prefix ) ) qname = " xmlns " ; else
 * qname = " xmlns : " + prefix ;
 * Element elem = ( Element ) m _ currentNode ; String val =
 * elem . getAttribute ( qname ) ; / / Obsolete , should be DOM2 . . . ? if ( val = =
 * null ) { elem . setAttributeNS ( " http : / / www . w3 . org / XML / 1998 / namespace " ,
 * qname , uri ) ; } } */


signature:
public class RobotRulesParser { /** * Parses the robots content using the { @ link SimpleRobotRulesParser } from
 * crawler commons
 * @ param url
 * A string containing url
 * @ param content
 * Contents of the robots file in a byte array
 * @ param contentType
 * The
 * @ param robotName
 * A string containing value of
 * @ return BaseRobotRules object */
public BaseRobotRules parseRules ( String url , byte [ ] content , String contentType , String robotName ) { } }

implementation: return robotParser . parseContent ( url , content , contentType , robotName ) ;


signature:
public class AbstractIndexerBolt { /** * Determine whether a document should be indexed based on the presence of a
 * given key / value or the RobotsTags . ROBOTS _ NO _ INDEX directive .
 * @ return true if the document should be kept . */
protected boolean filterDocument ( Metadata meta ) { } }

implementation:
String noindexVal = meta . getFirstValue ( RobotsTags . ROBOTS_NO_INDEX ) ; if ( "true" . equalsIgnoreCase ( noindexVal ) ) return false ; if ( filterKeyValue == null ) return true ; String [ ] values = meta . getValues ( filterKeyValue [ 0 ] ) ; // key not found
if ( values == null ) return false ; return ArrayUtils . contains ( values , filterKeyValue [ 1 ] ) ;


signature:
public class AbstractIndexerBolt { /** * Returns a mapping field name / values for the metadata to index * */
protected Map < String , String [ ] > filterMetadata ( Metadata meta ) { } }

implementation:
Pattern indexValuePattern = Pattern . compile ( "\\[(\\d+)\\]" ) ; Map < String , String [ ] > fieldVals = new HashMap < > ( ) ; Iterator < Entry < String , String > > iter = metadata2field . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Entry < String , String > entry = iter . next ( ) ; // check whether we want a specific value or all of them ?
int index = - 1 ; String key = entry . getKey ( ) ; Matcher match = indexValuePattern . matcher ( key ) ; if ( match . find ( ) ) { index = Integer . parseInt ( match . group ( 1 ) ) ; key = key . substring ( 0 , match . start ( ) ) ; } String [ ] values = meta . getValues ( key ) ; // not found
if ( values == null || values . length == 0 ) continue ; // want a value index that it outside the range given
if ( index >= values . length ) continue ; // store all values available
if ( index == - 1 ) fieldVals . put ( entry . getValue ( ) , values ) ; // or only the one we want
else fieldVals . put ( entry . getValue ( ) , new String [ ] { values [ index ] } ) ; } return fieldVals ;


signature:
public class AbstractIndexerBolt { /** * Returns the value to be used as the URL for indexing purposes , if present
 * the canonical value is used instead */
protected String valueForURL ( Tuple tuple ) { } }

implementation:
String url = tuple . getStringByField ( "url" ) ; Metadata metadata = ( Metadata ) tuple . getValueByField ( "metadata" ) ; // functionality deactivated
if ( StringUtils . isBlank ( canonicalMetadataParamName ) ) { return url ; } String canonicalValue = metadata . getFirstValue ( canonicalMetadataName ) ; // no value found ?
if ( StringUtils . isBlank ( canonicalValue ) ) { return url ; } try { URL sURL = new URL ( url ) ; URL canonical = URLUtil . resolveURL ( sURL , canonicalValue ) ; String sDomain = PaidLevelDomain . getPLD ( sURL . getHost ( ) ) ; String canonicalDomain = PaidLevelDomain . getPLD ( canonical . getHost ( ) ) ; // check that the domain is the same
if ( sDomain . equalsIgnoreCase ( canonicalDomain ) ) { return canonical . toExternalForm ( ) ; } else { LOG . info ( "Canonical URL references a different domain, ignoring in {} " , url ) ; } } catch ( MalformedURLException e ) { LOG . error ( "Malformed canonical URL {} was found in {} " , canonicalValue , url ) ; } return url ;


signature:
public class AbstractIndexerBolt { /** * Returns a trimmed string or the original one if it is below the threshold
 * set in the configuration . */
protected String trimText ( String text ) { } }

implementation: if ( maxLengthText == - 1 ) return text ; if ( text == null ) return text ; if ( text . length ( ) <= maxLengthText ) return text ; return text . substring ( 0 , maxLengthText ) ;


signature:
public class DefaultScheduler { /** * ( non - Javadoc )
 * @ see
 * com . digitalpebble . stormcrawler . persistence . Scheduler # init ( java . util . Map ) */
@ SuppressWarnings ( "rawtypes" ) @ Override public void init ( Map stormConf ) { } }

implementation:
defaultfetchInterval = ConfUtils . getInt ( stormConf , Constants . defaultFetchIntervalParamName , 1440 ) ; fetchErrorFetchInterval = ConfUtils . getInt ( stormConf , Constants . fetchErrorFetchIntervalParamName , 120 ) ; errorFetchInterval = ConfUtils . getInt ( stormConf , Constants . errorFetchIntervalParamName , 44640 ) ; // loads any custom key values
// must be of form fetchInterval ( . STATUS ) ? . keyname = value
// e . g . fetchInterval . isFeed = true
// e . g . fetchInterval . FETCH _ ERROR . isFeed = true
Map < String , CustomInterval > intervals = new HashMap < > ( ) ; Pattern pattern = Pattern . compile ( "^fetchInterval(\\..+?)?\\.(.+)=(.+)" ) ; Iterator < String > keyIter = stormConf . keySet ( ) . iterator ( ) ; while ( keyIter . hasNext ( ) ) { String key = keyIter . next ( ) ; Matcher m = pattern . matcher ( key ) ; if ( ! m . matches ( ) ) { continue ; } Status status = null ; // was a status specified ?
if ( m . group ( 1 ) != null ) { status = Status . valueOf ( m . group ( 1 ) . substring ( 1 ) ) ; } String mdname = m . group ( 2 ) ; String mdvalue = m . group ( 3 ) ; int customInterval = ConfUtils . getInt ( stormConf , key , - 1 ) ; if ( customInterval != - 1 ) { CustomInterval interval = intervals . get ( mdname + mdvalue ) ; if ( interval == null ) { interval = new CustomInterval ( mdname , mdvalue , status , customInterval ) ; } else { interval . setDurationForStatus ( status , customInterval ) ; } // specify particular interval for this status
intervals . put ( mdname + mdvalue , interval ) ; } } customIntervals = intervals . values ( ) . toArray ( new CustomInterval [ intervals . size ( ) ] ) ;


signature:
public class DefaultScheduler { /** * ( non - Javadoc )
 * @ see com . digitalpebble . stormcrawler . persistence . Scheduler # schedule ( com .
 * digitalpebble . stormcrawler . persistence . Status ,
 * com . digitalpebble . stormcrawler . Metadata ) */
@ Override public Date schedule ( Status status , Metadata metadata ) { } }

implementation:
int minutesIncrement = 0 ; Optional < Integer > customInterval = Optional . empty ( ) ; // try with a value set in the metadata
String customInMetadata = metadata . getFirstValue ( DELAY_METADATA ) ; if ( customInMetadata != null ) { customInterval = Optional . of ( Integer . parseInt ( customInMetadata ) ) ; } // try with the rules from the configuration
if ( ! customInterval . isPresent ( ) ) { customInterval = checkCustomInterval ( metadata , status ) ; } if ( customInterval . isPresent ( ) ) { minutesIncrement = customInterval . get ( ) ; } else { switch ( status ) { case FETCHED : minutesIncrement = defaultfetchInterval ; break ; case FETCH_ERROR : minutesIncrement = fetchErrorFetchInterval ; break ; case ERROR : minutesIncrement = errorFetchInterval ; break ; case REDIRECTION : minutesIncrement = defaultfetchInterval ; break ; default : // leave it to now e . g . DISCOVERED
} } // a value of - 1 means never fetch
// we use a conventional value
if ( minutesIncrement == - 1 ) { return NEVER ; } Calendar cal = Calendar . getInstance ( ) ; cal . add ( Calendar . MINUTE , minutesIncrement ) ; return cal . getTime ( ) ;


signature:
public class DefaultScheduler { /** * Returns the first matching custom interval */
protected final Optional < Integer > checkCustomInterval ( Metadata metadata , Status s ) { } }

implementation: if ( customIntervals == null ) return Optional . empty ( ) ; for ( CustomInterval customInterval : customIntervals ) { String [ ] values = metadata . getValues ( customInterval . key ) ; if ( values == null ) { continue ; } for ( String v : values ) { if ( v . equals ( customInterval . value ) ) { return customInterval . getDurationForStatus ( s ) ; } } } return Optional . empty ( ) ;


signature:
public class URLFilters { /** * Loads and configure the URLFilters based on the storm config if there is
 * one otherwise returns an empty URLFilter . */
public static URLFilters fromConf ( Map stormConf ) { } }

implementation: String configFile = ConfUtils . getString ( stormConf , "urlfilters.config.file" ) ; if ( StringUtils . isNotBlank ( configFile ) ) { try { return new URLFilters ( stormConf , configFile ) ; } catch ( IOException e ) { String message = "Exception caught while loading the URLFilters from " + configFile ; LOG . error ( message ) ; throw new RuntimeException ( message , e ) ; } } return URLFilters . emptyURLFilters ;


signature:
public class Scheduler { /** * Returns a Scheduler instance based on the configuration * */
@ SuppressWarnings ( { } }

implementation: "rawtypes" , "unchecked" } ) public static Scheduler getInstance ( Map stormConf ) { Scheduler scheduler ; String className = ConfUtils . getString ( stormConf , schedulerClassParamName ) ; if ( StringUtils . isBlank ( className ) ) { throw new RuntimeException ( "Missing value for config  " + schedulerClassParamName ) ; } try { Class < ? > schedulerc = Class . forName ( className ) ; boolean interfaceOK = Scheduler . class . isAssignableFrom ( schedulerc ) ; if ( ! interfaceOK ) { throw new RuntimeException ( "Class " + className + " must extend Scheduler" ) ; } scheduler = ( Scheduler ) schedulerc . newInstance ( ) ; } catch ( Exception e ) { throw new RuntimeException ( "Can't instanciate " + className ) ; } scheduler . init ( stormConf ) ; return scheduler ;


signature:
public class ConfigurableTopology { /** * Submits the topology with the name taken from the configuration * */
protected int submit ( Config conf , TopologyBuilder builder ) { } }

implementation: String name = ConfUtils . getString ( conf , Config . TOPOLOGY_NAME ) ; if ( StringUtils . isBlank ( name ) ) throw new RuntimeException ( "No value found for " + Config . TOPOLOGY_NAME ) ; return submit ( name , conf , builder ) ;


signature:
public class ConfigurableTopology { /** * Submits the topology under a specific name * */
protected int submit ( String name , Config conf , TopologyBuilder builder ) { } }

implementation:
// register Metadata for serialization with FieldsSerializer
Config . registerSerialization ( conf , Metadata . class ) ; if ( isLocal ) { LocalCluster cluster = new LocalCluster ( ) ; cluster . submitTopology ( name , conf , builder . createTopology ( ) ) ; if ( ttl != - 1 ) { Utils . sleep ( ttl * 1000 ) ; cluster . shutdown ( ) ; } } else { try { StormSubmitter . submitTopology ( name , conf , builder . createTopology ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return - 1 ; } } return 0 ;


signature:
public class Poiji { /** * converts excel rows into a list of objects
 * @ param file
 * excel file ending with . xls or . xlsx .
 * @ param type
 * type of the root object .
 * @ param < T >
 * type of the root object .
 * @ return
 * the newly created a list of objects
 * @ throws PoijiException
 * if an internal exception occurs during the mapping process .
 * @ throws InvalidExcelFileExtension
 * if the specified excel file extension is invalid .
 * @ throws IllegalCastException
 * if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final .
 * @ see Poiji # fromExcel ( File , Class , PoijiOptions ) */
public static synchronized < T > List < T > fromExcel ( final File file , final Class < T > type ) { } }

implementation: final ArrayList < T > list = new ArrayList < > ( ) ; fromExcel ( file , type , list :: add ) ; return list ;


signature:
public class Poiji { /** * converts excel rows into a list of objects
 * @ param file excel file ending with . xls or . xlsx .
 * @ param type type of the root object .
 * @ param < T > type of the root object .
 * @ param consumer output retrieves records
 * @ throws PoijiException if an internal exception occurs during the mapping
 * process .
 * @ throws InvalidExcelFileExtension if the specified excel file extension
 * is invalid .
 * @ throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final .
 * @ see Poiji # fromExcel ( File , Class , PoijiOptions ) */
public static synchronized < T > void fromExcel ( final File file , final Class < T > type , final Consumer < ? super T > consumer ) { } }

implementation: final Unmarshaller unmarshaller = deserializer ( file , PoijiOptionsBuilder . settings ( ) . build ( ) ) ; unmarshaller . unmarshal ( type , consumer ) ;


signature:
public class Poiji { /** * converts excel rows into a list of objects
 * @ param inputStream excel file stream
 * @ param excelType type of the excel file , xls or xlsx
 * @ param type type of the root object .
 * @ param < T > type of the root object .
 * @ return the newly created a list of objects
 * @ throws PoijiException if an internal exception occurs during the mapping process .
 * @ throws InvalidExcelFileExtension if the specified excel file extension is invalid .
 * @ throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final .
 * @ see Poiji # fromExcel ( File , Class , PoijiOptions ) */
public static synchronized < T > List < T > fromExcel ( final InputStream inputStream , PoijiExcelType excelType , final Class < T > type ) { } }

implementation: final ArrayList < T > list = new ArrayList < > ( ) ; fromExcel ( inputStream , excelType , type , list :: add ) ; return list ;


signature:
public class Poiji { /** * converts excel rows into a list of objects
 * @ param inputStream excel file stream
 * @ param excelType type of the excel file , xls or xlsx
 * @ param type type of the root object .
 * @ param < T > type of the root object .
 * @ param consumer represents an operation that accepts the type argument
 * @ throws PoijiException if an internal exception occurs during the mapping process .
 * @ throws InvalidExcelFileExtension if the specified excel file extension is invalid .
 * @ throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final .
 * @ see Poiji # fromExcel ( File , Class , PoijiOptions ) */
public static synchronized < T > void fromExcel ( final InputStream inputStream , PoijiExcelType excelType , final Class < T > type , final Consumer < ? super T > consumer ) { } }

implementation: Objects . requireNonNull ( excelType ) ; final Unmarshaller unmarshaller = deserializer ( inputStream , excelType , PoijiOptionsBuilder . settings ( ) . build ( ) ) ; unmarshaller . unmarshal ( type , consumer ) ;


signature:
public class Poiji { /** * converts excel rows into a list of objects
 * @ param file excel file ending with . xls or . xlsx .
 * @ param type type of the root object .
 * @ param < T > type of the root object .
 * @ param options specifies to change the default behaviour of the poiji .
 * @ param consumer represents an operation that accepts the type argument
 * @ throws PoijiException if an internal exception occurs during the mapping process .
 * @ throws InvalidExcelFileExtension if the specified excel file extension is invalid .
 * @ throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final .
 * @ see Poiji # fromExcel ( File , Class ) */
public static synchronized < T > void fromExcel ( final File file , final Class < T > type , final PoijiOptions options , final Consumer < ? super T > consumer ) { } }

implementation: final Unmarshaller unmarshaller = deserializer ( file , options ) ; unmarshaller . unmarshal ( type , consumer ) ;


signature:
public class Poiji { /** * converts excel rows into a list of objects
 * @ param inputStream excel file stream
 * @ param excelType type of the excel file , xls or xlsx
 * @ param type type of the root object .
 * @ param < T > type of the root object .
 * @ param options specifies to change the default behaviour of the poiji .
 * @ return the newly created a list of objects
 * @ throws PoijiException if an internal exception occurs during the mapping process .
 * @ throws InvalidExcelFileExtension if the specified excel file extension is invalid .
 * @ throws IllegalCastException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final .
 * @ see Poiji # fromExcel ( File , Class ) */
public static synchronized < T > List < T > fromExcel ( final InputStream inputStream , final PoijiExcelType excelType , final Class < T > type , final PoijiOptions options ) { } }

implementation: Objects . requireNonNull ( excelType ) ; final ArrayList < T > list = new ArrayList < > ( ) ; fromExcel ( inputStream , excelType , type , options , list :: add ) ; return list ;


signature:
public class Poiji { /** * converts excel rows into a list of objects
 * @ param inputStream excel file stream
 * @ param excelType type of the excel file , xls or xlsx
 * @ param type type of the root object .
 * @ param < T > type of the root object .
 * @ param options specifies to change the default behaviour of the poiji .
 * @ param consumer represents an operation that accepts the type argument
 * @ throws PoijiException if an internal exception occurs during the mapping process .
 * @ throws InvalidExcelFileExtension if the specified excel file extension is invalid .
 * @ throws IllegalCastException if this Field object is enforcing Java
 * language access control and the underlying field is either inaccessible or final .
 * @ see Poiji # fromExcel ( File , Class ) */
public static synchronized < T > void fromExcel ( final InputStream inputStream , final PoijiExcelType excelType , final Class < T > type , final PoijiOptions options , final Consumer < ? super T > consumer ) { } }

implementation: Objects . requireNonNull ( excelType ) ; final Unmarshaller unmarshaller = deserializer ( inputStream , excelType , options ) ; unmarshaller . unmarshal ( type , consumer ) ;


signature:
public class PoijiHandler { /** * Using this to hold inner objects that will be mapped to the main object */
private Object getInstance ( Field field ) { } }

implementation: Object ins = null ; try { if ( fieldInstances . containsKey ( field . getName ( ) ) ) { ins = fieldInstances . get ( field . getName ( ) ) ; } else { ins = field . getType ( ) . getDeclaredConstructor ( ) . newInstance ( ) ; fieldInstances . put ( field . getName ( ) , ins ) ; } } catch ( NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e ) { throw new PoijiInstantiationException ( "Cannot create a new instance of " + type . getName ( ) ) ; } return ins ;


signature:
public class PoijiHandler { /** * Modified this method so that for each time it reads a cell
 * it doesn ' t need to check all fields even after it as found
 * the matching field */
private boolean setValue ( String content , Class < ? super T > type , int column ) { } }

implementation:
// For ExcelRow annotation
if ( columnToField . containsKey ( - 1 ) ) { Field field = columnToField . get ( - 1 ) ; Object o = casting . castValue ( field . getType ( ) , valueOf ( internalCount ) , options ) ; setFieldData ( field , o , instance ) ; } if ( columnToField . containsKey ( column ) ) { Field field = columnToField . get ( column ) ; if ( columnToSuperClassField . containsKey ( column ) ) { Object ins = null ; ins = getInstance ( columnToSuperClassField . get ( column ) ) ; if ( setValue ( field , column , content , ins ) ) { setFieldData ( columnToSuperClassField . get ( column ) , ins , instance ) ; return true ; } else { return false ; } } return setValue ( field , column , content , instance ) ; } for ( Field field : type . getDeclaredFields ( ) ) { ExcelRow excelRow = field . getAnnotation ( ExcelRow . class ) ; if ( excelRow != null ) { Object o = casting . castValue ( field . getType ( ) , valueOf ( internalCount ) , options ) ; setFieldData ( field , o , instance ) ; columnToField . put ( - 1 , field ) ; } ExcelCellRange range = field . getAnnotation ( ExcelCellRange . class ) ; if ( range != null ) { Object ins = null ; ins = getInstance ( field ) ; for ( Field f : field . getType ( ) . getDeclaredFields ( ) ) { if ( setValue ( f , column , content , ins ) ) { setFieldData ( field , ins , instance ) ; columnToField . put ( column , f ) ; columnToSuperClassField . put ( column , field ) ; return true ; } } } else { if ( setValue ( field , column , content , instance ) ) { columnToField . put ( column , field ) ; return true ; } } } return false ;


signature:
public class WheelView { /** * Sets the number of items to be displayed on the wheel . */
public void setWheelItemCount ( int count ) { } }

implementation:
mItemCount = count ; mItemAngle = calculateItemAngle ( count ) ; if ( mWheelBounds != null ) { invalidate ( ) ; // TODO ?
}


signature:
public class WheelView { /** * Taken and modified from Android Source for API < 11 */
public static int resolveSizeAndState ( int size , int measureSpec ) { } }

implementation: int result = size ; int specMode = MeasureSpec . getMode ( measureSpec ) ; int specSize = MeasureSpec . getSize ( measureSpec ) ; switch ( specMode ) { case MeasureSpec . UNSPECIFIED : result = size ; break ; case MeasureSpec . AT_MOST : if ( specSize < size ) { result = specSize ; } else { result = size ; } break ; case MeasureSpec . EXACTLY : result = specSize ; break ; } return result ;


signature:
public class WheelView { /** * Sets the wheel ' s drawable that can also rotate with the items .
 * Note if the drawable has infinite lines of symmetry then you should set the wheel drawable to
 * not rotate , see { @ link # setWheelDrawableRotatable ( boolean ) } . In other words , if the drawable
 * doesn ' t look any different whilst it is rotating , you should improve the performance by
 * disabling the drawable from rotating .
 * @ see # setWheelDrawableRotatable ( boolean ) */
public void setWheelDrawable ( Drawable drawable ) { } }

implementation: mWheelDrawable = drawable ; if ( mWheelBounds != null ) { mWheelDrawable . setBounds ( mWheelBounds . getBoundingRect ( ) ) ; invalidate ( ) ; }


signature:
public class WheelView { /** * Sets the empty item drawable that is drawn when outside of the adapter range .
 * @ see # isEmptyItemPosition ( int ) */
public void setEmptyItemDrawable ( Drawable drawable ) { } }

implementation: mEmptyItemDrawable = drawable ; EMPTY_CACHE_ITEM . mDrawable = drawable ; if ( mWheelBounds != null ) { invalidate ( ) ; }


signature:
public class WheelView { /** * Set the angle of the wheel instantaneously .
 * Note this does not animate to the provided angle .
 * @ param angle given in degrees and can be any value ( not only between 0 and 360) */
public void setAngle ( float angle ) { } }

implementation: mAngle = angle ; updateSelectedPosition ( ) ; if ( mOnAngleChangeListener != null ) { mOnAngleChangeListener . onWheelAngleChange ( mAngle ) ; } invalidate ( ) ;


signature:
public class WheelView { /** * Checks to see if the selectedPosition has changed . */
private void updateSelectedPosition ( ) { } }

implementation: int position = ( int ) ( ( - mAngle + - 0.5 * Math . signum ( mAngle ) * mItemAngle ) / mItemAngle ) ; setSelectedPosition ( position ) ;


signature:
public class WheelView { /** * Invalidate the drawable at the specific position so that the next Draw call
 * will refresh the Drawable at this given position in the adapter . */
public void invalidateWheelItemDrawable ( int position ) { } }

implementation: int adapterPos = rawPositionToAdapterPosition ( position ) ; if ( isEmptyItemPosition ( adapterPos ) ) return ; CacheItem cacheItem = mItemCacheArray [ adapterPos ] ; if ( cacheItem != null ) cacheItem . mDirty = true ; invalidate ( ) ;


signature:
public class WheelView { /** * Converts the raw position to a position within the wheel item bounds .
 * @ see # rawPositionToAdapterPosition ( int )
 * @ see # rawPositionToWheelPosition ( int ) */
public int rawPositionToWheelPosition ( int position , int adapterPosition ) { } }

implementation: int circularOffset = mIsRepeatable ? ( ( int ) Math . floor ( ( position / ( float ) mAdapterItemCount ) ) * ( mAdapterItemCount - mItemCount ) ) : 0 ; return Circle . clamp ( adapterPosition + circularOffset , mItemCount ) ;


signature:
public class WheelView { /** * Estimates the wheel ' s new angle and angular velocity */
private void update ( float deltaTime ) { } }

implementation:
float vel = mAngularVelocity ; float velSqr = vel * vel ; if ( vel > 0f ) { // TODO the damping is not based on time
mAngularVelocity -= velSqr * VELOCITY_FRICTION_COEFFICIENT + CONSTANT_FRICTION_COEFFICIENT ; if ( mAngularVelocity < 0f ) mAngularVelocity = 0f ; } else if ( vel < 0f ) { mAngularVelocity -= velSqr * - VELOCITY_FRICTION_COEFFICIENT - CONSTANT_FRICTION_COEFFICIENT ; if ( mAngularVelocity > 0f ) mAngularVelocity = 0f ; } if ( mAngularVelocity != 0f ) { addAngle ( mAngularVelocity * deltaTime ) ; } else { mRequiresUpdate = false ; }


signature:
public class MainActivity { /** * get the materials darker contrast */
private int getContrastColor ( Map . Entry < String , Integer > entry ) { } }

implementation: String colorName = MaterialColor . getColorName ( entry ) ; return MaterialColor . getContrastColor ( colorName ) ;


signature:
public class Circle { /** * Clamps the value to a number between 0 and the upperLimit */
static int clamp ( int value , int upperLimit ) { } }

implementation: if ( value < 0 ) { return value + ( - 1 * ( int ) Math . floor ( value / ( float ) upperLimit ) ) * upperLimit ; } else { return value % upperLimit ; }


signature:
public class Wildcards { /** * Matches text against a wildcard pattern where ? is single letter and * is zero or more
 * letters .
 * @ param text the text to test against
 * @ param wildcard the wildcard pattern
 * @ return < code > true < / code > if the given text matches the wildcard , otherwise < code > false < / code > */
public static boolean matches ( final String text , final String wildcard ) { } }

implementation: String pattern = wildcard . replace ( "?" , "\\w" ) . replace ( "*" , "\\w*" ) ; return ( text != null && text . matches ( pattern ) ) ;


signature:
public class CoverallsReportMojo { /** * @ return source loader that extracts source files
 * @ param job the job describing the coveralls report */
protected SourceLoader createSourceLoader ( final Job job ) { } }

implementation: return new SourceLoaderFactory ( job . getGit ( ) . getBaseDir ( ) , project , sourceEncoding ) . withSourceDirectories ( sourceDirectories ) . withScanForSources ( scanForSources ) . createSourceLoader ( ) ;


signature:
public class CoverallsReportMojo { /** * Writes coverage data to JSON file .
 * @ param writer JSON writer that writes the coveralls data
 * @ param sourceCallback the source callback handler
 * @ param parsers list of coverage parsers
 * @ throws ProcessingException if process to to create JSON file fails
 * @ throws IOException if an I / O error occurs */
protected void writeCoveralls ( final JsonWriter writer , final SourceCallback sourceCallback , final List < CoverageParser > parsers ) throws ProcessingException , IOException { } }

implementation: try { getLog ( ) . info ( "Writing Coveralls data to " + writer . getCoverallsFile ( ) . getAbsolutePath ( ) + "..." ) ; long now = System . currentTimeMillis ( ) ; sourceCallback . onBegin ( ) ; for ( CoverageParser parser : parsers ) { getLog ( ) . info ( "Processing coverage report from " + parser . getCoverageFile ( ) . getAbsolutePath ( ) ) ; parser . parse ( sourceCallback ) ; } sourceCallback . onComplete ( ) ; long duration = System . currentTimeMillis ( ) - now ; getLog ( ) . info ( "Successfully wrote Coveralls data in " + duration + "ms" ) ; } finally { writer . close ( ) ; }


signature:
public class ArrayChar { /** * / * create new ArrayChar with given indexImpl and backing store .
 * Should be private .
 * @ param index use this Index
 * @ param stor . use this storage . if null , allocate .
 * @ return . new ArrayDouble . D < rank > or ArrayDouble object . */
static ArrayChar factory ( Index index , char [ ] storage ) { } }

implementation: if ( index instanceof Index0D ) { return new ArrayChar . D0 ( index , storage ) ; } else if ( index instanceof Index1D ) { return new ArrayChar . D1 ( index , storage ) ; } else if ( index instanceof Index2D ) { return new ArrayChar . D2 ( index , storage ) ; } else if ( index instanceof Index3D ) { return new ArrayChar . D3 ( index , storage ) ; } else if ( index instanceof Index4D ) { return new ArrayChar . D4 ( index , storage ) ; } else if ( index instanceof Index5D ) { return new ArrayChar . D5 ( index , storage ) ; } else if ( index instanceof Index6D ) { return new ArrayChar . D6 ( index , storage ) ; } else if ( index instanceof Index7D ) { return new ArrayChar . D7 ( index , storage ) ; } else { return new ArrayChar ( index , storage ) ; }


signature:
public class ArrayChar { /** * copy from javaArray to storage using the iterator : used by factory ( Object ) ; */
protected void copyFrom1DJavaArray ( IndexIterator iter , Object javaArray ) { } }

implementation: char [ ] ja = ( char [ ] ) javaArray ; for ( char aJa : ja ) iter . setCharNext ( aJa ) ;


signature:
public class ArrayChar { /** * Trasfer data to a ByteBuffer .
 * Note we cast char to byte , discarding top byte , if any .
 * This is because CDM char is really a byte , not a java char .
 * @ return data in a ByteBuffer */
@ Override public ByteBuffer getDataAsByteBuffer ( ) { } }

implementation: ByteBuffer bb = ByteBuffer . allocate ( ( int ) getSize ( ) ) ; resetLocalIterator ( ) ; while ( hasNext ( ) ) bb . put ( nextByte ( ) ) ; return bb ;


signature:
public class ArrayChar { /** * Create a String out of this rank one ArrayChar object .
 * If there is a null ( 0 ) value in the ArrayChar array , the String will end there .
 * The null is not returned as part of the String .
 * @ return String value of CharArray
 * @ throws IllegalArgumentException if rank ! = 1 */
public String getString ( ) { } }

implementation: int rank = getRank ( ) ; if ( rank == 0 ) { return new String ( storage ) ; } if ( rank != 1 ) throw new IllegalArgumentException ( "ArayChar.getString rank must be 1" ) ; int strLen = indexCalc . getShape ( 0 ) ; int count = 0 ; for ( int k = 0 ; k < strLen ; k ++ ) { if ( 0 == storage [ k ] ) break ; count ++ ; } return new String ( storage , 0 , count ) ;


signature:
public class ArrayChar { /** * Create a String out of this rank two ArrayChar object .
 * This treats the ArrayChar as a 1D array of Strings .
 * If there is a null ( 0 ) value in the ArrayChar array , the String will end there .
 * The null is not returned as part of the String .
 * @ param index index into 1D String array , must be < getShape ( 0 ) .
 * @ return String value
 * @ throws IllegalArgumentException if rank ! = 2 */
public String getString ( int index ) { } }

implementation: Index ima = getIndex ( ) ; return getString ( ima . set ( index ) ) ;


signature:
public class ArrayChar { /** * Create a String out of this ArrayChar object . The rank must be 1 or greater .
 * If there is a null ( 0 ) value in the ArrayChar array , the String will end there .
 * The null is not returned as part of the String .
 * If rank = 1 , then this will make a string out of the entire CharArray , ignoring ima .
 * If rank is greater than 1 , then make a String out of the characters of the last dimension ,
 * indexed by ima . This method treats the CharArray like an array of Strings , and
 * allows you to iterate over them , eg for a 2D ArrayChar :
 * < p > < code >
 * ArrayChar ca ;
 * Index ima = ca . getIndex ( ) ;
 * for ( int i = 0 ; i < ca . getShape ( ) [ 0 ] ; i + + )
 * String s = ca . getString ( ima . set0 ( i ) ) ;
 * < / code >
 * @ param ima the Index of where in the Array to start .
 * @ return String value of CharArray
 * @ throws IllegalArgumentException if rank ! = 1 */
public String getString ( Index ima ) { } }

implementation: int rank = getRank ( ) ; if ( rank == 0 ) throw new IllegalArgumentException ( "ArayChar.getString rank must not be 0" ) ; if ( rank == 1 ) return getString ( ) ; int strLen = indexCalc . getShape ( rank - 1 ) ; char [ ] carray = new char [ strLen ] ; int count = 0 ; for ( int k = 0 ; k < strLen ; k ++ ) { ima . setDim ( rank - 1 , k ) ; carray [ k ] = getChar ( ima ) ; if ( 0 == carray [ k ] ) break ; count ++ ; } return new String ( carray , 0 , count ) ;


signature:
public class ArrayChar { /** * Set the ArrayChar values from the characters in the String . Rank must be 1.
 * If String longer than ArrayChar , ignore extra chars ; if shorter , fill with 0.
 * @ param val set characters from this String
 * @ throws IllegalArgumentException if rank ! = 2 */
public void setString ( String val ) { } }

implementation: int rank = getRank ( ) ; if ( rank != 1 ) throw new IllegalArgumentException ( "ArayChar.setString rank must be 1" ) ; int arrayLen = indexCalc . getShape ( 0 ) ; int strLen = Math . min ( val . length ( ) , arrayLen ) ; for ( int k = 0 ; k < strLen ; k ++ ) storage [ k ] = val . charAt ( k ) ; char c = 0 ; for ( int k = strLen ; k < arrayLen ; k ++ ) storage [ k ] = c ;


signature:
public class ArrayChar { /** * Set the ArrayChar values from the characters in the String . Rank must be 2.
 * This treats the ArrayChar as a 1D array of Strings .
 * If String val longer than ArrayChar , ignore extra chars ; if shorter , fill with 0.
 * < p > < code >
 * String [ ] val = new String [ n ] ;
 * ArrayChar ca ;
 * Index ima = ca . getIndex ( ) ;
 * for ( int i = 0 ; i < n ; i + + )
 * ca . setString ( i , val [ i ] ) ;
 * < / code >
 * @ param index index into 1D String array , must be < getShape ( 0 ) .
 * @ param val set chars from this sString */
public void setString ( int index , String val ) { } }

implementation: int rank = getRank ( ) ; if ( rank != 2 ) throw new IllegalArgumentException ( "ArrayChar.setString rank must be 2" ) ; Index ima = getIndex ( ) ; setString ( ima . set ( index ) , val ) ;


signature:
public class ArrayChar { /** * Set the ArrayChar values from the characters in the String . Rank must be 1 or greater .
 * If String longer than ArrayChar , ignore extra chars ; if shorter , fill with 0.
 * If rank 1 , set entire ArrayChar , ignoring ima .
 * If rank > 1 , treat the ArrayChar like an array of Strings of rank - 1 , and set the
 * row indexed by ima . For example , rank 3:
 * < p > < code >
 * String [ ] [ ] val ;
 * ArrayChar ca ;
 * Index ima = ca . getIndex ( ) ;
 * int rank0 = ca . getShape ( ) [ 0 ] ;
 * int rank1 = ca . getShape ( ) [ 1 ] ;
 * for ( int i = 0 ; i < rank0 ; i + + )
 * for ( int j = 0 ; j < rank1 ; j + + ) {
 * ima . set ( i , j ) ;
 * ca . setString ( ima , val [ i ] [ j ] ) ;
 * < / code >
 * @ param ima the Index of where in the Array to start .
 * @ param val set to this value */
public void setString ( Index ima , String val ) { } }

implementation: int rank = getRank ( ) ; if ( rank == 0 ) throw new IllegalArgumentException ( "ArrayChar.setString rank must not be 0" ) ; int arrayLen = indexCalc . getShape ( rank - 1 ) ; int strLen = Math . min ( val . length ( ) , arrayLen ) ; int count = 0 ; for ( int k = 0 ; k < strLen ; k ++ ) { ima . setDim ( rank - 1 , k ) ; setChar ( ima , val . charAt ( k ) ) ; count ++ ; } char c = 0 ; for ( int k = count ; k < arrayLen ; k ++ ) { ima . setDim ( rank - 1 , k ) ; setChar ( ima , c ) ; }


signature:
public class ArrayChar { /** * Make this into the equivilent 1D ArrayObject of Strings .
 * @ return 1D ArrayObject of Strings */
public ArrayObject make1DStringArray ( ) { } }

implementation: int nelems = ( getRank ( ) == 0 ) ? 1 : ( int ) getSize ( ) / indexCalc . getShape ( getRank ( ) - 1 ) ; Array sarr = Array . factory ( DataType . STRING , new int [ ] { nelems } ) ; IndexIterator newsiter = sarr . getIndexIterator ( ) ; ArrayChar . StringIterator siter = getStringIterator ( ) ; while ( siter . hasNext ( ) ) { newsiter . setObjectNext ( siter . next ( ) ) ; } return ( ArrayObject ) sarr ;


signature:
public class ArrayChar { /** * Create an ArrayChar from a String
 * @ param s String
 * @ param max maximum length
 * @ return equivilent ArrayChar */
public static ArrayChar makeFromString ( String s , int max ) { } }

implementation: ArrayChar result = new ArrayChar . D1 ( max ) ; for ( int i = 0 ; i < max && i < s . length ( ) ; i ++ ) result . setChar ( i , s . charAt ( i ) ) ; return result ;


signature:
public class ArrayChar { /** * Create an ArrayChar from an ArrayObject of Strings .
 * @ param values ArrayObject of String
 * @ return equivilent ArrayChar , using maximum length of String . Unused are zero filled . */
public static ArrayChar makeFromStringArray ( ArrayObject values ) { } }

implementation:
// find longest string
IndexIterator ii = values . getIndexIterator ( ) ; int strlen = 0 ; while ( ii . hasNext ( ) ) { String s = ( String ) ii . next ( ) ; strlen = Math . max ( s . length ( ) , strlen ) ; } return makeFromStringArray ( values , strlen ) ;


signature:
public class ArrayChar { /** * Create an ArrayChar from an ArrayObject of Strings .
 * Inverse of make1DStringArray . Copies the data .
 * @ param values ArrayObject of String
 * @ param strlen string length dimension size
 * @ return equivilent ArrayChar . Unused are zero filled . */
public static ArrayChar makeFromStringArray ( ArrayObject values , int strlen ) { } }

implementation:
// create shape for equivilent charArray
try { Section section = new Section ( values . getShape ( ) ) ; section . appendRange ( strlen ) ; int [ ] shape = section . getShape ( ) ; long size = section . computeSize ( ) ; // populate char array
char [ ] cdata = new char [ ( int ) size ] ; int start = 0 ; IndexIterator ii = values . getIndexIterator ( ) ; while ( ii . hasNext ( ) ) { String s = ( String ) ii . next ( ) ; for ( int k = 0 ; k < s . length ( ) && k < strlen ; k ++ ) cdata [ start + k ] = s . charAt ( k ) ; start += strlen ; } // ready to create the char Array
Array carr = Array . factory ( DataType . CHAR , shape , cdata ) ; return ( ArrayChar ) carr ; } catch ( InvalidRangeException e ) { e . printStackTrace ( ) ; // cant happen .
return null ; }


signature:
public class MAMatrix { /** * Dot product of matrix and vector : return M dot v
 * @ param v dot product with this vector
 * @ return MAVector result : new vector
 * @ exception IllegalArgumentException if ncols ! = v . getSize ( ) . */
public MAVector dot ( MAVector v ) { } }

implementation: if ( ncols != v . getNelems ( ) ) throw new IllegalArgumentException ( "MAMatrix.dot " + ncols + " != " + v . getNelems ( ) ) ; ArrayDouble . D1 result = new ArrayDouble . D1 ( nrows ) ; Index imr = result . getIndex ( ) ; for ( int i = 0 ; i < nrows ; i ++ ) { double sum = 0.0 ; for ( int k = 0 ; k < ncols ; k ++ ) sum += getDouble ( i , k ) * v . getDouble ( k ) ; result . setDouble ( imr . set ( i ) , sum ) ; } return new MAVector ( result ) ;


signature:
public class MAMatrix { /** * Matrix multiply : return m1 * m2.
 * @ param m1 left matrix
 * @ param m2 right matrix
 * @ return MAMatrix result : new matrix
 * @ exception IllegalArgumentException if m1 . getNcols ( ) ! = m2 . getNrows ( ) . */
static public MAMatrix multiply ( MAMatrix m1 , MAMatrix m2 ) { } }

implementation: if ( m1 . getNcols ( ) != m2 . getNrows ( ) ) throw new IllegalArgumentException ( "MAMatrix.multiply " + m1 . getNcols ( ) + " != " + m2 . getNrows ( ) ) ; int kdims = m1 . getNcols ( ) ; ArrayDouble . D2 result = new ArrayDouble . D2 ( m1 . getNrows ( ) , m2 . getNcols ( ) ) ; Index imr = result . getIndex ( ) ; for ( int i = 0 ; i < m1 . getNrows ( ) ; i ++ ) { for ( int j = 0 ; j < m2 . getNcols ( ) ; j ++ ) { double sum = 0.0 ; for ( int k = 0 ; k < kdims ; k ++ ) sum += m1 . getDouble ( i , k ) * m2 . getDouble ( k , j ) ; result . setDouble ( imr . set ( i , j ) , sum ) ; } } return new MAMatrix ( result ) ;


signature:
public class MAMatrix { /** * Matrix multiply by a diagonal matrix , store result in this : this = this * diag
 * @ param diag diagonal matrix stored as a Vector
 * @ exception IllegalArgumentException if ncols ! = diag . getNelems ( ) . */
public void postMultiplyDiagonal ( MAVector diag ) { } }

implementation: if ( ncols != diag . getNelems ( ) ) throw new IllegalArgumentException ( "MAMatrix.postMultiplyDiagonal " + ncols + " != " + diag . getNelems ( ) ) ; for ( int i = 0 ; i < nrows ; i ++ ) { for ( int j = 0 ; j < ncols ; j ++ ) { double val = a . getDouble ( ima . set ( i , j ) ) * diag . getDouble ( j ) ; a . setDouble ( ima , val ) ; } }


signature:
public class CfsrLocalTables { /** * Reference time is the start time of the first forecast , other forecasts at 6 - hour intervals . Number in Ave = number of forecast used */
@ Override public int [ ] getForecastTimeIntervalOffset ( Grib2Record gr ) { } }

implementation:
Grib2Pds pds = gr . getPDS ( ) ; if ( ! pds . isTimeInterval ( ) ) { return null ; } // LOOK this is hack for CFSR monthly combobulation
// see http : / / rda . ucar . edu / datasets / ds093.2 / # docs / time _ ranges . html
int statType = pds . getOctet ( 47 ) ; int n = pds . getInt4StartingAtOctet ( 50 ) ; int p2 = pds . getInt4StartingAtOctet ( 55 ) ; int p2mp1 = pds . getInt4StartingAtOctet ( 62 ) ; int p1 = p2 - p2mp1 ; int start , end ; switch ( statType ) { case 193 : start = p1 ; end = p1 + n * p2 ; break ; case 194 : start = 0 ; end = n * p2 ; break ; case 195 : case 204 : case 205 : start = p1 ; end = p2 ; break ; default : throw new IllegalArgumentException ( "unknown statType " + statType ) ; } return new int [ ] { start , end } ;


signature:
public class CfsrLocalTables { /** * see http : / / www . nco . ncep . noaa . gov / pmb / docs / grib2 / grib2 _ doc . shtml */
private void initLocalTable ( ) { } }

implementation:
String tableName = config . getPath ( ) ; ClassLoader cl = this . getClass ( ) . getClassLoader ( ) ; try ( InputStream is = cl . getResourceAsStream ( tableName ) ) { if ( is == null ) { throw new IllegalStateException ( "Cant find " + tableName ) ; } try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( is , CDM . utf8Charset ) ) ) { while ( true ) { String line = br . readLine ( ) ; if ( line == null ) { break ; } if ( ( line . length ( ) == 0 ) || line . startsWith ( "#" ) ) { continue ; } String [ ] flds = StringUtil2 . splitString ( line ) ; int p1 = Integer . parseInt ( flds [ 0 ] . trim ( ) ) ; // must have a number
int p2 = Integer . parseInt ( flds [ 1 ] . trim ( ) ) ; // must have a number
int p3 = Integer . parseInt ( flds [ 2 ] . trim ( ) ) ; // must have a number
StringBuilder b = new StringBuilder ( ) ; int count = 3 ; while ( count < flds . length && ! flds [ count ] . equals ( "." ) ) { b . append ( flds [ count ++ ] ) . append ( ' ' ) ; } String abbrev = b . toString ( ) . trim ( ) ; b . setLength ( 0 ) ; count ++ ; while ( count < flds . length && ! flds [ count ] . equals ( "." ) ) { b . append ( flds [ count ++ ] ) . append ( ' ' ) ; } String name = b . toString ( ) . trim ( ) ; b . setLength ( 0 ) ; count ++ ; while ( count < flds . length && ! flds [ count ] . equals ( "." ) ) { b . append ( flds [ count ++ ] ) . append ( ' ' ) ; } String unit = b . toString ( ) . trim ( ) ; Grib2Parameter s = new Grib2Parameter ( p1 , p2 , p3 , name , unit , abbrev , null ) ; local . put ( makeParamId ( p1 , p2 , p3 ) , s ) ; } } } catch ( IOException ioe ) { throw new RuntimeException ( ioe ) ; }


signature:
public class ContourFeatureRenderer { /** * Overrides the GisFeatureRenderer draw ( ) method , to draw contours
 * and with contour labels .
 * @ param g the Graphics2D context on which to draw
 * @ param deviceFromNormalAT transforms " Normalized Device " to Device coordinates */
public void draw ( java . awt . Graphics2D g , AffineTransform deviceFromNormalAT ) { } }

implementation:
/* OLD WAY
 / / make & set desired font for contour label .
 / / contour label size in " points " is last arg
 Font font1 = new Font ( " Helvetica " , Font . PLAIN , 25 ) ;
 / / make a transform to un - flip the font
 AffineTransform unflip = AffineTransform . getScaleInstance ( 1 , - 1 ) ;
 Font font = font1 . deriveFont ( unflip ) ;
 g . setFont ( font ) ; */
/* from original GisFeatureRenderer method draw : */
g . setColor ( Color . black ) ; g . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_OFF ) ; g . setStroke ( new java . awt . BasicStroke ( 0.0f ) ) ; Rectangle2D clipRect = ( Rectangle2D ) g . getClip ( ) ; Iterator siter = getShapes ( g , deviceFromNormalAT ) ; // draw the contours
while ( siter . hasNext ( ) ) { Shape s = ( Shape ) siter . next ( ) ; Rectangle2D shapeBounds = s . getBounds2D ( ) ; if ( shapeBounds . intersects ( clipRect ) ) g . draw ( s ) ; } // additional code beyond GisFeatureRenderer method draw ( ) :
// render contour value for this contour line . * /
if ( ShowLabels ) { Font f = FontUtil . getStandardFont ( 10 ) . getFont ( ) ; Font saveFont = g . getFont ( ) ; // use world coordinates for position , but draw in " normal " coordinates
// so that the symbols stay the same size
AffineTransform deviceFromWorldAT = g . getTransform ( ) ; AffineTransform normalFromWorldAT ; // transform World to Normal coords :
// normalFromWorldAT = deviceFromNormalAT - 1 * deviceFromWorldAT
try { normalFromWorldAT = deviceFromNormalAT . createInverse ( ) ; normalFromWorldAT . concatenate ( deviceFromWorldAT ) ; } catch ( java . awt . geom . NoninvertibleTransformException e ) { System . out . println ( " ContourFeatureRenderer: NoninvertibleTransformException on " + deviceFromNormalAT ) ; return ; } g . setTransform ( deviceFromNormalAT ) ; // so g now wants " normal coords "
g . setFont ( f ) ; siter = getShapes ( g , deviceFromNormalAT ) ; Iterator CViter = contourList . iterator ( ) ; Point2D worldPt = new Point2D . Double ( ) ; Point2D normalPt = new Point2D . Double ( ) ; float [ ] coords = new float [ 6 ] ; while ( siter . hasNext ( ) ) { Shape s = ( Shape ) siter . next ( ) ; double contValue = ( ( ContourFeature ) CViter . next ( ) ) . getContourValue ( ) ; // get position xpos , ypos on this contour where to put label
// in current world coordinates in the current Shape s .
PathIterator piter = s . getPathIterator ( null ) ; // int cs , count = - 1 ; original
int cs , count = 12 ; while ( ! piter . isDone ( ) ) { count ++ ; if ( count % 25 == 0 ) { // for every 25th position on this path
cs = piter . currentSegment ( coords ) ; if ( cs == PathIterator . SEG_MOVETO || cs == PathIterator . SEG_LINETO ) { worldPt . setLocation ( coords [ 0 ] , coords [ 1 ] ) ; normalFromWorldAT . transform ( worldPt , normalPt ) ; // convert to normal
// render the contour value to the screen
g . drawString ( Format . d ( contValue , 4 ) , ( int ) normalPt . getX ( ) , ( int ) normalPt . getY ( ) ) ; } } piter . next ( ) ; } // while not done
} // end while shape . hasNext ( )
// restore original transform and font
g . setTransform ( deviceFromWorldAT ) ; g . setFont ( saveFont ) ; } // end if ShowLabels = = true
if ( Debug . isSet ( "contour/doLabels" ) ) { // get iterator to the class member ArrayList of GisFeature - s
for ( Object aContourList : contourList ) { // ContourFeature cf = iter . next ( ) ;
System . out . println ( " ContourFeatureRenderer: contour value = " + ( ( ContourFeature ) aContourList ) . getContourValue ( ) ) ; } }


signature:
public class IndependentWindow { /** * show the window . */
public void show ( ) { } }

implementation:
setState ( Frame . NORMAL ) ; // deiconify if needed
super . toFront ( ) ; // need to put on event thread
SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { IndependentWindow . super . show ( ) ; } } ) ;


signature:
public class IndependentWindow { /** * show if not iconified */
public void showIfNotIconified ( ) { } }

implementation:
if ( getState ( ) == Frame . ICONIFIED ) return ; // need to put on event thread
SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { IndependentWindow . super . show ( ) ; } } ) ;


signature:
public class Giniiosp { /** * all the work is here , so can be called recursively */
private Array readData ( ucar . nc2 . Variable v2 , long dataPos , List < Range > ranges , int [ ] levels ) throws IOException , InvalidRangeException { } }

implementation:
// Get to the proper offset and read in the data
raf . seek ( dataPos ) ; int data_size = ( int ) ( raf . length ( ) - dataPos ) ; byte [ ] data = new byte [ data_size ] ; raf . readFully ( data ) ; // Turn it into an array
Array array = makeArray ( data , levels , v2 . getShape ( ) ) ; return array . sectionNoReduce ( ranges ) ;


signature:
public class Giniiosp { /** * for the compressed data read all out into a array and then parse into requested */
private Array readCompressedData ( ucar . nc2 . Variable v2 , long dataPos , List < Range > ranges , int [ ] levels ) throws IOException , InvalidRangeException { } }

implementation:
// Get to the proper offset and read in the rest of the compressed data
raf . seek ( dataPos ) ; int data_size = ( int ) ( raf . length ( ) - dataPos ) ; byte [ ] data = new byte [ data_size ] ; raf . readFully ( data ) ; // Send the compressed data to ImageIO ( to handle PNG )
ByteArrayInputStream ios = new ByteArrayInputStream ( data ) ; BufferedImage image = javax . imageio . ImageIO . read ( ios ) ; // LOOK why ImageIO ? ?
DataBuffer db = image . getData ( ) . getDataBuffer ( ) ; // If the image had byte data , turn into an array
if ( db instanceof DataBufferByte ) { DataBufferByte dbb = ( DataBufferByte ) db ; Array array = makeArray ( dbb . getData ( ) , levels , v2 . getShape ( ) ) ; if ( levels == null ) v2 . setCachedData ( array , false ) ; return array . sectionNoReduce ( ranges ) ; } return null ;


signature:
public class CFGridWriter2 { /** * Compute the size of the file without writing
 * @ param gds the GridDataset
 * @ param gridList the list of variables to be written , or null for all
 * @ param llbb the lat / lon bounding box , or null for all
 * @ param projRect the projection bounding box , or null for all
 * @ param horizStride the x and y stride
 * @ param zRange the z stride
 * @ param dateRange date range , or null for all
 * @ param stride _ time the time stride
 * @ param addLatLon add 2D lat / lon coordinates if needed
 * @ return total bytes written
 * @ throws IOException
 * @ throws InvalidRangeException */
static public long makeSizeEstimate ( ucar . nc2 . dt . GridDataset gds , List < String > gridList , LatLonRect llbb , ProjectionRect projRect , int horizStride , Range zRange , CalendarDateRange dateRange , int stride_time , boolean addLatLon ) throws IOException , InvalidRangeException { } }

implementation: CFGridWriter2 writer2 = new CFGridWriter2 ( ) ; return writer2 . writeOrTestSize ( gds , gridList , llbb , projRect , horizStride , zRange , dateRange , stride_time , addLatLon , true , null ) ;


signature:
public class CFGridWriter2 { /** * Write a netcdf / CF file from a GridDataset
 * @ param gds the GridDataset
 * @ param gridList the list of variables to be written , or null for all
 * @ param llbb the lat / lon bounding box , or null for all
 * @ param projRect the projection bounding box , or null for all
 * @ param horizStride the x and y stride
 * @ param zRange the z stride
 * @ param dateRange date range , or null for all
 * @ param stride _ time the time stride
 * @ param addLatLon add 2D lat / lon coordinates if needed
 * @ param writer this does the actual writing
 * @ return total bytes written
 * @ throws IOException
 * @ throws InvalidRangeException */
static public long writeFile ( ucar . nc2 . dt . GridDataset gds , List < String > gridList , LatLonRect llbb , ProjectionRect projRect , int horizStride , Range zRange , CalendarDateRange dateRange , int stride_time , boolean addLatLon , NetcdfFileWriter writer ) throws IOException , InvalidRangeException { } }

implementation: CFGridWriter2 writer2 = new CFGridWriter2 ( ) ; return writer2 . writeOrTestSize ( gds , gridList , llbb , projRect , horizStride , zRange , dateRange , stride_time , addLatLon , false , writer ) ;


signature:
public class Level2VolumeScan { /** * Write equivilent uncompressed version of the file .
 * @ param inputRaf file to uncompress
 * @ param ufilename write to this file
 * @ return raf of uncompressed file
 * @ throws IOException on read error */
private RandomAccessFile uncompress ( RandomAccessFile inputRaf , String ufilename ) throws IOException { } }

implementation:
RandomAccessFile outputRaf = new RandomAccessFile ( ufilename , "rw" ) ; FileLock lock ; while ( true ) { // loop waiting for the lock
try { lock = outputRaf . getRandomAccessFile ( ) . getChannel ( ) . lock ( 0 , 1 , false ) ; break ; } catch ( OverlappingFileLockException oe ) { // not sure why lock ( ) doesnt block
try { Thread . sleep ( 100 ) ; // msecs
} catch ( InterruptedException e1 ) { } } catch ( IOException e ) { outputRaf . close ( ) ; throw e ; } } try { inputRaf . seek ( 0 ) ; byte [ ] header = new byte [ Level2Record . FILE_HEADER_SIZE ] ; int bytesRead = inputRaf . read ( header ) ; if ( bytesRead != header . length ) { throw new IOException ( "Error reading NEXRAD2 header -- got " + bytesRead + " rather than" + header . length ) ; } outputRaf . write ( header ) ; boolean eof = false ; int numCompBytes ; byte [ ] ubuff = new byte [ 40000 ] ; byte [ ] obuff = new byte [ 40000 ] ; CBZip2InputStream cbzip2 = new CBZip2InputStream ( ) ; while ( ! eof ) { try { numCompBytes = inputRaf . readInt ( ) ; if ( numCompBytes == - 1 ) { if ( log . isDebugEnabled ( ) ) log . debug ( "  done: numCompBytes=-1 " ) ; break ; } } catch ( EOFException ee ) { log . debug ( "got EOFException" ) ; break ; // assume this is ok
} if ( log . isDebugEnabled ( ) ) { log . debug ( "reading compressed bytes " + numCompBytes + " input starts at " + inputRaf . getFilePointer ( ) + "; output starts at " + outputRaf . getFilePointer ( ) ) ; } /* * For some stupid reason , the last block seems to
 * have the number of bytes negated . So , we just
 * assume that any negative number ( other than - 1)
 * is the last block and go on our merry little way . */
if ( numCompBytes < 0 ) { if ( log . isDebugEnabled ( ) ) log . debug ( "last block?" + numCompBytes ) ; numCompBytes = - numCompBytes ; eof = true ; } byte [ ] buf = new byte [ numCompBytes ] ; inputRaf . readFully ( buf ) ; ByteArrayInputStream bis = new ByteArrayInputStream ( buf , 2 , numCompBytes - 2 ) ; // CBZip2InputStream cbzip2 = new CBZip2InputStream ( bis ) ;
cbzip2 . setStream ( bis ) ; int total = 0 ; int nread ; /* while ( ( nread = cbzip2 . read ( ubuff ) ) ! = - 1 ) {
 dout2 . write ( ubuff , 0 , nread ) ;
 total + = nread ; */
try { while ( ( nread = cbzip2 . read ( ubuff ) ) != - 1 ) { if ( total + nread > obuff . length ) { byte [ ] temp = obuff ; obuff = new byte [ temp . length * 2 ] ; System . arraycopy ( temp , 0 , obuff , 0 , temp . length ) ; } System . arraycopy ( ubuff , 0 , obuff , total , nread ) ; total += nread ; } if ( obuff . length >= 0 ) outputRaf . write ( obuff , 0 , total ) ; } catch ( BZip2ReadException ioe ) { log . warn ( "Nexrad2IOSP.uncompress " , ioe ) ; } float nrecords = ( float ) ( total / 2432.0 ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "  unpacked " + total + " num bytes " + nrecords + " records; ouput ends at " + outputRaf . getFilePointer ( ) ) ; } outputRaf . flush ( ) ; } catch ( IOException e ) { if ( outputRaf != null ) outputRaf . close ( ) ; // dont leave bad files around
File ufile = new File ( ufilename ) ; if ( ufile . exists ( ) ) { if ( ! ufile . delete ( ) ) log . warn ( "failed to delete uncompressed file (IOException)" + ufilename ) ; } throw e ; } finally { try { if ( lock != null ) lock . release ( ) ; } catch ( IOException e ) { if ( outputRaf != null ) outputRaf . close ( ) ; throw e ; } } return outputRaf ;


signature:
public class Grib1RecordScanner { /** * Count the number of records in a grib1 file . */
public static void main ( String [ ] args ) throws IOException { } }

implementation: int count = 0 ; String file = ( args . length > 0 ) ? args [ 0 ] : "Q:/cdmUnitTest/formats/grib1/ECMWF.hybrid.grib1" ; RandomAccessFile raf = new RandomAccessFile ( file , "r" ) ; System . out . printf ( "Read %s%n" , raf . getLocation ( ) ) ; Grib1RecordScanner scan = new Grib1RecordScanner ( raf ) ; while ( scan . hasNext ( ) ) { scan . next ( ) ; count ++ ; } raf . close ( ) ; System . out . printf ( "count=%d%n" , count ) ;


signature:
public class UnitName { /** * Factory method for constructing a UnitName from a name and a plural form
 * of the name .
 * @ param name
 * The name of the unit . Shall not be < code >
 * null < / code > .
 * @ param plural
 * The plural form of the name . May be < code >
 * null < / code > , in which
 * case regular plural - forming rules are used to construct the
 * plural form from the name .
 * @ throws NameException
 * < code > name = = null < / code > . */
public static UnitName newUnitName ( final String name , final String plural ) throws NameException { } }

implementation: return newUnitName ( name , plural , null ) ;


signature:
public class UnitName { /** * Factory method for constructing a UnitName from a name , a plural form of
 * the name , and a symbol .
 * @ param name
 * The name of the unit . Shall not be < code >
 * null < / code > .
 * @ param plural
 * The plural form of the name . May be < code >
 * null < / code > , in which
 * case regular plural - forming rules are used to construct the
 * plural form from the name .
 * @ param symbol
 * The symbol for the unit . May be < code > null
 * < / code > .
 * @ throws NameException
 * < code > name = = null < / code > . */
public static UnitName newUnitName ( final String name , final String plural , final String symbol ) throws NameException { } }

implementation: return new UnitName ( name , plural , symbol ) ;


signature:
public class UnitName { /** * Returns the plural form of a name . Regular rules are used to generate the
 * plural form .
 * @ param name
 * The name .
 * @ return The plural form of the name . */
protected String makePlural ( final String name ) { } }

implementation: String plural ; final int length = name . length ( ) ; final char lastChar = name . charAt ( length - 1 ) ; if ( lastChar != 'y' ) { plural = name + ( lastChar == 's' || lastChar == 'x' || lastChar == 'z' || name . endsWith ( "ch" ) ? "es" : "s" ) ; } else { if ( length == 1 ) { plural = name + "s" ; } else { final char penultimateChar = name . charAt ( length - 2 ) ; plural = ( penultimateChar == 'a' || penultimateChar == 'e' || penultimateChar == 'i' || penultimateChar == 'o' || penultimateChar == 'u' ) ? name + "s" : name . substring ( 0 , length - 1 ) + "ies" ; } } return plural ;


signature:
public class DateRange { /** * choose a resolution based on # seconds */
private String chooseResolution ( double time ) { } }

implementation:
if ( time < 180 ) // 3 minutes
return "secs" ; time /= 60 ; // minutes
if ( time < 180 ) // 3 hours
return "minutes" ; time /= 60 ; // hours
if ( time < 72 ) // 3 days
return "hours" ; time /= 24 ; // days
if ( time < 90 ) // 3 months
return "days" ; time /= 30 ; // months
if ( time < 36 ) // 3 years
return "months" ; return "years" ;


signature:
public class DateRange { /** * Determine if the given date is included in this date range .
 * The date range includes the start and end dates .
 * @ param d date to check
 * @ return true if date in inside this range */
public boolean included ( Date d ) { } }

implementation: if ( isEmpty ) return false ; if ( getStart ( ) . after ( d ) ) return false ; if ( getEnd ( ) . before ( d ) ) return false ; return true ;


signature:
public class DateRange { /** * Determine if the given range intersects this date range .
 * @ param start _ want range starts here
 * @ param end _ want range ends here
 * @ return true if ranges intersect */
public boolean intersects ( Date start_want , Date end_want ) { } }

implementation: if ( isEmpty ) return false ; if ( getStart ( ) . after ( end_want ) ) return false ; if ( getEnd ( ) . before ( start_want ) ) return false ; return true ;


signature:
public class DateRange { /** * Determine if the given range intersects this date range .
 * @ param other date range
 * @ return true if ranges intersect */
public boolean intersects ( DateRange other ) { } }

implementation: return intersects ( other . getStart ( ) . getDate ( ) , other . getEnd ( ) . getDate ( ) ) ;


signature:
public class DateRange { /** * Intersect with another date range
 * @ param clip intersect with this date range
 * @ return new date range that is the intersection */
public DateRange intersect ( DateRange clip ) { } }

implementation: if ( isEmpty ) return this ; if ( clip . isEmpty ) return clip ; DateType ss = getStart ( ) ; DateType s = ss . before ( clip . getStart ( ) ) ? clip . getStart ( ) : ss ; DateType ee = getEnd ( ) ; DateType e = ee . before ( clip . getEnd ( ) ) ? ee : clip . getEnd ( ) ; return new DateRange ( s , e , null , resolution ) ;


signature:
public class DateRange { /** * Extend this date range by the given one .
 * @ param dr given DateRange */
public void extend ( DateRange dr ) { } }

implementation: boolean localEmpty = isEmpty ; if ( localEmpty || dr . getStart ( ) . before ( getStart ( ) ) ) setStart ( dr . getStart ( ) ) ; if ( localEmpty || getEnd ( ) . before ( dr . getEnd ( ) ) ) setEnd ( dr . getEnd ( ) ) ;


signature:
public class DateRange { /** * Extend this date range by the given Date .
 * @ param d given Date */
public void extend ( Date d ) { } }

implementation: if ( d . before ( getStart ( ) . getDate ( ) ) ) setStart ( new DateType ( false , d ) ) ; if ( getEnd ( ) . before ( d ) ) setEnd ( new DateType ( false , d ) ) ;


signature:
public class DateRange { /** * Set the starting Date . Makes useStart true .
 * If useEnd , recalculate the duration , else recalculate end .
 * @ param start starting Date */
public void setStart ( DateType start ) { } }

implementation: this . start = start ; useStart = true ; if ( useEnd ) { this . isMoving = this . start . isPresent ( ) || this . end . isPresent ( ) ; useDuration = false ; recalcDuration ( ) ; } else { this . isMoving = this . start . isPresent ( ) ; this . end = this . start . add ( duration ) ; } checkIfEmpty ( ) ;


signature:
public class DateRange { /** * Set the ending Date . Makes useEnd true .
 * If useStart , recalculate the duration , else recalculate start .
 * @ param end ending Date */
public void setEnd ( DateType end ) { } }

implementation: this . end = end ; useEnd = true ; if ( useStart ) { this . isMoving = this . start . isPresent ( ) || this . end . isPresent ( ) ; useDuration = false ; recalcDuration ( ) ; } else { this . isMoving = this . end . isPresent ( ) ; this . start = this . end . subtract ( duration ) ; } checkIfEmpty ( ) ;


signature:
public class DateRange { /** * Set the duration of the interval . Makes useDuration true .
 * If useStart , recalculate end , else recalculate start .
 * @ param duration duration of the interval */
public void setDuration ( TimeDuration duration ) { } }

implementation: this . duration = duration ; useDuration = true ; if ( useStart ) { this . isMoving = this . start . isPresent ( ) ; this . end = this . start . add ( duration ) ; useEnd = false ; } else { this . isMoving = this . end . isPresent ( ) ; this . start = this . end . subtract ( duration ) ; } checkIfEmpty ( ) ;


signature:
public class DateRange { /** * assumes not moving */
private void recalcDuration ( ) { } }

implementation:
long min = getStart ( ) . getDate ( ) . getTime ( ) ; long max = getEnd ( ) . getDate ( ) . getTime ( ) ; double secs = .001 * ( max - min ) ; if ( secs < 0 ) secs = 0 ; if ( duration == null ) { try { duration = new TimeDuration ( chooseResolution ( secs ) ) ; } catch ( ParseException e ) { // cant happen
throw new RuntimeException ( e ) ; } } if ( resolution == null ) { duration . setValueInSeconds ( secs ) ; } else { // make it a multiple of resolution
double resSecs = resolution . getValueInSeconds ( ) ; double closest = Math . round ( secs / resSecs ) ; secs = closest * resSecs ; duration . setValueInSeconds ( secs ) ; } hashCode = 0 ;


signature:
public class GridUI { /** * save all data in the PersistentStore */
public void storePersistentData ( ) { } }

implementation:
store . putInt ( "vertSplit" , splitDraw . getDividerLocation ( ) ) ; store . putBoolean ( "navToolbarAction" , ( ( Boolean ) navToolbarAction . getValue ( BAMutil . STATE ) ) . booleanValue ( ) ) ; store . putBoolean ( "moveToolbarAction" , ( ( Boolean ) moveToolbarAction . getValue ( BAMutil . STATE ) ) . booleanValue ( ) ) ; if ( projManager != null ) projManager . storePersistentData ( ) ; /* if ( csManager ! = null )
 csManager . storePersistentData ( ) ;
 if ( sysConfigDialog ! = null )
 sysConfigDialog . storePersistentData ( ) ; */
dsTable . save ( ) ; dsTable . getPrefs ( ) . putBeanObject ( "DialogBounds" , dsDialog . getBounds ( ) ) ; store . put ( GEOTIFF_FILECHOOSER_DEFAULTDIR , geotiffFileChooser . getCurrentDirectory ( ) ) ; controller . storePersistentData ( ) ;


signature:
public class GridUI { /** * add a MapBean to the User Interface */
public void addMapBean ( MapBean mb ) { } }

implementation:
mapBeanMenu . addAction ( mb . getActionDesc ( ) , mb . getIcon ( ) , mb . getAction ( ) ) ; // first one is the " default "
if ( mapBeanCount == 0 ) { setMapRenderer ( mb . getRenderer ( ) ) ; } mapBeanCount ++ ; mb . addPropertyChangeListener ( new PropertyChangeListener ( ) { public void propertyChange ( java . beans . PropertyChangeEvent e ) { if ( e . getPropertyName ( ) . equals ( "Renderer" ) ) { setMapRenderer ( ( Renderer ) e . getNewValue ( ) ) ; } } } ) ;


signature:
public class GridUI { /** * actions that control the dataset */
private void makeActionsDataset ( ) { } }

implementation:
// choose local dataset
AbstractAction chooseLocalDatasetAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { String filename = fileChooser . chooseFilename ( ) ; if ( filename == null ) return ; Dataset invDs ; try { invDs = Dataset . makeStandalone ( filename , FeatureType . GRID . toString ( ) , "" , ServiceType . File . toString ( ) ) ; } catch ( Exception ue ) { JOptionPane . showMessageDialog ( GridUI . this , "Invalid filename = <" + filename + ">\n" + ue . getMessage ( ) ) ; ue . printStackTrace ( ) ; return ; } setDataset ( invDs ) ; } } ; BAMutil . setActionProperties ( chooseLocalDatasetAction , "FileChooser" , "open Local dataset..." , false , 'L' , - 1 ) ; /* saveDatasetAction = new AbstractAction ( ) {
 public void actionPerformed ( ActionEvent e ) {
 String fname = controller . getDatasetName ( ) ;
 if ( fname ! = null ) {
 savedDatasetList . add ( fname ) ;
 BAMutil . addActionToMenu ( savedDatasetMenu , new DatasetAction ( fname ) , 0 ) ;
 BAMutil . setActionProperties ( saveDatasetAction , null , " save dataset " , false , ' S ' , 0 ) ; */
// Configure
chooseProjectionAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { getProjectionManager ( ) . setVisible ( ) ; } } ; BAMutil . setActionProperties ( chooseProjectionAction , null , "Projection Manager..." , false , 'P' , 0 ) ; saveCurrentProjectionAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { getProjectionManager ( ) ; // set the bounding box
ProjectionImpl proj = panz . getProjectionImpl ( ) . constructCopy ( ) ; proj . setDefaultMapArea ( panz . getMapArea ( ) ) ; // if ( debug ) System . out . println ( " GV save projection " + proj ) ;
// projManage . setMap ( renderAll . get ( " Map " ) ) ; LOOK !
// projManager . saveProjection ( proj ) ;
} } ; BAMutil . setActionProperties ( saveCurrentProjectionAction , null , "save Current Projection" , false , 'S' , 0 ) ; /* chooseColorScaleAction = new AbstractAction ( ) {
 public void actionPerformed ( ActionEvent e ) {
 if ( null = = csManager ) / / lazy instantiation
 makeColorScaleManager ( ) ;
 csManager . show ( ) ;
 BAMutil . setActionProperties ( chooseColorScaleAction , null , " ColorScale Manager . . . " , false , ' C ' , 0 ) ; */
// redraw
redrawAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { repaint ( ) ; controller . start ( true ) ; controller . draw ( true ) ; } } ; BAMutil . setActionProperties ( redrawAction , "alien" , "RedRaw" , false , 'W' , 0 ) ; showDatasetInfoAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { if ( infoWindow == null ) { datasetInfoTA = new TextHistoryPane ( ) ; infoWindow = new IndependentWindow ( "Dataset Information" , BAMutil . getImage ( "GDVs" ) , datasetInfoTA ) ; infoWindow . setSize ( 700 , 700 ) ; infoWindow . setLocation ( 100 , 100 ) ; } datasetInfoTA . clear ( ) ; datasetInfoTA . appendLine ( controller . getDatasetInfo ( ) ) ; datasetInfoTA . gotoTop ( ) ; infoWindow . show ( ) ; } } ; BAMutil . setActionProperties ( showDatasetInfoAction , "Information" , "Show info..." , false , 'S' , - 1 ) ; showNcMLAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { if ( ncmlWindow == null ) { ncmlTA = new TextHistoryPane ( ) ; ncmlWindow = new IndependentWindow ( "Dataset NcML" , BAMutil . getImage ( "GDVs" ) , ncmlTA ) ; ncmlWindow . setSize ( 700 , 700 ) ; ncmlWindow . setLocation ( 200 , 70 ) ; } ncmlTA . clear ( ) ; // datasetInfoTA . appendLine ( " GeoGrid XML for " + controller . getDatasetName ( ) + " \ n " ) ;
ncmlTA . appendLine ( controller . getNcML ( ) ) ; ncmlTA . gotoTop ( ) ; ncmlWindow . show ( ) ; } } ; BAMutil . setActionProperties ( showNcMLAction , null , "Show NcML..." , false , 'X' , - 1 ) ; showGridDatasetInfoAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { if ( ncmlWindow == null ) { ncmlTA = new TextHistoryPane ( ) ; ncmlWindow = new IndependentWindow ( "Dataset NcML" , BAMutil . getImage ( "GDVs" ) , ncmlTA ) ; ncmlWindow . setSize ( 700 , 700 ) ; ncmlWindow . setLocation ( 200 , 70 ) ; } ncmlTA . clear ( ) ; // datasetInfoTA . appendLine ( " GeoGrid XML for " + controller . getDatasetName ( ) + " \ n " ) ;
ncmlTA . appendLine ( controller . getDatasetXML ( ) ) ; ncmlTA . gotoTop ( ) ; ncmlWindow . show ( ) ; } } ; BAMutil . setActionProperties ( showGridDatasetInfoAction , null , "Show GridDataset Info XML..." , false , 'X' , - 1 ) ; // show gridTable
showGridTableAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { gtWindow . show ( ) ; } } ; BAMutil . setActionProperties ( showGridTableAction , "Table" , "grid Table..." , false , 'T' , - 1 ) ; // show netcdf dataset Table
showNetcdfDatasetAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { NetcdfDataset netcdfDataset = controller . getNetcdfDataset ( ) ; if ( null != netcdfDataset ) { try { dsTable . setDataset ( netcdfDataset , null ) ; } catch ( IOException e1 ) { e1 . printStackTrace ( ) ; return ; } dsDialog . show ( ) ; } } } ; BAMutil . setActionProperties ( showNetcdfDatasetAction , "netcdf" , "NetcdfDataset Table Info..." , false , 'D' , - 1 ) ; /* write geotiff file
 geotiffAction = new AbstractAction ( ) {
 public void actionPerformed ( ActionEvent e ) {
 GeoGrid grid = controller . getCurrentField ( ) ;
 ucar . ma2 . Array data = controller . getCurrentHorizDataSlice ( ) ;
 if ( ( grid = = null ) | | ( data = = null ) ) return ;
 String filename = geotiffFileChooser . chooseFilename ( ) ;
 if ( filename = = null ) return ;
 GeoTiff geotiff = null ;
 try {
 / * System . out . println ( " write to = " + filename ) ;
 ucar . nc2 . geotiff . Writer . write2D ( grid , data , filename + " . tfw " ) ;
 geotiff = new GeoTiff ( filename ) ; / / read back in
 geotiff . read ( ) ;
 System . out . println ( geotiff . showInfo ( ) ) ;
 / / geotiff . testReadData ( ) ;
 geotiff . close ( ) ; * /
 / / write two
 ucar . nc2 . geotiff . GeotiffWriter writer = new ucar . nc2 . geotiff . GeotiffWriter ( filename ) ;
 writer . writeGrid ( grid , data , false ) ;
 geotiff = new GeoTiff ( filename ) ; / / read back in
 geotiff . read ( ) ;
 System . out . println ( " * * * * * " ) ;
 System . out . println ( geotiff . showInfo ( ) ) ;
 / / geotiff . testReadData ( ) ;
 geotiff . close ( ) ;
 } catch ( IOException ioe ) {
 ioe . printStackTrace ( ) ;
 } finally {
 try {
 if ( geotiff ! = null ) geotiff . close ( ) ;
 } catch ( IOException ioe ) { }
 BAMutil . setActionProperties ( geotiffAction , " Geotiff " , " Write Geotiff file " , false , ' G ' , - 1 ) ; */
minmaxHorizAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { csDataMinMax . setSelectedItem ( ColorScale . MinMaxType . horiz ) ; controller . setDataMinMaxType ( ColorScale . MinMaxType . horiz ) ; } } ; BAMutil . setActionProperties ( minmaxHorizAction , null , "Horizontal plane" , false , 'H' , 0 ) ; minmaxLogAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { csDataMinMax . setSelectedItem ( ColorScale . MinMaxType . log ) ; controller . setDataMinMaxType ( ColorScale . MinMaxType . log ) ; } } ; BAMutil . setActionProperties ( minmaxLogAction , null , "log horiz plane" , false , 'V' , 0 ) ; /* minmaxVolAction = new AbstractAction ( ) {
 public void actionPerformed ( ActionEvent e ) {
 csDataMinMax . setSelectedIndex ( GridRenderer . VOL _ MinMaxType ) ;
 controller . setDataMinMaxType ( GridRenderer . MinMaxType . vert ;
 BAMutil . setActionProperties ( minmaxVolAction , null , " Grid volume " , false , ' G ' , 0 ) ; */
minmaxHoldAction = new AbstractAction ( ) { public void actionPerformed ( ActionEvent e ) { csDataMinMax . setSelectedItem ( ColorScale . MinMaxType . hold ) ; controller . setDataMinMaxType ( ColorScale . MinMaxType . hold ) ; } } ; BAMutil . setActionProperties ( minmaxHoldAction , null , "Hold scale constant" , false , 'C' , 0 ) ; fieldLoopAction = new LoopControlAction ( fieldChooser ) ; levelLoopAction = new LoopControlAction ( levelChooser ) ; timeLoopAction = new LoopControlAction ( timeChooser ) ;


signature:
public class OceanSG1 { /** * Get the 3D vertical coordinate array for this time step .
 * @ param timeIndex the time index . Ignored if ! isTimeDependent ( ) .
 * @ return vertical coordinate array
 * @ throws java . io . IOException problem reading data
 * @ throws ucar . ma2 . InvalidRangeException _ more _ */
public ArrayDouble . D3 getCoordinateArray ( int timeIndex ) throws IOException , InvalidRangeException { } }

implementation: Array etaArray = readArray ( etaVar , timeIndex ) ; Array sArray = readArray ( sVar , timeIndex ) ; Array depthArray = readArray ( depthVar , timeIndex ) ; Array cArray = readArray ( cVar , timeIndex ) ; depth_c = depthCVar . readScalarDouble ( ) ; return makeHeight ( etaArray , sArray , depthArray , cArray , depth_c ) ;


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

implementation: Array etaArray = readArray ( etaVar , timeIndex ) ; Array sArray = readArray ( sVar , timeIndex ) ; Array depthArray = readArray ( depthVar , timeIndex ) ; Array cArray = readArray ( cVar , timeIndex ) ; depth_c = depthCVar . readScalarDouble ( ) ; return makeHeight1D ( etaArray , sArray , depthArray , cArray , depth_c , xIndex , yIndex ) ;


signature: public class LayoutRegularSegmented { private long getFilePos ( long elem ) { } }

implementation: long segno = elem / innerNelems ; long offset = elem % innerNelems ; return startPos + segno * recSize + offset * elemSize ;