⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linkprotocoltablemodel.java

📁 270的linux说明
💻 JAVA
字号:
/*

Copyright (c) 2008, Intel Corporation. 

All rights reserved.

 

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:


    * Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation and/or 
other materials provided with the distribution.

    * Neither the name of Intel Corporation nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.

*/import javax.swing.table.AbstractTableModel;import com.intel.mobile.base.IntelMobileException;import com.intel.mobile.base.UIntProperty;import com.intel.mobile.network.LinkProtocolInstance;public class LinkProtocolTableModel extends AbstractTableModel{	private final String[] names = { "Attribute", "Value", "Description" };	protected Object[][] data = null;	protected int index;	public LinkProtocolTableModel()	{		super();	}		public LinkProtocolTableModel(LinkProtocolInstance myInstance) throws IntelMobileException	{		super();		init(myInstance);	}	public int getColumnCount()	{		return names.length;	}    	public int getRowCount()	{		return data.length;	}    	public Object getValueAt(int row, int col)	{		return data[row][col];	}			// The default implementations of these methods in	// AbstractTableModel would work, but we can refine them.    	public String getColumnName(int column)	{		return names[column];	}    	public Class getColumnClass(int col)	{		return String.class;		//return getValueAt(0, col).getClass();	}    	public boolean isCellEditable(int row, int col)	{		return false;	}    	public void setValueAt(Object aValue, int row, int column)	{		data[row][column] = aValue;	}		// ------------- initialize --------------    	public void init(LinkProtocolInstance myInstance) throws IntelMobileException	{		data = new Object[500][3];        		int i = 0;        		if ( !myInstance.MacAddress.IsNull() )		{			data[i][0] = "MacAddress";					for (int j = 0; j < myInstance.MacAddress.GetSize(); j++)			{				data[i][1] = getHexString(myInstance.MacAddress.GetValue(j));				data[i++][2] = "";			}		}				if ( !myInstance.MulticastAddresses.IsNull() )		{			data[i][0] = "MulticastAddresses";					for (int j = 0; j < myInstance.MulticastAddresses.GetSize(); j++)			{				data[i][1] = String.valueOf(myInstance.MulticastAddresses.GetValue(j));				data[i++][2] = "";			}		}				data[i][0] = "DataRateRx";		if ( !myInstance.DataRateRx.IsNull() )		{		    data[i][1] = com.intel.mobile.base.UInt64Property.toUnsignedString(myInstance.DataRateRx.GetValue());		}		data[i++][2] = "";		data[i][0] = "DataRateTx";		if ( !myInstance.DataRateTx.IsNull() )		{			data[i][1] = com.intel.mobile.base.UInt64Property.toUnsignedString(myInstance.DataRateTx.GetValue());		}		data[i++][2] = "";		data[i][0] = "Enabled";		if ( !myInstance.Enabled.IsNull() )		{			data[i][1] = String.valueOf(myInstance.Enabled.GetValue());		}		data[i++][2] = "";		data[i][0] = "Id";		if ( !myInstance.Id.IsNull() )		{			data[i][1] = String.valueOf(myInstance.Id.GetValue());		}		data[i++][2] = "";		if(!myInstance.IpAddress.IsNull())		{		data[i][0] = "IpAddress";		if ( !myInstance.IpAddress.IsNull() )		{			data[i][1] = String.valueOf(myInstance.IpAddress.GetValue());		}		data[i++][2] = "";		}		data[i][0] = "MaxLinkSpeed";		if ( !myInstance.MaxLinkSpeed.IsNull() )		{			data[i][1] = com.intel.mobile.base.UInt64Property.toUnsignedString(myInstance.MaxLinkSpeed.GetValue());		}		data[i++][2] = "";		data[i][0] = "MediaPresent";		if ( !myInstance.MediaPresent.IsNull() )		{			data[i][1] = String.valueOf(myInstance.MediaPresent.GetValue());		}		data[i++][2] = "";		data[i][0] = "State";		if ( !myInstance.State.IsNull() )		{			data[i][1] = String.valueOf(myInstance.State.GetValue());		}		data[i++][2] = "";		data[i][0] = "Oids";		if ( !myInstance.Oids.IsNull() )		{			for (int j = 0; j < myInstance.Oids.GetSize(); j++)			{			    data[i][1] = UIntProperty.toUnsignedString(myInstance.Oids.GetValue(j));			    				data[i++][2] = "";			}		}		data[i][0] = "OidDescriptions";		if ( !myInstance.OidDescriptions.IsNull() )		{			for (int j = 0; j < myInstance.OidDescriptions.GetSize(); j++)			{			    data[i][1] = String.valueOf(myInstance.OidDescriptions.GetValue(j));			    				data[i++][2] = "";			}		}		data[i][0] = "DataRatesRx";		if ( !myInstance.DataRatesRx.IsNull() )		{			for (int j = 0; j < myInstance.DataRatesRx.GetSize(); j++)			{			    data[i][1] = com.intel.mobile.base.UInt64Property.toUnsignedString(myInstance.DataRatesRx.GetValue(j));			    				data[i++][2] = "";			}		}		data[i][0] = "DataRatesTx";		if ( !myInstance.DataRatesTx.IsNull() )		{			for (int j = 0; j < myInstance.DataRatesTx.GetSize(); j++)			{			    data[i][1] = com.intel.mobile.base.UInt64Property.toUnsignedString(myInstance.DataRatesTx.GetValue(j));			    				data[i++][2] = "";			}		}		if(!myInstance.TxPower.IsNull() )		{			data[i][0] = "TxPower";			if ( !myInstance.TxPower.IsNull() )			{				data[i][1] = com.intel.mobile.base.UIntProperty.toUnsignedString(myInstance.TxPower.GetValue());			}			data[i++][2] = "";		}				index = i;	}		// ------------ utility method ------------	public static String getHexString(byte value)	{		String hexStr = Integer.toHexString(value).toUpperCase();		if (hexStr.length() == 1)		    hexStr = "0" + hexStr;		hexStr = hexStr.substring(hexStr.length() - 2);				return hexStr;	}			}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -