org.w3c.rdfpic.core
Class ProtocolHandler

java.lang.Object
  |
  +--org.w3c.rdfpic.core.ProtocolHandler

public class ProtocolHandler
extends java.lang.Object

ProtocolHandler abstracts read/write access to a URL independant of the protocol. When initialized with its url, a ProtocolHandler instance buffers that entire URL into memory. ProtocolHandler's main advantage is HTTP 1.1 PUT support, allowing write access over the web.


Field Summary
(package private)  byte[] readBuf
           
(package private)  SubPHandler sph
           
(package private)  java.net.URL url
           
 
Constructor Summary
ProtocolHandler(java.net.URL url)
          Creates a new ProtocolHandler instance with the given url and buffers it's contents
 
Method Summary
 boolean canRead()
          Returns whether the file is readable.
 boolean canWrite()
          Returns whether the file is writable.
 java.lang.String contentType()
          Returns, if available, the MIME type of the url's contents.
(package private)  void filePH()
          Initializes a helper class to deal with file:// urls.
 int fileSize()
          Returns the size of the file loaded (measured in bytes)
 java.io.InputStream getIS()
          Returns a readable InputStream from the url.
(package private)  void httpPH()
          Initilizes a helper class to deal with http:// urls.
 byte[] read()
          Reads the entire file.
 void write(byte[] data)
          Writes the entire file (overwriting if necessary).
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

url

java.net.URL url

sph

SubPHandler sph

readBuf

byte[] readBuf
Constructor Detail

ProtocolHandler

public ProtocolHandler(java.net.URL url)
                throws PHException
Creates a new ProtocolHandler instance with the given url and buffers it's contents
Method Detail

httpPH

void httpPH()
      throws PHException
Initilizes a helper class to deal with http:// urls. (Called by constructor)

filePH

void filePH()
      throws PHException
Initializes a helper class to deal with file:// urls. (Called by constructor)

getIS

public java.io.InputStream getIS()
                          throws PH_noRead
Returns a readable InputStream from the url.

fileSize

public int fileSize()
             throws PH_noRead
Returns the size of the file loaded (measured in bytes)

read

public byte[] read()
            throws PH_noRead
Reads the entire file.

write

public void write(byte[] data)
           throws PHException
Writes the entire file (overwriting if necessary).

contentType

public java.lang.String contentType()
                             throws PHException
Returns, if available, the MIME type of the url's contents. (not fully implemented yet).

canRead

public boolean canRead()
Returns whether the file is readable. (The return value is guaranteed accurate.)

canWrite

public boolean canWrite()
Returns whether the file is writable. (May return true even when not writable.)