com.atlassian.confluence.content.render.xhtml
Class HtmlElementIdCreator

java.lang.Object
  extended by com.atlassian.confluence.content.render.xhtml.HtmlElementIdCreator
All Implemented Interfaces:
ElementIdCreator

public class HtmlElementIdCreator
extends Object
implements ElementIdCreator

A non-thread safe class used to create HTML ids within a render 'context'.


Constructor Summary
HtmlElementIdCreator()
           
 
Method Summary
static String convertToId(String str)
          HTML 4 id attribute values are restricted as follows in the specification - code ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
 String generateId()
          The current implementation is very simplistic and will simply create id's of the pattern "id-<n>".
 String generateId(String basis)
          HTML 4 id attribute values are restricted as follows in the specification - code ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlElementIdCreator

public HtmlElementIdCreator()
Method Detail

generateId

public String generateId()
The current implementation is very simplistic and will simply create id's of the pattern "id-<n>".

Specified by:
generateId in interface ElementIdCreator
Returns:
an auto-generate id unique within the context of a particular ConversionContext.

generateId

public String generateId(String basis)
HTML 4 id attribute values are restricted as follows in the specification -
code ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
(As specified at http://www.w3.org/TR/html4/types.html#type-name).

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).

Specified by:
generateId in interface ElementIdCreator
Parameters:
str - the string to be converted to an id
Returns:
a valid id String unique to the scope of the HtmlElementIdCreator instance.

convertToId

public static String convertToId(String str)
HTML 4 id attribute values are restricted as follows in the specification -
code ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
(As specified at http://www.w3.org/TR/html4/types.html#type-name).

This method will take an arbitrary String and ensure that the above encoding is followed. This method does not necessarily create unique ids. You should use #convertToUniqueId(String) if you have this requirement.

Parameters:
str - the string to be converted to an id
Returns:
a valid id


Copyright © 2003-2011 Atlassian. All Rights Reserved.