1 | package dmg.cells.nucleus ; |
2 | |
3 | import java.util.Date ; |
4 | import java.io.Serializable ; |
5 | |
6 | /** |
7 | * |
8 | * |
9 | * @author Patrick Fuhrmann |
10 | * @version 0.2, 14 Mar 2001 |
11 | */ |
12 | public class CellInfo implements Serializable { |
13 | static final long serialVersionUID = 8837418209418282912L; |
14 | |
15 | private String _cellName = "Unknown" ; |
16 | private String _cellType = "Unknown" ; |
17 | private String _cellClass = "Unknown" ; |
18 | private String _domainName = "Unknown" ; |
19 | private Date _creationTime = null ; |
20 | private String _shortInfo = "NA" ; |
21 | private String _privateInfo = "NA" ; |
22 | private int _state = 0 ; |
23 | private int _eventQueueSize = 0 ; |
24 | private int _threadCount = 0 ; |
25 | private CellVersion _version = new CellVersion() ; |
26 | |
27 | private static final String [] _stateNames = |
28 | { "Initial" , "Active" , "Removing" , "Dead" , "Unknown" } ; |
29 | public CellInfo(){} |
30 | public CellInfo( CellInfo info ){ |
31 | _cellName = info._cellName ; |
32 | _cellType = info._cellType ; |
33 | _cellClass = info._cellClass ; |
34 | _domainName = info._domainName ; |
35 | _creationTime = info._creationTime ; |
36 | _shortInfo = info._shortInfo ; |
37 | _privateInfo = info._privateInfo ; |
38 | _state = info._state ; |
39 | _eventQueueSize = info._eventQueueSize ; |
40 | _threadCount = info._threadCount ; |
41 | _version = info._version ; |
42 | } |
43 | |
44 | public void setCellName(String name ){ _cellName = name ; } |
45 | public void setCellType( String type ){ _cellType = type ; } |
46 | public void setCellClass( String info ){ _cellClass = info ; } |
47 | public void setCellVersion( CellVersion version ){ _version = version ; } |
48 | public void setDomainName( String name ){ _domainName = name ; } |
49 | public void setCreationTime( Date date ){ _creationTime = date ; } |
50 | public void setPrivateInfo( String info ){ _privateInfo = info ; } |
51 | public void setShortInfo( String info ){ _shortInfo = info ; } |
52 | public void setEventQueueSize( int size ){ _eventQueueSize = size ; } |
53 | public void setThreadCount( int threadCount ){ _threadCount = threadCount ; } |
54 | public void setState( int state ){ |
55 | _state = ( state < 0 ) || ( _state >= _stateNames.length ) ? |
56 | _stateNames.length : state ; |
57 | return ; |
58 | } |
59 | // |
60 | // and now the public getter's |
61 | // |
62 | public String toString(){ |
63 | return f( _cellName , 20 ) + |
64 | f( _stateNames[_state].substring(0,1) , 2 ) + |
65 | f( ""+_eventQueueSize , 3 ) + |
66 | f( ""+_threadCount , 3 ) + |
67 | f( cutClass( _cellClass ) , 20 ) + |
68 | _shortInfo ; |
69 | } |
70 | public CellVersion getCellVersion(){ return _version ; } |
71 | public String getPrivatInfo(){ return _privateInfo ; } |
72 | public int getEventQueueSize(){ return _eventQueueSize ; } |
73 | public String getCellName(){ return _cellName ; } |
74 | public String getCellType(){ return _cellType ; } |
75 | public String getCellClass(){ return _cellClass ; } |
76 | public String getShortInfo(){ return _shortInfo ; } |
77 | public Date getCreationTime(){ return _creationTime ; } |
78 | public String getDomainName(){ return _domainName ; } |
79 | public int getThreadCount(){ return _threadCount ; } |
80 | // |
81 | // and some needfull things |
82 | // |
83 | public static String f( String in , int field ){ return f(in,field,0) ;} |
84 | public static String f( String in , int field , int flags ){ |
85 | if( in.length() >= field )return in ; |
86 | StringBuffer sb = new StringBuffer() ; |
87 | sb.append( in ) ; |
88 | int diff = field - in.length() ; |
89 | for( int i = 0 ; i < diff ; i++ )sb.append(" ") ; |
90 | return sb.toString() ; |
91 | } |
92 | public static String cutClass( String c ){ |
93 | int lastDot = c.lastIndexOf( '.' ) ; |
94 | if( ( lastDot < 0 ) || ( lastDot >= ( c.length() - 1 ) ) )return c ; |
95 | return c.substring( lastDot+1 ) ; |
96 | |
97 | } |
98 | } |