~ubuntu-branches/ubuntu/trusty/mediathekview/trusty

« back to all changes in this revision

Viewing changes to src/msearch/tool/MSearchStringBuilder.java

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2014-01-07 17:25:52 UTC
  • mfrom: (4.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20140107172552-vkv6uixpou3sa5og
Tags: 4-1
* Imported Upstream version 4.
* Declare compliance with Standards-Version 3.9.5.
* Correct a mistake in the last changelog entry.
  - build-dependencies <-> dependencies
* Override lintian warning:incompatible-java-bytecode-format Java7 because
  Java7 is the current default JRE for Jessie. MediathekView also requires
  Java7 to run and is incompatible with Java6 or earlier.
* debian/control: Add libjackson2-core-java, libtimingframework-java and
  libxz-java to Build-Depends-Indep.
* Drop README.source. Now upstream provides a source tarball.
* Refresh modify-ant-build-system.patch.
* debian/rules: Remove get-orig-source target. No longer needed.
* Update mediathekview.manifest. Add new required libraries to classpath.
* Update debian/watch for new versioning scheme.
* Update debian/copyright for new release. Add BSD-3-clause license.
* Update man pages and remove unsupported options.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * MediathekView
 
3
 * Copyright (C) 2008 W. Xaver
 
4
 * W.Xaver[at]googlemail.com
 
5
 * http://zdfmediathk.sourceforge.net/
 
6
 *
 
7
 * This program is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation, either version 3 of the License, or
 
10
 * any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
package msearch.tool;
 
21
 
 
22
import java.util.ArrayList;
 
23
 
 
24
public class MSearchStringBuilder {
 
25
 
 
26
    private StringBuilder cont;
 
27
    private int pos1 = 0, pos2 = 0, pos3 = 0;
 
28
 
 
29
    public MSearchStringBuilder() {
 
30
        cont = new StringBuilder();
 
31
    }
 
32
 
 
33
    public MSearchStringBuilder(int capacity) {
 
34
        cont = new StringBuilder(capacity);
 
35
    }
 
36
 
 
37
    public String substring(int start) {
 
38
        return cont.substring(start);
 
39
    }
 
40
 
 
41
    public int lastIndexOf(String of) {
 
42
        return cont.lastIndexOf(of);
 
43
    }
 
44
 
 
45
    public int length() {
 
46
        return cont.length();
 
47
    }
 
48
 
 
49
    public String substring(int start, int end) {
 
50
        return cont.substring(start, end);
 
51
    }
 
52
 
 
53
    public synchronized void append(char[] str) {
 
54
        cont.append(str);
 
55
    }
 
56
 
 
57
    public synchronized void append(char[] str, int offset, int len) {
 
58
        cont.append(str, offset, len);
 
59
    }
 
60
 
 
61
    public synchronized void setLength(int newLength) {
 
62
        cont.setLength(newLength);
 
63
    }
 
64
 
 
65
    public synchronized int indexOf(String str, int fromIndex) {
 
66
        return cont.indexOf(str, fromIndex);
 
67
    }
 
68
 
 
69
    public synchronized int indexOf(String str) {
 
70
        return cont.indexOf(str);
 
71
    }
 
72
 
 
73
    public String extract(String musterStart, String musterEnde) {
 
74
        return extract(musterStart, musterEnde, 0);
 
75
    }
 
76
 
 
77
    public String extract(String musterStart, String musterEnde, int abPos) {
 
78
        if ((pos1 = cont.indexOf(musterStart, abPos)) != -1) {
 
79
            pos1 += musterStart.length();
 
80
            if ((pos2 = cont.indexOf(musterEnde, pos1)) != -1) {
 
81
                return cont.substring(pos1, pos2);
 
82
            }
 
83
        }
 
84
        return "";
 
85
    }
 
86
 
 
87
    public void extractList(String musterStart, String musterEnde, int abPos, String addUrl, ArrayList<String> result) {
 
88
        pos1 = abPos;
 
89
        while ((pos1 = cont.indexOf(musterStart, pos1)) != -1) {
 
90
            pos1 += musterStart.length();
 
91
            if ((pos2 = cont.indexOf(musterEnde, pos1)) != -1) {
 
92
                result.add(addUrl + cont.substring(pos1, pos2));
 
93
            }
 
94
        }
 
95
    }
 
96
 
 
97
    public String extractLast(String musterStart, String musterEnde) {
 
98
        if ((pos1 = cont.lastIndexOf(musterStart)) != -1) {
 
99
            pos1 += musterStart.length();
 
100
            if ((pos2 = cont.indexOf(musterEnde, pos1)) != -1) {
 
101
                return cont.substring(pos1, pos2);
 
102
            }
 
103
        }
 
104
        return "";
 
105
    }
 
106
 
 
107
    public String extract(String musterStart, String musterEnde, int abPos, int stopPos) {
 
108
        if ((pos1 = cont.indexOf(musterStart, abPos)) != -1) {
 
109
            pos1 += musterStart.length();
 
110
            if ((pos2 = cont.indexOf(musterEnde, pos1)) != -1) {
 
111
                if (stopPos < 0 || pos2 < stopPos) {
 
112
                    return cont.substring(pos1, pos2);
 
113
                }
 
114
            }
 
115
        }
 
116
        return "";
 
117
    }
 
118
 
 
119
    public String extract(String musterStart1, String musterStart2, String musterEnde) {
 
120
        return extract(musterStart1, musterStart2, musterEnde, 0, -1);
 
121
    }
 
122
 
 
123
    public String extract(String musterStart1, String musterStart2, String musterEnde, int abPos) {
 
124
        return extract(musterStart1, musterStart2, musterEnde, abPos, -1);
 
125
    }
 
126
 
 
127
    public String extract(String musterStart1, String musterStart2, String musterEnde, int abPos, int stopPos) {
 
128
        if ((pos1 = cont.indexOf(musterStart1, abPos)) != -1) {
 
129
            pos1 += musterStart1.length();
 
130
            if ((pos1 = cont.indexOf(musterStart2, pos1)) != -1) {
 
131
                pos1 += musterStart2.length();
 
132
                if ((pos2 = cont.indexOf(musterEnde, pos1)) != -1) {
 
133
                    if (stopPos < 0 || pos2 < stopPos) {
 
134
                        return cont.substring(pos1, pos2);
 
135
                    }
 
136
                }
 
137
            }
 
138
        }
 
139
        return "";
 
140
    }
 
141
}