cf = new CachedFile(entry.url).setHttpAccept(Utils.join(", ", mimes));
String zipEntryPath = cf.findZipEntryPath("mapcss", "style");
if (zipEntryPath != null) {
entry.isZip = true;
entry.zipEntryPath = zipEntryPath;
return new MapCSSStyleSource(entry);
}
zipEntryPath = cf.findZipEntryPath("xml", "style");
if (zipEntryPath != null)
return new XmlStyleSource(entry);
if (entry.url.toLowerCase().endsWith(".mapcss"))
return new MapCSSStyleSource(entry);
if (entry.url.toLowerCase().endsWith(".xml"))
return new XmlStyleSource(entry);
else {
try (InputStreamReader reader = new InputStreamReader(cf.getInputStream(), StandardCharsets.UTF_8)) {
WHILE: while (true) {
int c = reader.read();
switch (c) {
case -1:
break WHILE;
case ' ':
case '\t':
case '\n':
case '\r':
continue;
case '<':
return new XmlStyleSource(entry);
default:
return new MapCSSStyleSource(entry);
}
}
}
Main.warn("Could not detect style type. Using default (xml).");
return new XmlStyleSource(entry);