1 package org.apache.maven.doxia.site.decoration;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.codehaus.plexus.util.StringUtils;
23
24
25
26
27
28
29 public class DecorationUtils
30 {
31 public static boolean isLink( String href )
32 {
33 return StringUtils.isNotBlank( href )
34 && ( startsWithAnyIgnoreCase( href, "http:/", "https:/", "ftp:/", "mailto:", "file:/" )
35 || href.contains( "://" ) );
36 }
37
38 private static boolean startsWithIgnoreCase( String str, String prefix )
39 {
40 if ( str == null || prefix == null )
41 {
42 return ( str == null && prefix == null );
43 }
44 if ( prefix.length() > str.length() )
45 {
46 return false;
47 }
48 return str.regionMatches( true, 0, prefix, 0, prefix.length() );
49 }
50
51 public static boolean startsWithAnyIgnoreCase( String string, String... searchStrings )
52 {
53 for ( int i = 0; i < searchStrings.length; i++ )
54 {
55 String searchString = searchStrings[i];
56 if ( startsWithIgnoreCase( string, searchString ) )
57 {
58 return true;
59 }
60 }
61 return false;
62 }
63 }