Changeset 2174
- Timestamp:
- 05/22/08 09:42:11
(6 months ago)
- Author:
- apatel
- Message:
updated add and remove methods of the network configuration object. We need to put the system and network resources in the separate maps to overcome name collisions.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2172 |
r2174 |
|
| 8 | 8 | |*| $Rev:2113 $ |
|---|
| 9 | 9 | \*/ |
|---|
| 10 | | |
|---|
| 11 | 10 | |
|---|
| 12 | 11 | package com.tresys.framework.compiler.linkage.net; |
|---|
| … | … | |
| 20 | 19 | /** |
|---|
| 21 | 20 | * @author dsugar |
|---|
| 22 | | * |
|---|
| | 21 | * |
|---|
| 23 | 22 | */ |
|---|
| 24 | 23 | public class NetworkConfig |
|---|
| 25 | 24 | { |
|---|
| 26 | | private final Map m_items = new HashMap (); |
|---|
| 27 | | // private final Map m_resources = new HashMap (); |
|---|
| | 25 | private final Map m_netresources = new HashMap (); |
|---|
| | 26 | private final Map m_systems = new HashMap (); |
|---|
| 28 | 27 | private final Map m_connections = new HashMap (); |
|---|
| 29 | | |
|---|
| | 28 | |
|---|
| 30 | 29 | public NetworkConfig () |
|---|
| 31 | 30 | {} |
|---|
| 32 | | |
|---|
| | 31 | |
|---|
| 33 | 32 | public void Add (NetItem i_item) |
|---|
| 34 | 33 | { |
|---|
| 35 | 34 | if (i_item == null) |
|---|
| 36 | 35 | throw new IllegalArgumentException (); |
|---|
| 37 | | |
|---|
| | 36 | |
|---|
| 38 | 37 | String sName = i_item.getName (); |
|---|
| 39 | | m_items.put (sName, i_item); |
|---|
| | 38 | if (i_item instanceof NetSystem) |
|---|
| | 39 | m_systems.put (sName, i_item); |
|---|
| | 40 | else if (i_item instanceof NetResource) |
|---|
| | 41 | m_systems.put (sName, i_item); |
|---|
| 40 | 42 | } |
|---|
| 41 | | |
|---|
| | 43 | |
|---|
| 42 | 44 | public void Remove (NetItem i_item) |
|---|
| 43 | 45 | { |
|---|
| 44 | | if (i_item != null) |
|---|
| 45 | | { |
|---|
| 46 | | String sName = i_item.getName (); |
|---|
| 47 | | Remove (sName); |
|---|
| 48 | | } |
|---|
| 49 | | } |
|---|
| 50 | | |
|---|
| 51 | | public void Remove (String i_sName) |
|---|
| 52 | | { |
|---|
| 53 | | if (i_sName == null) |
|---|
| 54 | | throw new IllegalArgumentException (); |
|---|
| 55 | | |
|---|
| 56 | | m_items.remove (i_sName); |
|---|
| | 46 | if (i_item == null) |
|---|
| | 47 | return; |
|---|
| | 48 | String sName = i_item.getName (); |
|---|
| | 49 | if (i_item instanceof NetSystem) |
|---|
| | 50 | RemoveSystem (sName); |
|---|
| | 51 | else if (i_item instanceof NetResource) |
|---|
| | 52 | RemoveNetResource (sName); |
|---|
| 57 | 53 | } |
|---|
| 58 | 54 | |
|---|
| 59 | | public void Accept(INetVisitor i_visitor) |
|---|
| | 55 | public void RemoveSystem (String i_sSystemName) |
|---|
| | 56 | { |
|---|
| | 57 | m_systems.remove (i_sSystemName); |
|---|
| | 58 | } |
|---|
| | 59 | |
|---|
| | 60 | public void RemoveNetResource (String i_sNetResourceName) |
|---|
| | 61 | { |
|---|
| | 62 | m_netresources.remove (i_sNetResourceName); |
|---|
| | 63 | } |
|---|
| | 64 | |
|---|
| | 65 | public void Accept (INetVisitor i_visitor) |
|---|
| 60 | 66 | { |
|---|
| 61 | 67 | i_visitor.Visit (this); |
|---|
| 62 | | |
|---|
| 63 | | for( Iterator itr= m_items.values ().iterator (); itr.hasNext (); ) |
|---|
| | 68 | |
|---|
| | 69 | for (Iterator itr = m_systems.values ().iterator (); itr.hasNext ();) |
|---|
| 64 | 70 | { |
|---|
| 65 | | Object item = itr.next (); |
|---|
| 66 | | if( item instanceof NetResource) |
|---|
| 67 | | i_visitor.Visit ((NetResource)item); |
|---|
| 68 | | else if( item instanceof NetSystem) |
|---|
| 69 | | i_visitor.Visit ((NetSystem)item); |
|---|
| | 71 | i_visitor.Visit ((NetSystem) itr.next ()); |
|---|
| 70 | 72 | } |
|---|
| 71 | | for( Iterator itr= m_connections.values ().iterator (); itr.hasNext (); ) |
|---|
| | 73 | for (Iterator itr = m_netresources.values ().iterator (); itr.hasNext ();) |
|---|
| 72 | 74 | { |
|---|
| 73 | | i_visitor.Visit ((NetConnection)itr.next ()); |
|---|
| | 75 | i_visitor.Visit ((NetResource) itr.next ()); |
|---|
| | 76 | } |
|---|
| | 77 | for (Iterator itr = m_connections.values ().iterator (); itr.hasNext ();) |
|---|
| | 78 | { |
|---|
| | 79 | i_visitor.Visit ((NetConnection) itr.next ()); |
|---|
| 74 | 80 | } |
|---|
| 75 | 81 | } |
|---|
| … | … | |
| 77 | 83 | public NetSystem getSystem (String i_sName) |
|---|
| 78 | 84 | { |
|---|
| 79 | | NetItem item = (NetItem) m_items.get (i_sName); |
|---|
| | 85 | return (NetSystem) m_systems.get (i_sName); |
|---|
| | 86 | } |
|---|
| 80 | 87 | |
|---|
| 81 | | if (item instanceof NetSystem) |
|---|
| 82 | | return (NetSystem) item; |
|---|
| 83 | | return null; |
|---|
| 84 | | } |
|---|
| 85 | | |
|---|
| 86 | 88 | public NetResource getResource (String i_sName) |
|---|
| 87 | 89 | { |
|---|
| 88 | | NetItem item = (NetItem) m_items.get (i_sName); |
|---|
| 89 | | |
|---|
| 90 | | if (item instanceof NetResource) |
|---|
| 91 | | return (NetResource) item; |
|---|
| 92 | | return null; |
|---|
| | 90 | return (NetResource) m_netresources.get (i_sName); |
|---|
| 93 | 91 | } |
|---|
| 94 | 92 | |
|---|
| 95 | 93 | public Collection getNetworkItems () |
|---|
| 96 | 94 | { |
|---|
| 97 | | return m_items.values (); |
|---|
| | 95 | Collection coll = m_systems.values (); |
|---|
| | 96 | coll.addAll (m_netresources.values ()); |
|---|
| | 97 | return coll; |
|---|
| 98 | 98 | } |
|---|
| 99 | | |
|---|
| | 99 | |
|---|
| 100 | 100 | public void Add (NetConnection i_connection) |
|---|
| 101 | 101 | { |
|---|
| 102 | 102 | if (i_connection == null) |
|---|
| 103 | 103 | throw new IllegalArgumentException (); |
|---|
| 104 | | |
|---|
| | 104 | |
|---|
| 105 | 105 | String sName = i_connection.toString (); |
|---|
| 106 | 106 | m_connections.put (sName, i_connection); |
|---|
| 107 | 107 | } |
|---|
| 108 | | |
|---|
| | 108 | |
|---|
| 109 | 109 | public void Remove (NetConnection i_connection) |
|---|
| 110 | 110 | { |
|---|
| … | … | |
| 115 | 115 | } |
|---|
| 116 | 116 | } |
|---|
| 117 | | |
|---|
| | 117 | |
|---|
| 118 | 118 | public Collection getConnections (NetResource i_res) |
|---|
| 119 | 119 | { |
|---|
| … | … | |
| 121 | 121 | if (i_res == null) |
|---|
| 122 | 122 | return list; |
|---|
| 123 | | |
|---|
| 124 | | for (Iterator itr = m_connections.values ().iterator (); itr.hasNext (); ) |
|---|
| | 123 | |
|---|
| | 124 | for (Iterator itr = m_connections.values ().iterator (); itr.hasNext ();) |
|---|
| 125 | 125 | { |
|---|
| 126 | 126 | NetConnection connection = (NetConnection) itr.next (); |
|---|
| … | … | |
| 128 | 128 | list.add (connection); |
|---|
| 129 | 129 | } |
|---|
| 130 | | |
|---|
| | 130 | |
|---|
| 131 | 131 | return list; |
|---|
| 132 | 132 | } |
|---|
| r2171 |
r2174 |
|
| 638 | 638 | systems.remove(i_system); |
|---|
| 639 | 639 | // remove the system from the netconfig |
|---|
| 640 | | getNetworkConfiguration ().Remove(i_system.getName ()); |
|---|
| | 640 | getNetworkConfiguration ().RemoveSystem (i_system.getName ()); |
|---|
| 641 | 641 | } |
|---|
| 642 | 642 | } |
|---|
Download in other formats:
* Generating other formats may take time.