/** * Checks if the length of the string plus 1 for terminating zero * is less or equal than provided maximum. * * @param string the string to check * @param max the maximal length of the string with added term. zero * @exception WrongLengthOfStringException thrown if string with added * terminating zero would be longer than the maximum */ protected static void checkCString(String string, int max) throws WrongLengthOfStringException { checkCString(string, 1, max); // min = empty + 1 for zero }
/** * Checks if the length of string is less or equal than the provided * maximum. * * @param string the string to check * @param max the maximal length of the string * @exception WrongLengthOfStringException thrown if the string is longer * than the provided max length */ protected static void checkString(String string, int max) throws WrongLengthOfStringException { checkString(string, 0, max); }
public String debugString() { String dbgs = "(destaddr: "; dbgs += super.debugString(); dbgs += Integer.toString(getDestFlag()); dbgs += " "; dbgs += getTheAddress().debugString(); dbgs += ") "; return dbgs; } }
public void setData(ByteBuffer buffer) throws PDUException, NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, TooManyValuesException { resetValues(); int nrValues = 0; switch (lengthOfSize) { case BYTE_SIZE : nrValues = decodeUnsigned(buffer.removeByte()); break; case SHORT_SIZE : nrValues = decodeUnsigned(buffer.removeShort()); break; case INT_SIZE : // won't convert, maybe some other day (does anyone expect // correct values > 2147483648?) nrValues = buffer.removeInt(); break; } ByteData value; for (int i = 0; i < nrValues; i++) { value = createValue(); value.setData(buffer); addValue(value); } }
public ByteBuffer getData() throws ValueNotSetException // PDUException { ByteBuffer buffer = new ByteBuffer(); int nrValues = getCount(); switch (lengthOfSize) { case BYTE_SIZE : buffer.appendByte(encodeUnsigned((short) nrValues)); break; case SHORT_SIZE : buffer.appendShort(encodeUnsigned((int) nrValues)); break; case INT_SIZE : buffer.appendInt(nrValues); break; } ByteData value; for (int i = 0; i < nrValues; i++) { value = getValue(i); buffer.appendBuffer(value.getData()); } return buffer; }
public String debugString() { String dbgs = "(dl: "; dbgs += super.debugString(); dbgs += getDlName(); dbgs += ") "; return dbgs; } }
public String debugString() { String dbgs = "(bdlist: "; dbgs += super.debugString(); int count = getCount(); dbgs += "(count: " + count + ") "; for (int i = 0; i < count; i++) { ByteData value = getValue(i); dbgs += (i + 1) + ": " + value.debugString(); dbgs += " "; } dbgs += ") "; return dbgs; } }
/** * Checks if the length of the data of the string is less or equal than * the provided maximum; necessery for multibyte encodings. * Note that the length checked is the length wfter transforming * the string to series of octets, so two-byte strings will efectively * require space (max size) two-times the length of the string. * @param string the string to check * @param max the maximal length of the string * @param encoding the encoding of the string * @exception WrongLengthOfStringException thrown if the string is longer * than the provided max length * @exception UnsupportedEncodingException the required encoding isn't * supported */ protected static void checkString(String string, int max, String encoding) throws WrongLengthOfStringException, UnsupportedEncodingException { checkString(string, 0, max, encoding); }
public String debugString() { String dbgs = "(addrrang: "; dbgs += super.debugString(); dbgs += Integer.toString(getTon()); dbgs += " "; dbgs += Integer.toString(getNpi()); dbgs += " "; dbgs += getAddressRange(); dbgs += ") "; return dbgs; } }
/** * Checks if the length of string is greater or equal than provided * minimum and less or equal than the provided maximum. * * @param string the string to check * @param min the minimal length of the string * @param max the maximal length of the string * @throws WrongLengthOfStringException thrown if the string is shorter * than min length or longer than max length */ protected static void checkString(String string, int min, int max) throws WrongLengthOfStringException { int length = string == null ? 0 : string.length(); checkString(min, length, max); }
public String debugString() { String dbgs = "(addr: "; dbgs += super.debugString(); dbgs += Integer.toString(getTon()); dbgs += " "; dbgs += Integer.toString(getNpi()); dbgs += " "; dbgs += getAddress(); dbgs += ") "; return dbgs; }
/** * Checks if the length of the data of the string is greater or equal * than provided minimum and less or equal than the provided maximum; * necessery for multibyte encodings. * * @param string the string to check * @param min the minimal length of the string * @param max the maximal length of the string * @param encoding the encoding of the string * @throws WrongLengthOfStringException thrown if the string is shorter * than min length or longer than max length * @exception UnsupportedEncodingException the required encoding isn't * supported */ protected static void checkString(String string, int min, int max, String encoding) throws WrongLengthOfStringException, UnsupportedEncodingException { byte[] stringBytes = string.getBytes(encoding); int length = stringBytes == null ? 0 : stringBytes.length; checkString(min, length, max); }
public String debugString() { String dbgs = "(pdu: "; dbgs += super.debugString(); dbgs += Integer.toString(getCommandLength()); dbgs += " "; dbgs += Integer.toHexString(getCommandId()); dbgs += " "; dbgs += Integer.toHexString(getCommandStatus()); dbgs += " "; if (sequenceNumberChanged) { dbgs += Integer.toString(getSequenceNumber()); } else { // it's likely that this will be the assigned seq number // (in simple cases :-) dbgs += "[" + (sequenceNumber + 1) + "]"; } dbgs += ") "; return dbgs; }