Class LinkHandlingUtilities
java.lang.Object
com.ibm.icu.impl.links.LinkHandlingUtilities
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumDefines the LinkTermination property
These will be replaced once we have a real property value in ICU.private static enumParallels the spec parts tableprivate static enumstatic classprivate static enumBased on https://url.spec.whatwg.org/#percent-encoded-bytes. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final UnicodeSetThese will be replaced once we have a real property value in ICU.private static final PatternRegex for percent escapingprivate static final Patternprivate static final UnicodeSet(package private) static final UnicodeSet -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidappendCheckingPercent(StringBuilder toAppendTo, String source, int lastEnd, int start) If we have in an unescaped string %xy, and xy are hex, then we have to escape the % sign.private static voidappendCodePointsBetween(StringBuilder output, int[] cp, int copyEnd, int notToCopy) private static voidappendPercentEscaped(StringBuilder output, int cp) private static voidappendPercentEscaped(StringBuilder output, String source) cleanList(LinkHandlingUtilities.Part part, String partString) static Stringescape(String source, UnicodeSet toEscape) percent-escape all the toEscape characters.getInternals(String source) private static intgetOpening(int cp) Defines the getOpening mapping
It will be replaced once we have a real property value in ICU.private static StringjoinListEscaping(String sep, UnicodeSet toEscape, List<String> partParts) private static Stringprivate static booleanmatches(int[] codePoints, int cpIndex, int[] fragmentDirective) Simple utility for finding matching int array regionsstatic intparsePathQueryFragment(String source, int codePointOffset) Set lastSafe to 0 — this marks the last code point that is definitely included in the linkification.
Set closingStack to empty
Set the current code point position i to 0
Loop from i = 0 to n
Set LT to LinkTermination(cp[i])
If LT == none, set lastSafe to be i+1, continue loop
If LT == soft, continue loop
If LT == hard, stop linkification and return lastSafe
If LT == opening, push cp[i] onto closingStack
If LT == closing, set open to the pop of closingStack, or 0 if the closingStack is empty
If LinkPairedOpeners(cp[i]) == open, set lastSafe to be i+1, continue loop.
Otherwise, stop linkification and return lastSafe
If lastSafe == n+1, then the entire part is safe; continue to the next part
Otherwise, stop linkification and return lastSafeprivate static StringpercentUnescape(String escapedSource) We are guaranteed that string is all percent escaped utf8, %a3%c0 ...static intscanEmailBackwards(CharSequence source, int hardStart, int atSignPos) splitList(LinkHandlingUtilities.Part part, String separator, String partString) private static StringUnescape a string.private static Stringunescape(String stringWithEscapes, UnicodeSet toEscape) Unescape a string; however, code points in toEscape are escaped back.
-
Field Details
-
SOFAR
-
EMAIL_ASCII_INCLUDES
These will be replaced once we have a real property value in ICU. -
VALID_EMAIL_LOCAL_PART
-
ESCAPED_BYTE_PATTERN
Regex for percent escaping -
ESCAPED_SINGLE
-
-
Constructor Details
-
LinkHandlingUtilities
public LinkHandlingUtilities()
-
-
Method Details
-
getOpening
private static int getOpening(int cp) Defines the getOpening mapping
It will be replaced once we have a real property value in ICU. -
scanEmailBackwards
-
joinListListEscaping
-
joinListEscaping
-
cleanList
-
splitList
private static List<String> splitList(LinkHandlingUtilities.Part part, String separator, String partString) -
parsePathQueryFragment
Set lastSafe to 0 — this marks the last code point that is definitely included in the linkification.
Set closingStack to empty
Set the current code point position i to 0
Loop from i = 0 to n
Set LT to LinkTermination(cp[i])
If LT == none, set lastSafe to be i+1, continue loop
If LT == soft, continue loop
If LT == hard, stop linkification and return lastSafe
If LT == opening, push cp[i] onto closingStack
If LT == closing, set open to the pop of closingStack, or 0 if the closingStack is empty
If LinkPairedOpeners(cp[i]) == open, set lastSafe to be i+1, continue loop.
Otherwise, stop linkification and return lastSafe
If lastSafe == n+1, then the entire part is safe; continue to the next part
Otherwise, stop linkification and return lastSafe -
matches
private static boolean matches(int[] codePoints, int cpIndex, int[] fragmentDirective) Simple utility for finding matching int array regions -
appendCodePointsBetween
private static void appendCodePointsBetween(StringBuilder output, int[] cp, int copyEnd, int notToCopy) -
unescape
-
unescape
Unescape a string; however, code points in toEscape are escaped back. -
appendPercentEscaped
-
appendPercentEscaped
-
escape
percent-escape all the toEscape characters. -
appendCheckingPercent
private static void appendCheckingPercent(StringBuilder toAppendTo, String source, int lastEnd, int start) If we have in an unescaped string %xy, and xy are hex, then we have to escape the % sign. -
percentUnescape
-
getInternals
-