/** * Returns a {@link FieldToolSub} holding a {@link Map} * of all the public static field names to values (or a placeholder * if the value is not final) for the {@link Class} of the * specified Object. * @param instance target instance * @return {@link FieldToolSub} object * @see #in(Class clazz) */ public FieldToolSub in(Object instance) { if (instance == null) { return null; } return in(instance.getClass()); }
/** * Returns a {@link FieldToolSub} holding a {@link Map} * of all the public static field names to values (or a placeholder * if the value is not final) for the specified class(name). If the * {@link Class} with the specified name cannot be loaded, this will * return {@code null}, rather than throw an exception. * * @param classname target class name * @return {@link FieldToolSub} object * @see #in(Class clazz) */ public FieldToolSub in(String classname) { try { return in(ClassUtils.getClass(classname)); } catch (ClassNotFoundException cnfe) { return null; } }
protected void configure(ValueParser values) { // retrieve any classnames to be inspected and inspect them // *before* setting the storeDynamicLookups property! String[] classnames = values.getStrings(INCLUDE_KEY); if (classnames != null) { for (String classname : classnames) { // make sure we get results for each classname // since these come from the configuration, it's // an error if they're invalid if (in(classname) == null) { // shame that ClassNotFoundException is checked... throw new RuntimeException("Could not find "+classname+" in the classpath"); } } } // find out whether or not we should store dynamic lookups this.storeDynamicLookups = values.getBoolean(STORE_DYNAMIC_KEY, this.storeDynamicLookups); }
private Context getContext(final Model model, final Node subject) { final FieldTool fieldTool = new FieldTool(); final Context context = new VelocityContext(); final String[] baseUrl = uriInfo.getBaseUri().getPath().split("/"); if (baseUrl.length > 0) { final String staticBaseUrl = String.join("/", Arrays.copyOf(baseUrl, baseUrl.length - 1)); context.put("staticBaseUrl", staticBaseUrl); } else { context.put("staticBaseUrl", "/"); } context.put("rdfLexicon", fieldTool.in(RdfLexicon.class)); context.put("helpers", VIEW_HELPERS); context.put("esc", escapeTool); context.put("rdf", model.getGraph()); context.put("model", model); context.put("subjects", model.listSubjects()); context.put("nodeany", ANY); context.put("topic", subject); context.put("originalResource", VIEW_HELPERS.getOriginalResource(subject)); context.put("uriInfo", uriInfo); return context; }