Ila

org.topoweb.ila
Class HttpState

java.lang.Object
  |
  +--org.topoweb.ila.State
        |
        +--org.topoweb.ila.VisitedState
              |
              +--org.topoweb.ila.HttpState
All Implemented Interfaces:
NodeConstants, StateConstants

public class HttpState
extends VisitedState

The respresentation of the state of an HTTP node in an Ila system. Instances are immutable. This class represents results of idempotent HTTP operations, and then, to the extent feasible, only if the results are not client-specific. Client-specific results are those caused by a limitation or a qualification of the type of HTTP response expected by the user-agent. Network errors (e.g. no-route-to-host or DNS erros) are not encapsulated by this class.

Interpretation of HTTP Status Codes

The following HTTP response codes are interpreted to be in the OK state: The 4xx class of HTTP response codes are generally interpreted to be in the NF (or NK, if the back link count is zero) state. These are 400-405, 410, 414; all other 4xx class response codes result in IllegalArgumentException being thrown. The content-length must be zero.

The 1xx and 5xx class of HTTP response codes are not supported by this class. The rationale for not representing the 5xx class as NF is that these should typically be fixed by the administator of the HTTP server and are thus temporary.

Author:
Babak Farhang
See Also:
HttpStateBuffer

Field Summary
 
Fields inherited from interface org.topoweb.ila.StateConstants
NF, NK, NV, OK
 
Fields inherited from interface org.topoweb.ila.NodeConstants
BACK, FIRST_PAGE, FORE, LAST_PAGE, LINK_MASK, PAGE_MASK
 
Constructor Summary
HttpState(int status, int versionId, long versionTimestamp, int syncVersionId, long syncVersionTimestamp, int forelinkCount, int coForelinkCount, long backlinkCount, long coBacklinkCount, int httpStatus, java.lang.String contentType, int contentLength, long lastModified, long expiration, java.lang.String title, java.lang.String userAgent)
          Creates a new instance using the given HTTP status code, content-length, and user-agent fields.
 
Method Summary
 int getContentLength()
          Returns the content-length.
 java.lang.String getContentType()
          Returns the content-type HTTP header field
 long getExpiration()
           
 int getHttpStatus()
          Returns the HTTP status code.
 long getLastModified()
           
 java.lang.String getTitle()
           
 
Methods inherited from class org.topoweb.ila.VisitedState
getUserAgent
 
Methods inherited from class org.topoweb.ila.State
getCoLinkCount, getLinkCount, getStatus, getSyncVersionId, getSyncVersionTimestamp, getVersionId, getVersionTimestamp, statusToString, supercedes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpState

public HttpState(int status,
                 int versionId,
                 long versionTimestamp,
                 int syncVersionId,
                 long syncVersionTimestamp,
                 int forelinkCount,
                 int coForelinkCount,
                 long backlinkCount,
                 long coBacklinkCount,
                 int httpStatus,
                 java.lang.String contentType,
                 int contentLength,
                 long lastModified,
                 long expiration,
                 java.lang.String title,
                 java.lang.String userAgent)
          throws java.lang.IllegalArgumentException
Creates a new instance using the given HTTP status code, content-length, and user-agent fields.

Parameters:
status - the status, as defined by StateConstants
versionId - the version ID
versionTimestamp - the version timestamp
syncVersionId - the sync version ID
syncVersionTimestamp - the sync version timestamp
forelinkCount - the total number of forelinks
coForelinkCount - the total number of co--forelinks
backlinkCount - the total number of backlinks
coBacklinkCount - the total number of co-backlinks
httpStatus - the HTTP status code
contentType - the mime-type of the document returned by the HTTP server
contentLength - the content-length (as determined either by the header field or by counting the number of bytes in the content)
lastModified - the date last modified (in millis)
expiration - the expiration date (in millis)
title - the title
userAgent - the user-agent that retrieved the contents of the HTTP URL
Throws:
java.lang.IllegalArgumentException -
if the super constructor throws it;
if userAgent is null;
if the HTTP status code ( httpStatus ) is not represented by this class;
if status, forelinkCount, contentType , or contentLength is not consistent with the HTTP status code;
if lastModified or expiration is less than zero
See Also:
Interpretation of HTTP Status Codes, State.State(int,int,long,int,long,int,int,long,long)
Method Detail

getHttpStatus

public final int getHttpStatus()
Returns the HTTP status code.

Returns:
the HTTP status code

getContentType

public final java.lang.String getContentType()
Returns the content-type HTTP header field

Returns:
the content type (a mime-type), or null if not specified

getContentLength

public final int getContentLength()
Returns the content-length. This is either specified in the content-length HTTP header field or from the byte count of the content returned by the HTTP server.

Returns:
the content length, or zero if not applicable

getLastModified

public final long getLastModified()

getExpiration

public final long getExpiration()

getTitle

public final java.lang.String getTitle()

Ila

Copyright (C) 2002 Babak Farhang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.