Gets a URL from a wiki page value.
@param htmlLink link as present on wiki page.
@return address the link points to (if it is an 'a'), the original link otherwise.
484969
public String getUrl(String htmlLink) {
        String result = htmlLink;
        if (htmlLink != null) {
            Matcher linkMatcher = LINKPATTERN.matcher(htmlLink);
            Matcher imgMatcher = IMAGEPATTERN.matcher(htmlLink);
            if (linkMatcher.matches()) {
                String href = linkMatcher.group(2);
                href = StringEscapeUtils.unescapeHtml4(href);
                result = href + linkMatcher.group(4);
            } else if (imgMatcher.matches()) {
                String src = imgMatcher.group(2);
                result = StringEscapeUtils.unescapeHtml4(src);
            }
        }
        return result;
    }
1016114
String lastLink() {
    if (totalResults == null || currentLimit == 0L) {
      return null;
    }

    Long lastOffset;
    if (totalResults % currentLimit == 0L) {
      lastOffset = totalResults - currentLimit;
    } else {
      // Truncation due to integral division gives floor-like behavior for free.
      lastOffset = totalResults / currentLimit * currentLimit;
    }

    return urlWithUpdatedPagination(lastOffset, currentLimit);
  }
621649
public String getToLink() {

        if (m_link == null) {
            String target = toString();
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(target)) {
                m_link = substituteLink(getCmsObject(), target);
            } else {
                m_link = "";
            }
        }
        return m_link;
    }
906119
@Override
    public Content getNavLinkPrevious() {
        Content prevletterLabel = contents.prevLetter;
        if (prev == -1) {
            return HtmlTree.LI(prevletterLabel);
        }
        else {
            Content prevLink = getHyperLink(DocPaths.indexN(prev),
                    prevletterLabel);
            return HtmlTree.LI(prevLink);
        }
    }
1205263
function urlX(link)
	{
		if (link != null && link.toString().toLowerCase().substring(0, 11) !== 'javascript:')
		{
			return link;
		}
		
		return null;
	}
89436
public String getLink(CmsObject cms) {

        if (m_internal) {
            // if we have a local link, leave it unchanged
            // cms may be null for unit tests
            if ((cms == null) || (m_uri.length() == 0) || (m_uri.charAt(0) == '#')) {
                return m_uri;
            }

            checkConsistency(cms);
            //String target = replaceTargetWithDetailPageIfNecessary(cms, m_resource, m_target);
            String target = m_target;
            String uri = computeUri(target, m_query, m_anchor);

            CmsObjectWrapper wrapper = (CmsObjectWrapper)cms.getRequestContext().getAttribute(
                CmsObjectWrapper.ATTRIBUTE_NAME);
            if (wrapper != null) {
                // if an object wrapper is used, rewrite the URI
                m_uri = wrapper.rewriteLink(m_uri);
                uri = wrapper.rewriteLink(uri);
            }

            if ((cms.getRequestContext().getSiteRoot().length() == 0)
                && (cms.getRequestContext().getAttribute(CmsRequestContext.ATTRIBUTE_EDITOR) == null)) {
                // Explanation why this check is required:
                // If the site root name length is 0, this means that a user has switched
                // the site root to the root site "/" in the Workplace.
                // In this case the workplace site must also be the active site.
                // If the editor is opened in the root site, because of this code the links are
                // always generated _with_ server name / port so that the source code looks identical to code
                // that would normally be created when running in a regular site.
                // If normal link processing would be used, the site information in the link
                // would be lost.
                return OpenCms.getLinkManager().substituteLink(cms, uri);
            }

            // get the site root for this URI / link
            // if there is no site root, we either have a /system link, or the site was deleted,
            // return the full URI prefixed with the opencms context
            String siteRoot = getSiteRoot();
            if (siteRoot == null) {
                return OpenCms.getLinkManager().substituteLink(cms, uri);
            }

            if (cms.getRequestContext().getAttribute(CmsRequestContext.ATTRIBUTE_FULLLINKS) != null) {
                // full links should be generated even if we are in the same site
                return OpenCms.getLinkManager().getServerLink(cms, uri);
            }

            // return the link with the server prefix, if necessary
            return OpenCms.getLinkManager().substituteLink(cms, getSitePath(uri), siteRoot);
        } else {

            // don't touch external links
            return m_uri;
        }
    }
117466
private static String linkToHtml( Link l ){
		if( l == null ) {
			return "null";
		}

		StringBuilder result = new StringBuilder();

		result.append("<div class=\"Link\"><b class=\"Link\">Link:</b>" +
				l.getType() + ": \"" +
				convertTags( l.getText() )+ "\" -> \"" + convertTags( l.getTarget() ) +"\"");

		if( l.getParameters().size() != 0 ){
			for( String parameter: l.getParameters() ) {
				result.append("<br>\nPARAMETER: \""+convertTags( parameter )+"\"");
			}
		}

		result.append("</div>\n");

		return result.toString();
	}
653723
private static String url(final WayPoint point) {
		return point.getLinks().isEmpty()
			? null
			: point.getLinks().get(0).getHref().toString();
	}
627064
public static String getURLPath(String url) {
		url = stripURLScheme(url);
		int pathIdx = url.indexOf(UrlOperations.PATH_START);
		if(pathIdx == -1) {
			return "/";
		}
		return url.substring(pathIdx);
	}
681483
@Override
	public boolean apply(final Link link) {
		final String sourceHost = link.source.getHost(), targetHost = link.target.getHost();
		if (sourceHost == null) throw new IllegalArgumentException("URI \"" + link.source + "\" has no host");
		if (targetHost == null) throw new IllegalArgumentException("URI \"" + link.target + "\" has no host");
		// BURL hosts are always lower cased
		return sourceHost.equals(targetHost);
	}
748737
public String getLinkUrl(JSONObject jsonObject){
        if(jsonObject == null) return null;
        try {
            JSONObject urlObject =  jsonObject.has("url") ? jsonObject.getJSONObject("url") : null;
            if(urlObject == null) return null;
            JSONObject androidObject =  urlObject.has("android") ? urlObject.getJSONObject("android") : null;
            if(androidObject != null){
                return androidObject.has("text") ? androidObject.getString("text") : "";
            }else{
                return "";
            }
        } catch (JSONException e) {
            Logger.v("Unable to get Link URL with JSON - "+e.getLocalizedMessage());
            return null;
        }
    }
106217
public String getURL(WebPage page) throws IOException, SQLException {
		return getURL(page, (Object)null);
	}
353415
@Exported
    public String getUrl() {
        // first look for the manifest entry. This is new in maven-hpi-plugin 1.30
        String url = manifest.getMainAttributes().getValue("Url");
        if(url!=null)      return url;

        // fallback to update center metadata
        UpdateSite.Plugin ui = getInfo();
        if(ui!=null)    return ui.wiki;

        return null;
    }
1195447
private String getUrl(DataSource dataSource) {
        Connection conn = null;
        try {
            conn = dataSource.getConnection();
            return conn.getMetaData().getURL();
        } catch (SQLException e) {
            throw new PageException(e);
        } finally {
            if (conn != null) {
                try {
                    if (closeConn) {
                        conn.close();
                    }
                } catch (SQLException e) {
                    //ignore
                }
            }
        }
    }
360255
public Content getLink(LinkInfoImpl linkInfo) {
        LinkFactoryImpl factory = new LinkFactoryImpl(this);
        return factory.getLink(linkInfo);
    }
9402
public static String getDomainFromURL(String strURL, String strContextPathAtEnd, boolean includePortNumber)
    {
        String strDomain = strURL;
        
        if (strDomain.indexOf(':') < 8)
            strDomain = strDomain.substring(strDomain.indexOf(':') + 1);  // Get rid of protocol
        if (strDomain.indexOf("//") == 0)
            strDomain = strDomain.substring(2);  // Get rid of '//'
        if (strDomain.indexOf('?') != -1)
            strDomain = strDomain.substring(0, strDomain.indexOf('?'));   // Get rid of params
        int iEndDomain = strDomain.indexOf('/');
        if (iEndDomain == -1)
            iEndDomain = strDomain.length();
        if (strDomain.lastIndexOf(Constants.DEFAULT_SERVLET) >= iEndDomain)
            strDomain = strDomain.substring(0, strDomain.lastIndexOf(Constants.DEFAULT_SERVLET) - 1);   // Strip servlet name
        if ((strDomain.indexOf(':') != -1) && (includePortNumber == false))
            strDomain = strDomain.substring(0, strDomain.indexOf(':'));  // Get rid of port number
        else
            strDomain = strDomain.substring(0, iEndDomain);
        
        if (strContextPathAtEnd != null)
        {
            int iStartIndex = strURL.indexOf(strDomain);
            int iContextIndex = strURL.indexOf(strContextPathAtEnd, iStartIndex + strDomain.length());
            if (iContextIndex != -1)
            {   // Always
                iContextIndex = iContextIndex + strContextPathAtEnd.length();
                strDomain = strURL.substring(iStartIndex, iContextIndex);
                if (!strDomain.endsWith(System.getProperty("file.separator")))
                    strDomain = strDomain + System.getProperty("file.separator");
            }
        }
        return strDomain;
    }
867932
private String parseLink(final String link) {
		String[] tokens = link.substring(7, link.length() - 1).split("\\s");
		if (tokens.length == 1) {
			return tokens[0];
		}
		StringBuilder result = new StringBuilder();

		boolean parametersSeen = false;
		boolean inParameters = false;

		for (int index = 0; index < tokens.length; index++) {
			result.append(" ").append(tokens[index]);
			if (tokens[index].indexOf('(') != -1 && !parametersSeen) {
				inParameters = true;
			}
			if (index == 1 && !inParameters) {
				result = new StringBuilder(tokens[index]);
			}
			if (tokens[index].indexOf(')') != -1 && !parametersSeen) {
				parametersSeen = true;
				if (index != tokens.length - 1) {
					result = new StringBuilder();
				}

			}

		}

		return result.toString().trim();
	}