String data = source.resourceToString(pageInfo); if(!data.isEmpty()) { Class<? extends PageContent> ctype = BookLoader.getPageType(type); content = BookLoader.getPageType(type).newInstance(); } catch(InstantiationException | IllegalAccessException | NullPointerException e) { content = new ContentError("Failed to create a page of type \"" + type + "\", perhaps the type is not registered?");