001/* 002 * Shredzone Commons 003 * 004 * Copyright (C) 2012 Richard "Shred" Körber 005 * http://commons.shredzone.org 006 * 007 * This program is free software: you can redistribute it and/or modify 008 * it under the terms of the GNU Library General Public License as 009 * published by the Free Software Foundation, either version 3 of the 010 * License, or (at your option) any later version. 011 * 012 * This program is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 015 * GNU General Public License for more details. 016 * 017 * You should have received a copy of the GNU Library General Public License 018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 019 */ 020package org.shredzone.commons.text; 021 022import edu.umd.cs.findbugs.annotations.CheckForNull; 023import edu.umd.cs.findbugs.annotations.Nullable; 024 025/** 026 * Analyzes internal and external links. 027 * 028 * @author Richard "Shred" Körber 029 */ 030public interface LinkAnalyzer { 031 032 /** 033 * Returns the type of a link. The returned string is used as CSS class name for the 034 * resulting link. Used e.g. to highlight external links. 035 * 036 * @param url 037 * URL to be analyzed 038 * @return CSS class name, or {@code null} if this is no special link 039 */ 040 @CheckForNull 041 String linkType(@Nullable String url); 042 043 /** 044 * Returns a resolved link. 045 * 046 * @param url 047 * URL to be analyzed, may be a relative link 048 * @return Link to be used, never {@code null} 049 */ 050 String linkUrl(@Nullable String url); 051 052 /** 053 * Image a resolved image URL. 054 * 055 * @param url 056 * URL to be analyzed, may be a relative link 057 * @return Image URL to be used, never {@code null} 058 */ 059 String imageUrl(@Nullable String url); 060 061}