/** * Highlights the given text * * @param text the text to highlight (can be blank) * @return the highlighted text */ static String highlight(final String text) { return decorate(text, FG_CYAN); }
/** * Write an XML document to the OutputStream provided. This will use the * pre-configured Roo provided Transformer. * * @param outputStream the output stream to write to. The stream is closed * upon completion. * @param document the document to write. */ public static void writeXml(final OutputStream outputStream, final Document document) { writeXml(createIndentingTransformer(), outputStream, document); }
/** * Returns the root element of an addon's configuration file. * * @param clazz which owns the configuration * @return the configuration root element */ public static Element getConfiguration(final Class<?> clazz) { return getRootElement(clazz, "configuration.xml"); }
public Document getDocumentTemplate(final String templateName) { return XmlUtils.readXml(FileUtils.getInputStream(getClass(), templateName)); } }
/** * Returns the child node with the given tag name, creating it if it does * not exist. * * @param tagName the child tag to look for and possibly create (required) * @param parent the parent in which to look for the child (required) * @param document the document containing the parent (required) * @return the existing or created child (never <code>null</code>) * @since 1.2.0 */ public static Element createChildIfNotExists(final String tagName, final Node parent, final Document document) { final Element existingChild = XmlUtils.findFirstElement(tagName, parent); if (existingChild != null) { return existingChild; } // No such child; add it return createChildElement(tagName, parent, document); }
private static String getTypeCode(final Element dependencyElement) { if (dependencyElement.hasAttribute("type")) { return dependencyElement.getAttribute("type"); } // Read it from the "type" child element, if any return DomUtils.getTextContent(XmlUtils.findFirstElement("type", dependencyElement), "").trim(); }
/** * Each {@link FileDetails} is known by its canonical file name, which is * also the format used for Ant path matching etc. This method provides the * canonical file name without forcing the user to deal with the exceptions * that would arise from using {@link File} directly. * * @return the canonical path. */ public String getCanonicalPath() { return FileUtils.getCanonicalPath(file); }
/** * Returns the first child element value identified by its name. * * @param element the DOM element to analyze * @param childElementName the child element name to look for * @return the extracted text value, or <code>null</code> if no child * element found */ public static String getChildElementValueByTagName(final Element element, final String childElementName) { final Element child = getChildElementByTagName(element, childElementName); return child != null ? getTextValue(child) : null; }
/** * Constructor * * @param customData * @param declaredByMetadataId * @param modifier * @param annotations can be <code>null</code> for none */ protected AbstractIdentifiableAnnotatedJavaStructureProvider(final CustomData customData, final String declaredByMetadataId, final int modifier, final Collection<AnnotationMetadata> annotations) { super(customData, declaredByMetadataId, modifier); CollectionUtils.populate(this.annotations, annotations); }
private static void addCommentBefore(final Element element, final String comment, final Document document) { if (null == XmlUtils.findNode("//comment()[.=' " + comment + " ']", document.getDocumentElement())) { document.getDocumentElement().insertBefore(document.createComment(" " + comment + " "), element); addLineBreakBefore(element, document); } }
public ParentBuilder(final Element parentElement, final String pomPath) { groupId = XmlUtils.getTextContent("/project/groupId", parentElement); artifactId = XmlUtils.getTextContent("/project/artifactId", parentElement); version = XmlUtils.getTextContent("/project/version", parentElement); relativePath = XmlUtils.getTextContent("/project/relativePath", parentElement); this.pomPath = pomPath; }
/** * Same as {@link #displayFile(String, Class, boolean)} except it passes * false as the final argument. * * @param fileName the simple filename (required) * @param owner the class which owns the file (required) */ public static void displayFile(final String fileName, final Class<?> owner) { displayFile(fileName, owner, false); }
/** * Invoke the given callback on all fields in the target class, going up the * class hierarchy to get all declared fields. * * @param targetClass the target class to analyze * @param fc the callback to invoke for each field */ public static void doWithFields(final Class<?> targetClass, final FieldCallback fc) throws IllegalArgumentException { doWithFields(targetClass, fc, null); }
/** * Attempt to find a {@link Field field} on the supplied {@link Class} with * the supplied <code>name</code>. Searches all superclasses up to * {@link Object}. * * @param clazz the class to introspect * @param name the name of the field * @return the corresponding Field object, or <code>null</code> if not found */ public static Field findField(final Class<?> clazz, final String name) { return findField(clazz, name, null); }
/** * Invoke the specified JDBC API {@link Method} against the supplied target * object with no arguments. * * @param method the method to invoke * @param target the target object to invoke the method on * @return the invocation result, if any * @throws SQLException the JDBC API SQLException to rethrow (if any) * @see #invokeJdbcMethod(java.lang.reflect.Method, Object, Object[]) */ public static Object invokeJdbcMethod(final Method method, final Object target) throws SQLException { return invokeJdbcMethod(method, target, null); }
/** * Attempt to find a {@link Method} on the supplied class with the supplied * name and no parameters. Searches all superclasses up to * <code>Object</code>. * <p> * Returns <code>null</code> if no {@link Method} can be found. * * @param clazz the class to introspect * @param name the name of the method * @return the Method object, or <code>null</code> if none found */ public static Method findMethod(final Class<?> clazz, final String name) { return findMethod(clazz, name, new Class[0]); }
public String getName() { return getLeft(); }
/** * Perform the given callback operation on all matching methods of the given * class and superclasses. * <p> * The same named method occurring on subclass and superclass will appear * twice, unless excluded by a {@link MethodFilter}. * * @param targetClass class to start looking at * @param mc the callback to invoke for each method * @see #doWithMethods(Class, MethodCallback, MethodFilter) */ public static void doWithMethods(final Class<?> targetClass, final MethodCallback mc) throws IllegalArgumentException { doWithMethods(targetClass, mc, null); }
public String getCanonicalPath() { return FileUtils.getCanonicalPath(file); }
public static String getTextContent(final String path, final Element parentElement) { return getTextContent(path, parentElement, null); }