Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

OperationModel.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk.
00022  * Contributor(s): ______________________.
00023  */
00024 
00025 package org.objectweb.cjdbc.console.gui.model;
00026 
00027 import javax.management.MBeanOperationInfo;
00028 import javax.management.MBeanParameterInfo;
00029 import javax.swing.table.AbstractTableModel;
00030 
00031 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
00032 
00033 public class OperationModel extends AbstractTableModel
00034 {
00035   private MBeanOperationInfo[] info;
00036 
00037   /**
00038    * @see javax.swing.table.TableModel#getColumnCount()
00039    */
00040   public int getColumnCount()
00041   {
00042     return 2;
00043   }
00044 
00045   /**
00046    * Returns the info value.
00047    * 
00048    * @return Returns the info.
00049    */
00050   public MBeanOperationInfo[] getInfo()
00051   {
00052     return info;
00053   }
00054 
00055   /**
00056    * @see javax.swing.table.TableModel#getRowCount()
00057    */
00058   public int getRowCount()
00059   {
00060     return info.length;
00061   }
00062 
00063   /**
00064    * @see javax.swing.table.TableModel#isCellEditable(int, int)
00065    */
00066   public boolean isCellEditable(int rowIndex, int columnIndex)
00067   {
00068     return false;
00069   }
00070 
00071   /**
00072    * @see javax.swing.table.TableModel#getValueAt(int, int)
00073    */
00074   public Object getValueAt(int rowIndex, int columnIndex)
00075   {
00076     if ((rowIndex >= 0 && rowIndex < info.length) == false)
00077       return null;
00078     switch (columnIndex)
00079     {
00080       case 0 :
00081         StringBuffer name = new StringBuffer(info[rowIndex].getName());
00082         MBeanParameterInfo[] param = info[rowIndex].getSignature();
00083         name.append("(");
00084         for (int i = 0; i < param.length; i++)
00085         {
00086           if (i != 0)
00087             name.append(",");
00088           name.append(GuiConstants.getParameterType(param[i].getType()));
00089         }
00090         name.append(")");
00091         return name.toString();
00092       case 1 :
00093         return GuiConstants.getParameterType(info[rowIndex].getReturnType());
00094       default :
00095         return null;
00096     }
00097   }
00098 
00099   public OperationModel(MBeanOperationInfo[] info)
00100   {
00101     this.info = info;
00102   }
00103 
00104   /**
00105    * @see javax.swing.table.TableModel#getColumnName(int)
00106    */
00107   public String getColumnName(int column)
00108   {
00109     switch (column)
00110     {
00111       case 0 :
00112         return "Name";
00113       case 1 :
00114         return "Return";
00115       default :
00116         return null;
00117     }
00118   }
00119 }

Generated on Mon Apr 11 22:01:33 2005 for C-JDBC by  doxygen 1.3.9.1