/** * Throws a MALException when supplied with a NULL value * * @param value The value to check * @throws MALException if value is NULL */ protected void checkForNull(Object value) throws MALException { if (null == value) { throw new MALException("Null value supplied in a non-nullable field"); } }
/** * Ok for debugging but don't put it nowhere near the final code. * Performance! * * @return */ public String bodytoString() { if (this.body != null) { StringBuilder output = new StringBuilder(); output.append(this.body.getClass().getCanonicalName()); for (int i = 0; i < this.body.getElementCount(); i++) { try { if (this.body.getBodyElement(i, null) != null) { output.append(" | "); output.append(this.body.getBodyElement(i, null).toString()); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (MALException e) { e.printStackTrace(); } } return output.toString(); } return " --no body--"; } }
exceptionList.append(ex.getMessage()); throw new MALException("Error during closing of transports" + exceptionList);
ex.printStackTrace(); throw new MALTransmitErrorException(msg.getHeader(), new MALStandardError(MALHelper.BAD_ENCODING_ERROR_NUMBER, new Union(ex.getLocalizedMessage())), msg.getQoSProperties());
/** * Send return error method. * * @param msgAddress Address structure to use for return message. * @param srcHdr Message header to use as reference for return messages header. * @param rspnInteractionStage Interaction stage to use on the response. * @param error Response message error. * @return The sent MAL message. */ public MALMessage returnError(final Address msgAddress, final MALMessageHeader srcHdr, final UOctet rspnInteractionStage, final MALException error) { return initiateReturnError(msgAddress, srcHdr, srcHdr.getQoSlevel(), rspnInteractionStage, new MALStandardError(MALHelper.INTERNAL_ERROR_NUMBER, new Union(error.getLocalizedMessage()))); }
private void internalHandleProgress(final MALMessage msg, final Address address) throws MALInteractionException { ProgressInteractionImpl interaction = new ProgressInteractionImpl(sender, address, msg); try { try { MALContextFactoryImpl.LOGGER.log(Level.FINE, "internalHandleProgresss for {0} type {1}", new Object[] { msg.getHeader().getTransactionId(), address.handler }); address.handler.handleProgress(interaction, msg.getBody()); } catch (MALInteractionException ex) { interaction.sendError(ex.getStandardError()); } } catch (MALException ex) { try { interaction.sendError(new MALStandardError(MALHelper.INTERNAL_ERROR_NUMBER, new Union(ex.getLocalizedMessage()))); } catch (MALException noex) { // this exception cannot actually be thrown in this implmentation, therefore we can safely ignore it } } }
@Override public MALEncodedElement getEncodedUpdate(final int listIndex, final int updateIndex) throws MALException { //ToDo throw new MALException("Not supported yet."); } }
private void internalHandleInvoke(final MALMessage msg, final Address address) throws MALInteractionException { InvokeInteractionImpl interaction = new InvokeInteractionImpl(sender, address, msg); try { try { MALContextFactoryImpl.LOGGER.log(Level.FINE, "internalHandleInvoke for {0} type {1}", new Object[] { msg.getHeader().getTransactionId(), address.handler }); address.handler.handleInvoke(interaction, msg.getBody()); } catch (MALInteractionException ex) { interaction.sendError(ex.getStandardError()); } } catch (MALException ex) { try { interaction.sendError(new MALStandardError(MALHelper.INTERNAL_ERROR_NUMBER, new Union(ex.getLocalizedMessage()))); } catch (MALException noex) { // this exception cannot actually be thrown in this implmentation, therefore we can safely ignore it } } }
/** * Throws a MALException when supplied with a NULL value * * @param value The value to check * @throws MALException if value is NULL */ protected void checkForNull(Object value) throws MALException { if (null == value) { throw new MALException("Null value supplied in a non-nullable field"); } }
@Override public void flush() throws MALException { try { dos.flush(); } catch (IOException ex) { throw new MALException("IO exception flushing Element stream", ex); } }
@Override public MALListEncoder createListEncoder(final java.util.List value) throws MALException { try { outputStream.addUnsignedInt(value.size()); return this; } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
@Override public MALListEncoder createListEncoder(final java.util.List value) throws MALException { try { outputStream.addUnsignedInt(value.size()); return this; } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
/** * Encode a long * * @param val * @throws MALException */ public void encodeMALLong(Long val) throws MALException { try { outputStream.addSignedLong(val); } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
/** * Allows the encoding of a byte array, usually for already encoded values * * @param value The type to encode * @throws MALException if there is an error */ public void directEncodeBytes(final byte[] value) throws MALException { try { outputStream.directAdd(value); } catch (IOException ex) { throw new MALException(ENCODING_EXCEPTION_STR, ex); } }
@Override public int getSignedInt() throws MALException { try { return Integer.valueOf(removeFirst()); } catch (NumberFormatException ex) { throw new MALException(ex.getLocalizedMessage(), ex); } }
@Override public long getSignedLong() throws MALException { try { return Long.valueOf(removeFirst()); } catch (NumberFormatException ex) { throw new MALException(ex.getLocalizedMessage(), ex); } }
@Override public short getSignedShort() throws MALException { try { return Short.valueOf(removeFirst()); } catch (NumberFormatException ex) { throw new MALException(ex.getLocalizedMessage(), ex); } }
@Override public byte get8() throws MALException { try { return Byte.valueOf(removeFirst()); } catch (NumberFormatException ex) { throw new MALException(ex.getLocalizedMessage(), ex); } }
@Override public BigInteger getBigInteger() throws MALException { try { return new BigInteger(removeFirst()); } catch (NumberFormatException ex) { throw new MALException(ex.getLocalizedMessage(), ex); } }
@Override public float getFloat() throws MALException { try { return Float.valueOf(removeFirst()); } catch (NumberFormatException ex) { throw new MALException(ex.getLocalizedMessage(), ex); } }