home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / Response.java < prev    next >
Text File  |  1997-10-25  |  5KB  |  208 lines

  1. /*  ********************************************************************************
  2.     Response.java ******************************************************************
  3.     ********************************************************************************  */
  4.  
  5. package aspcomp;
  6.  
  7. import com.ms.asp.*;
  8. import com.ms.com.*;
  9. import java.io.*;
  10. import java.util.*;
  11.  
  12. /**
  13.  * Cover class for the ASP Response intrinsic.
  14.  */
  15.  
  16. public class Response extends OutputStream
  17. {
  18.  
  19. /*  ********************************************************************************
  20.     Constructor ********************************************************************
  21.     ********************************************************************************  */
  22.  
  23.     public Response(IResponse response) 
  24.     {
  25.         m_IResponse = response;
  26.     }
  27.  
  28.  
  29. /*  ********************************************************************************
  30.     Internal (Private) Variables ***************************************************
  31.     ********************************************************************************  */
  32.  
  33.     private IResponse m_IResponse;
  34.  
  35.  
  36. /*  ********************************************************************************
  37.     External (Public) Methods ******************************************************
  38.     ********************************************************************************  */
  39.  
  40.     public void addHeader(String name, String value) 
  41.     {
  42.         m_IResponse.AddHeader(name, value);
  43.     }
  44.  
  45.     public boolean getBuffered() 
  46.     {
  47.         return m_IResponse.getBuffer();
  48.     }
  49.  
  50.     public void setBuffered(boolean fIsBuffered) 
  51.     {
  52.         m_IResponse.putBuffer(fIsBuffered);
  53.     }
  54.  
  55.     public int getExpires() 
  56.     {
  57.         return VariantToJava.getInt(m_IResponse.getExpires());
  58.     }
  59.  
  60.     public void setExpires(int iExpirationMinutes) 
  61.     {
  62.         m_IResponse.putExpires(iExpirationMinutes);
  63.     }
  64.  
  65.     public Date getExpiresAbsolute() 
  66.     {
  67.         return VariantToJava.getDate(m_IResponse.getExpiresAbsolute());
  68.     }
  69.  
  70.     public void setExpiresAbsolute(Date dateExpire) 
  71.     {
  72.         m_IResponse.putExpiresAbsolute(JavaToVariant.dateToDouble(dateExpire));
  73.     }
  74.  
  75.     public String getCharSet() 
  76.     {
  77.         return m_IResponse.getCharSet();
  78.     }
  79.  
  80.     public void setCharSet(String strCharSet) 
  81.     {
  82.         m_IResponse.putCharSet(strCharSet);
  83.     }
  84.  
  85.     public String getContentType() 
  86.     {
  87.         return m_IResponse.getContentType();
  88.     }
  89.  
  90.     public void setContentType(String strContentType) 
  91.     {
  92.         m_IResponse.putContentType(strContentType);
  93.     }
  94.  
  95.     public String getCacheControl() 
  96.     {
  97.         return m_IResponse.getCacheControl();
  98.     }
  99.  
  100.     public void setCacheControl(String strCacheControl) 
  101.     {
  102.         m_IResponse.putCacheControl(strCacheControl);
  103.     }
  104.  
  105.     public String getStatus() 
  106.     {
  107.         return m_IResponse.getStatus();
  108.     }
  109.  
  110.     public void setStatus(String strStatus) 
  111.     {
  112.         m_IResponse.putStatus(strStatus);
  113.     }
  114.  
  115.     public void appendToLog(String s) 
  116.     {
  117.         m_IResponse.AppendToLog(s);
  118.     }
  119.  
  120.     public boolean isClientConnected() 
  121.     {
  122.         return m_IResponse.IsClientConnected();
  123.     }
  124.  
  125.     public void end() 
  126.     {
  127.         m_IResponse.End();
  128.     }
  129.  
  130.     public void clear() 
  131.     {
  132.         m_IResponse.Clear();
  133.     }
  134.  
  135. //    public void flush() is covered below (overriding OutputStream.flush()).
  136.  
  137.     public void write(String str) 
  138.     {
  139.         m_IResponse.Write(new Variant(str));
  140.     }
  141.  
  142.     public void pics(String str) 
  143.     {
  144.         m_IResponse.Pics(str);
  145.     }
  146.  
  147.     public void redirect(String str) 
  148.     {
  149.         m_IResponse.Redirect(str);
  150.     }
  151.  
  152.     public CookieDictionary getCookies()  
  153.     {
  154.         return new CookieDictionary(m_IResponse.getCookies());
  155.     }
  156.  
  157.  
  158. /*  ********************************************************************************
  159.     External (Public) java.io.OutputStream Interface Methods ***********************
  160.     ********************************************************************************  */
  161.  
  162.     public void write(int i) 
  163.         throws IOException,
  164.                NullPointerException,
  165.                 IndexOutOfBoundsException
  166.     {
  167.         byte [] b = new byte[1];
  168.         b[0] = (byte) i;
  169.         write(b, 0, 1);
  170.     }
  171.  
  172.     public void write(byte[] b) 
  173.         throws IOException,
  174.                NullPointerException,
  175.                IndexOutOfBoundsException
  176.     {
  177.         write(b, 0, b.length);
  178.     }
  179.  
  180.     public void write(byte[] b, int off, int len) 
  181.         throws IOException,
  182.                 NullPointerException,
  183.                 IndexOutOfBoundsException
  184.     {
  185.         SafeArray sa = new SafeArray(Variant.VariantByte, len);
  186.         sa.setBytes(0, len, b, off);
  187.         Variant v = new Variant(sa, true);
  188.         m_IResponse.BinaryWrite(v);
  189.     }
  190.  
  191.     public void close() 
  192.         throws IOException
  193.     {
  194.         // Nothing to do here -- we don't have to close the ASP response stream
  195.     }
  196.  
  197.     public void flush() 
  198.         throws IOException
  199.     {
  200.         // Can only flush if ASP buffering is on
  201.         if (getBuffered() == true)
  202.         {
  203.             m_IResponse.Flush();
  204.         }
  205.     }
  206.  
  207. }
  208.