mstover1    02/03/17 16:48:25

  Modified:    src/org/apache/jmeter/control/gui WorkBenchGui.java
               src/org/apache/jmeter/resources messages.properties
               src/org/apache/jmeter/util JMeterUtils.java
  Added:       src/org/apache/jmeter/control TestElement.java
               src/org/apache/jmeter/gui JMeterGUIComponent.java
               src/org/apache/jmeter/protocol/http/modifier ParamMask.java
                        ParamModifier.java
               src/org/apache/jmeter/protocol/http/modifier/gui
                        ParamModifierGui.java
               src/org/apache/jmeter/protocol/http/save
                        ParamMaskHandler.java
  Log:
  Adding new Parameter Mask Modifier
  
  Revision  Changes    Path
  1.1                  jakarta-jmeter/src/org/apache/jmeter/control/TestElement.java
  
  Index: TestElement.java
  ===================================================================
  package org.apache.jmeter.control;
  
  import java.util.List;
  
  /**
   * <p>Title: Jakarta JMeter</p>
   * <p>Description: Load testing software</p>
   * <p>Copyright: Copyright (c) 2002</p>
   * <p>Company: Apache Foundation</p>
   * @author Michael Stover
   * @version 1.0
   */
  
  public interface TestElement extends Cloneable
  {
        public void addTestElement(TestElement child);
  
        public List getPropertyNames();
  
        public Object getProperty(String key);
  
        public void setProperty(String key,Object property);
  
        //lifecycle methods
  
        public Object clone();
  
        public void initialize();
  }
  
  
  1.2       +42 -5     
jakarta-jmeter/src/org/apache/jmeter/control/gui/WorkBenchGui.java
  
  Index: WorkBenchGui.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/control/gui/WorkBenchGui.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WorkBenchGui.java 29 Sep 2001 15:12:12 -0000      1.1
  +++ WorkBenchGui.java 18 Mar 2002 00:48:25 -0000      1.2
  @@ -64,18 +64,20 @@
   import org.apache.jmeter.gui.*;
   import org.apache.jmeter.util.JMeterUtils;
   import org.apache.jmeter.control.WorkBench;
  +import org.apache.jmeter.control.TestElement;
   
   /************************************************************
    *  Title: JMeter Description: Copyright: Copyright (c) 2000 Company: Apache
    *
    *@author     Kevin Hammond
  - *@created    $Date: 2001/09/29 15:12:12 $
  + *@created    $Date: 2002/03/18 00:48:25 $
    *@version    1.0
    ***********************************************************/
   
  -public class WorkBenchGui extends JPanel implements ModelSupported
  +public class WorkBenchGui extends JPanel implements 
ModelSupported,JMeterGUIComponent
   {
        WorkBench model;
  +     NamePanel namePanel;
   
        /************************************************************
         *  !ToDo (Constructor description)
  @@ -114,7 +116,7 @@
   
                // TITLE
                JLabel panelTitleLabel;
  -             if (model.isRootNode()) 
  +             if (model.isRootNode())
                {
                        panelTitleLabel = new 
JLabel(JMeterUtils.getResString("root_title"));
                }
  @@ -122,7 +124,7 @@
                {
                        panelTitleLabel = new 
JLabel(JMeterUtils.getResString("workbench_title"));
                }
  -             
  +
                Font curFont = panelTitleLabel.getFont();
                int curFontSize = curFont.getSize();
                curFontSize += 4;
  @@ -130,8 +132,43 @@
                mainPanel.add(panelTitleLabel);
   
                // NAME
  -             mainPanel.add(new NamePanel(model));
  +             namePanel = new NamePanel(model);
  +             mainPanel.add(namePanel);
   
                this.add(mainPanel);
  +     }
  +
  +     public String getName()
  +     {
  +             return namePanel.getName();
  +     }
  +
  +     public void setName(String name)
  +     {
  +             namePanel.setName(name);
  +     }
  +
  +     public TestElement createTestElement()
  +     {
  +             return null;
  +     }
  +
  +     public void configure(TestElement element)
  +     {
  +             if(element instanceof WorkBench)
  +             {
  +                     setModel((WorkBench)element);
  +                     updateGui();
  +             }
  +     }
  +
  +     public JMenu createPopupMenu()
  +     {
  +             return null;
  +     }
  +
  +     public String getStaticLabel()
  +     {
  +             return JMeterUtils.getResString("workbench");
        }
   }
  
  
  
  1.1                  jakarta-jmeter/src/org/apache/jmeter/gui/JMeterGUIComponent.java
  
  Index: JMeterGUIComponent.java
  ===================================================================
  package org.apache.jmeter.gui;
  
  import org.apache.jmeter.control.TestElement;
  import javax.swing.JMenu;
  /**
   * <p>Title: Jakarta JMeter</p>
   * <p>Description: Load testing software</p>
   * <p>Copyright: Copyright (c) 2002</p>
   * <p>Company: Apache Foundation</p>
   * @author Michael Stover
   * @version 1.0
   */
  
  public interface JMeterGUIComponent {
  
        public void setName(String name);
  
        public String getName();
  
        public String getStaticLabel();
  
        public TestElement createTestElement();
  
        public JMenu createPopupMenu();
  
        public void configure(TestElement element);
  }
  
  
  1.1                  
jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/ParamMask.java
  
  Index: ParamMask.java
  ===================================================================
  package org.apache.jmeter.protocol.http.modifier;
  
  import org.apache.jmeter.save.Saveable;
  
  
  /**
   * This object defines with what a parameter has its value replaced, and the 
policies for how that
   * value changes.  Used in {@link ParamModifier}.
   *
   * @author David La France
   * @created Jan 18, 2002
   */
  public class ParamMask implements Saveable, Cloneable {
  
  
      
/*----------------------------------------------------------------------------------------------
       * Constructors
       
*--------------------------------------------------------------------------------------------*/
  
      /**
       * Default constructor
       */
      public ParamMask() {
          _name       = "";
          _prefix     = "";
          _value      = 0;
          _lowerBound = 0;
          _upperBound = 0;
          _increment  = 0;
      }
  
      /**
       * Constructor
       *
       * @param name        The name of the parameter to be masked
       * @param prefix      Value to be prefixed to the parameter value
       * @param lowerBound  The lowest possible parameter value
       * @param upperBound  The highest possible parameter value
       * @param incr        The number by which the parameter value is incremented 
each time
       */
      public ParamMask(String name, String prefix, long lowerBound, long upperBound, 
long incr) {
          _name       = name;
          _prefix     = prefix;
          _lowerBound = lowerBound;
          _upperBound = upperBound;
          _increment  = incr;
      }
  
  
      
/*----------------------------------------------------------------------------------------------
       * Overridden from java.lang.Object
       
*--------------------------------------------------------------------------------------------*/
  
      /**
       * Returns a clone of this ParamMask
       */
      public Object clone() {
          ParamMask clone = new ParamMask(_name, _prefix, _lowerBound, _upperBound, 
_increment);
          clone.setValue(_value);
          return clone;
      }
  
  
      
/*----------------------------------------------------------------------------------------------
       * Implements interface org.apache.jmeter.save.Saveable
       
*--------------------------------------------------------------------------------------------*/
  
      /**
       * Gets the TagHandler that will handle the parsing of the xml for this type
         * of object.
       *
         * @return The tag handler class
       */
      public Class getTagHandlerClass() {
          return org.apache.jmeter.protocol.http.save.ParamMaskHandler.class;
      }
  
      
/*----------------------------------------------------------------------------------------------
       * Getters and setters
       
*--------------------------------------------------------------------------------------------*/
  
      /**
       * Acessor method, returns the name of the parameter to be masked
       *
       * @return The name of the parameter to be masked
       */
      public String getName() {
          return _name;
      }
  
      /**
       * Sets the name of the parameter to be masked
       *
       * @param name The parameter name
       */
      public void setName(String name) {
          _name = name;
      }
  
      /**
       * Acessor method to return the <code>String</code> that will be prefixed to the
       * <code>long</code> value, creating the complete parameter value.
       * @return The parameter value prefix
       */
      public String getPrefix() {
          return _prefix;
      }
  
      /**
       * Sets the prefix for the <code>long</code> value.  The two are used appended 
as the parameter
       * value to be replaced.  This allows a wider range of posibilities for the 
parameter values.
       *
       * @param prefix A string to prefix to the parameter value
       */
      public void setPrefix(String prefix) {
          _prefix = prefix;
      }
  
      /**
       * Set the current value of the <code>long<code> portion of the parameter value 
to replace.
       * This is usually not used, as the method {@link #resetValue} is used to define 
a policy for
       * the starting value.
       *
       * @param val The new parameter value
       */
      public void setValue(long val) {
          _value = val;
      }
  
      /**
       * Acessor method, returns the lowest possible value that the <code>long</code> 
portion of the
       * parameter value may be.
       * @return The lower bound of the possible values
       */
      public long getLowerBound() {
          return _lowerBound;
      }
  
      /**
       * Sets the lowest possible value that the <code>long</code> portion of the
       * parameter value may be.
       *
       * @param val The new lowest possible parameter value
       */
      public void setLowerBound(long val) {
          _lowerBound = val;
      }
  
      /**
       * Acessor method, returns the highest possible value that the <code>long</code> 
portion of the
       * parameter value may be.
       *
       * @return The higher bound of the possible values
       */
      public long getUpperBound() {
          return _upperBound;
      }
  
      /**
       * Sets the highest possible value that the <code>long</code> portion of the
       * parameter value may be.
       *
       * @param val The new highest possible parameter value
       */
      public void setUpperBound(long val) {
          _upperBound = val;
      }
  
      /**
       * Acessor method, returns the number by which the parameter value is 
incremented between loops.
       *
       * @return The increment
       */
      public long getIncrement() {
          return _increment;
      }
  
      /**
       * Sets the number by which the parameter value is incremented between loops.
       *
       * @param incr The new increment for the parameter value
       */
      public void setIncrement(long incr) {
          _increment = incr;
      }
  
  
      
/*----------------------------------------------------------------------------------------------
       * Methods
       
*--------------------------------------------------------------------------------------------*/
  
      /**
       * <P>Returns the current value, prefixed, as a string, then increments it.  If 
the incremented
       * value is above the upper bound, the value is reset to the lower bound.
       * <BR>
       * <P>This method determines the policy of what happens when an upper bound is
       * reached/surpassed.
       *
       * @return A <code>String</code> representing the current <code>long</code> value
       */
      public String getNextValue() {
          // return the current value (don't forget the prefix!)
          String retval = _prefix + Long.toString(_value);
  
          // increment the value
          _value += _increment;
          if (_value > _upperBound) {
              _value = _lowerBound;
          }
  
          return retval;
      }
  
      /**
       * This method determines the policy of what value to start (and re-start) at
       */
      public void resetValue() {
          _value = _lowerBound;
      }
  
      /**
       * For debugging purposes
       *
       * @return A <code>String</code> representing the object
       */
      public String toString() {
          StringBuffer sb = new StringBuffer();
          sb.append("-------------------------------\n");
          sb.append("Dumping ParamMask Object\n");
          sb.append("-------------------------------\n");
          sb.append("Name          = "+ _name +"\n");
          sb.append("Prefix        = "+ _prefix +"\n");
          sb.append("Current Value = "+ _value +"\n");
          sb.append("Lower Bound   = "+ _lowerBound +"\n");
          sb.append("Upper Bound   = "+ _upperBound +"\n");
          sb.append("Increment     = "+ _increment +"\n");
          sb.append("-------------------------------\n");
  
          return sb.toString();
      }
  
  
      
/*----------------------------------------------------------------------------------------------
       * Fields
       
*--------------------------------------------------------------------------------------------*/
  
      /**
       * The parameter to be masked
       */
      private String _name;
  
      /**
       * The (optional) string value to prefix to the long value
       */
      private String _prefix;
  
      /**
       * The parameter's current replacement value (not including prefix)
       */
      private long   _value;
  
      /**
       * The lowest possible number that the numerical part of the parameter value may 
be
       */
      private long   _lowerBound;
  
      /**
       * The lowest possible number that the numerical part of the parameter value may 
be
       */
      private long   _upperBound;
  
      /**
       * The value with which to increment the parameter value every time through the 
loop
       */
      private long   _increment;
  }
  
  
  
  1.1                  
jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/ParamModifier.java
  
  Index: ParamModifier.java
  ===================================================================
  package org.apache.jmeter.protocol.http.modifier;
  
  import org.apache.jmeter.config.*;
  import org.apache.jmeter.gui.JMeterComponentModel;
  import org.apache.jmeter.samplers.Entry;
  import org.apache.jmeter.protocol.http.config.UrlConfig;
  
  import java.io.Serializable;
  import java.util.*;
  
  /**
   * <P>This modifier will replace any single http sampler's url parameter value with 
a value
   * from a given range - thereby "masking" the value set in the http sampler. The 
parameter names
   * must match exactly, and the parameter value must be preset to "*" to diferentiate 
between
   * duplicate parameter names.
   * <BR>
   * <P>For example, if you set up the modifier with a lower bound of 1, an upper 
bound of 10, and
   * an increment of 2, and run the loop 12 times, the parameter will have the 
following values
   * (one per loop): 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3
   * <BR>
   * <P>The {@link ParamMask} object contains most of the logic for stepping through 
this loop.
   * You can make large modifications to this modifier's behaviour by changing one or 
two method
   * implementations there.
   *
   * @see ParamMask
   *
   * @author David La France
   * @created Jan 18, 2002
   */
  public class ParamModifier extends AbstractConfigElement implements 
JMeterComponentModel,
          Modifier, Serializable {
  
      
/*----------------------------------------------------------------------------------------------
       * Constructors
       
*--------------------------------------------------------------------------------------------*/
  
      /**
       * Default constructor
       */
      public ParamModifier() {
          setName(getClassLabel());
          putProperty(MASK, new ParamMask());
      }
  
  
      
/*----------------------------------------------------------------------------------------------
       * Methods overriden/implemented from 
org.apache.jmeter.config.AbstractConfigElement
       
*--------------------------------------------------------------------------------------------*/
  
  
      /**
       * Not implemented. This object does not allow child componenets
       *
       * @param obj A component to allow as a child
       */
      public void addJMeterComponent(JMeterComponentModel obj) {
      }
  
      /**
       * Runs before the start of every test. Used to change the mask replacement 
value back to its
       * starting value
       */
      public void uncompile() {
          getMask().resetValue();
      }
  
      /**
       * Not implemented. This object does not allow child components
       *
       * @return <code>null</code>
       */
      public Collection getAddList() {
          return null;
      }
  
      /**
       * Returns the gui class used to interface with this object
       *
       * @return A gui (panel) class
       */
      public Class getGuiClass() {
          return org.apache.jmeter.protocol.http.modifier.gui.ParamModifierGui.class;
      }
  
      /**
         *  Not implemented. This object does not support layered config objects
       *
       * @param config A config object to allow as a child
         */
      public void addConfigElement(ConfigElement config) {
      }
  
      /**
       * Clones this object
       *
       * @return A clone of this object
       */
      public Object clone() {
          ParamModifier clone = new ParamModifier();
          configureClone((AbstractConfigElement)clone);
          return clone;
      }
  
      /**
       * Helper method for the {@link #clone} method
       * Creates a deepcopy of the <code>Map</code>
       *
       * @param clone The clone to configure
       */
      protected void configureClone(AbstractConfigElement clone)
      {
          super.configureClone(clone);
          clone.putProperty(this.MASK,this.getMask().clone());
      }
  
  
      
/*----------------------------------------------------------------------------------------------
       * Methods implemented from org.apache.jmeter.gui.JMeterComponentModel
       
*--------------------------------------------------------------------------------------------*/
  
      /**
         * Gets the user friendly name given to this object
       *
         * @return The user friendly name of this object
         */
      public String getClassLabel() {
          return "HTML Parameter Mask";
      }
  
  
      
/*----------------------------------------------------------------------------------------------
       * Methods implemented from interface org.apache.jmeter.config.Modifier
       
*--------------------------------------------------------------------------------------------*/
  
      /**
       * Modifies an entry object to replace the value of any url parameter that 
matches a defined
       * mask.
       *
       * @param entry Entry object containing information about the current test
       * @return <code>True</code> if modified, else <code>false</code>
       */
      public boolean modifyEntry(Entry entry) {
          boolean modified = false;
          UrlConfig config = (UrlConfig) entry.getConfigElement(UrlConfig.class);
          Iterator iter = config.getArguments().iterator();
          while (iter.hasNext()) {
              Argument arg = (Argument) iter.next();
              modified = modifyArgument(arg);
              if (modified) {
                  break;
              }
          }
          return modified;
      }
  
  
      
/*----------------------------------------------------------------------------------------------
       * Methods
       
*--------------------------------------------------------------------------------------------*/
  
      /**
       * Helper method for {@link #modifyEntry}
       * Replaces a parameter's value if the parameter name matches the mask name and 
the value
       * is a "*"
       *
       * @param arg An {@link Argument} representing a http parameter
       * @return <code>true</code>if the value was replaced
       */
      private boolean modifyArgument(Argument arg) {
          // if a mask for this argument exists
          if (arg.getName().equals(getMask().getName())) {
              // values to be masked must be set in the WebApp to "*"
              if ("*".equals(arg.getValue())) {
                  arg.setValue(getMask().getNextValue());
                  return true;
              }
          }
          return false;
      }
  
      /**
       * Used to access the mask from the hashmap
       *
       * @return A reference to the {@link ParamMask} object
       */
      public ParamMask getMask() {
          return (ParamMask)getProperty(MASK);
      }
  
  
      
/*----------------------------------------------------------------------------------------------
       * Fields
       
*--------------------------------------------------------------------------------------------*/
  
      /**
       * The key used to find the ParamMask object in the HashMap
       */
      private String MASK = "mask";
  }
  
  
  
  1.1                  
jakarta-jmeter/src/org/apache/jmeter/protocol/http/modifier/gui/ParamModifierGui.java
  
  Index: ParamModifierGui.java
  ===================================================================
  package org.apache.jmeter.protocol.http.modifier.gui;
  
  import org.apache.jmeter.gui.ModelSupported;
  import org.apache.jmeter.gui.VerticalLayout;
  import org.apache.jmeter.gui.NamePanel;
  import org.apache.jmeter.protocol.http.modifier.ParamModifier;
  import org.apache.jmeter.util.JMeterUtils;
  
  import javax.swing.*;
  import javax.swing.border.Border;
  import javax.swing.border.EmptyBorder;
  import java.awt.*;
  import java.awt.event.*;
  
  /**
   * A swing panel to allow UI with the ParamModifier class.
   *
   * @author David La France
   * @created Jan 18, 2002
   */
  public class ParamModifierGui extends JPanel implements ModelSupported, 
FocusListener {
  
  
         public ParamModifierGui() {
         }
  
  
         public void updateGui() {
                  _namePanel.updateGui();
  
                  _name.setText      (_model.getMask().getName());
                  _prefix.setText    (_model.getMask().getPrefix());
                  _lowerBound.setText(Long.toString(_model.getMask().getLowerBound()));
                  _upperBound.setText(Long.toString(_model.getMask().getUpperBound()));
                  _increment.setText (Long.toString(_model.getMask().getIncrement()));
         }
  
         public void setModel(Object model) {
                  _model = (ParamModifier) model;
                  init();
         }
  
         protected void init() {
                  this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, 
VerticalLayout.TOP));
  
                  // MAIN PANEL
                  JPanel mainPanel = new JPanel();
                  Border margin = new EmptyBorder(10, 10, 5, 10);
                  mainPanel.setBorder(margin);
                  mainPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
  
                  // TITLE
                  //JLabel panelTitleLabel = new 
JLabel(JMeterUtils.getResString("url_config_title"));
                  JLabel panelTitleLabel = new JLabel(JMeterUtils.getResString("HTML 
Parameter Mask"));
                  Font curFont = panelTitleLabel.getFont();
                  int curFontSize = curFont.getSize();
                  curFontSize += 4;
                  panelTitleLabel.setFont(new Font(curFont.getFontName(), 
curFont.getStyle(), curFontSize));
                  mainPanel.add(panelTitleLabel);
  
                  // NAME
                  _namePanel = new NamePanel(_model);
                  mainPanel.add(_namePanel);
  
                  // PARAMETER MASK
                  mainPanel.add(getParameterMaskPanel());
  
                  this.add(mainPanel);
                  this.updateUI();
         }
  
         private JPanel getParameterMaskPanel() {
                  JPanel paramMaskPanel = new JPanel();
                  paramMaskPanel.setLayout(new GridBagLayout());
                  
//paramMaskPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
 JMeterUtils.getResString("web_request")));
                  paramMaskPanel.setBorder(BorderFactory.createTitledBorder(
                                         BorderFactory.createEtchedBorder(), 
JMeterUtils.getResString("HTML Parameter Mask")));
  
                  GridBagConstraints gridBagConstraints;
  
                  JLabel name = new JLabel(JMeterUtils.getResString("Name"));
                  gridBagConstraints = new GridBagConstraints();
                  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                  gridBagConstraints.ipadx = 40;
                  gridBagConstraints.insets = new Insets(5, 15, 0, 0);
                  paramMaskPanel.add(name, gridBagConstraints);
  
                  JLabel prefix = new JLabel(JMeterUtils.getResString("ID Prefix"));
                  gridBagConstraints = new GridBagConstraints();
                  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                  gridBagConstraints.ipadx = 40;
                  gridBagConstraints.insets = new Insets(5, 15, 0, 0);
                  paramMaskPanel.add(prefix, gridBagConstraints);
  
                  JLabel start = new JLabel(JMeterUtils.getResString("Lower Bound"));
                  gridBagConstraints = new GridBagConstraints();
                  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                  gridBagConstraints.insets = new Insets(5, 15, 0, 0);
                  paramMaskPanel.add(start, gridBagConstraints);
  
                  JLabel stop = new JLabel(JMeterUtils.getResString("Upper Bound"));
                  gridBagConstraints = new GridBagConstraints();
                  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                  gridBagConstraints.insets = new Insets(5, 15, 0, 0);
                  paramMaskPanel.add(stop, gridBagConstraints);
  
                  JLabel increment = new JLabel(JMeterUtils.getResString("Increment"));
                  gridBagConstraints = new GridBagConstraints();
                  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                  gridBagConstraints.insets = new Insets(5, 15, 0, 0);
                  paramMaskPanel.add(increment, gridBagConstraints);
  
                  _name = new JTextField("", 10);
                  gridBagConstraints = new GridBagConstraints();
                  gridBagConstraints.gridx = 0;
                  gridBagConstraints.gridy = 1;
                  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                  gridBagConstraints.insets = new Insets(10, 15, 0, 0);
                  _name.addFocusListener(this);
                  _name.setName(NAME);
                  paramMaskPanel.add(_name, gridBagConstraints);
  
                  _prefix = new JTextField("", 5);
                  gridBagConstraints = new GridBagConstraints();
                  gridBagConstraints.gridx = 1;
                  gridBagConstraints.gridy = 1;
                  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                  gridBagConstraints.insets = new Insets(10, 15, 0, 0);
                  _prefix.addFocusListener(this);
                  _prefix.setName(PREFIX);
                  paramMaskPanel.add(_prefix, gridBagConstraints);
  
                  _lowerBound = new JTextField("", 5);
                  gridBagConstraints = new GridBagConstraints();
                  gridBagConstraints.gridx = 2;
                  gridBagConstraints.gridy = 1;
                  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                  gridBagConstraints.insets = new Insets(10, 15, 0, 0);
                  _lowerBound.addFocusListener(this);
                  _lowerBound.setName(LOWERBOUND);
                  paramMaskPanel.add(_lowerBound, gridBagConstraints);
  
                  _upperBound = new JTextField("", 5);
                  gridBagConstraints = new GridBagConstraints();
                  gridBagConstraints.gridx = 3;
                  gridBagConstraints.gridy = 1;
                  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                  gridBagConstraints.insets = new Insets(10, 15, 0, 0);
                  _upperBound.addFocusListener(this);
                  _upperBound.setName(UPPERBOUND);
                  paramMaskPanel.add(_upperBound, gridBagConstraints);
  
                  _increment = new JTextField("", 3);
                  gridBagConstraints = new GridBagConstraints();
                  gridBagConstraints.gridx = 4;
                  gridBagConstraints.gridy = 1;
                  gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
                  gridBagConstraints.insets = new Insets(10, 15, 0, 0);
                  _increment.addFocusListener(this);
                  _increment.setName(INCREMENT);
                  paramMaskPanel.add(_increment, gridBagConstraints);
  
                  return paramMaskPanel;
         }
  
         public void focusGained(FocusEvent evt) {
         }
  
         public void focusLost(FocusEvent evt) {
                  if (evt.isTemporary()) {
                                return;
                  }
                  String name = evt.getComponent().getName();
  
                  if (name.equals(NAME)) {
                                _model.getMask().setName(_name.getText());
                  }
                  else if (name.equals(PREFIX)) {
                                _model.getMask().setPrefix(_prefix.getText());
                  }
                  else if (name.equals(LOWERBOUND)) {
                                try {
                                         
_model.getMask().setLowerBound(checkTextField(evt, "0"));
                                } catch (NumberFormatException err) {
                                         _model.getMask().setLowerBound(0);
                                }
                  }
                  else if (name.equals(UPPERBOUND)) {
                                try {
                                         
_model.getMask().setUpperBound(checkTextField(evt, "0"));
                                } catch (NumberFormatException err) {
                                         _model.getMask().setUpperBound(0);
                                }
                  }
                  else if (name.equals(INCREMENT)) {
                                try {
                                         
_model.getMask().setIncrement(checkTextField(evt, "0"));
                                } catch (NumberFormatException err) {
                                         _model.getMask().setIncrement(0);
                                }
                  }
         }
  
         /**
          * Used to validate a text field that requires a <code>long</code> input. 
Returns the
          * <code>long</code> if valid, else creates a pop-up error message and throws 
a
          * NumberFormatException.
          * @return The number entered in the text field
          */
         private long checkTextField(FocusEvent evt, String defaultValue) throws 
NumberFormatException {
                  JTextField temp = (JTextField) evt.getSource();
                  boolean pass = true;
                  long longVal = 0;
  
                  try {
                                longVal = Long.parseLong(temp.getText());
                  } catch (NumberFormatException err) {
                                JOptionPane.showMessageDialog(this,
                                  "This field must have a long value!",
                                  "Value Required",
                                  JOptionPane.ERROR_MESSAGE);
                                temp.setText(defaultValue);
                                temp.requestFocus();
                                throw new NumberFormatException();
                  }
                  return longVal;
         }
  
  
  
         private ParamModifier _model;
  
         private NamePanel _namePanel;
         private JTextField _name;
         private JTextField _prefix;
         private JTextField _lowerBound;
         private JTextField _upperBound;
         private JTextField _increment;
  
         private final String NAME = "name";
         private final String PREFIX = "prefix";
         private final String LOWERBOUND = "lowerBound";
         private final String UPPERBOUND = "upperBound";
         private final String INCREMENT = "increment";
  
  }
  
  
  
  1.1                  
jakarta-jmeter/src/org/apache/jmeter/protocol/http/save/ParamMaskHandler.java
  
  Index: ParamMaskHandler.java
  ===================================================================
  package org.apache.jmeter.protocol.http.save;
  
  import org.xml.sax.Attributes;
  
  import org.apache.jmeter.save.Saveable;
  import org.apache.jmeter.save.handlers.JMeterHandler;
  import org.apache.jmeter.save.xml.*;
  import org.apache.jmeter.config.*;
  import org.apache.jmeter.protocol.http.modifier.ParamMask;
  
  import java.util.*;
  import java.io.*;
  
  /**
   * Saves and loads a {@link ParamMask} object to/from XML format.
   *
   * @author David La France
   * @version 1.0
   */
  public class ParamMaskHandler extends TagHandler {
  
      /**
       * Default constructor
       */
      public ParamMaskHandler() {
      }
  
      /**
       * Writes a {@link ParamMask} object in XML format to the given 
<code>Writer</code>
       */
      public void save(Saveable parm1, Writer out) throws IOException {
          ParamMask mask = (ParamMask) parm1;
          out.write("\n");
          out.write("  <ParamMask>\n");
          out.write("    <mask name=\"");
          out.write(JMeterHandler.convertToXML(mask.getName()));
          out.write("\" prefix=\"");
          out.write(JMeterHandler.convertToXML(mask.getPrefix()));
          out.write("\" upperBound=\"");
          out.write(JMeterHandler.convertToXML(Long.toString(mask.getUpperBound())));
          out.write("\" lowerBound=\"");
          out.write(JMeterHandler.convertToXML(Long.toString(mask.getLowerBound())));
          out.write("\" increment=\"");
          out.write(JMeterHandler.convertToXML(Long.toString(mask.getIncrement())));
          out.write("\">");
          out.write("</mask>\n");
          out.write("  </ParamMask>\n");
      }
  
      /**
       * This method is automatically called whenever a "ParamMask" tag is reached.  
The ParamMask
       * tag does not currently support attributes
       *
       * @param atts The attributes of the XML "ParamMask" tag
       */
      public void setAtts(Attributes atts) throws Exception {
          _mask = new ParamMask();
      }
  
  
      public String getPrimaryTagName() {
          return "ParamMask";
      }
  
      /**
       * This method is automatically called whenever a "mask" tag is reached.  Loads 
the values for
       * the ParamMask
       *
       * @param atts The attributes of the XML "mask" tag
       */
      public void mask(Attributes atts) {
          _mask.setName       (atts.getValue("name"));
          _mask.setPrefix     (atts.getValue("prefix"));
          _mask.setUpperBound (Long.parseLong(atts.getValue("upperBound")));
          _mask.setLowerBound (Long.parseLong(atts.getValue("lowerBound")));
          _mask.setIncrement  (Long.parseLong(atts.getValue("increment")));
      }
  
      /**
       * This method is called with any String data found between the start and end 
tags of a "mask"
       * tag.
       *
       * @param data The string data found
       */
      public void mask(String data) {
      }
  
      public Object getModel() {
          return _mask;
      }
  
      ParamMask _mask;
  }
  
  
  1.48      +5 -0      
jakarta-jmeter/src/org/apache/jmeter/resources/messages.properties
  
  Index: messages.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/org/apache/jmeter/resources/messages.properties,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- messages.properties       17 Mar 2002 16:06:49 -0000      1.47
  +++ messages.properties       18 Mar 2002 00:48:25 -0000      1.48
  @@ -199,3 +199,8 @@
   paste_add=Paste As Add
   url=URL
   Success?=Success?
  +html_parameter_mask=HTML Parameter Mask
  +id_prefix=ID Prefix
  +lower_bound=Lower Bound
  +upper_bound=Upper Bound
  +increment=Increment
  
  
  
  1.27      +7 -1      jakarta-jmeter/src/org/apache/jmeter/util/JMeterUtils.java
  
  Index: JMeterUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/org/apache/jmeter/util/JMeterUtils.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- JMeterUtils.java  7 Mar 2002 23:03:13 -0000       1.26
  +++ JMeterUtils.java  18 Mar 2002 00:48:25 -0000      1.27
  @@ -76,7 +76,7 @@
    *
    *@author     <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
    *@created    June 28, 2001
  - *@version    $Revision: 1.26 $ $Date: 2002/03/07 23:03:13 $
  + *@version    $Revision: 1.27 $ $Date: 2002/03/18 00:48:25 $
    */
   
   public class JMeterUtils
  @@ -138,6 +138,12 @@
          */
         public static String getResString(String key)
         {
  +             if(key == null)
  +             {
  +                     return null;
  +             }
  +             key = key.replace(' ','_');
  +             key = key.toLowerCase();
                  String resString = null;
   
                  try
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to