Skip to content

Commit 5e63cbe

Browse files
authored
Merge pull request #47 from levigo/bugfix/JF-1177_classcastexception_descritpion
Bugfix/jf 1177 classcastexception descritpion
2 parents c37e353 + 37481d6 commit 5e63cbe

File tree

4 files changed

+37
-24
lines changed

4 files changed

+37
-24
lines changed

pom.xml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<zip4j.version>2.11.5</zip4j.version>
5353
<slf4j.version>1.7.36</slf4j.version>
5454

55-
<poi.version>5.3.0</poi.version>
55+
<poi.version>5.4.0</poi.version>
5656
<rtfparserkit.version>1.16.0</rtfparserkit.version>
5757
<commons.io.version>2.18.0</commons.io.version>
5858
<commons-compress.version>1.27.1</commons-compress.version>
@@ -65,8 +65,8 @@
6565
<jaxb-impl.version>4.0.5</jaxb-impl.version>
6666

6767
<!-- testing -->
68-
<junit.version>5.11.3</junit.version>
69-
<hamcrest.version>2.2</hamcrest.version>
68+
<junit.version>5.11.4</junit.version>
69+
<hamcrest.version>3.0</hamcrest.version>
7070
<jmock-junit5.version>2.13.1</jmock-junit5.version>
7171
<log4j.version>2.24.2</log4j.version>
7272

@@ -75,15 +75,15 @@
7575
<sonar.organization>levigo</sonar.organization>
7676
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
7777

78-
<bouncycastle.version>1.79</bouncycastle.version>
78+
<bouncycastle.version>1.80</bouncycastle.version>
7979
</properties>
8080

8181
<build>
8282
<plugins>
8383
<plugin>
8484
<groupId>org.apache.maven.plugins</groupId>
8585
<artifactId>maven-compiler-plugin</artifactId>
86-
<version>3.12.1</version>
86+
<version>3.13.0</version>
8787
<configuration>
8888
<source>1.8</source>
8989
<target>1.8</target>
@@ -93,7 +93,7 @@
9393
<!-- Calculating the test coverage -->
9494
<groupId>org.jacoco</groupId>
9595
<artifactId>jacoco-maven-plugin</artifactId>
96-
<version>0.8.11</version>
96+
<version>0.8.12</version>
9797
<executions>
9898
<execution>
9999
<id>pre-unit-test</id>
@@ -117,7 +117,7 @@
117117
<plugin>
118118
<groupId>org.apache.maven.plugins</groupId>
119119
<artifactId>maven-surefire-plugin</artifactId>
120-
<version>3.2.3</version>
120+
<version>3.5.2</version>
121121
<configuration>
122122
<!-- Sets the VM argument line as defined by the JaCoCo plugin. -->
123123
<argLine>${jacocoAgentArgLine}</argLine>
@@ -138,7 +138,7 @@
138138
<dependency>
139139
<groupId>org.codehaus.mojo</groupId>
140140
<artifactId>extra-enforcer-rules</artifactId>
141-
<version>1.7.0</version>
141+
<version>1.9.0</version>
142142
</dependency>
143143
</dependencies>
144144
<executions>
@@ -182,7 +182,7 @@
182182
<plugin>
183183
<groupId>org.apache.maven.plugins</groupId>
184184
<artifactId>maven-release-plugin</artifactId>
185-
<version>3.0.1</version>
185+
<version>3.1.1</version>
186186
<configuration>
187187
<username>git</username>
188188
<password/>
@@ -200,22 +200,22 @@
200200
<plugin>
201201
<groupId>org.apache.maven.plugins</groupId>
202202
<artifactId>maven-jar-plugin</artifactId>
203-
<version>3.3.0</version>
203+
<version>3.4.2</version>
204204
</plugin>
205205
<plugin>
206206
<groupId>org.apache.maven.plugins</groupId>
207207
<artifactId>maven-clean-plugin</artifactId>
208-
<version>3.3.2</version>
208+
<version>3.4.0</version>
209209
</plugin>
210210
<plugin>
211211
<groupId>org.apache.maven.plugins</groupId>
212212
<artifactId>maven-install-plugin</artifactId>
213-
<version>3.1.1</version>
213+
<version>3.1.3</version>
214214
</plugin>
215215
<plugin>
216216
<groupId>org.apache.maven.plugins</groupId>
217217
<artifactId>maven-site-plugin</artifactId>
218-
<version>3.12.1</version>
218+
<version>3.21.0</version>
219219
</plugin>
220220
<plugin>
221221
<groupId>org.apache.maven.plugins</groupId>
@@ -225,12 +225,12 @@
225225
<plugin>
226226
<groupId>org.apache.maven.plugins</groupId>
227227
<artifactId>maven-deploy-plugin</artifactId>
228-
<version>3.1.1</version>
228+
<version>3.1.3</version>
229229
</plugin>
230230
<plugin>
231231
<groupId>org.apache.maven.plugins</groupId>
232232
<artifactId>maven-javadoc-plugin</artifactId>
233-
<version>3.6.3</version>
233+
<version>3.11.2</version>
234234
</plugin>
235235
</plugins>
236236
</pluginManagement>
@@ -436,7 +436,7 @@
436436
<plugin>
437437
<groupId>org.apache.maven.plugins</groupId>
438438
<artifactId>maven-source-plugin</artifactId>
439-
<version>3.3.0</version>
439+
<version>3.3.1</version>
440440
<executions>
441441
<execution>
442442
<id>attach-sources</id>
@@ -468,7 +468,7 @@
468468
<plugin>
469469
<groupId>org.apache.maven.plugins</groupId>
470470
<artifactId>maven-gpg-plugin</artifactId>
471-
<version>3.0.1</version>
471+
<version>3.1.0</version>
472472
<executions>
473473
<execution>
474474
<id>sign-artifacts</id>

src/main/java/org/jadice/filetype/Context.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,9 @@ public void warning(final Object src, final String message) {
9393
public Locale getLocale() {
9494
return locale;
9595
}
96+
97+
@Override
98+
public String toString() {
99+
return "Context{" + "result=" + result + ", locale=" + locale + ", statedExtension='" + statedExtension + '\'' + '}';
100+
}
96101
}

src/main/java/org/jadice/filetype/database/DescriptionAction.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class DescriptionAction extends Action {
2828
public static class Description implements Serializable {
2929
private static final long serialVersionUID = 1L;
3030

31-
private List<Map<String, String>> content = new ArrayList<Map<String, String>>();
31+
private final List<Map<String, String>> content = new ArrayList<>();
3232

3333
private final Locale locale;
3434

@@ -48,7 +48,7 @@ public void append(String lang, String description, boolean replace) {
4848
// default desc. ist der indikator für eine neue map,
4949
// alle lok. sprachen müssen danach in der xml datei definiert werden
5050
if (content.isEmpty() || lang.equalsIgnoreCase(DEFAULT_LANG)) {
51-
content.add(new HashMap<String, String>());
51+
content.add(new HashMap<>());
5252
}
5353

5454
Map<String, String> map = content.get(content.size() - 1);
@@ -94,7 +94,14 @@ public String toString() {
9494

9595
@Override
9696
public void perform(Context ctx) {
97-
Description desc = (Description) ctx.getProperty(KEY);
97+
Description desc = null;
98+
99+
if (ctx.getProperty(KEY) instanceof Description) {
100+
desc = (Description) ctx.getProperty(KEY);
101+
} else if (ctx.getProperty(KEY) instanceof String) {
102+
desc = new Description(ctx.getLocale());
103+
desc.append(null, (String) ctx.getProperty(KEY), replace);
104+
}
98105

99106
if (desc == null) {
100107
desc = new Description(ctx.getLocale());

src/main/java/org/jadice/filetype/matchers/TextMatcher.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public boolean matches(final Context context) {
108108
boolean isCSV = false;
109109
String mimeType = "text/plain";
110110
final String statedExtension = context.getStatedExtension();
111-
if(matches && statedExtension != null && statedExtension.equals("csv")) {
111+
LOGGER.debug("stated extension: {}", statedExtension);
112+
if (matches && statedExtension != null && statedExtension.equalsIgnoreCase("csv")) {
112113
isCSV = true;
113114
mimeType = "text/csv";
114115
}
@@ -117,7 +118,7 @@ public boolean matches(final Context context) {
117118
// Inject charset in MIME type for later usage
118119
context.setProperty(MimeTypeAction.KEY, mimeType + ";charset=" + bom.charset.name());
119120
context.info(this, String.format("Determined charset: %s", bom.charset.name()));
120-
if(isCSV){
121+
if (isCSV) {
121122
context.setProperty(ExtensionAction.KEY, "csv");
122123
context.setProperty(DescriptionAction.KEY, "Comma-separated values (CSV)");
123124
}
@@ -159,10 +160,10 @@ private float countCharacters(final String text, final Context context) {
159160
|| Character.isIdentifierIgnorable(c) //
160161
|| Character.isSpaceChar(c) //
161162
|| Character.isWhitespace(c)) {
162-
LOGGER.debug("Recognized char '" + c + "' @ " + i);
163+
LOGGER.debug("Recognized char '{}' @ {}", c, i);
163164
defined++;
164165
} else if (PUNCTUATION.contains(c)) {
165-
LOGGER.debug("Ignoring punctuation char '" + c + "' @ " + i);
166+
LOGGER.debug("Ignoring punctuation char '{}' @ {}", c, i);
166167
ignored++;
167168
}
168169
}

0 commit comments

Comments
 (0)