Search in sources :

Example 1 with AbstractFilter

use of org.omegat.filters2.AbstractFilter in project omegat by omegat-org.

the class TestFilterBase method parse3.

protected List<ParsedEntry> parse3(AbstractFilter filter, String filename, Map<String, String> options) throws Exception {
    final List<ParsedEntry> result = new ArrayList<ParsedEntry>();
    filter.parseFile(new File(filename), options, context, new IParseCallback() {

        public void addEntry(String id, String source, String translation, boolean isFuzzy, String comment, IFilter filter) {
            addEntry(id, source, translation, isFuzzy, comment, null, filter, null);
        }

        public void addEntry(String id, String source, String translation, boolean isFuzzy, String comment, String path, IFilter filter, List<ProtectedPart> protectedParts) {
            String[] props = comment == null ? null : new String[] { SegmentProperties.COMMENT, comment };
            addEntryWithProperties(id, source, translation, isFuzzy, props, path, filter, protectedParts);
        }

        @Override
        public void addEntryWithProperties(String id, String source, String translation, boolean isFuzzy, String[] props, String path, IFilter filter, List<ProtectedPart> protectedParts) {
            if (source.isEmpty()) {
                return;
            }
            ParsedEntry e = new ParsedEntry();
            e.id = id;
            e.source = source;
            e.translation = translation;
            e.isFuzzy = isFuzzy;
            e.props = props;
            e.path = path;
            result.add(e);
        }

        public void linkPrevNextSegments() {
        }
    });
    return result;
}
Also used : IParseCallback(org.omegat.filters2.IParseCallback) ProtectedPart(org.omegat.core.data.ProtectedPart) IFilter(org.omegat.filters2.IFilter) ArrayList(java.util.ArrayList) File(java.io.File)

Example 2 with AbstractFilter

use of org.omegat.filters2.AbstractFilter in project omegat by omegat-org.

the class TestFilterBase method parse.

protected List<String> parse(AbstractFilter filter, String filename) throws Exception {
    final List<String> result = new ArrayList<String>();
    filter.parseFile(new File(filename), Collections.emptyMap(), context, new IParseCallback() {

        public void addEntry(String id, String source, String translation, boolean isFuzzy, String comment, IFilter filter) {
            addEntry(id, source, translation, isFuzzy, comment, null, filter, null);
        }

        public void addEntry(String id, String source, String translation, boolean isFuzzy, String comment, String path, IFilter filter, List<ProtectedPart> protectedParts) {
            String[] props = comment == null ? null : new String[] { SegmentProperties.COMMENT, comment };
            addEntryWithProperties(id, source, translation, isFuzzy, props, path, filter, protectedParts);
        }

        public void addEntryWithProperties(String id, String source, String translation, boolean isFuzzy, String[] props, String path, IFilter filter, List<ProtectedPart> protectedParts) {
            if (!source.isEmpty()) {
                result.add(source);
            }
        }

        public void linkPrevNextSegments() {
        }
    });
    return result;
}
Also used : IParseCallback(org.omegat.filters2.IParseCallback) ProtectedPart(org.omegat.core.data.ProtectedPart) IFilter(org.omegat.filters2.IFilter) ArrayList(java.util.ArrayList) File(java.io.File)

Example 3 with AbstractFilter

use of org.omegat.filters2.AbstractFilter in project omegat by omegat-org.

the class TestFilterBase method parse.

protected List<String> parse(AbstractFilter filter, String filename, Map<String, String> options) throws Exception {
    final List<String> result = new ArrayList<String>();
    filter.parseFile(new File(filename), options, context, new IParseCallback() {

        public void addEntry(String id, String source, String translation, boolean isFuzzy, String comment, IFilter filter) {
            addEntry(id, source, translation, isFuzzy, comment, null, filter, null);
        }

        public void addEntry(String id, String source, String translation, boolean isFuzzy, String comment, String path, IFilter filter, List<ProtectedPart> protectedParts) {
            String[] props = comment == null ? null : new String[] { SegmentProperties.COMMENT, comment };
            addEntryWithProperties(id, source, translation, isFuzzy, props, path, filter, protectedParts);
        }

        public void addEntryWithProperties(String id, String source, String translation, boolean isFuzzy, String[] props, String path, IFilter filter, List<ProtectedPart> protectedParts) {
            if (!source.isEmpty()) {
                result.add(source);
            }
        }

        public void linkPrevNextSegments() {
        }
    });
    return result;
}
Also used : IParseCallback(org.omegat.filters2.IParseCallback) ProtectedPart(org.omegat.core.data.ProtectedPart) IFilter(org.omegat.filters2.IFilter) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

File (java.io.File)3 ArrayList (java.util.ArrayList)3 ProtectedPart (org.omegat.core.data.ProtectedPart)3 IFilter (org.omegat.filters2.IFilter)3 IParseCallback (org.omegat.filters2.IParseCallback)3