MCPcopy Create free account
hub / github.com/BaseXdb/basex / parse

Method parse

basex-core/src/main/java/org/basex/core/Lang.java:88–117  ·  view source on GitHub ↗

Parses all available language files and returns the names and credits. @return language arrays

()

Source from the content-addressed store, hash-verified

86 * @return language arrays
87 */
88 public static synchronized String[][] parse() {
89 final StringList langs = new StringList();
90 final StringList creds = new StringList();
91
92 try {
93 // supported protocols: jar and file
94 final URL url = Lang.class.getResource('/' + SUFFIX);
95 if("jar".equals(url.getProtocol())) {
96 final JarURLConnection conn = (JarURLConnection) url.openConnection();
97 final String pre = conn.getEntryName();
98 final JarFile jar = conn.getJarFile();
99
100 for(final JarEntry entry : Collections.list(jar.entries())) {
101 final String name = entry.getName();
102 if(name.startsWith(pre) && name.endsWith(SUFFIX)) {
103 langs.add(name.replaceAll(".*/|." + SUFFIX, ""));
104 creds.add(credits(new IOStream(jar.getInputStream(entry)).read()));
105 }
106 }
107 } else {
108 for(final IO file : ((IOFile) IO.get(url.toString())).children()) {
109 langs.add(file.name().replace('.' + SUFFIX, ""));
110 creds.add(credits(file.read()));
111 }
112 }
113 } catch(final IOException ex) {
114 Util.errln(ex);
115 }
116 return new String[][] { langs.finish(), creds.finish() };
117 }
118
119 /**
120 * Returns the credits from the specified file.

Callers 2

DialogGeneralPrefsClass · 0.95
executeMethod · 0.45

Calls 15

addMethod · 0.95
creditsMethod · 0.95
getMethod · 0.95
errlnMethod · 0.95
entriesMethod · 0.65
readMethod · 0.65
toStringMethod · 0.65
nameMethod · 0.65
getResourceMethod · 0.45
equalsMethod · 0.45
listMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected