MCPcopy Create free account
hub / github.com/GateNLP/gate-core / getFileSuffixes

Method getFileSuffixes

src/main/java/gate/DocumentFormat.java:475–489  ·  view source on GitHub ↗

Given a URL, this method returns all the 'file extensions' for the file part of the URL. For this purposes, a 'file extension' is any sequence of .-separated tokens (such as .gate.xml.gz). The order the extensions are returned in is from the most specific (longest) to the most generic (shortest) one

(URL url)

Source from the content-addressed store, hash-verified

473 * (shortest) one, e.g. [.gate.xml.gz, .xml.gz, .gz].
474 */
475 private static List<String> getFileSuffixes(URL url){
476 List<String> res = new LinkedList<String>();
477 if (url != null){
478 // get the file name from the URL
479 String fileName = url.getPath();
480 int pos = fileName.lastIndexOf('/');
481 if(pos > 0) fileName = fileName.substring(pos);
482 pos = fileName.indexOf('.', 1);
483 while(pos > 0 && pos < fileName.length() - 1) {
484 res.add(fileName.substring(pos + 1));
485 pos = fileName.indexOf('.', pos + 1);
486 }
487 }
488 return res;
489 }
490
491
492 /**

Callers 2

getMimeTypeMethod · 0.95
willReadFromUrlMethod · 0.95

Calls 4

indexOfMethod · 0.65
addMethod · 0.65
lastIndexOfMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected