StartSubfilter events have null mimeType and type

Issue #828 new
Former user created an issue

See code below. It prints mimeType:null type:null

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import net.sf.okapi.common.Event;
import net.sf.okapi.common.LocaleId;
import net.sf.okapi.common.filters.DefaultFilters;
import net.sf.okapi.common.filters.FilterConfigurationMapper;
import net.sf.okapi.common.filters.IFilter;
import net.sf.okapi.common.resource.RawDocument;
import net.sf.okapi.common.resource.StartSubfilter;

@RunWith(JUnit4.class)
@SuppressWarnings("static-method")
public class TestSubFilter {
    static FilterConfigurationMapper fcMapper = new FilterConfigurationMapper();
    static {
        DefaultFilters.setMappings(fcMapper, true, true);
    }

    @Test
    public void testBug() {
        String testData = "key = <h1>Properties + HTML</h1>"
                + "<p>This is a paragraph with <b>bold</b> in it.<p>";

        try (RawDocument rawDoc = new RawDocument(testData, LocaleId.ENGLISH);
                IFilter filter = fcMapper.createFilter("okf_properties-html-subfilter")) {
            filter.open(rawDoc);

            while (filter.hasNext()) {
                Event event = filter.next();
                if (event.isStartSubfilter()) {
                    StartSubfilter ssf = event.getStartSubfilter();
                    System.out.printf("mimeType:%s type:%s%n", ssf.getMimeType(), ssf.getType());
                }
            }
        }
    }
}

Comments (0)

  1. Log in to comment