public class HtmlElementIdCreator extends Object implements ElementIdCreator
Constructor and Description |
---|
HtmlElementIdCreator() |
Modifier and Type | Method and Description |
---|---|
static String |
convertToId(String str)
Deprecated.
since 4.3 this method strips characters leading to useless IDs in some cases. Use
convertToIdHtml5(String) . |
static String |
convertToIdHtml5(String original)
The draft HTML5 spec states that the id attribute value
must be unique amongst all the IDs in the element's home subtree and must contain at least one character.
|
String |
generateId()
The current implementation is very simplistic and will simply create id's of the pattern "id-<n>".
|
String |
generateId(String basis)
The draft HTML5 spec states that the id attribute value
must be unique amongst all the IDs in the element's home subtree and must contain at least one character.
|
public String generateId()
generateId
in interface ElementIdCreator
ConversionContext
.public String generateId(String basis)
must be unique amongst all the IDs in the element's home subtree and must contain at least one character. The value must not contain any space characters.(As specified at http://dev.w3.org/html5/spec/elements.html#the-id-attribute).
This method will take an arbitrary String and ensure that the above encoding is followed as well as ensuring that the id returned is unique (within the scope
of this HtmlElementIdCreator
instance).
generateId
in interface ElementIdCreator
basis
- the string to be converted to an idHtmlElementIdCreator
instance.@Deprecated public static String convertToId(String str)
convertToIdHtml5(String)
.must be unique amongst all the IDs in the element's home subtree and must contain at least one character. The value must not contain any space characters.(As specified at http://dev.w3.org/html5/spec/elements.html#the-id-attribute).
This method will take an arbitrary String and ensure that all white space and punctuation are removed, except for hyphens.
This method does not create unique ids. You should instantiate an instance of HtmlElementIdCreator and use
generateId(String)
if you have this requirement.
str
- the string to be converted to an idpublic static String convertToIdHtml5(String original)
must be unique amongst all the IDs in the element's home subtree and must contain at least one character. The value must not contain any space characters.(As specified at http://dev.w3.org/html5/spec/elements.html#the-id-attribute).
This method will not generate IDs that are safe to put directly into HTML or URLs. The result of this method should be appropriately encoded for the environment in which it is used.
This method will take an arbitrary String return a valid HTML5 ID derived from the original string. It will strip
out all whitespace.
This method does not create unique ids. You should instantiate an instance of HtmlElementIdCreator and use
generateId(String)
if you have this requirement.
original
- the string to be converted to an idCopyright © 2003–2016 Atlassian. All rights reserved.