Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Code Block

Wiki Markup
/*---------------------------------------------------------------*/
/*          STANFORD UNIVERSITY NOTICES FOR SLAC SOFTWARE        \*/
/*               ON WHICH COPYRIGHT IS DISCLAIMED                \*/
/*                                                               \*/
/\* AUTHORSHIP                                                    \*/
/\* This software was created by Yee-Ting Li, Stanford Linear     \*/
/\* Accelerator Center, Stanford University.                      \*/
/*                                                               \*/
/\* ACKNOWLEDGEMENT OF SPONSORSHIP                                \*/
/\* This software was produced by the Stanford Linear Accelerator \*/
/\* Center, Stanford University, under Contract DE-AC03-76SFO0515 \*/
/\* with the Department of Energy.                                \*/
/*                                                               \*/
/\* GOVERNMENT DISCLAIMER OF LIABILITY                            \*/
/\* Neither the United States nor the United States Department of \*/
/\* Energy, nor any of their employees, makes any warranty,       \*/
/\* express or implied, or assumes any legal liability or         \*/
/\* responsibility for the accuracy, completeness, or usefulness  \*/
/\* of any data, apparatus, product, or process disclosed, or     \*/
/\* represents that its use would not infringe privately owned    \*/
/\* rights.                                                       \*/
/*                                                               \*/
/\* STANFORD DISCLAIMER OF LIABILITY                              \*/
/\* Stanford University makes no representations or warranties,   \*/
/\* express or implied, nor assumes any liability for the use of  \*/
/\* this software.                                                \*/
/*                                                               \*/
/\* STANFORD DISCLAIMER OF COPYRIGHT                              \*/
/\* Stanford University, owner of the copyright, hereby disclaims \*/
/\* its copyright and all other rights in this software.  Hence,  \*/
/\* anyone may freely use it for any purpose without restriction. \*/
/*                                                               \*/
/*                                                               \*/
/\* MAINTENANCE OF NOTICES                                        \*/
/\* In the interest of clarity regarding the origin and status of \*/
/\* this SLAC software, this and all the preceding Stanford       \*/
/\* University notices are to remain affixed to any copy or       \*/
/\* derivative of this software made or distributed by the        \*/
/\* recipient and are to be affixed to any copy of software made  \*/
/\* or distributed by the recipient that contains a copy or       \*/
/\* derivative of this software.                                  \*/
/*                                                               \*/
/\* SLAC Software Notices, Set 4 (OTT.002a, 2004 FEB 03)          \*/
/*---------------------------------------------------------------*/

/\* TracerouteResponseGenerator.java
 \*
 \* Created on January 2, 2007, 1:49 PM
 \*
 \* To change this template, choose Tools \| Template Manager
 \* and open the template in the editor.
 */

package org.perfsonar.service.measurementArchive.sqlType.fetch;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Date;

import org.ggf.ns.nmwg.base.v2_0.Data;
import org.ggf.ns.nmwg.tools.traceroute.v2_0.Datum;

import org.perfsonar.commons.auxiliary.AuxiliaryComponentManager;
import org.perfsonar.commons.auxiliary.ComponentNames;
import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;

import org.perfsonar.service.commons.exceptions.SystemException;
/*\*
 \ *
 \ * @author Mohammad Asif
 \ * Created on January 2, 2007, 1:49 PM
  */
public class TracerouteResponseGenerator extends ResponseGenerator {
    
   
    /*\* Creates a new instance of TracerouteResponseGenerator \*/
       public TracerouteResponseGenerator() throws SystemException{
               super() ;
       }

   
       public Data getResponse(List resultList) throws Exception {
        
        
    	Data data = new Data();
        
       
        for (int i = 0; i < resultList.size(); i++) {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            Datum datum = new Datum();

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            Map resultMap = (Map) resultList.get(i);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            Collection<String> kCollection = ((Map)resultList.get(i)).keySet();

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            for (String column : kCollection) {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                Object value = resultMap.get(column);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                String className = value.getClass().getName();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                String strValue = null;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                if (className.equals("java.lang.Float"))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    strValue = Float.toString((Float) value);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                if (className.equals("java.lang.Double"))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;                	strValue = Double.toString((Double) value);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                else if (className.equals("java.lang.Integer"))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    strValue = Integer.toString((Integer) value);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                else if (className.equals("java.lang.Long"))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;                	strValue = Long.toString((Long) value);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                else if (className.equals("java.lang.Date"))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    strValue = ((Date) value).toString();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                else if (className.equals("java.lang.String"))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                    strValue = (String) value;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                if (strValue \!= null) {

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;	    	    if (column.equals("results")) datum.setDatumsetHopMax(strValue);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                }

            }

            data.addChild(datum);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        }

        return data;

&nbsp;&nbsp;&nbsp;    }
&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;

    public static void main (String \[\] arg )
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
&nbsp;&nbsp;&nbsp; }
&nbsp; &nbsp;
}    {

    }

}