private ResourceReference parseDocumentLink ( StringBuilder content ) { // Extract any query string. String queryString = null ; String text = parseElementAfterString ( content , SEPARATOR_QUERYSTRING ) ; if ( text != null ) { queryString = removeEscapesFromExtraParts ( text ) ; } // Extract any anchor. String anchor = null ; text = parseElementAfterString ( content , SEPARATOR_ANCHOR ) ; if ( text != null ) { anchor = removeEscapesFromExtraParts ( text ) ; } // Make sure to unescape the remaining reference string. String unescapedReferenceString = removeEscapesFromReferencePart ( content . toString ( ) ) ; // Parse the string as an untyped link reference. ResourceReference reference = untypedLinkReferenceParser . parse ( unescapedReferenceString ) ; reference . setTyped ( false ) ; // Set any previously extracted parameters. if ( StringUtils . isNotBlank ( queryString ) ) { reference . setParameter ( DocumentResourceReference . QUERY_STRING , queryString ) ; } if ( StringUtils . isNotBlank ( anchor ) ) { reference . setParameter ( DocumentResourceReference . ANCHOR , anchor ) ; } return reference ; }
Construct a Document Link reference out of the passed content .