signature:
public class BasicAuthentication { /** * Parse the basic authentication header
 * @ param request
 * the request to fetch the header from
 * @ return either < code > null < / code > if no valid header entry was found , or a
 * string array with exactly two entries ( username , password ) */
public static String [ ] parseAuthorization ( final HttpServletRequest request ) { } }

implementation: final String auth = request . getHeader ( "Authorization" ) ; logger . debug ( "Auth header: {}" , auth ) ; if ( auth == null || auth . isEmpty ( ) ) { return null ; } final String [ ] toks = auth . split ( "\\s" ) ; if ( toks . length < 2 ) { return null ; } if ( ! "Basic" . equalsIgnoreCase ( toks [ 0 ] ) ) { return null ; } final byte [ ] authData = Base64 . getDecoder ( ) . decode ( toks [ 1 ] ) ; final String authStr = StandardCharsets . ISO_8859_1 . decode ( ByteBuffer . wrap ( authData ) ) . toString ( ) ; logger . debug ( "Auth String: {}" , authStr ) ; final String [ ] authToks = authStr . split ( ":" , 2 ) ; logger . debug ( "Auth tokens: {}" , new Object [ ] { authToks } ) ; if ( authToks . length != 2 ) { return null ; } return authToks ;


signature:
public class ProtectedFunctionMapper { /** * Generated Servlet and Tag Handler implementations call this
 * method to retrieve an instance of the ProtectedFunctionMapper .
 * This is necessary since generated code does not have access to
 * create instances of classes in this package .
 * @ return A new protected function mapper . */
public static ProtectedFunctionMapper getInstance ( ) { } }

implementation: ProtectedFunctionMapper funcMapper ; if ( SecurityUtil . isPackageProtectionEnabled ( ) ) { funcMapper = AccessController . doPrivileged ( new PrivilegedAction < ProtectedFunctionMapper > ( ) { public ProtectedFunctionMapper run ( ) { return new ProtectedFunctionMapper ( ) ; } } ) ; } else { funcMapper = new ProtectedFunctionMapper ( ) ; } funcMapper . fnmap = new java . util . HashMap < String , Method > ( ) ; return funcMapper ;


signature:
public class ProtectedFunctionMapper { /** * Stores a mapping from the given EL function prefix and name to
 * the given Java method .
 * @ param fnQName The EL function qualified name ( including prefix )
 * @ param c The class containing the Java method
 * @ param methodName The name of the Java method
 * @ param args The arguments of the Java method
 * @ throws RuntimeException if no method with the given signature
 * could be found . */
public void mapFunction ( String fnQName , final Class < ? > c , final String methodName , final Class < ? > [ ] args ) { } }

implementation: java . lang . reflect . Method method ; if ( SecurityUtil . isPackageProtectionEnabled ( ) ) { try { method = AccessController . doPrivileged ( new PrivilegedExceptionAction < Method > ( ) { public Method run ( ) throws Exception { return c . getDeclaredMethod ( methodName , args ) ; } } ) ; } catch ( PrivilegedActionException ex ) { throw new RuntimeException ( "Invalid function mapping - no such method: " + ex . getException ( ) . getMessage ( ) ) ; } } else { try { method = c . getDeclaredMethod ( methodName , args ) ; } catch ( NoSuchMethodException e ) { throw new RuntimeException ( "Invalid function mapping - no such method: " + e . getMessage ( ) ) ; } } this . fnmap . put ( fnQName , method ) ;


signature:
public class ProtectedFunctionMapper { /** * Creates an instance for this class , and stores the Method for
 * the given EL function prefix and name . This method is used for
 * the case when there is only one function in the EL expression .
 * @ param fnQName The EL function qualified name ( including prefix )
 * @ param c The class containing the Java method
 * @ param methodName The name of the Java method
 * @ param args The arguments of the Java method
 * @ throws RuntimeException if no method with the given signature
 * could be found . */
public static ProtectedFunctionMapper getMapForFunction ( String fnQName , final Class < ? > c , final String methodName , final Class < ? > [ ] args ) { } }

implementation: java . lang . reflect . Method method ; ProtectedFunctionMapper funcMapper ; if ( SecurityUtil . isPackageProtectionEnabled ( ) ) { funcMapper = AccessController . doPrivileged ( new PrivilegedAction < ProtectedFunctionMapper > ( ) { public ProtectedFunctionMapper run ( ) { return new ProtectedFunctionMapper ( ) ; } } ) ; try { method = AccessController . doPrivileged ( new PrivilegedExceptionAction < Method > ( ) { public Method run ( ) throws Exception { return c . getDeclaredMethod ( methodName , args ) ; } } ) ; } catch ( PrivilegedActionException ex ) { throw new RuntimeException ( "Invalid function mapping - no such method: " + ex . getException ( ) . getMessage ( ) ) ; } } else { funcMapper = new ProtectedFunctionMapper ( ) ; try { method = c . getDeclaredMethod ( methodName , args ) ; } catch ( NoSuchMethodException e ) { throw new RuntimeException ( "Invalid function mapping - no such method: " + e . getMessage ( ) ) ; } } funcMapper . theMethod = method ; return funcMapper ;


signature:
public class ProtectedFunctionMapper { /** * Resolves the specified local name and prefix into a Java . lang . Method .
 * Returns null if the prefix and local name are not found .
 * @ param prefix the prefix of the function
 * @ param localName the short name of the function
 * @ return the result of the method mapping . Null means no entry found . */
public Method resolveFunction ( String prefix , String localName ) { } }

implementation: if ( this . fnmap != null ) { return this . fnmap . get ( prefix + ":" + localName ) ; } return theMethod ;


signature:
public class XMLString { /** * Initializes the contents of the XMLString structure with the
 * specified values .
 * @ param ch The character array .
 * @ param offset The offset into the character array .
 * @ param length The length of characters from the offset . */
public void setValues ( char [ ] ch , int offset , int length ) { } }

implementation: this . ch = ch ; this . offset = offset ; this . length = length ;


signature:
public class XMLString { /** * Initializes the contents of the XMLString structure with copies
 * of the given string structure .
 * < strong > Note : < / strong > This does not copy the character array ;
 * only the reference to the array is copied .
 * @ param s */
public void setValues ( XMLString s ) { } }

implementation: setValues ( s . ch , s . offset , s . length ) ;


signature:
public class DescriptionController { /** * interface extensions */
@ Override public List < MenuEntry > getViews ( final HttpServletRequest request , final Object object ) { } }

implementation: if ( ! ( object instanceof ChannelId ) ) { return null ; } final ChannelId channel = ( ChannelId ) object ; final List < MenuEntry > result = new LinkedList < > ( ) ; final Map < String , Object > model = new HashMap < > ( 1 ) ; model . put ( "channelId" , channel . getId ( ) ) ; result . add ( new MenuEntry ( "Help" , 100_000 , "Description" , 1_000 , LinkTarget . createFromController ( DescriptionController . class , "channelDescription" ) . expand ( model ) , Modifier . DEFAULT , "comment" ) ) ; return result ;


signature:
public class VariableResolverImpl { /** * Resolves the specified variable within the given context .
 * Returns null if the variable is not found . */
public Object resolveVariable ( String pName ) throws javax . servlet . jsp . el . ELException { } }

implementation: ELContext elContext = pageContext . getELContext ( ) ; ELResolver elResolver = elContext . getELResolver ( ) ; try { return elResolver . getValue ( elContext , null , pName ) ; } catch ( javax . el . ELException ex ) { throw new javax . servlet . jsp . el . ELException ( ) ; }


signature:
public class ParserController { /** * Parses a JSP page or tag file . This is invoked by the compiler .
 * @ param inFileName The path to the JSP page or tag file to be parsed . */
public Node . Nodes parse ( String inFileName ) throws FileNotFoundException , JasperException , IOException { } }

implementation:
// If we ' re parsing a packaged tag file or a resource included by it
// ( using an include directive ) , ctxt . getTagFileJar ( ) returns the
// JAR file from which to read the tag file or included resource ,
// respectively .
isTagFile = ctxt . isTagFile ( ) ; directiveOnly = false ; return doParse ( inFileName , null , ctxt . getTagFileJarUrl ( ) ) ;


signature:
public class ParserController { /** * Processes an include directive with the given path .
 * @ param inFileName The path to the resource to be included .
 * @ param parent The parent node of the include directive .
 * @ param jarFile The JAR file from which to read the included resource ,
 * or null of the included resource is to be read from the filesystem */
public Node . Nodes parse ( String inFileName , Node parent , URL jarFileUrl ) throws FileNotFoundException , JasperException , IOException { } }

implementation:
// For files that are statically included , isTagfile and directiveOnly
// remain unchanged .
return doParse ( inFileName , parent , jarFileUrl ) ;


signature:
public class ParserController { /** * Extracts tag file directive information from the tag file with the
 * given name .
 * This is invoked by the compiler
 * @ param inFileName The name of the tag file to be parsed . */
public Node . Nodes parseTagFileDirectives ( String inFileName ) throws FileNotFoundException , JasperException , IOException { } }

implementation: boolean isTagFileSave = isTagFile ; boolean directiveOnlySave = directiveOnly ; isTagFile = true ; directiveOnly = true ; Node . Nodes page = doParse ( inFileName , null , ( URL ) ctxt . getTagFileJarUrls ( ) . get ( inFileName ) ) ; directiveOnly = directiveOnlySave ; isTagFile = isTagFileSave ; return page ;


signature:
public class ParserController { /** * Parses the JSP page or tag file with the given path name .
 * @ param inFileName The name of the JSP page or tag file to be parsed .
 * @ param parent The parent node ( non - null when processing an include
 * directive )
 * @ param isTagFile true if file to be parsed is tag file , and false if it
 * is a regular JSP page
 * @ param directivesOnly true if the file to be parsed is a tag file and
 * we are only interested in the directives needed for constructing a
 * TagFileInfo .
 * @ param jarFile The JAR file from which to read the JSP page or tag file ,
 * or null if the JSP page or tag file is to be read from the filesystem */
private Node . Nodes doParse ( String inFileName , Node parent , URL jarFileUrl ) throws FileNotFoundException , JasperException , IOException { } }

implementation:
Node . Nodes parsedPage = null ; isEncodingSpecifiedInProlog = false ; isDefaultPageEncoding = false ; hasBom = false ; JarFile jarFile = getJarFile ( jarFileUrl ) ; String absFileName = resolveFileName ( inFileName ) ; String jspConfigPageEnc = getJspConfigPageEncoding ( absFileName ) ; // Figure out what type of JSP document and encoding type we are
// dealing with
determineSyntaxAndEncoding ( absFileName , jarFile , jspConfigPageEnc ) ; if ( parent != null ) { // Included resource , add to dependent list
compiler . getPageInfo ( ) . addDependant ( absFileName ) ; } comparePageEncodings ( jspConfigPageEnc ) ; // Dispatch to the appropriate parser
if ( isXml ) { // JSP document ( XML syntax )
// InputStream for jspx page is created and properly closed in
// JspDocumentParser .
parsedPage = JspDocumentParser . parse ( this , absFileName , jarFile , parent , isTagFile , directiveOnly , sourceEnc , jspConfigPageEnc , isEncodingSpecifiedInProlog ) ; } else { // Standard syntax
InputStreamReader inStreamReader = null ; try { inStreamReader = JspUtil . getReader ( absFileName , sourceEnc , jarFile , ctxt , err ) ; JspReader jspReader = new JspReader ( ctxt , absFileName , sourceEnc , inStreamReader , err ) ; parsedPage = Parser . parse ( this , absFileName , jspReader , parent , isTagFile , directiveOnly , jarFileUrl , sourceEnc , jspConfigPageEnc , isDefaultPageEncoding , hasBom ) ; } finally { if ( inStreamReader != null ) { try { inStreamReader . close ( ) ; } catch ( Exception any ) { } } } } if ( jarFile != null ) { try { jarFile . close ( ) ; } catch ( Throwable t ) { } } baseDirStack . pop ( ) ; return parsedPage ;


signature:
public class ParserController { /** * Ensures that the page encoding specified in the JSP config element
 * ( with matching URL pattern ) , if present , matches the page encoding
 * specified in the XML prolog of a JSP document ( XML syntax ) and the
 * page encoding derived from the BOM .
 * @ param jspConfigPageEnc Page encoding specified in JSP config element
 * @ throws JasperException if page encoding mismatch */
private void comparePageEncodings ( String jspConfigPageEnc ) throws JasperException { } }

implementation:
if ( jspConfigPageEnc == null ) { return ; } if ( isXml && isEncodingSpecifiedInProlog ) { /* * Make sure the encoding specified in the XML prolog matches
 * that in the JSP config element , treating " UTF - 16 " , " UTF - 16BE " ,
 * and " UTF - 16LE " as identical . */
if ( ! jspConfigPageEnc . equalsIgnoreCase ( sourceEnc ) && ( ! jspConfigPageEnc . toLowerCase ( ) . startsWith ( "utf-16" ) || ! sourceEnc . toLowerCase ( ) . startsWith ( "utf-16" ) ) ) { err . jspError ( "jsp.error.prolog_config_encoding_mismatch" , sourceEnc , jspConfigPageEnc ) ; } } if ( hasBom ) { /* * Make sure the encoding specified in the BOM matches
 * that in the JSP config element , treating " UTF - 16 " , " UTF - 16BE " ,
 * and " UTF - 16LE " as identical . */
if ( ! jspConfigPageEnc . equalsIgnoreCase ( sourceEnc ) && ( ! jspConfigPageEnc . toLowerCase ( ) . startsWith ( "utf-16" ) || ! sourceEnc . toLowerCase ( ) . startsWith ( "utf-16" ) ) ) { err . jspError ( "jsp.error.bom_config_encoding_mismatch" , sourceEnc , jspConfigPageEnc ) ; } }


signature:
public class ParserController { /** * Checks to see if the given URI is matched by a URL pattern specified in
 * a jsp - property - group in web . xml , and if so , returns the value of the
 * < page - encoding > element .
 * @ param absFileName The URI to match
 * @ return The value of the < page - encoding > attribute of the
 * jsp - property - group with matching URL pattern */
private String getJspConfigPageEncoding ( String absFileName ) throws JasperException { } }

implementation: JspConfig jspConfig = ctxt . getOptions ( ) . getJspConfig ( ) ; JspProperty jspProperty = jspConfig . findJspProperty ( absFileName ) ; return jspProperty . getPageEncoding ( ) ;


signature:
public class ParserController { /** * Determines the syntax ( standard or XML ) and page encoding properties
 * for the given file , and stores them in the ' isXml ' and ' sourceEnc '
 * instance variables , respectively . */
private void determineSyntaxAndEncoding ( String absFileName , JarFile jarFile , String jspConfigPageEnc ) throws JasperException , IOException { } }

implementation:
isXml = false ; /* * ' true ' if the syntax ( XML or standard ) of the file is given
 * from external information : either via a JSP configuration element ,
 * the " . jspx " suffix , or the enclosing file ( for included resources ) */
boolean isExternal = false ; /* * Indicates whether we need to revert from temporary usage of
 * " ISO - 8859-1 " back to " UTF - 8" */
boolean revert = false ; JspConfig jspConfig = ctxt . getOptions ( ) . getJspConfig ( ) ; JspProperty jspProperty = jspConfig . findJspProperty ( absFileName ) ; if ( jspProperty . isXml ( ) != null ) { // If < is - xml > is specified in a < jsp - property - group > , it is used .
isXml = JspUtil . booleanValue ( jspProperty . isXml ( ) ) ; isExternal = true ; } else if ( absFileName . endsWith ( ".jspx" ) || absFileName . endsWith ( ".tagx" ) ) { isXml = true ; isExternal = true ; } if ( isExternal && ! isXml ) { // JSP ( standard ) syntax . Use encoding specified in jsp - config
// if provided .
sourceEnc = jspConfigPageEnc ; if ( sourceEnc != null ) { return ; } // We don ' t know the encoding
sourceEnc = "ISO-8859-1" ; } else { // XML syntax or unknown , ( auto ) detect encoding . . .
Object [ ] ret = XMLEncodingDetector . getEncoding ( absFileName , jarFile , ctxt , err ) ; sourceEnc = ( String ) ret [ 0 ] ; if ( ( ( Boolean ) ret [ 1 ] ) . booleanValue ( ) ) { isEncodingSpecifiedInProlog = true ; } if ( ret [ 2 ] != null && ( ( Boolean ) ret [ 2 ] ) . booleanValue ( ) ) { hasBom = true ; } if ( ! isXml && sourceEnc . equalsIgnoreCase ( "utf-8" ) && ! hasBom ) { /* * We don ' t know if we ' re dealing with XML or standard syntax .
 * Therefore , we need to check to see if the page contains
 * a < jsp : root > element .
 * We need to be careful , because the page may be encoded in
 * ISO - 8859-1 ( or something entirely different : UTF - 8 was
 * chosen as the default , for lack of better alternative ) ,
 * and may contain byte sequences that will cause a UTF - 8
 * converter to throw exceptions .
 * It is safe to use a source encoding of ISO - 8859-1 in this
 * case , as there are no invalid byte sequences in ISO - 8859-1,
 * and the byte / character sequences we ' re looking for ( i . e . ,
 * < jsp : root > ) are identical in either encoding ( both UTF - 8
 * and ISO - 8859-1 are extensions of ASCII ) . */
sourceEnc = "ISO-8859-1" ; revert = true ; } } if ( isXml ) { // ( This implies ' isExternal ' is TRUE . )
// We know we ' re dealing with a JSP document ( via JSP config or
// " . jspx " suffix ) , so we ' re done .
return ; } /* * At this point , ' isExternal ' or ' isXml ' is FALSE .
 * Search for jsp : root action , in order to determine if we ' re dealing
 * with XML or standard syntax ( unless we already know what we ' re
 * dealing with , i . e . , when ' isExternal ' is TRUE and ' isXml ' is FALSE ) .
 * No check for XML prolog , since nothing prevents a page from
 * outputting XML and still using JSP syntax ( in this case , the
 * XML prolog is treated as template text ) . */
JspReader jspReader = null ; try { jspReader = new JspReader ( ctxt , absFileName , sourceEnc , jarFile , err ) ; } catch ( FileNotFoundException ex ) { throw new JasperException ( ex ) ; } jspReader . setSingleFile ( true ) ; Mark startMark = jspReader . mark ( ) ; if ( ! isExternal ) { jspReader . reset ( startMark ) ; if ( hasJspRoot ( jspReader ) ) { isXml = true ; if ( revert ) sourceEnc = "UTF-8" ; return ; } else { isXml = false ; } } /* * At this point , we know we ' re dealing with JSP syntax .
 * If an XML prolog is provided , it ' s treated as template text .
 * Determine the page encoding from the page directive , unless it ' s
 * specified via JSP config . */
if ( ! hasBom ) { sourceEnc = jspConfigPageEnc ; } if ( sourceEnc == null ) { sourceEnc = getPageEncodingForJspSyntax ( jspReader , startMark ) ; if ( sourceEnc == null ) { // Default to " ISO - 8859-1 " per JSP spec
sourceEnc = "ISO-8859-1" ; isDefaultPageEncoding = true ; } }


signature:
public class ParserController { /** * Determines page source encoding for page or tag file in JSP syntax ,
 * by reading ( in this order ) the value of the ' pageEncoding ' page
 * directive attribute , or the charset value of the ' contentType ' page
 * directive attribute .
 * @ return The page encoding , or null if not found */
private String getPageEncodingForJspSyntax ( JspReader jspReader , Mark startMark ) throws JasperException { } }

implementation:
String encoding = null ; String saveEncoding = null ; jspReader . reset ( startMark ) ; /* * Determine page encoding from directive of the form < % @ page % > ,
 * < % @ tag % > , < jsp : directive . page > or < jsp : directive . tag > . */
while ( true ) { if ( jspReader . skipUntil ( "<" ) == null ) { break ; } // If this is a comment , skip until its end
if ( jspReader . matches ( "%--" ) ) { if ( jspReader . skipUntil ( "--%>" ) == null ) { // error will be caught in Parser
break ; } continue ; } boolean isDirective = jspReader . matches ( "%@" ) ; if ( isDirective ) { jspReader . skipSpaces ( ) ; } else { isDirective = jspReader . matches ( "jsp:directive." ) ; } if ( ! isDirective ) { continue ; } // compare for " tag " , so we don ' t match " taglib "
if ( jspReader . matches ( "tag " ) || jspReader . matches ( "page" ) ) { jspReader . skipSpaces ( ) ; Attributes attrs = Parser . parseAttributes ( this , jspReader ) ; encoding = getPageEncodingFromDirective ( attrs , "pageEncoding" ) ; if ( encoding != null ) { break ; } encoding = getPageEncodingFromDirective ( attrs , "contentType" ) ; if ( encoding != null ) { saveEncoding = encoding ; } } } if ( encoding == null ) { encoding = saveEncoding ; } return encoding ;


signature:
public class ParserController { /** * Scans the given attributes for the attribute with the given name ,
 * which is either ' pageEncoding ' or ' contentType ' , and returns the
 * specified page encoding .
 * In the case of ' contentType ' , the page encoding is taken from the
 * content type ' s ' charset ' component .
 * @ param attrs The page directive attributes
 * @ param attrName The name of the attribute to search for ( either
 * ' pageEncoding ' or ' contentType ' )
 * @ return The page encoding , or null */
private String getPageEncodingFromDirective ( Attributes attrs , String attrName ) { } }

implementation:
String value = attrs . getValue ( attrName ) ; if ( attrName . equals ( "pageEncoding" ) ) { return value ; } // attrName = contentType
String contentType = value ; String encoding = null ; if ( contentType != null ) { int loc = contentType . indexOf ( CHARSET ) ; if ( loc != - 1 ) { encoding = contentType . substring ( loc + CHARSET . length ( ) ) ; } } return encoding ;


signature:
public class ParserController { /** * Resolve the name of the file and update baseDirStack ( ) to keep track of
 * the current base directory for each included file .
 * The ' root ' file is always an ' absolute ' path , so no need to put an
 * initial value in the baseDirStack . */
private String resolveFileName ( String inFileName ) { } }

implementation: String fileName = inFileName . replace ( '\\' , '/' ) ; boolean isAbsolute = fileName . startsWith ( "/" ) ; fileName = isAbsolute ? fileName : baseDirStack . peek ( ) + fileName ; String baseDir = fileName . substring ( 0 , fileName . lastIndexOf ( "/" ) + 1 ) ; baseDirStack . push ( baseDir ) ; return fileName ;


signature:
public class ParserController { /** * Checks to see if the given page contains , as its first element , a < root >
 * element whose prefix is bound to the JSP namespace , as in :
 * < wombat : root xmlns : wombat = " http : / / java . sun . com / JSP / Page " version = " 1.2 " >
 * < / wombat : root >
 * @ param reader The reader for this page
 * @ return true if this page contains a root element whose prefix is bound
 * to the JSP namespace , and false otherwise */
private boolean hasJspRoot ( JspReader reader ) throws JasperException { } }

implementation:
// < prefix > : root must be the first element
Mark start = null ; while ( ( start = reader . skipUntil ( "<" ) ) != null ) { int c = reader . nextChar ( ) ; if ( c != '!' && c != '?' ) break ; } if ( start == null ) { return false ; } Mark stop = reader . skipUntil ( ":root" ) ; if ( stop == null ) { return false ; } // call substring to get rid of leading ' < '
String prefix = reader . getText ( start , stop ) . substring ( 1 ) ; start = stop ; stop = reader . skipUntil ( ">" ) ; if ( stop == null ) { return false ; } // Determine namespace associated with < root > element ' s prefix
String root = reader . getText ( start , stop ) ; String xmlnsDecl = "xmlns:" + prefix ; int index = root . indexOf ( xmlnsDecl ) ; if ( index == - 1 ) { return false ; } index += xmlnsDecl . length ( ) ; while ( index < root . length ( ) && Character . isWhitespace ( root . charAt ( index ) ) ) { index ++ ; } if ( index < root . length ( ) && root . charAt ( index ) == '=' ) { index ++ ; while ( index < root . length ( ) && Character . isWhitespace ( root . charAt ( index ) ) ) { index ++ ; } if ( index < root . length ( ) && root . charAt ( index ++ ) == '"' && root . regionMatches ( index , JSP_URI , 0 , JSP_URI . length ( ) ) ) { return true ; } } return false ;


signature:
public class JspCompilationContext { /** * Create a " Compiler " object . */
public Compiler createCompiler ( boolean jspcMode ) throws JasperException { } }

implementation: if ( jspCompiler != null ) { return jspCompiler ; } jspCompiler = new Compiler ( this , jsw , jspcMode ) ; return jspCompiler ;


signature:
public class JspCompilationContext { /** * Gets a resource as a stream , relative to the meanings of this
 * context ' s implementation .
 * @ return a null if the resource cannot be found or represented
 * as an InputStream . */
public java . io . InputStream getResourceAsStream ( String res ) throws JasperException { } }

implementation: return context . getResourceAsStream ( canonicalURI ( res ) ) ;


signature:
public class JspCompilationContext { /** * Gets the ' location ' of the TLD associated with the given taglib ' uri ' .
 * @ return An array of two Strings : The first element denotes the real
 * path to the TLD . If the path to the TLD points to a jar file , then the
 * second element denotes the name of the TLD entry in the jar file .
 * Returns null if the given uri is not associated with any tag library
 * ' exposed ' in the web application . */
public String [ ] getTldLocation ( String uri ) throws JasperException { } }

implementation: String [ ] location = getOptions ( ) . getTldScanner ( ) . getLocation ( uri ) ; return location ;


signature:
public class JspCompilationContext { /** * = = = = = Removal = = = = = */
public void incrementRemoved ( ) { } }

implementation: if ( removed > 1 ) { jspCompiler . removeGeneratedFiles ( ) ; if ( rctxt != null ) rctxt . removeWrapper ( jspUri ) ; } removed ++ ;


signature:
public class JspCompilationContext { /** * = = = = = Compile and reload = = = = = */
public void compile ( ) throws JasperException , FileNotFoundException { } }

implementation:
createCompiler ( false ) ; if ( jspCompiler . isOutDated ( ) ) { try { jspCompiler . compile ( true ) ; jsw . setReload ( true ) ; jsw . setCompilationException ( null ) ; } catch ( JasperException ex ) { // Cache compilation exception
jsw . setCompilationException ( ex ) ; throw ex ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; JasperException je = new JasperException ( Localizer . getMessage ( "jsp.error.unable.compile" ) , ex ) ; // Cache compilation exception
jsw . setCompilationException ( je ) ; throw je ; } }


signature:
public class JspCompilationContext { /** * = = = = = Manipulating the class = = = = = */
public Class load ( ) throws JasperException , ClassNotFoundException { } }

implementation:
try { String name = getFullClassName ( ) ; if ( options . getUsePrecompiled ( ) ) { servletClass = getClassLoader ( ) . loadClass ( name ) ; } else { servletClass = getJspLoader ( ) . loadClass ( name ) ; } } catch ( ClassNotFoundException cex ) { // Do not wrapper this in JasperException if use - precompiled is set ,
// because this is really a 404.
if ( options . getUsePrecompiled ( ) ) { throw cex ; } throw new JasperException ( Localizer . getMessage ( "jsp.error.unable.load" ) , cex ) ; } catch ( Exception ex ) { throw new JasperException ( Localizer . getMessage ( "jsp.error.unable.compile" ) , ex ) ; } removed = 0 ; return servletClass ;


signature:
public class ASCIIReader { /** * Read a single character . This method will block until a character is
 * available , an I / O error occurs , or the end of the stream is reached .
 * < p > Subclasses that intend to support efficient single - character input
 * should override this method .
 * @ return The character read , as an integer in the range 0 to 127
 * ( < tt > 0x00-0x7f < / tt > ) , or - 1 if the end of the stream has
 * been reached
 * @ exception IOException If an I / O error occurs */
public int read ( ) throws IOException { } }

implementation: int b0 = fInputStream . read ( ) ; if ( b0 > 0x80 ) { throw new IOException ( Localizer . getMessage ( "jsp.error.xml.invalidASCII" , Integer . toString ( b0 ) ) ) ; } return b0 ;


signature:
public class ASCIIReader { /** * Read characters into a portion of an array . This method will block
 * until some input is available , an I / O error occurs , or the end of the
 * stream is reached .
 * @ param ch Destination buffer
 * @ param offset Offset at which to start storing characters
 * @ param length Maximum number of characters to read
 * @ return The number of characters read , or - 1 if the end of the
 * stream has been reached
 * @ exception IOException If an I / O error occurs */
public int read ( char ch [ ] , int offset , int length ) throws IOException { } }

implementation: if ( length > fBuffer . length ) { length = fBuffer . length ; } int count = fInputStream . read ( fBuffer , 0 , length ) ; for ( int i = 0 ; i < count ; i ++ ) { int b0 = fBuffer [ i ] ; if ( b0 < 0 ) { throw new IOException ( Localizer . getMessage ( "jsp.error.xml.invalidASCII" , Integer . toString ( b0 ) ) ) ; } ch [ offset + i ] = ( char ) b0 ; } return count ;


signature:
public class OsgiSitemapGenerator { /** * Find the last modification timestamp of all channels
 * @ return the latest modification timestamp of all channels */
private Optional < Instant > calcLastMod ( ) { } }

implementation: Instant globalLastMod = null ; for ( final ChannelInformation ci : this . channelService . list ( ) ) { final Optional < Instant > lastMod = ofNullable ( ci . getState ( ) . getModificationTimestamp ( ) ) ; if ( globalLastMod == null || lastMod . get ( ) . isAfter ( globalLastMod ) ) { globalLastMod = lastMod . get ( ) ; } } return Optional . ofNullable ( globalLastMod ) ;


signature:
public class JSPContextFinder { /** * We assume that the bootclassloader never uses the context classloader to find classes in itself . */
ArrayList basicFindClassLoaders ( ) { } }

implementation:
Class [ ] stack = contextFinder . getClassContext ( ) ; ArrayList result = new ArrayList ( 1 ) ; ClassLoader previousLoader = null ; for ( int i = 1 ; i < stack . length ; i ++ ) { ClassLoader tmp = stack [ i ] . getClassLoader ( ) ; if ( checkClass ( stack [ i ] ) && tmp != null && tmp != this ) { if ( checkClassLoader ( tmp ) ) { if ( previousLoader != tmp ) { result . add ( tmp ) ; previousLoader = tmp ; } } // stop at the framework classloader or the first bundle classloader
if ( Activator . getBundle ( stack [ i ] ) != null ) break ; } } return result ;


signature:
public class JSPContextFinder { /** * not be used as a delegate , otherwise we endup in endless recursion . */
private boolean checkClassLoader ( ClassLoader classloader ) { } }

implementation: if ( classloader == null || classloader == getParent ( ) ) return false ; for ( ClassLoader parent = classloader . getParent ( ) ; parent != null ; parent = parent . getParent ( ) ) if ( parent == this ) return false ; return true ;


signature:
public class JSPContextFinder { /** * False is returned when a cycle is being detected */
private boolean startLoading ( String name ) { } }

implementation: Set classesAndResources = ( Set ) cycleDetector . get ( ) ; if ( classesAndResources != null && classesAndResources . contains ( name ) ) return false ; if ( classesAndResources == null ) { classesAndResources = new HashSet ( 3 ) ; cycleDetector . set ( classesAndResources ) ; } classesAndResources . add ( name ) ; return true ;


signature:
public class SingleXZInputStream { /** * Reads the Stream Header into a buffer .
 * This is a helper function for the constructors . */
private static byte [ ] readStreamHeader ( InputStream in ) throws IOException { } }

implementation: byte [ ] streamHeader = new byte [ DecoderUtil . STREAM_HEADER_SIZE ] ; new DataInputStream ( in ) . readFully ( streamHeader ) ; return streamHeader ;


signature:
public class SingleXZInputStream { /** * Decompresses into an array of bytes .
 * If < code > len < / code > is zero , no bytes are read and < code > 0 < / code >
 * is returned . Otherwise this will try to decompress < code > len < / code >
 * bytes of uncompressed data . Less than < code > len < / code > bytes may
 * be read only in the following situations :
 * < ul >
 * < li > The end of the compressed data was reached successfully . < / li >
 * < li > An error is detected after at least one but less < code > len < / code >
 * bytes have already been successfully decompressed .
 * The next call with non - zero < code > len < / code > will immediately
 * throw the pending exception . < / li >
 * < li > An exception is thrown . < / li >
 * < / ul >
 * @ param buf target buffer for uncompressed data
 * @ param off start offset in < code > buf < / code >
 * @ param len maximum number of uncompressed bytes to read
 * @ return number of bytes read , or < code > - 1 < / code > to indicate
 * the end of the compressed stream
 * @ throws CorruptedInputException
 * @ throws UnsupportedOptionsException
 * @ throws MemoryLimitException
 * @ throws XZIOException if the stream has been closed
 * @ throws EOFException
 * compressed input is truncated or corrupt
 * @ throws IOException may be thrown by < code > in < / code > */
public int read ( byte [ ] buf , int off , int len ) throws IOException { } }

implementation: if ( off < 0 || len < 0 || off + len < 0 || off + len > buf . length ) throw new IndexOutOfBoundsException ( ) ; if ( len == 0 ) return 0 ; if ( in == null ) throw new XZIOException ( "Stream closed" ) ; if ( exception != null ) throw exception ; if ( endReached ) return - 1 ; int size = 0 ; try { while ( len > 0 ) { if ( blockDecoder == null ) { try { blockDecoder = new BlockInputStream ( in , check , verifyCheck , memoryLimit , - 1 , - 1 , arrayCache ) ; } catch ( IndexIndicatorException e ) { indexHash . validate ( in ) ; validateStreamFooter ( ) ; endReached = true ; return size > 0 ? size : - 1 ; } } int ret = blockDecoder . read ( buf , off , len ) ; if ( ret > 0 ) { size += ret ; off += ret ; len -= ret ; } else if ( ret == - 1 ) { indexHash . add ( blockDecoder . getUnpaddedSize ( ) , blockDecoder . getUncompressedSize ( ) ) ; blockDecoder = null ; } } } catch ( IOException e ) { exception = e ; if ( size == 0 ) throw e ; } return size ;


signature:
public class SingleXZInputStream { /** * Returns the number of uncompressed bytes that can be read
 * without blocking . The value is returned with an assumption
 * that the compressed input data will be valid . If the compressed
 * data is corrupt , < code > CorruptedInputException < / code > may get
 * thrown before the number of bytes claimed to be available have
 * been read from this input stream .
 * @ return the number of uncompressed bytes that can be read
 * without blocking */
public int available ( ) throws IOException { } }

implementation: if ( in == null ) throw new XZIOException ( "Stream closed" ) ; if ( exception != null ) throw exception ; return blockDecoder == null ? 0 : blockDecoder . available ( ) ;


signature:
public class SingleXZInputStream { /** * Closes the stream and optionally calls < code > in . close ( ) < / code > .
 * If the stream was already closed , this does nothing .
 * If < code > close ( false ) < / code > has been called , a further
 * call of < code > close ( true ) < / code > does nothing ( it doesn ' t call
 * < code > in . close ( ) < / code > ) .
 * If you don ' t want to close the underlying < code > InputStream < / code > ,
 * there is usually no need to worry about closing this stream either ;
 * it ' s fine to do nothing and let the garbage collector handle it .
 * However , if you are using { @ link ArrayCache } , < code > close ( false ) < / code >
 * can be useful to put the allocated arrays back to the cache without
 * closing the underlying < code > InputStream < / code > .
 * Note that if you successfully reach the end of the stream
 * ( < code > read < / code > returns < code > - 1 < / code > ) , the arrays are
 * automatically put back to the cache by that < code > read < / code > call . In
 * this situation < code > close ( false ) < / code > is redundant ( but harmless ) .
 * @ throws IOException if thrown by < code > in . close ( ) < / code >
 * @ since 1.7 */
public void close ( boolean closeInput ) throws IOException { } }

implementation: if ( in != null ) { if ( blockDecoder != null ) { blockDecoder . close ( ) ; blockDecoder = null ; } try { if ( closeInput ) in . close ( ) ; } finally { in = null ; } }


signature:
public class Pagination { /** * Paginate from a full data set
 * @ param startPage
 * the start page
 * @ param pageSize
 * the size of a single page
 * @ param fullDataSet
 * the full data set
 * @ return a subset of the full data set , containing the items which match
 * the page window */
public static < T > PaginationResult < T > paginate ( final Integer startPage , final int pageSize , final List < T > fullDataSet ) { } }

implementation: return paginate ( startPage , pageSize , ( start , length ) -> { final int len = fullDataSet . size ( ) ; if ( start > len ) { return Collections . emptyList ( ) ; } return fullDataSet . subList ( start , Math . min ( start + length , len ) ) ; } ) ;


signature:
public class SeekableFileInputStream { /** * Calls
 * { @ link RandomAccessFile # read ( byte [ ] , int , int )
 * randomAccessFile . read ( buf , off , len ) } . */
public int read ( byte [ ] buf , int off , int len ) throws IOException { } }

implementation: return randomAccessFile . read ( buf , off , len ) ;


signature:
public class MetaKey { /** * Convert a string to a MetaKey if possible
 * @ param string
 * the string to convert
 * @ return the new MetaKey instance or < code > null < / code > if the format was
 * invalid */
public static MetaKey fromString ( final String string ) { } }

implementation:
final int idx = string . indexOf ( ':' ) ; if ( idx < 1 ) { // -1 : none at all , 0 : empty namespace
return null ; } if ( idx + 1 >= string . length ( ) ) { // empty key segment
return null ; } return new MetaKey ( string . substring ( 0 , idx ) , string . substring ( idx + 1 ) , true ) ;


signature:
public class RpmBuilder { /** * Fill extra requirements the RPM file itself may have
 * @ throws IOException */
private void fillRequirements ( ) throws IOException { } }

implementation: this . requirements . add ( new Dependency ( "rpmlib(CompressedFileNames)" , "3.0.4-1" , RpmDependencyFlags . LESS , RpmDependencyFlags . EQUAL , RpmDependencyFlags . RPMLIB ) ) ; if ( ! this . options . getFileDigestAlgorithm ( ) . equals ( DigestAlgorithm . MD5 ) ) { this . requirements . add ( new Dependency ( "rpmlib(FileDigests)" , "4.6.0-1" , RpmDependencyFlags . LESS , RpmDependencyFlags . EQUAL , RpmDependencyFlags . RPMLIB ) ) ; } this . requirements . add ( new Dependency ( "rpmlib(PayloadFilesHavePrefix)" , "4.0-1" , RpmDependencyFlags . LESS , RpmDependencyFlags . EQUAL , RpmDependencyFlags . RPMLIB ) ) ; this . options . getPayloadCoding ( ) . createProvider ( ) . fillRequirements ( this . requirements :: add ) ;


signature:
public class RpmBuilder { /** * Actually build the RPM file
 * < strong > Note : < / strong > this method may only be called once per instance
 * @ throws IOException
 * in case of any IO error */
public void build ( ) throws IOException { } }

implementation: if ( this . hasBuilt ) { throw new IllegalStateException ( "RPM file has already been built. Can only be built once." ) ; } this . hasBuilt = true ; fillProvides ( ) ; fillRequirements ( ) ; fillHeader ( ) ; final LeadBuilder leadBuilder = new LeadBuilder ( this . name , this . version ) ; leadBuilder . fillFlagsFromHeader ( this . header , createLeadArchitectureMapper ( ) , createLeadOperatingSystemMapper ( ) ) ; if ( this . headerCustomizer != null ) { this . headerCustomizer . accept ( this . header ) ; } try ( final RpmWriter writer = new RpmWriter ( this . targetFile , leadBuilder , this . header , this . options . getHeaderCharset ( ) , this . options . getOpenOptions ( ) ) ) { writer . addAllSignatureProcessors ( this . signatureProcessors ) ; writer . setPayload ( this . recorder ) ; }


signature:
public class ImplicitTagLibraryInfo { /** * Returns an array of TagLibraryInfo objects representing the entire set
 * of tag libraries ( including this TagLibraryInfo ) imported by taglib
 * directives in the translation unit that references this
 * TagLibraryInfo .
 * If a tag library is imported more than once and bound to different
 * prefices , only the TagLibraryInfo bound to the first prefix must be
 * included in the returned array .
 * @ return Array of TagLibraryInfo objects representing the entire set
 * of tag libraries ( including this TagLibraryInfo ) imported by taglib
 * directives in the translation unit that references this TagLibraryInfo .
 * @ since 2.1 */
public TagLibraryInfo [ ] getTagLibraryInfos ( ) { } }

implementation: TagLibraryInfo [ ] taglibs = null ; Collection c = pageInfo . getTaglibs ( ) ; if ( c != null ) { Object [ ] objs = c . toArray ( ) ; if ( objs != null && objs . length > 0 ) { taglibs = new TagLibraryInfo [ objs . length ] ; for ( int i = 0 ; i < objs . length ; i ++ ) { taglibs [ i ] = ( TagLibraryInfo ) objs [ i ] ; } } } return taglibs ;


signature:
public class ImplicitTagLibraryInfo { /** * Checks to see if the given tag name maps to a tag file path ,
 * and if so , parses the corresponding tag file .
 * @ return The TagFileInfo corresponding to the given tag name , or null if
 * the given tag name is not implemented as a tag file */
public TagFileInfo getTagFile ( String shortName ) { } }

implementation: TagFileInfo tagFile = super . getTagFile ( shortName ) ; if ( tagFile == null ) { String path = tagFileMap . get ( shortName ) ; if ( path == null ) { return null ; } TagInfo tagInfo = null ; try { tagInfo = TagFileProcessor . parseTagFileDirectives ( pc , shortName , path , this ) ; } catch ( JasperException je ) { throw new RuntimeException ( je . toString ( ) ) ; } tagFile = new TagFileInfo ( shortName , path , tagInfo ) ; vec . add ( tagFile ) ; this . tagFiles = vec . toArray ( new TagFileInfo [ vec . size ( ) ] ) ; } return tagFile ;


signature:
public class ImplicitTagLibraryInfo { /** * Parses the JSP version and tlib - version from the implicit . tld at the
 * given path . */
private void parseImplicitTld ( JspCompilationContext ctxt , String path ) throws JasperException { } }

implementation:
InputStream is = null ; TreeNode tld = null ; try { URL uri = ctxt . getResource ( path ) ; if ( uri == null ) { // no implicit . tld
return ; } is = uri . openStream ( ) ; /* SJSAS 6384538
 tld = new ParserUtils ( ) . parseXMLDocument ( IMPLICIT _ TLD , is ) ; */
// START SJSAS 6384538
tld = new ParserUtils ( ) . parseXMLDocument ( IMPLICIT_TLD , is , ctxt . getOptions ( ) . isValidationEnabled ( ) ) ; // END SJSAS 6384538
} catch ( Exception ex ) { throw new JasperException ( ex ) ; } finally { if ( is != null ) { try { is . close ( ) ; } catch ( Throwable t ) { } } } this . jspversion = tld . findAttribute ( "version" ) ; Iterator list = tld . findChildren ( ) ; while ( list . hasNext ( ) ) { TreeNode element = ( TreeNode ) list . next ( ) ; String tname = element . getName ( ) ; if ( "tlibversion" . equals ( tname ) || "tlib-version" . equals ( tname ) ) { this . tlibversion = element . getBody ( ) ; } else if ( "jspversion" . equals ( tname ) || "jsp-version" . equals ( tname ) ) { this . jspversion = element . getBody ( ) ; } else if ( ! "shortname" . equals ( tname ) && ! "short-name" . equals ( tname ) ) { err . jspError ( "jsp.error.implicitTld.additionalElements" , path , tname ) ; } } // JSP version in implicit . tld must be 2.0 or greater
Double jspVersionDouble = Double . valueOf ( this . jspversion ) ; if ( Double . compare ( jspVersionDouble , Constants . JSP_VERSION_2_0 ) < 0 ) { err . jspError ( "jsp.error.implicitTld.jspVersion" , path , this . jspversion ) ; }


signature:
public class OutputSpooler { /** * Get the digest of a closed file
 * @ param fileName
 * the file name to get the digest for
 * @ param algorithm
 * the digest algorithm
 * @ return the digest or < code > null < / code > if the digest was not requested .
 * The digest will be lower case hex encoded .
 * @ throws IllegalStateException
 * If the file is still open or was never opened */
public String getChecksum ( final String fileName , final String algorithm ) { } }

implementation: if ( ! this . digests . contains ( algorithm ) ) { return null ; } final String result = this . checksums . get ( fileName + ":" + algorithm ) ; if ( result == null ) { throw new IllegalStateException ( String . format ( "Stream '%s' not closed." , fileName ) ) ; } return result ;


signature:
public class OutputSpooler { /** * Get the size of a closed file
 * @ param fileName
 * the file name to get the size for
 * @ return the size
 * @ throws IllegalStateException
 * If the file is still open or was never opened */
public long getSize ( final String fileName ) { } }

implementation: final Long result = this . sizes . get ( fileName ) ; if ( result == null ) { throw new IllegalStateException ( String . format ( "Stream '%s' not closed or was not added" , fileName ) ) ; } return result ;


signature:
public class ChannelController { /** * Validate the name of the channel
 * @ param name
 * the channel name to test
 * @ param ctx
 * the validation context */
private static void validateChannelName ( final String name , final ValidationContext ctx ) { } }

implementation: if ( name == null || name . isEmpty ( ) ) { return ; } final Matcher m = ChannelService . NAME_PATTERN . matcher ( name ) ; if ( ! m . matches ( ) ) { ctx . error ( "names" , String . format ( "The channel name '%s' must match the pattern '%s'" , name , ChannelService . NAME_PATTERN . pattern ( ) ) ) ; }


signature:
public class SeekableInputStream { /** * Seeks < code > n < / code > bytes forward in this stream .
 * This will not seek past the end of the file . If the current position
 * is already at or past the end of the file , this doesn ' t seek at all
 * and returns < code > 0 < / code > . Otherwise , if skipping < code > n < / code > bytes
 * would cause the position to exceed the stream size , this will do
 * equivalent of < code > seek ( length ( ) ) < / code > and the return value will
 * be adjusted accordingly .
 * If < code > n < / code > is negative , the position isn ' t changed and
 * the return value is < code > 0 < / code > . It doesn ' t seek backward
 * because it would conflict with the specification of
 * { @ link java . io . InputStream # skip ( long ) InputStream . skip } .
 * @ return < code > 0 < / code > if < code > n < / code > is negative ,
 * less than < code > n < / code > if skipping < code > n < / code >
 * bytes would seek past the end of the file ,
 * < code > n < / code > otherwise
 * @ throws IOException might be thrown by { @ link # seek ( long ) } */
public long skip ( long n ) throws IOException { } }

implementation: if ( n <= 0 ) return 0 ; long size = length ( ) ; long pos = position ( ) ; if ( pos >= size ) return 0 ; if ( size - pos < n ) n = size - pos ; seek ( pos + n ) ; return n ;


signature:
public class FilterOptions { /** * Gets how much memory the encoder will need with
 * the given filter chain . This function simply calls
 * < code > getEncoderMemoryUsage ( ) < / code > for every filter
 * in the array and returns the sum of the returned values . */
public static int getEncoderMemoryUsage ( FilterOptions [ ] options ) { } }

implementation: int m = 0 ; for ( int i = 0 ; i < options . length ; ++ i ) m += options [ i ] . getEncoderMemoryUsage ( ) ; return m ;


signature:
public class FilterOptions { /** * Gets how much memory the decoder will need with
 * the given filter chain . This function simply calls
 * < code > getDecoderMemoryUsage ( ) < / code > for every filter
 * in the array and returns the sum of the returned values . */
public static int getDecoderMemoryUsage ( FilterOptions [ ] options ) { } }

implementation: int m = 0 ; for ( int i = 0 ; i < options . length ; ++ i ) m += options [ i ] . getDecoderMemoryUsage ( ) ; return m ;


signature:
public class SeekableXZInputStream { /** * Decompresses into an array of bytes .
 * If < code > len < / code > is zero , no bytes are read and < code > 0 < / code >
 * is returned . Otherwise this will try to decompress < code > len < / code >
 * bytes of uncompressed data . Less than < code > len < / code > bytes may
 * be read only in the following situations :
 * < ul >
 * < li > The end of the compressed data was reached successfully . < / li >
 * < li > An error is detected after at least one but less than
 * < code > len < / code > bytes have already been successfully
 * decompressed . The next call with non - zero < code > len < / code >
 * will immediately throw the pending exception . < / li >
 * < li > An exception is thrown . < / li >
 * < / ul >
 * @ param buf target buffer for uncompressed data
 * @ param off start offset in < code > buf < / code >
 * @ param len maximum number of uncompressed bytes to read
 * @ return number of bytes read , or < code > - 1 < / code > to indicate
 * the end of the compressed stream
 * @ throws CorruptedInputException
 * @ throws UnsupportedOptionsException
 * @ throws MemoryLimitException
 * @ throws XZIOException if the stream has been closed
 * @ throws IOException may be thrown by < code > in < / code > */
public int read ( byte [ ] buf , int off , int len ) throws IOException { } }

implementation:
if ( off < 0 || len < 0 || off + len < 0 || off + len > buf . length ) throw new IndexOutOfBoundsException ( ) ; if ( len == 0 ) return 0 ; if ( in == null ) throw new XZIOException ( "Stream closed" ) ; if ( exception != null ) throw exception ; int size = 0 ; try { if ( seekNeeded ) seek ( ) ; if ( endReached ) return - 1 ; while ( len > 0 ) { if ( blockDecoder == null ) { seek ( ) ; if ( endReached ) break ; } int ret = blockDecoder . read ( buf , off , len ) ; if ( ret > 0 ) { curPos += ret ; size += ret ; off += ret ; len -= ret ; } else if ( ret == - 1 ) { blockDecoder = null ; } } } catch ( IOException e ) { // We know that the file isn ' t simply truncated because we could
// parse the Indexes in the constructor . So convert EOFException
// to CorruptedInputException .
if ( e instanceof EOFException ) e = new CorruptedInputException ( ) ; exception = e ; if ( size == 0 ) throw e ; } return size ;


signature:
public class SeekableXZInputStream { /** * Returns the number of uncompressed bytes that can be read
 * without blocking . The value is returned with an assumption
 * that the compressed input data will be valid . If the compressed
 * data is corrupt , < code > CorruptedInputException < / code > may get
 * thrown before the number of bytes claimed to be available have
 * been read from this input stream .
 * @ return the number of uncompressed bytes that can be read
 * without blocking */
public int available ( ) throws IOException { } }

implementation: if ( in == null ) throw new XZIOException ( "Stream closed" ) ; if ( exception != null ) throw exception ; if ( endReached || seekNeeded || blockDecoder == null ) return 0 ; return blockDecoder . available ( ) ;


signature:
public class SeekableXZInputStream { /** * Seeks to the specified absolute uncompressed position in the stream .
 * This only stores the new position , so this function itself is always
 * very fast . The actual seek is done when < code > read < / code > is called
 * to read at least one byte .
 * Seeking past the end of the stream is possible . In that case
 * < code > read < / code > will return < code > - 1 < / code > to indicate
 * the end of the stream .
 * @ param pos new uncompressed read position
 * @ throws XZIOException
 * if < code > pos < / code > is negative , or
 * if stream has been closed */
public void seek ( long pos ) throws IOException { } }

implementation: if ( in == null ) throw new XZIOException ( "Stream closed" ) ; if ( pos < 0 ) throw new XZIOException ( "Negative seek position: " + pos ) ; seekPos = pos ; seekNeeded = true ;


signature:
public class SeekableXZInputStream { /** * Seeks to the beginning of the given XZ Block .
 * @ throws XZIOException
 * if < code > blockNumber & nbsp ; & lt ; & nbsp ; 0 < / code > or
 * < code > blockNumber & nbsp ; & gt ; = & nbsp ; getBlockCount ( ) < / code > ,
 * or if stream has been closed
 * @ since 1.3 */
public void seekToBlock ( int blockNumber ) throws IOException { } }

implementation:
if ( in == null ) throw new XZIOException ( "Stream closed" ) ; if ( blockNumber < 0 || blockNumber >= blockCount ) throw new XZIOException ( "Invalid XZ Block number: " + blockNumber ) ; // This is a bit silly implementation . Here we locate the uncompressed
// offset of the specified Block , then when doing the actual seek in
// seek ( ) , we need to find the Block number based on seekPos .
seekPos = getBlockPos ( blockNumber ) ; seekNeeded = true ;


signature:
public class SeekableXZInputStream { /** * Does the actual seeking . This is also called when < code > read < / code >
 * needs a new Block to decode . */
private void seek ( ) throws IOException { } }

implementation:
// If seek ( long ) wasn ' t called , we simply need to get the next Block
// from the same Stream . If there are no more Blocks in this Stream ,
// then we behave as if seek ( long ) had been called .
if ( ! seekNeeded ) { if ( curBlockInfo . hasNext ( ) ) { curBlockInfo . setNext ( ) ; initBlockDecoder ( ) ; return ; } seekPos = curPos ; } seekNeeded = false ; // Check if we are seeking to or past the end of the file .
if ( seekPos >= uncompressedSize ) { curPos = seekPos ; if ( blockDecoder != null ) { blockDecoder . close ( ) ; blockDecoder = null ; } endReached = true ; return ; } endReached = false ; // Locate the Block that contains the uncompressed target position .
locateBlockByPos ( curBlockInfo , seekPos ) ; // Seek in the underlying stream and create a new Block decoder
// only if really needed . We can skip it if the current position
// is already in the correct Block and the target position hasn ' t
// been decompressed yet .
// NOTE : If curPos points to the beginning of this Block , it ' s
// because it was left there after decompressing an earlier Block .
// In that case , decoding of the current Block hasn ' t been started
// yet . ( Decoding of a Block won ' t be started until at least one
// byte will also be read from it . )
if ( ! ( curPos > curBlockInfo . uncompressedOffset && curPos <= seekPos ) ) { // Seek to the beginning of the Block .
in . seek ( curBlockInfo . compressedOffset ) ; // Since it is possible that this Block is from a different
// Stream than the previous Block , initialize a new Check .
check = Check . getInstance ( curBlockInfo . getCheckType ( ) ) ; // Create a new Block decoder .
initBlockDecoder ( ) ; curPos = curBlockInfo . uncompressedOffset ; } // If the target wasn ' t at a Block boundary , decompress and throw
// away data to reach the target position .
if ( seekPos > curPos ) { // NOTE : The " if " below is there just in case . In this situation ,
// blockDecoder . skip will always skip the requested amount
// or throw an exception .
long skipAmount = seekPos - curPos ; if ( blockDecoder . skip ( skipAmount ) != skipAmount ) throw new CorruptedInputException ( ) ; curPos = seekPos ; }


signature:
public class SeekableXZInputStream { /** * Locates the Block that contains the given uncompressed position . */
private void locateBlockByPos ( BlockInfo info , long pos ) { } }

implementation:
if ( pos < 0 || pos >= uncompressedSize ) throw new IndexOutOfBoundsException ( "Invalid uncompressed position: " + pos ) ; // Locate the Stream that contains the target position .
IndexDecoder index ; for ( int i = 0 ; ; ++ i ) { index = streams . get ( i ) ; if ( index . hasUncompressedOffset ( pos ) ) break ; } // Locate the Block from the Stream that contains the target position .
index . locateBlock ( info , pos ) ; assert ( info . compressedOffset & 3 ) == 0 ; assert info . uncompressedSize > 0 ; assert pos >= info . uncompressedOffset ; assert pos < info . uncompressedOffset + info . uncompressedSize ;


signature:
public class SeekableXZInputStream { /** * Locates the given Block and stores information about it
 * to < code > info < / code > . */
private void locateBlockByNumber ( BlockInfo info , int blockNumber ) { } }

implementation:
// Validate .
if ( blockNumber < 0 || blockNumber >= blockCount ) throw new IndexOutOfBoundsException ( "Invalid XZ Block number: " + blockNumber ) ; // Skip the search if info already points to the correct Block .
if ( info . blockNumber == blockNumber ) return ; // Search the Stream that contains the given Block and then
// search the Block from that Stream .
for ( int i = 0 ; ; ++ i ) { IndexDecoder index = streams . get ( i ) ; if ( index . hasRecord ( blockNumber ) ) { index . setBlockInfo ( info , blockNumber ) ; return ; } }


signature:
public class SeekableXZInputStream { /** * Initializes a new BlockInputStream . This is a helper function for
 * < code > seek ( ) < / code > . */
private void initBlockDecoder ( ) throws IOException { } }

implementation:
try { // Set it to null first so that GC can collect it if memory
// runs tight when initializing a new BlockInputStream .
if ( blockDecoder != null ) { blockDecoder . close ( ) ; blockDecoder = null ; } blockDecoder = new BlockInputStream ( in , check , verifyCheck , memoryLimit , curBlockInfo . unpaddedSize , curBlockInfo . uncompressedSize , arrayCache ) ; } catch ( MemoryLimitException e ) { // BlockInputStream doesn ' t know how much memory we had
// already needed so we need to recreate the exception .
assert memoryLimit >= 0 ; throw new MemoryLimitException ( e . getMemoryNeeded ( ) + indexMemoryUsage , memoryLimit + indexMemoryUsage ) ; } catch ( IndexIndicatorException e ) { // It cannot be Index so the file must be corrupt .
throw new CorruptedInputException ( ) ; }


signature:
public class ForEach { /** * Generate codes for Collections
 * The pseudo code is : */
private void doCollection ( TagPluginContext ctxt ) { } }

implementation:
ctxt . generateImport ( "java.util.*" ) ; generateIterators ( ctxt ) ; String itemsV = ctxt . getTemporaryVariableName ( ) ; ctxt . generateJavaSource ( "Object " + itemsV + "= " ) ; ctxt . generateAttribute ( "items" ) ; ctxt . generateJavaSource ( ";" ) ; String indexV = null , beginV = null , endV = null , stepV = null ; if ( hasBegin ) { beginV = ctxt . getTemporaryVariableName ( ) ; ctxt . generateJavaSource ( "int " + beginV + " = " ) ; ctxt . generateAttribute ( "begin" ) ; ctxt . generateJavaSource ( ";" ) ; } if ( hasEnd ) { indexV = ctxt . getTemporaryVariableName ( ) ; ctxt . generateJavaSource ( "int " + indexV + " = 0;" ) ; endV = ctxt . getTemporaryVariableName ( ) ; ctxt . generateJavaSource ( "int " + endV + " = " ) ; ctxt . generateAttribute ( "end" ) ; ctxt . generateJavaSource ( ";" ) ; } if ( hasStep ) { stepV = ctxt . getTemporaryVariableName ( ) ; ctxt . generateJavaSource ( "int " + stepV + " = " ) ; ctxt . generateAttribute ( "step" ) ; ctxt . generateJavaSource ( ";" ) ; } String iterV = ctxt . getTemporaryVariableName ( ) ; ctxt . generateJavaSource ( "Iterator " + iterV + " = null;" ) ; // Object [ ]
ctxt . generateJavaSource ( "if (" + itemsV + " instanceof Object[])" ) ; ctxt . generateJavaSource ( iterV + "=toIterator((Object[])" + itemsV + ");" ) ; // boolean [ ]
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof boolean[])" ) ; ctxt . generateJavaSource ( iterV + "=toIterator((boolean[])" + itemsV + ");" ) ; // byte [ ]
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof byte[])" ) ; ctxt . generateJavaSource ( iterV + "=toIterator((byte[])" + itemsV + ");" ) ; // char [ ]
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof char[])" ) ; ctxt . generateJavaSource ( iterV + "=toIterator((char[])" + itemsV + ");" ) ; // short [ ]
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof short[])" ) ; ctxt . generateJavaSource ( iterV + "=toIterator((short[])" + itemsV + ");" ) ; // int [ ]
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof int[])" ) ; ctxt . generateJavaSource ( iterV + "=toIterator((int[])" + itemsV + ");" ) ; // long [ ]
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof long[])" ) ; ctxt . generateJavaSource ( iterV + "=toIterator((long[])" + itemsV + ");" ) ; // float [ ]
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof float[])" ) ; ctxt . generateJavaSource ( iterV + "=toIterator((float[])" + itemsV + ");" ) ; // double [ ]
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof double[])" ) ; ctxt . generateJavaSource ( iterV + "=toIterator((double[])" + itemsV + ");" ) ; // Collection
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof Collection)" ) ; ctxt . generateJavaSource ( iterV + "=((Collection)" + itemsV + ").iterator();" ) ; // Iterator
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof Iterator)" ) ; ctxt . generateJavaSource ( iterV + "=(Iterator)" + itemsV + ";" ) ; // Enumeration
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof Enumeration)" ) ; ctxt . generateJavaSource ( iterV + "=toIterator((Enumeration)" + itemsV + ");" ) ; // Map
ctxt . generateJavaSource ( "else if (" + itemsV + " instanceof Map)" ) ; ctxt . generateJavaSource ( iterV + "=((Map)" + itemsV + ").entrySet().iterator();" ) ; if ( hasBegin ) { String tV = ctxt . getTemporaryVariableName ( ) ; ctxt . generateJavaSource ( "for (int " + tV + "=" + beginV + ";" + tV + ">0 && " + iterV + ".hasNext(); " + tV + "--)" ) ; ctxt . generateJavaSource ( iterV + ".next();" ) ; } ctxt . generateJavaSource ( "while (" + iterV + ".hasNext()){" ) ; if ( hasVar ) { ctxt . generateJavaSource ( "_jspx_page_context.setAttribute(" ) ; ctxt . generateAttribute ( "var" ) ; ctxt . generateJavaSource ( ", " + iterV + ".next());" ) ; } ctxt . generateBody ( ) ; if ( hasStep ) { String tV = ctxt . getTemporaryVariableName ( ) ; ctxt . generateJavaSource ( "for (int " + tV + "=" + stepV + "-1;" + tV + ">0 && " + iterV + ".hasNext(); " + tV + "--)" ) ; ctxt . generateJavaSource ( iterV + ".next();" ) ; } if ( hasEnd ) { if ( hasStep ) { ctxt . generateJavaSource ( indexV + "+=" + stepV + ";" ) ; } else { ctxt . generateJavaSource ( indexV + "++;" ) ; } if ( hasBegin ) { ctxt . generateJavaSource ( "if(" + beginV + "+" + indexV + ">" + endV + ")" ) ; } else { ctxt . generateJavaSource ( "if(" + indexV + ">" + endV + ")" ) ; } ctxt . generateJavaSource ( "break;" ) ; } ctxt . generateJavaSource ( "}" ) ; // while


signature:
public class ForEach { /** * Generate iterators for data types supported in items */
private void generateIterators ( TagPluginContext ctxt ) { } }

implementation:
// Object [ ]
ctxt . generateDeclaration ( "ObjectArrayIterator" , "private Iterator toIterator(final Object[] a){\n" + "  return (new Iterator() {\n" + "    int index=0;\n" + "    public boolean hasNext() {\n" + "      return index < a.length;}\n" + "    public Object next() {\n" + "      return a[index++];}\n" + "    public void remove() {}\n" + "  });\n" + "}" ) ; // boolean [ ]
ctxt . generateDeclaration ( "booleanArrayIterator" , "private Iterator toIterator(final boolean[] a){\n" + "  return (new Iterator() {\n" + "    int index=0;\n" + "    public boolean hasNext() {\n" + "      return index < a.length;}\n" + "    public Object next() {\n" + "      return new Boolean(a[index++]);}\n" + "    public void remove() {}\n" + "  });\n" + "}" ) ; // byte [ ]
ctxt . generateDeclaration ( "byteArrayIterator" , "private Iterator toIterator(final byte[] a){\n" + "  return (new Iterator() {\n" + "    int index=0;\n" + "    public boolean hasNext() {\n" + "      return index < a.length;}\n" + "    public Object next() {\n" + "      return new Byte(a[index++]);}\n" + "    public void remove() {}\n" + "  });\n" + "}" ) ; // char [ ]
ctxt . generateDeclaration ( "charArrayIterator" , "private Iterator toIterator(final char[] a){\n" + "  return (new Iterator() {\n" + "    int index=0;\n" + "    public boolean hasNext() {\n" + "      return index < a.length;}\n" + "    public Object next() {\n" + "      return new Character(a[index++]);}\n" + "    public void remove() {}\n" + "  });\n" + "}" ) ; // short [ ]
ctxt . generateDeclaration ( "shortArrayIterator" , "private Iterator toIterator(final short[] a){\n" + "  return (new Iterator() {\n" + "    int index=0;\n" + "    public boolean hasNext() {\n" + "      return index < a.length;}\n" + "    public Object next() {\n" + "      return new Short(a[index++]);}\n" + "    public void remove() {}\n" + "  });\n" + "}" ) ; // int [ ]
ctxt . generateDeclaration ( "intArrayIterator" , "private Iterator toIterator(final int[] a){\n" + "  return (new Iterator() {\n" + "    int index=0;\n" + "    public boolean hasNext() {\n" + "      return index < a.length;}\n" + "    public Object next() {\n" + "      return new Integer(a[index++]);}\n" + "    public void remove() {}\n" + "  });\n" + "}" ) ; // long [ ]
ctxt . generateDeclaration ( "longArrayIterator" , "private Iterator toIterator(final long[] a){\n" + "  return (new Iterator() {\n" + "    int index=0;\n" + "    public boolean hasNext() {\n" + "      return index < a.length;}\n" + "    public Object next() {\n" + "      return new Long(a[index++]);}\n" + "    public void remove() {}\n" + "  });\n" + "}" ) ; // float [ ]
ctxt . generateDeclaration ( "floatArrayIterator" , "private Iterator toIterator(final float[] a){\n" + "  return (new Iterator() {\n" + "    int index=0;\n" + "    public boolean hasNext() {\n" + "      return index < a.length;}\n" + "    public Object next() {\n" + "      return new Float(a[index++]);}\n" + "    public void remove() {}\n" + "  });\n" + "}" ) ; // double [ ]
ctxt . generateDeclaration ( "doubleArrayIterator" , "private Iterator toIterator(final double[] a){\n" + "  return (new Iterator() {\n" + "    int index=0;\n" + "    public boolean hasNext() {\n" + "      return index < a.length;}\n" + "    public Object next() {\n" + "      return new Double(a[index++]);}\n" + "    public void remove() {}\n" + "  });\n" + "}" ) ; // Enumeration
ctxt . generateDeclaration ( "enumIterator" , "private Iterator toIterator(final Enumeration e){\n" + "  return (new Iterator() {\n" + "    public boolean hasNext() {\n" + "      return e.hasMoreElements();}\n" + "    public Object next() {\n" + "      return e.nextElement();}\n" + "    public void remove() {}\n" + "  });\n" + "}" ) ;


signature:
public class UnzipServlet { /** * Get a list of all relevant maven artifacts
 * @ param artifactsSupplier
 * the supplier of artifacts
 * @ param groupId
 * the group id to filter for , must not be < code > null
 * @ param artifactId
 * the artifact id to filter for , must not be < code > null
 * @ param snapshot
 * whether to consider snapshot versions of not
 * @ param versionFilter
 * an optional version filter
 * @ return a list of all matching artifacts wrapped in
 * { @ link MavenVersionedArtifact } , if there is a snapshot version
 * present , then the snapshot version of used as version */
protected static List < MavenVersionedArtifact > getMavenArtifacts ( final String channelId , final Supplier < Collection < ArtifactInformation > > artifactsSupplier , final String groupId , final String artifactId , final boolean snapshot , final Predicate < ComparableVersion > versionFilter ) { } }

implementation:
final List < MavenVersionedArtifact > arts = new ArrayList < > ( ) ; for ( final ArtifactInformation ai : artifactsSupplier . get ( ) ) { if ( ! isZip ( ai ) ) { // if is is anot a zip , then this is not for the unzip plugin
continue ; } // fetch meta data
final String mvnGroupId = ai . getMetaData ( ) . get ( MK_GROUP_ID ) ; final String mvnArtifactId = ai . getMetaData ( ) . get ( MK_ARTIFACT_ID ) ; final String classifier = ai . getMetaData ( ) . get ( MK_CLASSIFIER ) ; final String mvnVersion = ai . getMetaData ( ) . get ( MK_VERSION ) ; final String mvnSnapshotVersion = ai . getMetaData ( ) . get ( MK_SNAPSHOT_VERSION ) ; if ( mvnGroupId == null || mvnArtifactId == null || mvnVersion == null ) { // no GAV information
continue ; } if ( classifier != null && ! classifier . isEmpty ( ) ) { // no classifiers right now
continue ; } if ( ! mvnGroupId . equals ( groupId ) || ! mvnArtifactId . equals ( artifactId ) ) { // wrong group or artifact id
continue ; } if ( ! snapshot && ( mvnSnapshotVersion != null || mvnVersion . endsWith ( "-SNAPSHOT" ) ) ) { // we are not looking for snapshots
continue ; } final ComparableVersion v = parseVersion ( mvnVersion ) ; final ComparableVersion sv = parseVersion ( mvnSnapshotVersion ) ; if ( v == null ) { // unable to parse v
continue ; } if ( versionFilter == null ) { // no filter , add it
arts . add ( new MavenVersionedArtifact ( sv != null ? sv : v , channelId , ai ) ) ; } else if ( versionFilter . test ( v ) ) { // filter matched , add it
arts . add ( new MavenVersionedArtifact ( sv != null ? sv : v , channelId , ai ) ) ; } else if ( sv != null && versionFilter . test ( sv ) ) { // we have a snapshot version and it matched , add it
arts . add ( new MavenVersionedArtifact ( sv , channelId , ai ) ) ; } } return arts ;


signature:
public class UnzipServlet { /** * Check if an artifact is a ZIP file
 * An artifact is a ZIP file if at least one of th following tests is true :
 * < ul >
 * < li > Its lower case name ends with < code > . zip < / code > < / li >
 * < li > The meta data field < code > mvn : extension < / code > is set to
 * < code > zip < / code >
 * < li > The meta data field < code > mime : type < / code > is set to
 * < code > application / zip < / code >
 * < / ul >
 * @ param artifact
 * the artifact to check
 * @ return < code > true < / code > if the artifact is a ZIP file ,
 * < code > false < / code > otherwise */
protected static boolean isZip ( final ArtifactInformation artifact ) { } }

implementation: if ( artifact . getName ( ) . toLowerCase ( ) . endsWith ( ".zip" ) ) { return true ; } final String mdExtension = artifact . getMetaData ( ) . get ( MK_MVN_EXTENSION ) ; if ( mdExtension != null && mdExtension . equalsIgnoreCase ( "zip" ) ) { return true ; } final String mdMime = artifact . getMetaData ( ) . get ( MK_MIME_TYPE ) ; if ( mdMime != null && mdMime . equalsIgnoreCase ( "application/zip" ) ) { return true ; } return false ;


signature:
public class LZMAEncoderNormal { /** * Converts the opts array from backward indexes to forward indexes .
 * Then it will be simple to get the next symbol from the array
 * in later calls to < code > getNextSymbol ( ) < / code > . */
private int convertOpts ( ) { } }

implementation: optEnd = optCur ; int optPrev = opts [ optCur ] . optPrev ; do { Optimum opt = opts [ optCur ] ; if ( opt . prev1IsLiteral ) { opts [ optPrev ] . optPrev = optCur ; opts [ optPrev ] . backPrev = - 1 ; optCur = optPrev -- ; if ( opt . hasPrev2 ) { opts [ optPrev ] . optPrev = optPrev + 1 ; opts [ optPrev ] . backPrev = opt . backPrev2 ; optCur = optPrev ; optPrev = opt . optPrev2 ; } } int temp = opts [ optPrev ] . optPrev ; opts [ optPrev ] . optPrev = optCur ; optCur = optPrev ; optPrev = temp ; } while ( optCur > 0 ) ; optCur = opts [ 0 ] . optPrev ; back = opts [ optCur ] . backPrev ; return optCur ;


signature:
public class LZMAEncoderNormal { /** * Updates the state and reps for the current byte in the opts array . */
private void updateOptStateAndReps ( ) { } }

implementation:
int optPrev = opts [ optCur ] . optPrev ; assert optPrev < optCur ; if ( opts [ optCur ] . prev1IsLiteral ) { -- optPrev ; if ( opts [ optCur ] . hasPrev2 ) { opts [ optCur ] . state . set ( opts [ opts [ optCur ] . optPrev2 ] . state ) ; if ( opts [ optCur ] . backPrev2 < REPS ) opts [ optCur ] . state . updateLongRep ( ) ; else opts [ optCur ] . state . updateMatch ( ) ; } else { opts [ optCur ] . state . set ( opts [ optPrev ] . state ) ; } opts [ optCur ] . state . updateLiteral ( ) ; } else { opts [ optCur ] . state . set ( opts [ optPrev ] . state ) ; } if ( optPrev == optCur - 1 ) { // Must be either a short rep or a literal .
assert opts [ optCur ] . backPrev == 0 || opts [ optCur ] . backPrev == - 1 ; if ( opts [ optCur ] . backPrev == 0 ) opts [ optCur ] . state . updateShortRep ( ) ; else opts [ optCur ] . state . updateLiteral ( ) ; System . arraycopy ( opts [ optPrev ] . reps , 0 , opts [ optCur ] . reps , 0 , REPS ) ; } else { int back ; if ( opts [ optCur ] . prev1IsLiteral && opts [ optCur ] . hasPrev2 ) { optPrev = opts [ optCur ] . optPrev2 ; back = opts [ optCur ] . backPrev2 ; opts [ optCur ] . state . updateLongRep ( ) ; } else { back = opts [ optCur ] . backPrev ; if ( back < REPS ) opts [ optCur ] . state . updateLongRep ( ) ; else opts [ optCur ] . state . updateMatch ( ) ; } if ( back < REPS ) { opts [ optCur ] . reps [ 0 ] = opts [ optPrev ] . reps [ back ] ; int rep ; for ( rep = 1 ; rep <= back ; ++ rep ) opts [ optCur ] . reps [ rep ] = opts [ optPrev ] . reps [ rep - 1 ] ; for ( ; rep < REPS ; ++ rep ) opts [ optCur ] . reps [ rep ] = opts [ optPrev ] . reps [ rep ] ; } else { opts [ optCur ] . reps [ 0 ] = back - REPS ; System . arraycopy ( opts [ optPrev ] . reps , 0 , opts [ optCur ] . reps , 1 , REPS - 1 ) ; } }


signature:
public class LZMAEncoderNormal { /** * Calculates prices of a literal , a short rep , and literal + rep0. */
private void calc1BytePrices ( int pos , int posState , int avail , int anyRepPrice ) { } }

implementation:
// This will be set to true if using a literal or a short rep .
boolean nextIsByte = false ; int curByte = lz . getByte ( 0 ) ; int matchByte = lz . getByte ( opts [ optCur ] . reps [ 0 ] + 1 ) ; // Try a literal .
int literalPrice = opts [ optCur ] . price + literalEncoder . getPrice ( curByte , matchByte , lz . getByte ( 1 ) , pos , opts [ optCur ] . state ) ; if ( literalPrice < opts [ optCur + 1 ] . price ) { opts [ optCur + 1 ] . set1 ( literalPrice , optCur , - 1 ) ; nextIsByte = true ; } // Try a short rep .
if ( matchByte == curByte && ( opts [ optCur + 1 ] . optPrev == optCur || opts [ optCur + 1 ] . backPrev != 0 ) ) { int shortRepPrice = getShortRepPrice ( anyRepPrice , opts [ optCur ] . state , posState ) ; if ( shortRepPrice <= opts [ optCur + 1 ] . price ) { opts [ optCur + 1 ] . set1 ( shortRepPrice , optCur , 0 ) ; nextIsByte = true ; } } // If neither a literal nor a short rep was the cheapest choice ,
// try literal + long rep0.
if ( ! nextIsByte && matchByte != curByte && avail > MATCH_LEN_MIN ) { int lenLimit = Math . min ( niceLen , avail - 1 ) ; int len = lz . getMatchLen ( 1 , opts [ optCur ] . reps [ 0 ] , lenLimit ) ; if ( len >= MATCH_LEN_MIN ) { nextState . set ( opts [ optCur ] . state ) ; nextState . updateLiteral ( ) ; int nextPosState = ( pos + 1 ) & posMask ; int price = literalPrice + getLongRepAndLenPrice ( 0 , len , nextState , nextPosState ) ; int i = optCur + 1 + len ; while ( optEnd < i ) opts [ ++ optEnd ] . reset ( ) ; if ( price < opts [ i ] . price ) opts [ i ] . set2 ( price , optCur , 0 ) ; } }


signature:
public class LZMAEncoderNormal { /** * Calculates prices of long rep and long rep + literal + rep0. */
private int calcLongRepPrices ( int pos , int posState , int avail , int anyRepPrice ) { } }

implementation:
int startLen = MATCH_LEN_MIN ; int lenLimit = Math . min ( avail , niceLen ) ; for ( int rep = 0 ; rep < REPS ; ++ rep ) { int len = lz . getMatchLen ( opts [ optCur ] . reps [ rep ] , lenLimit ) ; if ( len < MATCH_LEN_MIN ) continue ; while ( optEnd < optCur + len ) opts [ ++ optEnd ] . reset ( ) ; int longRepPrice = getLongRepPrice ( anyRepPrice , rep , opts [ optCur ] . state , posState ) ; for ( int i = len ; i >= MATCH_LEN_MIN ; -- i ) { int price = longRepPrice + repLenEncoder . getPrice ( i , posState ) ; if ( price < opts [ optCur + i ] . price ) opts [ optCur + i ] . set1 ( price , optCur , rep ) ; } if ( rep == 0 ) startLen = len + 1 ; int len2Limit = Math . min ( niceLen , avail - len - 1 ) ; int len2 = lz . getMatchLen ( len + 1 , opts [ optCur ] . reps [ rep ] , len2Limit ) ; if ( len2 >= MATCH_LEN_MIN ) { // Rep
int price = longRepPrice + repLenEncoder . getPrice ( len , posState ) ; nextState . set ( opts [ optCur ] . state ) ; nextState . updateLongRep ( ) ; // Literal
int curByte = lz . getByte ( len , 0 ) ; int matchByte = lz . getByte ( 0 ) ; // lz . getByte ( len , len )
int prevByte = lz . getByte ( len , 1 ) ; price += literalEncoder . getPrice ( curByte , matchByte , prevByte , pos + len , nextState ) ; nextState . updateLiteral ( ) ; // Rep0
int nextPosState = ( pos + len + 1 ) & posMask ; price += getLongRepAndLenPrice ( 0 , len2 , nextState , nextPosState ) ; int i = optCur + len + 1 + len2 ; while ( optEnd < i ) opts [ ++ optEnd ] . reset ( ) ; if ( price < opts [ i ] . price ) opts [ i ] . set3 ( price , optCur , rep , len , 0 ) ; } } return startLen ;


signature:
public class LZMAEncoderNormal { /** * Calculates prices of a normal match and normal match + literal + rep0. */
private void calcNormalMatchPrices ( int pos , int posState , int avail , int anyMatchPrice , int startLen ) { } }

implementation:
// If the longest match is so long that it would not fit into
// the opts array , shorten the matches .
if ( matches . len [ matches . count - 1 ] > avail ) { matches . count = 0 ; while ( matches . len [ matches . count ] < avail ) ++ matches . count ; matches . len [ matches . count ++ ] = avail ; } if ( matches . len [ matches . count - 1 ] < startLen ) return ; while ( optEnd < optCur + matches . len [ matches . count - 1 ] ) opts [ ++ optEnd ] . reset ( ) ; int normalMatchPrice = getNormalMatchPrice ( anyMatchPrice , opts [ optCur ] . state ) ; int match = 0 ; while ( startLen > matches . len [ match ] ) ++ match ; for ( int len = startLen ; ; ++ len ) { int dist = matches . dist [ match ] ; // Calculate the price of a match of len bytes from the nearest
// possible distance .
int matchAndLenPrice = getMatchAndLenPrice ( normalMatchPrice , dist , len , posState ) ; if ( matchAndLenPrice < opts [ optCur + len ] . price ) opts [ optCur + len ] . set1 ( matchAndLenPrice , optCur , dist + REPS ) ; if ( len != matches . len [ match ] ) continue ; // Try match + literal + rep0 . First get the length of the rep0.
int len2Limit = Math . min ( niceLen , avail - len - 1 ) ; int len2 = lz . getMatchLen ( len + 1 , dist , len2Limit ) ; if ( len2 >= MATCH_LEN_MIN ) { nextState . set ( opts [ optCur ] . state ) ; nextState . updateMatch ( ) ; // Literal
int curByte = lz . getByte ( len , 0 ) ; int matchByte = lz . getByte ( 0 ) ; // lz . getByte ( len , len )
int prevByte = lz . getByte ( len , 1 ) ; int price = matchAndLenPrice + literalEncoder . getPrice ( curByte , matchByte , prevByte , pos + len , nextState ) ; nextState . updateLiteral ( ) ; // Rep0
int nextPosState = ( pos + len + 1 ) & posMask ; price += getLongRepAndLenPrice ( 0 , len2 , nextState , nextPosState ) ; int i = optCur + len + 1 + len2 ; while ( optEnd < i ) opts [ ++ optEnd ] . reset ( ) ; if ( price < opts [ i ] . price ) opts [ i ] . set3 ( price , optCur , dist + REPS , len , 0 ) ; } if ( ++ match == matches . count ) break ; }


signature:
public class LZMA2InputStream { /** * Decompresses into an array of bytes .
 * If < code > len < / code > is zero , no bytes are read and < code > 0 < / code >
 * is returned . Otherwise this will block until < code > len < / code >
 * bytes have been decompressed , the end of the LZMA2 stream is reached ,
 * or an exception is thrown .
 * @ param buf target buffer for uncompressed data
 * @ param off start offset in < code > buf < / code >
 * @ param len maximum number of uncompressed bytes to read
 * @ return number of bytes read , or < code > - 1 < / code > to indicate
 * the end of the compressed stream
 * @ throws CorruptedInputException
 * @ throws XZIOException if the stream has been closed
 * @ throws EOFException
 * compressed input is truncated or corrupt
 * @ throws IOException may be thrown by < code > in < / code > */
public int read ( byte [ ] buf , int off , int len ) throws IOException { } }

implementation: if ( off < 0 || len < 0 || off + len < 0 || off + len > buf . length ) throw new IndexOutOfBoundsException ( ) ; if ( len == 0 ) return 0 ; if ( in == null ) throw new XZIOException ( "Stream closed" ) ; if ( exception != null ) throw exception ; if ( endReached ) return - 1 ; try { int size = 0 ; while ( len > 0 ) { if ( uncompressedSize == 0 ) { decodeChunkHeader ( ) ; if ( endReached ) return size == 0 ? - 1 : size ; } int copySizeMax = Math . min ( uncompressedSize , len ) ; if ( ! isLZMAChunk ) { lz . copyUncompressed ( in , copySizeMax ) ; } else { lz . setLimit ( copySizeMax ) ; lzma . decode ( ) ; } int copiedSize = lz . flush ( buf , off ) ; off += copiedSize ; len -= copiedSize ; size += copiedSize ; uncompressedSize -= copiedSize ; if ( uncompressedSize == 0 ) if ( ! rc . isFinished ( ) || lz . hasPending ( ) ) throw new CorruptedInputException ( ) ; } return size ; } catch ( IOException e ) { exception = e ; throw e ; }


signature:
public class LZMA2InputStream { /** * Returns the number of uncompressed bytes that can be read
 * without blocking . The value is returned with an assumption
 * that the compressed input data will be valid . If the compressed
 * data is corrupt , < code > CorruptedInputException < / code > may get
 * thrown before the number of bytes claimed to be available have
 * been read from this input stream .
 * In LZMA2InputStream , the return value will be non - zero when the
 * decompressor is in the middle of an LZMA2 chunk . The return value
 * will then be the number of uncompressed bytes remaining from that
 * chunk . The return value can also be non - zero in the middle of
 * an uncompressed chunk , but then the return value depends also on
 * the < code > available ( ) < / code > method of the underlying InputStream .
 * @ return the number of uncompressed bytes that can be read
 * without blocking */
public int available ( ) throws IOException { } }

implementation: if ( in == null ) throw new XZIOException ( "Stream closed" ) ; if ( exception != null ) throw exception ; return isLZMAChunk ? uncompressedSize : Math . min ( uncompressedSize , in . available ( ) ) ;


signature:
public class Activator { /** * ( non - Javadoc )
 * @ see org . osgi . framework . BundleActivator # start ( org . osgi . framework . BundleContext ) */
@ Override public void start ( final BundleContext bundleContext ) throws Exception { } }

implementation: Activator . INSTANCE = this ; this . aspects = new ChannelAspectProcessor ( bundleContext ) ; this . recipes = new RecipeProcessor ( bundleContext ) ; this . generatorProcessor = new GeneratorProcessor ( bundleContext ) ; this . generatorProcessor . open ( ) ;


signature:
public class Activator { /** * ( non - Javadoc )
 * @ see org . osgi . framework . BundleActivator # stop ( org . osgi . framework . BundleContext ) */
@ Override public void stop ( final BundleContext bundleContext ) throws Exception { } }

implementation: this . aspects . close ( ) ; this . recipes . dispose ( ) ; this . generatorProcessor . close ( ) ; Activator . INSTANCE = null ;


signature:
public class UTF8Reader { /** * Read a single character . This method will block until a character is
 * available , an I / O error occurs , or the end of the stream is reached .
 * < p > Subclasses that intend to support efficient single - character input
 * should override this method .
 * @ return The character read , as an integer in the range 0 to 16383
 * ( < tt > 0x00-0xffff < / tt > ) , or - 1 if the end of the stream has
 * been reached
 * @ exception IOException If an I / O error occurs */
public int read ( ) throws IOException { } }

implementation:
// decode character
int c = fSurrogate ; if ( fSurrogate == - 1 ) { // NOTE : We use the index into the buffer if there are remaining
// bytes from the last block read . - Ac
int index = 0 ; // get first byte
int b0 = index == fOffset ? fInputStream . read ( ) : fBuffer [ index ++ ] & 0x00FF ; if ( b0 == - 1 ) { return - 1 ; } // UTF - 8 : [ 0xxx xxxx ]
// Unicode : [ 0000 0000 ] [ 0xxx xxxx ]
if ( b0 < 0x80 ) { c = ( char ) b0 ; } // UTF - 8 : [ 110y yyyy ] [ 10xx xxxx ]
// Unicode : [ 0000 0yyy ] [ yyxx xxxx ]
else if ( ( b0 & 0xE0 ) == 0xC0 ) { int b1 = index == fOffset ? fInputStream . read ( ) : fBuffer [ index ++ ] & 0x00FF ; if ( b1 == - 1 ) { expectedByte ( 2 , 2 ) ; } if ( ( b1 & 0xC0 ) != 0x80 ) { invalidByte ( 2 , 2 , b1 ) ; } c = ( ( b0 << 6 ) & 0x07C0 ) | ( b1 & 0x003F ) ; } // UTF - 8 : [ 1110 zzzz ] [ 10yy yyyy ] [ 10xx xxxx ]
// Unicode : [ zzzz yyyy ] [ yyxx xxxx ]
else if ( ( b0 & 0xF0 ) == 0xE0 ) { int b1 = index == fOffset ? fInputStream . read ( ) : fBuffer [ index ++ ] & 0x00FF ; if ( b1 == - 1 ) { expectedByte ( 2 , 3 ) ; } if ( ( b1 & 0xC0 ) != 0x80 ) { invalidByte ( 2 , 3 , b1 ) ; } int b2 = index == fOffset ? fInputStream . read ( ) : fBuffer [ index ++ ] & 0x00FF ; if ( b2 == - 1 ) { expectedByte ( 3 , 3 ) ; } if ( ( b2 & 0xC0 ) != 0x80 ) { invalidByte ( 3 , 3 , b2 ) ; } c = ( ( b0 << 12 ) & 0xF000 ) | ( ( b1 << 6 ) & 0x0FC0 ) | ( b2 & 0x003F ) ; } // UTF - 8 : [ 1111 0uuu ] [ 10uu zzzz ] [ 10yy yyyy ] [ 10xx xxxx ] *
// Unicode : [ 1101 10ww ] [ wwzz zzyy ] ( high surrogate )
// [1101 11yy ] [ yyxx xxxx ] ( low surrogate )
// * uuuuu = wwww + 1
else if ( ( b0 & 0xF8 ) == 0xF0 ) { int b1 = index == fOffset ? fInputStream . read ( ) : fBuffer [ index ++ ] & 0x00FF ; if ( b1 == - 1 ) { expectedByte ( 2 , 4 ) ; } if ( ( b1 & 0xC0 ) != 0x80 ) { invalidByte ( 2 , 3 , b1 ) ; } int b2 = index == fOffset ? fInputStream . read ( ) : fBuffer [ index ++ ] & 0x00FF ; if ( b2 == - 1 ) { expectedByte ( 3 , 4 ) ; } if ( ( b2 & 0xC0 ) != 0x80 ) { invalidByte ( 3 , 3 , b2 ) ; } int b3 = index == fOffset ? fInputStream . read ( ) : fBuffer [ index ++ ] & 0x00FF ; if ( b3 == - 1 ) { expectedByte ( 4 , 4 ) ; } if ( ( b3 & 0xC0 ) != 0x80 ) { invalidByte ( 4 , 4 , b3 ) ; } int uuuuu = ( ( b0 << 2 ) & 0x001C ) | ( ( b1 >> 4 ) & 0x0003 ) ; if ( uuuuu > 0x10 ) { invalidSurrogate ( uuuuu ) ; } int wwww = uuuuu - 1 ; int hs = 0xD800 | ( ( wwww << 6 ) & 0x03C0 ) | ( ( b1 << 2 ) & 0x003C ) | ( ( b2 >> 4 ) & 0x0003 ) ; int ls = 0xDC00 | ( ( b2 << 6 ) & 0x03C0 ) | ( b3 & 0x003F ) ; c = hs ; fSurrogate = ls ; } // error
else { invalidByte ( 1 , 1 , b0 ) ; } } // use surrogate
else { fSurrogate = - 1 ; } // return character
return c ;


signature:
public class UTF8Reader { /** * Read characters into a portion of an array . This method will block
 * until some input is available , an I / O error occurs , or the end of the
 * stream is reached .
 * @ param ch Destination buffer
 * @ param offset Offset at which to start storing characters
 * @ param length Maximum number of characters to read
 * @ return The number of characters read , or - 1 if the end of the
 * stream has been reached
 * @ exception IOException If an I / O error occurs */
public int read ( char ch [ ] , int offset , int length ) throws IOException { } }

implementation:
// handle surrogate
int out = offset ; if ( fSurrogate != - 1 ) { ch [ offset + 1 ] = ( char ) fSurrogate ; fSurrogate = - 1 ; length -- ; out ++ ; } // read bytes
int count = 0 ; if ( fOffset == 0 ) { // adjust length to read
if ( length > fBuffer . length ) { length = fBuffer . length ; } // perform read operation
count = fInputStream . read ( fBuffer , 0 , length ) ; if ( count == - 1 ) { return - 1 ; } count += out - offset ; } // skip read ; last character was in error
// NOTE : Having an offset value other than zero means that there was
// an error in the last character read . In this case , we have
// skipped the read so we don ' t consume any bytes past the
// error . By signalling the error on the next block read we
// allow the method to return the most valid characters that
// it can on the previous block read . - Ac
else { count = fOffset ; fOffset = 0 ; } // convert bytes to characters
final int total = count ; for ( int in = 0 ; in < total ; in ++ ) { int b0 = fBuffer [ in ] & 0x00FF ; // UTF - 8 : [ 0xxx xxxx ]
// Unicode : [ 0000 0000 ] [ 0xxx xxxx ]
if ( b0 < 0x80 ) { ch [ out ++ ] = ( char ) b0 ; continue ; } // UTF - 8 : [ 110y yyyy ] [ 10xx xxxx ]
// Unicode : [ 0000 0yyy ] [ yyxx xxxx ]
if ( ( b0 & 0xE0 ) == 0xC0 ) { int b1 = - 1 ; if ( ++ in < total ) { b1 = fBuffer [ in ] & 0x00FF ; } else { b1 = fInputStream . read ( ) ; if ( b1 == - 1 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fOffset = 1 ; return out - offset ; } expectedByte ( 2 , 2 ) ; } count ++ ; } if ( ( b1 & 0xC0 ) != 0x80 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fBuffer [ 1 ] = ( byte ) b1 ; fOffset = 2 ; return out - offset ; } invalidByte ( 2 , 2 , b1 ) ; } int c = ( ( b0 << 6 ) & 0x07C0 ) | ( b1 & 0x003F ) ; ch [ out ++ ] = ( char ) c ; count -= 1 ; continue ; } // UTF - 8 : [ 1110 zzzz ] [ 10yy yyyy ] [ 10xx xxxx ]
// Unicode : [ zzzz yyyy ] [ yyxx xxxx ]
if ( ( b0 & 0xF0 ) == 0xE0 ) { int b1 = - 1 ; if ( ++ in < total ) { b1 = fBuffer [ in ] & 0x00FF ; } else { b1 = fInputStream . read ( ) ; if ( b1 == - 1 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fOffset = 1 ; return out - offset ; } expectedByte ( 2 , 3 ) ; } count ++ ; } if ( ( b1 & 0xC0 ) != 0x80 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fBuffer [ 1 ] = ( byte ) b1 ; fOffset = 2 ; return out - offset ; } invalidByte ( 2 , 3 , b1 ) ; } int b2 = - 1 ; if ( ++ in < total ) { b2 = fBuffer [ in ] & 0x00FF ; } else { b2 = fInputStream . read ( ) ; if ( b2 == - 1 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fBuffer [ 1 ] = ( byte ) b1 ; fOffset = 2 ; return out - offset ; } expectedByte ( 3 , 3 ) ; } count ++ ; } if ( ( b2 & 0xC0 ) != 0x80 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fBuffer [ 1 ] = ( byte ) b1 ; fBuffer [ 2 ] = ( byte ) b2 ; fOffset = 3 ; return out - offset ; } invalidByte ( 3 , 3 , b2 ) ; } int c = ( ( b0 << 12 ) & 0xF000 ) | ( ( b1 << 6 ) & 0x0FC0 ) | ( b2 & 0x003F ) ; ch [ out ++ ] = ( char ) c ; count -= 2 ; continue ; } // UTF - 8 : [ 1111 0uuu ] [ 10uu zzzz ] [ 10yy yyyy ] [ 10xx xxxx ] *
// Unicode : [ 1101 10ww ] [ wwzz zzyy ] ( high surrogate )
// [1101 11yy ] [ yyxx xxxx ] ( low surrogate )
// * uuuuu = wwww + 1
if ( ( b0 & 0xF8 ) == 0xF0 ) { int b1 = - 1 ; if ( ++ in < total ) { b1 = fBuffer [ in ] & 0x00FF ; } else { b1 = fInputStream . read ( ) ; if ( b1 == - 1 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fOffset = 1 ; return out - offset ; } expectedByte ( 2 , 4 ) ; } count ++ ; } if ( ( b1 & 0xC0 ) != 0x80 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fBuffer [ 1 ] = ( byte ) b1 ; fOffset = 2 ; return out - offset ; } invalidByte ( 2 , 4 , b1 ) ; } int b2 = - 1 ; if ( ++ in < total ) { b2 = fBuffer [ in ] & 0x00FF ; } else { b2 = fInputStream . read ( ) ; if ( b2 == - 1 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fBuffer [ 1 ] = ( byte ) b1 ; fOffset = 2 ; return out - offset ; } expectedByte ( 3 , 4 ) ; } count ++ ; } if ( ( b2 & 0xC0 ) != 0x80 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fBuffer [ 1 ] = ( byte ) b1 ; fBuffer [ 2 ] = ( byte ) b2 ; fOffset = 3 ; return out - offset ; } invalidByte ( 3 , 4 , b2 ) ; } int b3 = - 1 ; if ( ++ in < total ) { b3 = fBuffer [ in ] & 0x00FF ; } else { b3 = fInputStream . read ( ) ; if ( b3 == - 1 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fBuffer [ 1 ] = ( byte ) b1 ; fBuffer [ 2 ] = ( byte ) b2 ; fOffset = 3 ; return out - offset ; } expectedByte ( 4 , 4 ) ; } count ++ ; } if ( ( b3 & 0xC0 ) != 0x80 ) { if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fBuffer [ 1 ] = ( byte ) b1 ; fBuffer [ 2 ] = ( byte ) b2 ; fBuffer [ 3 ] = ( byte ) b3 ; fOffset = 4 ; return out - offset ; } invalidByte ( 4 , 4 , b2 ) ; } // decode bytes into surrogate characters
int uuuuu = ( ( b0 << 2 ) & 0x001C ) | ( ( b1 >> 4 ) & 0x0003 ) ; if ( uuuuu > 0x10 ) { invalidSurrogate ( uuuuu ) ; } int wwww = uuuuu - 1 ; int zzzz = b1 & 0x000F ; int yyyyyy = b2 & 0x003F ; int xxxxxx = b3 & 0x003F ; int hs = 0xD800 | ( ( wwww << 6 ) & 0x03C0 ) | ( zzzz << 2 ) | ( yyyyyy >> 4 ) ; int ls = 0xDC00 | ( ( yyyyyy << 6 ) & 0x03C0 ) | xxxxxx ; // set characters
ch [ out ++ ] = ( char ) hs ; ch [ out ++ ] = ( char ) ls ; count -= 2 ; continue ; } // error
if ( out > offset ) { fBuffer [ 0 ] = ( byte ) b0 ; fOffset = 1 ; return out - offset ; } invalidByte ( 1 , 1 , b0 ) ; } // return number of characters converted
return count ;


signature:
public class UTF8Reader { /** * Throws an exception for expected byte . */
private void expectedByte ( int position , int count ) throws UTFDataFormatException { } }

implementation: throw new UTFDataFormatException ( Localizer . getMessage ( "jsp.error.xml.expectedByte" , Integer . toString ( position ) , Integer . toString ( count ) ) ) ;


signature:
public class UTF8Reader { /** * Throws an exception for invalid byte . */
private void invalidByte ( int position , int count , int c ) throws UTFDataFormatException { } }

implementation: throw new UTFDataFormatException ( Localizer . getMessage ( "jsp.error.xml.invalidByte" , Integer . toString ( position ) , Integer . toString ( count ) ) ) ;


signature:
public class TldScanner { /** * Gets the ' location ' of the TLD associated with the given taglib ' uri ' .
 * Returns null if the uri is not associated with any tag library ' exposed '
 * in the web application . A tag library is ' exposed ' either explicitly in
 * web . xml or implicitly via the uri tag in the TLD of a taglib deployed
 * in a jar file ( WEB - INF / lib ) .
 * @ param uri The taglib uri
 * @ return An array of two Strings : The first element denotes the real
 * path to the TLD . If the path to the TLD points to a jar file , then the
 * second element denotes the name of the TLD entry in the jar file .
 * Returns null if the uri is not associated with any tag library ' exposed '
 * in the web application .
 * This method may be called when the scanning is in one of states :
 * 1 . Called from jspc script , then a full tld scan is required .
 * 2 . The is the first call after servlet initialization , then system jars
 * that are knwon to have tlds but not listeners need to be scanned .
 * 3 . Sebsequent calls , no need to scans . */
@ SuppressWarnings ( "unchecked" ) public String [ ] getLocation ( String uri ) throws JasperException { } }

implementation:
if ( mappings == null ) { // Recovering the map done in onStart .
mappings = ( HashMap < String , String [ ] > ) ctxt . getAttribute ( Constants . JSP_TLD_URI_TO_LOCATION_MAP ) ; } if ( mappings != null && mappings . get ( uri ) != null ) { // if the uri is in , return that , and dont bother to do full scan
return mappings . get ( uri ) ; } if ( ! doneScanning ) { scanListeners = false ; scanTlds ( ) ; doneScanning = true ; } if ( mappings == null ) { // Should never happend
return null ; } return mappings . get ( uri ) ;


signature:
public class TldScanner { /** * Scan the all the tlds accessible in the web app .
 * For performance reasons , this is done in two stages . At servlet
 * initialization time , we only scan the jar files for listeners . The
 * container passes a list of system jar files that are known to contain
 * tlds with listeners . The rest of the jar files will be scanned when
 * a JSP page with a tld referenced is compiled . */
private void scanTlds ( ) throws JasperException { } }

implementation:
mappings = new HashMap < String , String [ ] > ( ) ; // Make a local copy of the system jar cache
jarTldCacheLocal . putAll ( jarTldCache ) ; try { processWebDotXml ( ) ; scanJars ( ) ; processTldsInFileSystem ( "/WEB-INF/" ) ; } catch ( JasperException ex ) { throw ex ; } catch ( Exception ex ) { throw new JasperException ( Localizer . getMessage ( "jsp.error.internal.tldinit" ) , ex ) ; }


signature:
public class TldScanner { /** * Populates taglib map described in web . xml . */
private void processWebDotXml ( ) throws Exception { } }

implementation:
// Skip if we are only looking for listeners
if ( scanListeners ) { return ; } JspConfigDescriptor jspConfig = ctxt . getJspConfigDescriptor ( ) ; if ( jspConfig == null ) { return ; } for ( TaglibDescriptor taglib : jspConfig . getTaglibs ( ) ) { if ( taglib == null ) { continue ; } String tagUri = taglib . getTaglibURI ( ) ; String tagLoc = taglib . getTaglibLocation ( ) ; if ( tagUri == null || tagLoc == null ) { continue ; } // Ignore system tlds in web . xml , for backward compatibility
if ( systemUris . contains ( tagUri ) || ( ! useMyFaces && systemUrisJsf . contains ( tagUri ) ) ) { continue ; } // Save this location if appropriate
if ( uriType ( tagLoc ) == NOROOT_REL_URI ) tagLoc = "/WEB-INF/" + tagLoc ; String tagLoc2 = null ; if ( tagLoc . endsWith ( JAR_FILE_SUFFIX ) ) { tagLoc = ctxt . getResource ( tagLoc ) . toString ( ) ; tagLoc2 = "META-INF/taglib.tld" ; } if ( log . isLoggable ( Level . FINE ) ) { log . fine ( "Add tld map from web.xml: " + tagUri + "=>" + tagLoc + "," + tagLoc2 ) ; } mappings . put ( tagUri , new String [ ] { tagLoc , tagLoc2 } ) ; }