private static String getTitle(Source source) { Element titleElement = source.getFirstElement(HTMLElementName.TITLE); if (titleElement == null) return null; // TITLE element never contains other tags so just decode it collapsing whitespace: return CharacterReference.decodeCollapseWhiteSpace(titleElement.getContent()); }