test_class.file: handlebars-jackson2/src/test/java/com/github/jknack/handlebars/Jackson2HelperTest.java
test_class.identifier: Jackson2HelperTest
test_case.body: @Test
    public void toJSONViewExclusive() throws IOException {
      Handlebars handlebars = new Handlebars();
  
      ObjectMapper mapper = new ObjectMapper();
      mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);
  
      handlebars.registerHelper("@json", new Jackson2Helper(mapper));
  
      Template template =
          handlebars
              .compileInline("{{@json this view=\"com.github.jknack.handlebars.Blog$Views$Public\"}}");
  
      CharSequence result = template.apply(new Blog("First Post", "..."));
  
      assertEquals("{\"title\":\"First Post\"}", result);
    }
test_case.class_method_signature: Jackson2HelperTest.toJSONViewExclusive()
test_case.full_signature: @Test public void toJSONViewExclusive()
test_case.identifier: toJSONViewExclusive
test_case.invocations: configure registerHelper compileInline apply assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void toJSONViewExclusive()
focal_class.declarator: INSTANCE = new Jackson2Helper()
focal_class.modifier: public static final
focal_class.original_string: public static final Helper<Object> INSTANCE = new Jackson2Helper();
focal_class.type: Helper<Object>
focal_class.var_name: INSTANCE
focal_class.declarator: mapper
focal_class.modifier: private final
focal_class.original_string: private final ObjectMapper mapper;
focal_class.type: ObjectMapper
focal_class.var_name: mapper
focal_class.declarator: alias = new HashMap<String, Class<?>>()
focal_class.modifier: private final
focal_class.original_string: private final Map<String, Class<?>> alias = new HashMap<String, Class<?>>();
focal_class.type: Map<String, Class<?>>
focal_class.var_name: alias
focal_class.file: handlebars-jackson2/src/main/java/com/github/jknack/handlebars/Jackson2Helper.java
focal_class.identifier: Jackson2Helper
focal_class.interfaces: implements Helper<Object>
focal_class.class_method_signature: Jackson2Helper.Jackson2Helper(final ObjectMapper objectMapper)
focal_class.full_signature: public  Jackson2Helper(final ObjectMapper objectMapper)
focal_class.identifier: Jackson2Helper
focal_class.modifiers: public
focal_class.parameters: (final ObjectMapper objectMapper)
focal_class.signature:  Jackson2Helper(final ObjectMapper objectMapper)
focal_class.class_method_signature: Jackson2Helper.Jackson2Helper()
focal_class.full_signature: private  Jackson2Helper()
focal_class.identifier: Jackson2Helper
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  Jackson2Helper()
focal_class.class_method_signature: Jackson2Helper.apply(final Object context, final Options options)
focal_class.full_signature: @Override public Object apply(final Object context, final Options options)
focal_class.identifier: apply
focal_class.modifiers: @Override public
focal_class.parameters: (final Object context, final Options options)
focal_class.return: Object
focal_class.signature: Object apply(final Object context, final Options options)
focal_class.class_method_signature: Jackson2Helper.viewAlias(final String alias,
        final Class<?> viewClass)
focal_class.full_signature: public Jackson2Helper viewAlias(final String alias,
        final Class<?> viewClass)
focal_class.identifier: viewAlias
focal_class.modifiers: public
focal_class.parameters: (final String alias,
        final Class<?> viewClass)
focal_class.return: Jackson2Helper
focal_class.signature: Jackson2Helper viewAlias(final String alias,
        final Class<?> viewClass)
focal_method.body: @Override
    public Object apply(final Object context, final Options options)
        throws IOException {
      if (context == null) {
        return options.hash("default", "");
      }
      String viewName = options.hash("view", "");
      JsonGenerator generator = null;
      try {
        final ObjectWriter writer;
        // do we need to use a view?
        if (!Handlebars.Utils.isEmpty(viewName)) {
          Class<?> viewClass = alias.get(viewName);
          if (viewClass == null) {
            viewClass = getClass().getClassLoader().loadClass(viewName);
          }
          writer = mapper.writerWithView(viewClass);
        } else {
          writer = mapper.writer();
        }
        JsonFactory jsonFactory = mapper.getFactory();
  
        SegmentedStringWriter output = new SegmentedStringWriter(jsonFactory._getBufferRecycler());
  
        // creates a json generator.
        generator = jsonFactory.createJsonGenerator(output);
  
        Boolean escapeHtml = options.hash("escapeHTML", Boolean.FALSE);
        // do we need to escape html?
        if (escapeHtml) {
          generator.setCharacterEscapes(new HtmlEscapes());
        }
  
        Boolean pretty = options.hash("pretty", Boolean.FALSE);
  
        // write the JSON output.
        if (pretty) {
          writer.withDefaultPrettyPrinter().writeValue(generator, context);
        } else {
          writer.writeValue(generator, context);
        }
  
        generator.close();
  
        return new Handlebars.SafeString(output.getAndClear());
      } catch (ClassNotFoundException ex) {
        throw new IllegalArgumentException(viewName, ex);
      } finally {
        if (generator != null && !generator.isClosed()) {
          generator.close();
        }
      }
    }
focal_method.class_method_signature: Jackson2Helper.apply(final Object context, final Options options)
focal_method.full_signature: @Override public Object apply(final Object context, final Options options)
focal_method.identifier: apply
focal_method.invocations: hash hash isEmpty get loadClass getClassLoader getClass writerWithView writer getFactory _getBufferRecycler createJsonGenerator hash setCharacterEscapes hash writeValue withDefaultPrettyPrinter writeValue close getAndClear isClosed close
focal_method.modifiers: @Override public
focal_method.parameters: (final Object context, final Options options)
focal_method.return: Object
focal_method.signature: Object apply(final Object context, final Options options)