1 17 package org.alfresco.filesys.netbios; 18 19 import java.util.Vector ; 20 21 24 public class NetBIOSNameList 25 { 26 27 29 private Vector <NetBIOSName> m_nameList; 30 31 34 public NetBIOSNameList() 35 { 36 m_nameList = new Vector <NetBIOSName>(); 37 } 38 39 44 public final void addName(NetBIOSName name) 45 { 46 m_nameList.add(name); 47 } 48 49 55 public final NetBIOSName getName(int idx) 56 { 57 if (idx < m_nameList.size()) 58 return m_nameList.get(idx); 59 return null; 60 } 61 62 67 public final int numberOfNames() 68 { 69 return m_nameList.size(); 70 } 71 72 79 public final NetBIOSNameList findNames(String name) 80 { 81 82 84 NetBIOSNameList subList = new NetBIOSNameList(); 85 for (int i = 0; i < m_nameList.size(); i++) 86 { 87 NetBIOSName nbName = getName(i); 88 if (nbName.getName().compareTo(name) == 0) 89 subList.addName(nbName); 90 } 91 92 94 return subList; 95 } 96 97 104 public final NetBIOSName findName(char typ, boolean group) 105 { 106 107 109 for (int i = 0; i < m_nameList.size(); i++) 110 { 111 NetBIOSName name = getName(i); 112 if (name.getType() == typ && name.isGroupName() == group) 113 return name; 114 } 115 116 118 return null; 119 } 120 121 129 public final NetBIOSName findName(String name, char typ, boolean group) 130 { 131 132 134 for (int i = 0; i < m_nameList.size(); i++) 135 { 136 NetBIOSName nbName = getName(i); 137 if (nbName.getName().equals(name) && nbName.getType() == typ && nbName.isGroupName() == group) 138 return nbName; 139 } 140 141 143 return null; 144 } 145 146 153 public final NetBIOSNameList findNames(char typ, boolean group) 154 { 155 156 158 NetBIOSNameList subList = new NetBIOSNameList(); 159 for (int i = 0; i < m_nameList.size(); i++) 160 { 161 NetBIOSName name = getName(i); 162 if (name.getType() == typ && name.isGroupName() == group) 163 subList.addName(name); 164 } 165 166 168 return subList; 169 } 170 171 177 public final NetBIOSName removeName(NetBIOSName name) 178 { 179 for (int i = 0; i < m_nameList.size(); i++) 180 { 181 NetBIOSName curName = getName(i); 182 if (curName.equals(name)) 183 { 184 m_nameList.removeElementAt(i); 185 return curName; 186 } 187 } 188 return null; 189 } 190 191 194 public final void removeAllNames() 195 { 196 m_nameList.removeAllElements(); 197 } 198 } 199 | Popular Tags |