test_class.declarator: resolver
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Resolver resolver;
test_class.type: Resolver
test_class.var_name: resolver
test_class.declarator: sizeExpr
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Expression<Integer, Resolver> sizeExpr;
test_class.type: Expression<Integer, Resolver>
test_class.var_name: sizeExpr
test_class.declarator: builder
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Builder builder;
test_class.type: Builder
test_class.var_name: builder
test_class.file: preon-binding/src/test/java/org/codehaus/preon/codec/FixedLengthStringCodecTest.java
test_class.identifier: FixedLengthStringCodecTest
test_case.body: @Test
      public void shouldEncodeCorrectly() throws IOException, NullPointerException {
  		Charset charset = Charset.availableCharsets().get(BoundString.Encoding.ASCII);
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          BitChannel channel = new OutputStreamBitChannel(out);
          when(sizeExpr.eval(Matchers.any(Resolver.class))).thenReturn(4);
          FixedLengthStringCodec codec =
                  new FixedLengthStringCodec(charset, sizeExpr, null, new BoundString.NullConverter());
          codec.encode("Whatever", channel, resolver);
          out.flush();
          byte[] result = out.toByteArray();
          assertThat(result.length, is(4));
          assertThat(new String(result, "US-ASCII"), is("What"));
      }
test_case.class_method_signature: FixedLengthStringCodecTest.shouldEncodeCorrectly()
test_case.full_signature: @Test public void shouldEncodeCorrectly()
test_case.identifier: shouldEncodeCorrectly
test_case.invocations: get availableCharsets thenReturn when eval any encode flush toByteArray assertThat is assertThat is
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldEncodeCorrectly()
focal_class.declarator: encoding
focal_class.modifier: private final
focal_class.original_string: private final Charset encoding;
focal_class.type: Charset
focal_class.var_name: encoding
focal_class.declarator: encoder
focal_class.modifier: private final
focal_class.original_string: private final CharsetEncoder encoder;
focal_class.type: CharsetEncoder
focal_class.var_name: encoder
focal_class.declarator: sizeExpr
focal_class.modifier: private final
focal_class.original_string: private final Expression<Integer, Resolver> sizeExpr;
focal_class.type: Expression<Integer, Resolver>
focal_class.var_name: sizeExpr
focal_class.declarator: match
focal_class.modifier: private final
focal_class.original_string: private final String match;
focal_class.type: String
focal_class.var_name: match
focal_class.declarator: byteConverter
focal_class.modifier: private final
focal_class.original_string: private final BoundString.ByteConverter byteConverter;
focal_class.type: BoundString.ByteConverter
focal_class.var_name: byteConverter
focal_class.file: preon-binding/src/main/java/org/codehaus/preon/codec/FixedLengthStringCodec.java
focal_class.identifier: FixedLengthStringCodec
focal_class.interfaces: implements Codec<String>
focal_class.class_method_signature: FixedLengthStringCodec.FixedLengthStringCodec(Charset encoding,
                                    Expression<Integer, Resolver> sizeExpr, String match,
                                    BoundString.ByteConverter byteConverter)
focal_class.full_signature: public  FixedLengthStringCodec(Charset encoding,
                                    Expression<Integer, Resolver> sizeExpr, String match,
                                    BoundString.ByteConverter byteConverter)
focal_class.identifier: FixedLengthStringCodec
focal_class.modifiers: public
focal_class.parameters: (Charset encoding,
                                    Expression<Integer, Resolver> sizeExpr, String match,
                                    BoundString.ByteConverter byteConverter)
focal_class.signature:  FixedLengthStringCodec(Charset encoding,
                                    Expression<Integer, Resolver> sizeExpr, String match,
                                    BoundString.ByteConverter byteConverter)
focal_class.class_method_signature: FixedLengthStringCodec.decode(BitBuffer buffer, Resolver resolver,
                           Builder builder)
focal_class.full_signature: public String decode(BitBuffer buffer, Resolver resolver,
                           Builder builder)
focal_class.identifier: decode
focal_class.modifiers: public
focal_class.parameters: (BitBuffer buffer, Resolver resolver,
                           Builder builder)
focal_class.return: String
focal_class.signature: String decode(BitBuffer buffer, Resolver resolver,
                           Builder builder)
focal_class.class_method_signature: FixedLengthStringCodec.encode(String value, BitChannel channel, Resolver resolver)
focal_class.full_signature: public void encode(String value, BitChannel channel, Resolver resolver)
focal_class.identifier: encode
focal_class.modifiers: public
focal_class.parameters: (String value, BitChannel channel, Resolver resolver)
focal_class.return: void
focal_class.signature: void encode(String value, BitChannel channel, Resolver resolver)
focal_class.class_method_signature: FixedLengthStringCodec.getTypes()
focal_class.full_signature: public Class<?>[] getTypes()
focal_class.identifier: getTypes
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Class<?>[]
focal_class.signature: Class<?>[] getTypes()
focal_class.class_method_signature: FixedLengthStringCodec.getSize()
focal_class.full_signature: public Expression<Integer, Resolver> getSize()
focal_class.identifier: getSize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Expression<Integer, Resolver>
focal_class.signature: Expression<Integer, Resolver> getSize()
focal_class.class_method_signature: FixedLengthStringCodec.getType()
focal_class.full_signature: public Class<?> getType()
focal_class.identifier: getType
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Class<?>
focal_class.signature: Class<?> getType()
focal_class.class_method_signature: FixedLengthStringCodec.getCodecDescriptor()
focal_class.full_signature: public CodecDescriptor getCodecDescriptor()
focal_class.identifier: getCodecDescriptor
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: CodecDescriptor
focal_class.signature: CodecDescriptor getCodecDescriptor()
focal_method.body: public void encode(String value, BitChannel channel, Resolver resolver) throws IOException {
          int size = sizeExpr.eval(resolver);
          ByteBuffer bytebuffer = ByteBuffer.allocate(size);
          encoder.encode(CharBuffer.wrap(value), bytebuffer, true);
  
          if (bytebuffer.position() < size) { // pad with 0's
              bytebuffer.put(new byte[size - bytebuffer.position()]);
          }
          bytebuffer.flip(); // switch to reading
          
          byte[] bytes = new byte[size];
          bytebuffer.get(bytes);
          for (int i = 0; i < bytes.length; i++) {
              bytes[i] = byteConverter.revert(bytes[i]);
          }
          //assert (size <= bytes.length); //No longer needed
          channel.write(bytes, 0, size);
      }
focal_method.class_method_signature: FixedLengthStringCodec.encode(String value, BitChannel channel, Resolver resolver)
focal_method.full_signature: public void encode(String value, BitChannel channel, Resolver resolver)
focal_method.identifier: encode
focal_method.invocations: eval allocate encode wrap position put position flip get revert write
focal_method.modifiers: public
focal_method.parameters: (String value, BitChannel channel, Resolver resolver)
focal_method.return: void
focal_method.signature: void encode(String value, BitChannel channel, Resolver resolver)