View Javadoc
1   // NAME
2   //      $RCSfile: SetPdu_vec.java,v $
3   // DESCRIPTION
4   //      [given below in javadoc format]
5   // DELTA
6   //      $Revision: 3.14 $
7   // CREATED
8   //      $Date: 2006/11/29 16:12:50 $
9   // COPYRIGHT
10  //      Westhawk Ltd
11  // TO DO
12  //
13  
14  /*
15   * Copyright (C) 1996 - 1998 by Westhawk Ltd (www.westhawk.nl)
16   * Copyright (C) 1998 - 2006 by Westhawk Ltd 
17   * <a href="www.westhawk.co.uk">www.westhawk.co.uk</a>
18   *
19   * Permission to use, copy, modify, and distribute this software
20   * for any purpose and without fee is hereby granted, provided
21   * that the above copyright notices appear in all copies and that
22   * both the copyright notice and this permission notice appear in
23   * supporting documentation.
24   * This software is provided "as is" without express or implied
25   * warranty.
26   * author <a href="mailto:snmp@westhawk.co.uk">Tim Panton</a>
27   */
28   
29  package uk.co.westhawk.snmp.pdu;
30  
31  /*-
32   * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
33   * SNMP Java Client
34   * ჻჻჻჻჻჻
35   * Copyright 2023 MetricsHub, Westhawk
36   * ჻჻჻჻჻჻
37   * This program is free software: you can redistribute it and/or modify
38   * it under the terms of the GNU Lesser General Public License as
39   * published by the Free Software Foundation, either version 3 of the
40   * License, or (at your option) any later version.
41   *
42   * This program is distributed in the hope that it will be useful,
43   * but WITHOUT ANY WARRANTY; without even the implied warranty of
44   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
45   * GNU General Lesser Public License for more details.
46   *
47   * You should have received a copy of the GNU General Lesser Public
48   * License along with this program.  If not, see
49   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
50   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
51   */
52  import uk.co.westhawk.snmp.stack.*;
53  import java.lang.*;
54  
55  /**
56   * <p>
57   * The SetPdu_vec class will set the value of a number of 
58   * objects (OIDs), based on the Set request.
59   * </p>
60   *
61   * <p>
62   * Specify with <em>addOid()</em> the OIDs that should be requested with this
63   * PDU request. No more than <em>count</em> (see constructor) should be added.
64   * Add an Observer to the PDU with <em>addObserver()</em>, and send the PDU
65   * with <em>send()</em>.
66   * </p>
67   *
68   * <p>
69   * If no exception occurred whilst receiving the response, the Object to the 
70   * update() method of the Observer will be an array of
71   * varbinds, so they may contains any AsnObject type.
72   * If an exception occurred, that exception will be passed as the Object
73   * to the update() method.
74   * </p>
75   *
76   * @see SetPdu#addOid
77   * @see Pdu#send
78   * @see varbind
79   * @see OneSetPdu
80   *
81   * @author <a href="mailto:snmp@westhawk.co.uk">Birgit Arkesteijn</a>
82   * @version $Revision: 3.14 $ $Date: 2006/11/29 16:12:50 $
83   */
84  public class SetPdu_vec extends SetPdu {
85      private static final String version_id = "@(#)$Id: SetPdu_vec.java,v 3.14 2006/11/29 16:12:50 birgit Exp $ Copyright Westhawk Ltd";
86  
87      varbind[] value;
88  
89      /**
90       * Constructor.
91       *
92       * @param con   The context of the request
93       * @param count The number of OIDs to be get
94       */
95      public SetPdu_vec(SnmpContextBasisFace con, int count) {
96          super(con);
97          value = new varbind[count];
98      }
99  
100     /**
101      * The value of the request is set. This will be called by
102      * Pdu.fillin(). These are the values of the OIDs after the Set request
103      * was done. If the SNMP server allowed the sets, these will be the
104      * same values as was set in SetPdu.addOid().
105      *
106      * @param n   the index of the value
107      * @param var the value
108      * @see Pdu#new_value
109      * @see SetPdu#addOid(String, AsnObject)
110      */
111     protected void new_value(int n, varbind var) {
112         if (n < value.length) {
113             value[n] = var;
114         }
115     }
116 
117     /**
118      * This method notifies all observers.
119      * This will be called by Pdu.fillin().
120      * 
121      * <p>
122      * If no exception occurred whilst receiving the response, the
123      * Object to the update() method of the Observer will be an array of
124      * varbinds, so they may contains any AsnObject type. If an
125      * exception occurred, that exception will be passed as the Object
126      * to the update() method.
127      * </p>
128      */
129     protected void tell_them() {
130         notifyObservers(value);
131     }
132 }