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

  1. /*  ********************************************************************************
  2.     RequestDictionary.java *********************************************************
  3.     ********************************************************************************  */
  4.  
  5. package aspcomp;
  6.  
  7. import com.ms.asp.*;
  8. import com.ms.com.*;
  9. import java.util.*;
  10.  
  11. /**
  12.  * Used to access the subsidiary collections of the Request object.
  13.  */
  14.  
  15. public class RequestDictionary 
  16.     extends java.util.Dictionary
  17.     implements aspcomp.Map, aspcomp.Enumerator
  18. {
  19.  
  20. /*  ********************************************************************************
  21.     Constructor ********************************************************************
  22.     ********************************************************************************  */
  23.  
  24.     public RequestDictionary(IRequestDictionary reqDic) 
  25.     {
  26.         m_irdDict = reqDic;
  27.         enum = new VariantEnumerator((IEnumVariant) m_irdDict.get_NewEnum());
  28.     }
  29.  
  30.  
  31. /*  ********************************************************************************
  32.     Internal (Private) Variables ***************************************************
  33.     ********************************************************************************  */
  34.  
  35.     private IRequestDictionary m_irdDict;
  36.     private VariantEnumerator enum;
  37.  
  38.  
  39. /*  ********************************************************************************
  40.     Internal (Private) Methods *****************************************************
  41.     ********************************************************************************  */
  42.  
  43.     private Variant getItem(String name) 
  44.     {
  45.         Variant vr = m_irdDict.getItem(new Variant(name));
  46.         return vr;
  47.     }
  48.  
  49.  
  50. /*  ********************************************************************************
  51.     External (Public) Methods ******************************************************
  52.     ********************************************************************************  */
  53.  
  54.     public int getCount() 
  55.     {
  56.         return m_irdDict.getCount();
  57.     }
  58.  
  59.  
  60. /*  ********************************************************************************
  61.     External (Public) aspcomp.Map Interface Methods ********************************
  62.     ********************************************************************************  */
  63.  
  64.     public int getType(String name) 
  65.     {
  66.         Variant v = getItem(name);
  67.         return v.getvt();
  68.     }
  69.     
  70.     public boolean getBoolean(String name)        
  71.         throws ClassCastException 
  72.     {
  73.         return VariantToJava.getBoolean(getItem(name));
  74.     }
  75.  
  76.     public byte getByte(String name)            
  77.         throws ClassCastException 
  78.     {
  79.         return VariantToJava.getByte(getItem(name));
  80.     }
  81.  
  82.     public short getShort(String name)            
  83.         throws ClassCastException 
  84.     {
  85.         return VariantToJava.getShort(getItem(name));
  86.     }
  87.  
  88.     public char getChar(String name)            
  89.         throws ClassCastException 
  90.     {
  91.         return VariantToJava.getChar(getItem(name));
  92.     }
  93.  
  94.     public int getInt(String name)                
  95.         throws ClassCastException 
  96.     {
  97.         return VariantToJava.getInt(getItem(name));
  98.     }
  99.  
  100.     public long getLong(String name)            
  101.         throws ClassCastException 
  102.     {
  103.         return VariantToJava.getLong(getItem(name));
  104.     }
  105.  
  106.     public float getFloat(String name)            
  107.         throws ClassCastException 
  108.     {
  109.         return VariantToJava.getFloat(getItem(name));
  110.     }
  111.  
  112.     public double getDouble(String name)        
  113.         throws ClassCastException 
  114.     {
  115.         return VariantToJava.getDouble(getItem(name));
  116.     }
  117.  
  118.     public String getString(String name)        
  119.         throws ClassCastException 
  120.     {
  121.         return VariantToJava.getString(getItem(name));
  122.     }
  123.  
  124.     public Date getDate(String name)            
  125.         throws ClassCastException 
  126.     {
  127.         return VariantToJava.getDate(getItem(name));
  128.     }
  129.  
  130.     public Object getObject(String name)        
  131.         throws ClassCastException 
  132.     {
  133.         return VariantToJava.getObject(getItem(name));
  134.     }
  135.  
  136.     public Variant getVariant(String name)        
  137.         throws ClassCastException 
  138.     {
  139.         return getItem(name);
  140.     }
  141.  
  142.     //
  143.     //    Request dictionaries are read-only dictionaries, so they
  144.     //    should throw errors on an attempt to make a write.
  145.     //
  146.  
  147.     public void setObject(String name, Object o)        
  148.         throws AspComponentException 
  149.     {
  150.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  151.     }
  152.  
  153.     public void setBoolean(String name,boolean b)        
  154.         throws AspComponentException 
  155.     {
  156.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  157.     }
  158.  
  159.     public void setByte(String name,byte b)                
  160.         throws AspComponentException 
  161.     {
  162.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  163.     }
  164.  
  165.     public void setShort(String name,short i)            
  166.         throws AspComponentException 
  167.     {
  168.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  169.     }
  170.  
  171.     public void setInt(String name, int i)                
  172.         throws AspComponentException 
  173.     {
  174.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  175.     }
  176.  
  177.     public void setFloat(String name,float f)            
  178.         throws AspComponentException 
  179.     {
  180.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  181.     }
  182.  
  183.     public void setDouble(String name,double d)            
  184.         throws AspComponentException 
  185.     {
  186.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  187.     }
  188.  
  189.     public void setString(String name,String str)        
  190.         throws AspComponentException 
  191.     {
  192.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  193.     }
  194.  
  195.     public void setDate(String name, Date d)            
  196.         throws AspComponentException 
  197.     {
  198.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  199.     }
  200.  
  201.     public void setVariant(String name, Variant v)        
  202.         throws AspComponentException 
  203.     {
  204.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  205.     }
  206.  
  207.  
  208. /*  ********************************************************************************
  209.     External (Public) java.util.Dictionary Class Methods ***************************
  210.     ********************************************************************************  */
  211.     public Object get(Object key) 
  212.         throws AspComponentException 
  213.     {
  214.         if (key instanceof String) {
  215.             return getItem((String) key);
  216.         }
  217.         else if (key instanceof Variant) {
  218.             Variant v = (Variant) key;
  219.             if (v.getvt() == Variant.VariantString) {
  220.                 return getItem(v.getString());
  221.             }
  222.         }
  223.  
  224.         throw new AspComponentException(AspLocalizedStrings.ASP_E_NON_STRING_DICT_KEY);
  225.     }
  226.  
  227.     public Object put(Object key, Object value) 
  228.         throws AspComponentException 
  229.     {
  230.         throw new AspComponentException(AspLocalizedStrings.ASP_E_READ_ONLY_DICT);
  231.     }
  232.  
  233.     public int size() 
  234.     {
  235.         return getCount();
  236.     }
  237.  
  238.     public boolean isEmpty() 
  239.     {
  240.         return (m_irdDict.getCount() == 0);
  241.     }
  242.  
  243.     public Enumeration keys() 
  244.     {
  245.         return new VariantEnumerator((IEnumVariant) m_irdDict.get_NewEnum());
  246.     }
  247.     
  248.     public Enumeration elements() 
  249.     {
  250.         return new ObjectEnumerator((IEnumVariant) m_irdDict.get_NewEnum(), this);
  251.     }
  252.  
  253.     public Object remove(Object key) 
  254.         throws AspComponentException 
  255.     {
  256.         throw new AspComponentException(AspLocalizedStrings.ASP_E_DICT_REMOVE);
  257.     }
  258.  
  259.  
  260. /*  ********************************************************************************
  261.     External (Public) java.util.Enumeration Interface Methods **********************
  262.     ********************************************************************************  */
  263.  
  264.     public boolean hasMoreElements() 
  265.     {
  266.         return enum.hasMoreElements();
  267.     }
  268.  
  269.     public Object nextElement() 
  270.         throws NoSuchElementException 
  271.     {
  272.         return enum.nextElement();
  273.     }
  274.  
  275.  
  276. /*  ********************************************************************************
  277.     External (Public) java.lang.Cloneable Interface Methods ************************
  278.     ********************************************************************************  */
  279.  
  280.     public Object clone() 
  281.     {
  282.         return enum.clone();
  283.     }
  284.  
  285.  
  286. /*  ********************************************************************************
  287.     External (Public) aspcomp.Enumerator Interface Methods *************************
  288.     ********************************************************************************  */
  289.  
  290.     public void reset() 
  291.     {
  292.         enum.reset();
  293.     }
  294. }
  295.  
  296.