Author: sebb
Date: Sun Feb  3 09:16:14 2008
New Revision: 618025

URL: http://svn.apache.org/viewvc?rev=618025&view=rev
Log:
Use new JMeterUtils method for the machine name.
Replace tabs with spaces

Modified:
    
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/MachineName.java

Modified: 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/MachineName.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/MachineName.java?rev=618025&r1=618024&r2=618025&view=diff
==============================================================================
--- 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/MachineName.java 
(original)
+++ 
jakarta/jmeter/trunk/src/functions/org/apache/jmeter/functions/MachineName.java 
Sun Feb  3 09:16:14 2008
@@ -19,8 +19,6 @@
 package org.apache.jmeter.functions;
 
 import java.io.Serializable;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
@@ -33,72 +31,57 @@
 
 public class MachineName extends AbstractFunction implements Serializable {
 
-       private static final List desc = new LinkedList();
+    private static final List desc = new LinkedList();
 
-       private static final String KEY = "__machineName"; //$NON-NLS-1$
+    private static final String KEY = "__machineName"; //$NON-NLS-1$
 
-       static {
-               // desc.add("Use fully qualified host name: TRUE/FALSE (Default 
FALSE)");
-               desc.add(JMeterUtils.getResString("function_name_paropt")); 
//$NON-NLS-1$
-       }
-
-       private Object[] values;
-
-       public MachineName() {
-       }
-
-       public Object clone() throws CloneNotSupportedException {
-               return super.clone();
-       }
-
-       public synchronized String execute(SampleResult previousResult, Sampler 
currentSampler)
-                       throws InvalidVariableException {
-
-               /*
-                * boolean fullHostName = false; if (((CompoundFunction) 
values[0])
-                * .execute() .toLowerCase() .equals("true")) { fullHostName = 
true; }
-                */
-
-               String machineName = "";
-
-               try {
-
-                       InetAddress Address = InetAddress.getLocalHost();
-
-                       // fullHostName disabled until we move up to 1.4 as the 
support jre
-                       // if ( fullHostName ) {
-                       // machineName = Address.getCanonicalHostName();
-
-                       // } else {
-                       machineName = Address.getHostName();
-                       // }
-
-               } catch (UnknownHostException e) {
-               }
-
-               if (values.length >= 1){// we have a variable name
-                       JMeterVariables vars = getVariables();
-                       if (vars != null) {// May be null if function is used 
on TestPlan
-                               String varName = ((CompoundVariable) 
values[0]).execute();
-                               if (varName.length() > 0) {
-                                   vars.put(varName, machineName);
-                               }
-                       }
-               }
-               return machineName;
-
-       }
-
-       public synchronized void setParameters(Collection parameters) throws 
InvalidVariableException {
-               checkParameterCount(parameters, 0, 1);
-               values = parameters.toArray();
-       }
-
-       public String getReferenceKey() {
-               return KEY;
-       }
-
-       public List getArgumentDesc() {
-               return desc;
-       }
+    static {
+        // desc.add("Use fully qualified host name: TRUE/FALSE (Default 
FALSE)");
+        desc.add(JMeterUtils.getResString("function_name_paropt")); 
//$NON-NLS-1$
+    }
+
+    private Object[] values;
+
+    public MachineName() {
+    }
+
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+
+    public synchronized String execute(SampleResult previousResult, Sampler 
currentSampler)
+            throws InvalidVariableException {
+
+        /*
+         * boolean fullHostName = false; if (((CompoundFunction) values[0])
+         * .execute() .toLowerCase() .equals("true")) { fullHostName = true; }
+         */
+
+        String machineName = JMeterUtils.getLocalHostName();
+        
+        if (values.length >= 1){// we have a variable name
+            JMeterVariables vars = getVariables();
+            if (vars != null) {// May be null if function is used on TestPlan
+                String varName = ((CompoundVariable) values[0]).execute();
+                if (varName.length() > 0) {
+                    vars.put(varName, machineName);
+                }
+            }
+        }
+        return machineName;
+
+    }
+
+    public synchronized void setParameters(Collection parameters) throws 
InvalidVariableException {
+        checkParameterCount(parameters, 0, 1);
+        values = parameters.toArray();
+    }
+
+    public String getReferenceKey() {
+        return KEY;
+    }
+
+    public List getArgumentDesc() {
+        return desc;
+    }
 }



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

Reply via email to