1 package be
.nikiroo
.fanfix
.supported
;
4 import java
.io
.IOException
;
5 import java
.io
.InputStream
;
6 import java
.net
.URISyntaxException
;
9 import be
.nikiroo
.fanfix
.data
.MetaData
;
12 * Support class for <tt>.info</tt> text files ({@link Text} files with a
13 * <tt>.info</tt> metadata file next to them).
15 * The <tt>.info</tt> file is supposed to be written by this program, or
20 class InfoText
extends Text
{
22 public String
getSourceName() {
27 protected MetaData
getMeta(URL source
, InputStream in
) throws IOException
{
29 File sourceFile
= new File(source
.toURI());
30 sourceFile
= assureNoTxt(sourceFile
);
32 MetaData meta
= InfoReader
.readMeta(new File(sourceFile
.getPath()
35 // Some old .info files don't have those now required fields...
36 String test
= meta
.getTitle() == null ?
"" : meta
.getTitle();
37 test
+= meta
.getAuthor() == null ?
"" : meta
.getAuthor();
38 test
+= meta
.getDate() == null ?
"" : meta
.getDate();
39 test
+= meta
.getUrl() == null ?
"" : meta
.getUrl();
41 MetaData superMeta
= super.getMeta(source
, reset(in
));
42 if (meta
.getTitle() == null || meta
.getTitle().isEmpty()) {
43 meta
.setTitle(superMeta
.getTitle());
45 if (meta
.getAuthor() == null || meta
.getAuthor().isEmpty()) {
46 meta
.setAuthor(superMeta
.getAuthor());
48 if (meta
.getDate() == null || meta
.getDate().isEmpty()) {
49 meta
.setDate(superMeta
.getDate());
51 if (meta
.getUrl() == null || meta
.getUrl().isEmpty()) {
52 meta
.setUrl(superMeta
.getUrl());
58 } catch (URISyntaxException e
) {
59 throw new IOException("Cannot parse URL to file: " + source
, e
);
64 protected boolean supports(URL url
) {
65 return supports(url
, true);