FileDocCategorySizeDatePackage
HTMLPageImpl.javaAPI DocAzureus 3.0.3.42776Thu Feb 09 19:43:12 GMT 2006org.gudy.azureus2.core3.html.impl

HTMLPageImpl

public class HTMLPageImpl extends HTMLChunkImpl implements HTMLPage
author
parg

Fields Summary
Constructors Summary
public HTMLPageImpl(InputStream is, boolean close_file)

		BufferedReader	br = null;
		
		StringBuffer	res = new StringBuffer(1024);
		
		try{
			
			br = new BufferedReader( new InputStreamReader(is));
			
			while(true){
				
				String	line = br.readLine();
				
				if ( line == null ){
					
					break;
				}
				
				res.append( line );
			}
			
			setContent( res.toString());
			
		}catch( IOException e ){
			
			throw( new HTMLException( "Error reading HTML page", e ));
			
		}finally{
			
			if ( br != null && close_file ){
				
				try{
					
					br.close();
					
				}catch( IOException e ){
					
					Debug.printStackTrace( e );
				}
			}
		}
	
Methods Summary
public java.net.URLgetMetaRefreshURL()

	       // "<META HTTP-EQUIV=\"refresh\" content=\"5; URL=xxxxxxx>";
	       
		String[]	tags = getTags( "META" );
		
		for (int i=0;i<tags.length;i++){
			
			String	tag 	= tags[i];
			
			String	lc_tag	= tag.toLowerCase();
			
			int pos = lc_tag.indexOf("http-equiv=\"refresh\"");
							
			int	url_start = lc_tag.indexOf( "url=" );
			
			if ( pos != -1 && url_start != -1 ){
				
				url_start += 4;
				
				int	e1 = lc_tag.indexOf( "\"", url_start );
				int e2 = lc_tag.indexOf( ">", url_start );
				
				if ( e1 != -1 ){
					
					e2 = e1;
				
					try{
						return( new URL(tag.substring(url_start, e2).trim()));
						
					}catch( MalformedURLException e ){
						
						Debug.printStackTrace( e );
					}
				}
			}
		}
				
		return( null );