aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector/ox/OXGPXParser.java
blob: 5f11a11fe1f6cf2c33249212fdf820c7737c2db7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package cgeo.geocaching.connector.ox;

import cgeo.geocaching.Geocache;
import cgeo.geocaching.files.GPX10Parser;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.jdt.annotation.NonNull;

public class OXGPXParser extends GPX10Parser {

    private final boolean isDetailed;

    public OXGPXParser(int listIdIn, boolean isDetailed) {
        super(listIdIn);
        this.isDetailed = isDetailed;
    }

    @Override
    protected void afterParsing(Geocache cache) {
        cache.setUpdated(System.currentTimeMillis());
        if (isDetailed) {
            cache.setDetailedUpdate(cache.getUpdated());
            cache.setDetailed(true);
        }
        removeTitleFromShortDescription(cache);
    }

    /**
     * The short description of OX caches contains "title by owner, type(T/D/Awesomeness)". That is a lot of
     * duplication.
     *
     * @param cache
     */
    private static void removeTitleFromShortDescription(final @NonNull Geocache cache) {
        cache.setShortDescription(StringUtils.trim(StringUtils.substringAfterLast(cache.getShortDescription(), ",")));
    }
}