@SuppressWarnings("unchecked") public static Lexer getByFullName(String pack, String sub, String name) throws ResolutionException { String fullname = name; if (!pack.isEmpty()) { if (!sub.isEmpty()) { fullname = pack + "." + sub + "." + fullname; } else { fullname = pack + "." + fullname; } } // Try cache Lexer lexer = lexers.get(fullname); if (lexer != null) return lexer; try { return (Lexer) Jygments.class.getClassLoader().loadClass(fullname).newInstance(); } catch (InstantiationException x) { } catch (IllegalAccessException x) { } catch (ClassNotFoundException x) { } InputStream stream = Util.getJsonFile(pack, sub, name, fullname); if (stream != null) { try { String converted = Util.rejsonToJson(stream); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.getFactory().configure(JsonParser.Feature.ALLOW_COMMENTS, true); Map<String, Object> json = objectMapper.readValue(converted, HashMap.class); Object className = json.get("class"); if (className == null) className = ""; lexer = getByName(className.toString()); lexer.addJson(json); lexer.resolve(); if (lexer != null) { // Cache it Lexer existing = lexers.putIfAbsent(fullname, lexer); if (existing != null) lexer = existing; } return lexer; } catch (JsonParseException x) { throw new ResolutionException(x); } catch (JsonMappingException x) { throw new ResolutionException(x); } catch (IOException x) { throw new ResolutionException(x); } } return null; }