< prev index next >

src/com/sun/javatest/agent/SerialPortModeOptions.java

Print this page
rev 152 : 7902245: Correct Agent.productVersion
Reviewed-by: jjg


 112     public String[] getPortNames() {
 113         try {
 114             Vector<String> v = new Vector<>();
 115             for (Enumeration<?> e = CommPortIdentifier.getPortIdentifiers(); e.hasMoreElements(); ) {
 116                 CommPortIdentifier p = (CommPortIdentifier)(e.nextElement());
 117                 if (p.getPortType() == CommPortIdentifier.PORT_SERIAL)
 118                     v.addElement(p.getName());
 119             }
 120             String[] a = new String[v.size()];
 121             v.copyInto(a);
 122             return a;
 123         }
 124         catch (Throwable t) {
 125             return new String[] { };
 126         }
 127     }
 128 
 129 
 130     public ConnectionFactory createConnectionFactory(String port) throws BadValue {
 131         try {
 132             return new SerialPortConnectionFactory(port, Agent.productName, 10*1000);
 133         }
 134         catch (NoSuchPortException e) {
 135             throw new BadValue("invalid port: " + port);
 136         }
 137         catch (Throwable t) {
 138             throw new BadValue("problem accessing serial ports");
 139         }
 140     }
 141 }


 112     public String[] getPortNames() {
 113         try {
 114             Vector<String> v = new Vector<>();
 115             for (Enumeration<?> e = CommPortIdentifier.getPortIdentifiers(); e.hasMoreElements(); ) {
 116                 CommPortIdentifier p = (CommPortIdentifier)(e.nextElement());
 117                 if (p.getPortType() == CommPortIdentifier.PORT_SERIAL)
 118                     v.addElement(p.getName());
 119             }
 120             String[] a = new String[v.size()];
 121             v.copyInto(a);
 122             return a;
 123         }
 124         catch (Throwable t) {
 125             return new String[] { };
 126         }
 127     }
 128 
 129 
 130     public ConnectionFactory createConnectionFactory(String port) throws BadValue {
 131         try {
 132             return new SerialPortConnectionFactory(port, Agent.PRODUCT_NAME, 10*1000);
 133         }
 134         catch (NoSuchPortException e) {
 135             throw new BadValue("invalid port: " + port);
 136         }
 137         catch (Throwable t) {
 138             throw new BadValue("problem accessing serial ports");
 139         }
 140     }
 141 }
< prev index next >