@Test public void testNormalVer20EnfFileBuffer() throws Exception { CommandExchangeBuffer efid = CommandBuilderVer20.endFile(0, 17860); String createdBufferText = new String(efid.getRawBuffer().array()); assertEquals("Invalid created buffer text.", NORMAL_VER20_EFID_TEXT, createdBufferText); }
public ByteBuffer getRawBuffer() { ByteBuffer buffer = ByteBufferFactory.allocate(getSize()); buffer.order(ByteOrder.BIG_ENDIAN); for (String fieldName : getFieldNames()) { Field field = commandFormat.getField(fieldName); byte[] octets = null; if (field.getType() == Field.BINARY_TYPE) { octets = getByteArrayAttribute(fieldName); } else { String text = formatAttribute(field, getStringAttribute(fieldName)); if (text == null) { continue; } if (field.getType() == Field.ENCODED_TYPE) { octets = text.getBytes(UTF8_ENCODED_PROTOCOL_CHARSET); } else { octets = text.getBytes(DEFAULT_PROTOCOL_CHARSET); } } if (octets == null && LOGGER.isDebugEnabled()) LOGGER.debug("getBuffer() - Field is null: {}", fieldName); if (octets != null) { buffer.put(octets); } } buffer.flip(); return buffer; }
CommandExchangeBuffer implements OdetteFtpExchangeBuffer { public ByteBuffer getRawBuffer() { ByteBuffer buffer = ByteBufferFactory.allocate(getSize()); buffer.order(ByteOrder.BIG_ENDIAN); for (String fieldName : getFieldNames()) { Field field = commandFormat.getField(fieldName); byte[] octets = null; if (field.getType() == Field.BINARY_TYPE) { octets = getByteArrayAttribute(fieldName); } else { String text = formatAttribute(field, getStringAttribute(fieldName)); if (text == null) { continue; } if (field.getType() == Field.ENCODED_TYPE) { octets = text.getBytes(UTF8_ENCODED_PROTOCOL_CHARSET); } else { octets = text.getBytes(DEFAULT_PROTOCOL_CHARSET); } } if (octets == null && LOGGER.isDebugEnabled()) LOGGER.debug("getBuffer() - Field is null: {}", fieldName); if (octets != null) { buffer.put(octets); } } buffer.flip(); return buffer; } }
CommandExchangeBuffer implements OdetteFtpExchangeBuffer { public ByteBuffer getRawBuffer() { ByteBuffer buffer = ByteBufferFactory.allocate(getSize()); buffer.order(ByteOrder.BIG_ENDIAN); for (String fieldName : getFieldNames()) { Field field = commandFormat.getField(fieldName); byte[] octets = null; if (field.getType() == Field.BINARY_TYPE) { octets = getByteArrayAttribute(fieldName); } else { String text = formatAttribute(field, getStringAttribute(fieldName)); if (text == null) { continue; } if (field.getType() == Field.ENCODED_TYPE) { octets = text.getBytes(UTF8_ENCODED_PROTOCOL_CHARSET); } else { octets = text.getBytes(DEFAULT_PROTOCOL_CHARSET); } } if (octets == null && LOGGER.isDebugEnabled()) LOGGER.debug("getBuffer() - Field is null: {}", fieldName); if (octets != null) { buffer.put(octets); } } buffer.flip(); return buffer; } CommandExchangeBuffer(CommandFormat commandFormat); }
CommandExchangeBuffer implements OdetteFtpExchangeBuffer { public ByteBuffer getRawBuffer() { ByteBuffer buffer = ByteBufferFactory.allocate(getSize()); buffer.order(ByteOrder.BIG_ENDIAN); for (String fieldName : getFieldNames()) { Field field = commandFormat.getField(fieldName); byte[] octets = null; if (field.getType() == Field.BINARY_TYPE) { octets = getByteArrayAttribute(fieldName); } else { String text = formatAttribute(field, getStringAttribute(fieldName)); if (text == null) { continue; } if (field.getType() == Field.ENCODED_TYPE) { octets = text.getBytes(UTF8_ENCODED_PROTOCOL_CHARSET); } else { octets = text.getBytes(DEFAULT_PROTOCOL_CHARSET); } } if (octets == null && LOGGER.isDebugEnabled()) LOGGER.debug("getBuffer() - Field is null: {}", fieldName); if (octets != null) { buffer.put(octets); } } buffer.flip(); return buffer; } CommandExchangeBuffer(CommandFormat commandFormat); static String formatAttribute(Field field, String value); static boolean checkAttribute(char type, String value); Object getAttribute(String name); String getStringAttribute(String name); byte[] getByteArrayAttribute(String name); String getFormattedAttribute(String name); ByteBuffer getRawBuffer(); String[] getFieldNames(); CommandIdentifier getIdentifier(); int getSize(); Object setAttribute(String fieldName, Object value); @Override String toString(); @Override boolean equals(Object obj); }
CommandExchangeBuffer implements OdetteFtpExchangeBuffer { public ByteBuffer getRawBuffer() { ByteBuffer buffer = ByteBufferFactory.allocate(getSize()); buffer.order(ByteOrder.BIG_ENDIAN); for (String fieldName : getFieldNames()) { Field field = commandFormat.getField(fieldName); byte[] octets = null; if (field.getType() == Field.BINARY_TYPE) { octets = getByteArrayAttribute(fieldName); } else { String text = formatAttribute(field, getStringAttribute(fieldName)); if (text == null) { continue; } if (field.getType() == Field.ENCODED_TYPE) { octets = text.getBytes(UTF8_ENCODED_PROTOCOL_CHARSET); } else { octets = text.getBytes(DEFAULT_PROTOCOL_CHARSET); } } if (octets == null && LOGGER.isDebugEnabled()) LOGGER.debug("getBuffer() - Field is null: {}", fieldName); if (octets != null) { buffer.put(octets); } } buffer.flip(); return buffer; } CommandExchangeBuffer(CommandFormat commandFormat); static String formatAttribute(Field field, String value); static boolean checkAttribute(char type, String value); Object getAttribute(String name); String getStringAttribute(String name); byte[] getByteArrayAttribute(String name); String getFormattedAttribute(String name); ByteBuffer getRawBuffer(); String[] getFieldNames(); CommandIdentifier getIdentifier(); int getSize(); Object setAttribute(String fieldName, Object value); @Override String toString(); @Override boolean equals(Object obj); static final Charset DEFAULT_PROTOCOL_CHARSET; static final Charset UTF8_ENCODED_PROTOCOL_CHARSET; }