88 * was detected during the last call to {@linkplain #waitForChange}.
89 * If <code>waitForChange()</code> has not been called on this object,
90 * <code>CARD_INSERTION</code> is equivalent to <code>CARD_PRESENT</code>
91 * and <code>CARD_REMOVAL</code> is equivalent to <code>CARD_ABSENT</code>.
92 * For an example of the use of <code>CARD_INSERTION</code>,
93 * see {@link #waitForChange}.
94 *
95 * @param state the State
96 * @return an unmodifiable list of all terminals matching the specified
97 * attribute.
98 *
99 * @throws NullPointerException if attr is null
100 * @throws CardException if the card operation failed
101 */
102 public abstract List<CardTerminal> list(State state) throws CardException;
103
104 /**
105 * Returns the terminal with the specified name or null if no such
106 * terminal exists.
107 *
108 * @return the terminal with the specified name or null if no such
109 * terminal exists.
110 *
111 * @throws NullPointerException if name is null
112 */
113 public CardTerminal getTerminal(String name) {
114 if (name == null) {
115 throw new NullPointerException();
116 }
117 try {
118 for (CardTerminal terminal : list()) {
119 if (terminal.getName().equals(name)) {
120 return terminal;
121 }
122 }
123 return null;
124 } catch (CardException e) {
125 return null;
126 }
127 }
|
88 * was detected during the last call to {@linkplain #waitForChange}.
89 * If <code>waitForChange()</code> has not been called on this object,
90 * <code>CARD_INSERTION</code> is equivalent to <code>CARD_PRESENT</code>
91 * and <code>CARD_REMOVAL</code> is equivalent to <code>CARD_ABSENT</code>.
92 * For an example of the use of <code>CARD_INSERTION</code>,
93 * see {@link #waitForChange}.
94 *
95 * @param state the State
96 * @return an unmodifiable list of all terminals matching the specified
97 * attribute.
98 *
99 * @throws NullPointerException if attr is null
100 * @throws CardException if the card operation failed
101 */
102 public abstract List<CardTerminal> list(State state) throws CardException;
103
104 /**
105 * Returns the terminal with the specified name or null if no such
106 * terminal exists.
107 *
108 * @param name the terminal name
109 * @return the terminal with the specified name or null if no such
110 * terminal exists.
111 *
112 * @throws NullPointerException if name is null
113 */
114 public CardTerminal getTerminal(String name) {
115 if (name == null) {
116 throw new NullPointerException();
117 }
118 try {
119 for (CardTerminal terminal : list()) {
120 if (terminal.getName().equals(name)) {
121 return terminal;
122 }
123 }
124 return null;
125 } catch (CardException e) {
126 return null;
127 }
128 }
|