xpageproperties.java

来自「java写的浏览器」· Java 代码 · 共 110 行

JAVA
110
字号
/****************************************************************
*              XBrowser  -  eXtended web Browser                *
*                                                               *
*           Copyright (c) 2000-2001  Armond Avanes              *
*     Refer to ReadMe & License files for more information      *
*                                                               *
*                                                               *
*                      By: Armond Avanes                        *
*       Armond555@yahoo.com     &    Armond333@yahoo.com        *
*                http://xbrowser.sourceforge.net/               *
*****************************************************************/
package xbrowser.renderer;

import java.util.*;
import java.text.*;
import java.net.*;
import java.io.*;

/**
 * Properties that every renderer can extract on loading.
 */
public class XPageProperties
{
	public XPageProperties(URLConnection conn, URL page)
	{
		url = page.toString();
		protocol = page.getProtocol();
		contentType = conn.getContentType();
		connectionType = conn.getHeaderField("Connection");
		size = Integer.toString( conn.getContentLength() );
		created = df.format( new Date(conn.getDate()) );
		modified = df.format( new Date(conn.getLastModified()) );
	}

    public XPageProperties(String _url, String ct, long _size, long mod)
    {
        url = _url;
        protocol = "http";
        contentType = ct;
        size = Long.toString( _size);
        created = df.format( new Date( mod));
        modified = created;
		connectionType = "Taken from cache";
    }

	public String getURL()
	{
		return url;
	}

	public String getProtocol()
	{
		return protocol;
	}

	public String getContentType()
	{
		return contentType;
	}

	public String getConnectionType()
	{
		return connectionType;
	}

	public String getCreated()
	{
		return created;
	}

	public String getModified()
	{
		return modified;
	}

	public String getSize()
	{
		return size;
	}

	public File getCacheFile()
	{
		return cacheFile;
	}

	public boolean isFromCache()
	{
		return fromCache;
	}

	public void setCachingInfo(File cache_file, boolean from_cache)
	{
	    cacheFile = cache_file;
		fromCache = from_cache;
	}

// Attributes:
	private static DateFormat df = DateFormat.getDateInstance();

	private String url;
	private String protocol;
	private String contentType;
	private String connectionType;
	private String created, modified;
	private String size = "0";

	private File cacheFile; // null if not cacheable
	private boolean fromCache;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?