From 459a5af64211705fa6e5fcf729c5e02fa573cde6 Mon Sep 17 00:00:00 2001 From: Murali Shankar Date: Fri, 4 Dec 2015 17:20:16 -0800 Subject: [PATCH] Remove bogus IOExceptions from some methods as they interfere with using lambdas --- .classpath | 22 ++++------ .../retrieval/client/EpicsMessage.java | 43 +++++++++---------- 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/.classpath b/.classpath index 1e13b1f..64e488a 100644 --- a/.classpath +++ b/.classpath @@ -1,13 +1,9 @@ - - - - - - - - - - - - - + + + + + + + + + diff --git a/src/main/org/epics/archiverappliance/retrieval/client/EpicsMessage.java b/src/main/org/epics/archiverappliance/retrieval/client/EpicsMessage.java index 2f75962..6e99bc3 100644 --- a/src/main/org/epics/archiverappliance/retrieval/client/EpicsMessage.java +++ b/src/main/org/epics/archiverappliance/retrieval/client/EpicsMessage.java @@ -1,6 +1,5 @@ package org.epics.archiverappliance.retrieval.client; -import java.io.IOException; import java.sql.Timestamp; import java.util.Calendar; import java.util.HashMap; @@ -48,7 +47,7 @@ public int getElementCount() { } @SuppressWarnings("unchecked") - public Number getNumberValue() throws IOException { + public Number getNumberValue() { switch(info.getType()) { case SCALAR_BYTE: { return ((ByteString) message.getField(message.getDescriptorForType().findFieldByNumber(3))).toByteArray()[0]; @@ -93,15 +92,15 @@ public Number getNumberValue() throws IOException { return Double.parseDouble(((List) message.getField(message.getDescriptorForType().findFieldByNumber(3))).get(0)); } case V4_GENERIC_BYTES: { - throw new IOException("Can't cast V4_GENERIC_BYTES to Number"); + throw new UnsupportedOperationException("Can't cast V4_GENERIC_BYTES to Number"); } default: - throw new IOException("Unknown type " + info.getType()); + throw new UnsupportedOperationException("Unknown type " + info.getType()); } } @SuppressWarnings("unchecked") - public Number getNumberAt(int index) throws IOException { + public Number getNumberAt(int index) { switch(info.getType()) { case SCALAR_BYTE: { return ((ByteString) message.getField(message.getDescriptorForType().findFieldByNumber(3))).toByteArray()[0]; @@ -146,64 +145,64 @@ public Number getNumberAt(int index) throws IOException { return Double.parseDouble(((List) message.getField(message.getDescriptorForType().findFieldByNumber(3))).get(index)); } case V4_GENERIC_BYTES: { - throw new IOException("Can't cast V4_GENERIC_BYTES to Number"); + throw new UnsupportedOperationException("Can't cast V4_GENERIC_BYTES to Number"); } default: - throw new IOException("Unknown type " + info.getType()); + throw new UnsupportedOperationException("Unknown type " + info.getType()); } } @SuppressWarnings("unchecked") - public String getStringValue() throws IOException { + public String getStringValue() { String notSupportedMessage = "Conversion to string not supported yet"; switch(info.getType()) { case SCALAR_BYTE: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case SCALAR_DOUBLE: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case SCALAR_ENUM: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case SCALAR_FLOAT: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case SCALAR_INT: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case SCALAR_SHORT: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case SCALAR_STRING: { return (String) message.getField(message.getDescriptorForType().findFieldByNumber(3)); } case WAVEFORM_BYTE: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case WAVEFORM_DOUBLE: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case WAVEFORM_ENUM: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case WAVEFORM_FLOAT: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case WAVEFORM_INT: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case WAVEFORM_SHORT: { - throw new IOException(notSupportedMessage); + throw new UnsupportedOperationException(notSupportedMessage); } case WAVEFORM_STRING: { return ((List) message.getField(message.getDescriptorForType().findFieldByNumber(3))).get(0); } case V4_GENERIC_BYTES: { - throw new IOException("Can't cast V4_GENERIC_BYTES to Number"); + throw new UnsupportedOperationException("Can't cast V4_GENERIC_BYTES to Number"); } default: - throw new IOException("Unknown type " + info.getType()); + throw new UnsupportedOperationException("Unknown type " + info.getType()); } }