org.eclipse.mylyn.wikitext.core.parser
Class IdGenerator

java.lang.Object
  extended by org.eclipse.mylyn.wikitext.core.parser.IdGenerator

public class IdGenerator
extends Object

Since:
1.0
Author:
David Green

Constructor Summary
IdGenerator()
           
 
Method Summary
 Set<String> getAnchorNames()
          get the set of anchor names that were either reserved or created.
 IdGenerationStrategy getGenerationStrategy()
           
 String newId(String type, String text)
          create a new ID based on the given type and label text.
 boolean reserveId(String id)
          reserve the given id, ensuring that the generator will not generate the same id.
 void setGenerationStrategy(IdGenerationStrategy generationStrategy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IdGenerator

public IdGenerator()
Method Detail

reserveId

public boolean reserveId(String id)
reserve the given id, ensuring that the generator will not generate the same id. An id can only be reserved if it has not already been reserved and if it has not already been generated.

Parameters:
id - the id to reserve
Returns:
true if the id was reserved, otherwise false

newId

public String newId(String type,
                    String text)
create a new ID based on the given type and label text. Guarantees to return an id once and only once; duplicates are never created.

Parameters:
type - the type of id to produce, usually an indication of what the id is created for. For example, 'h1', or 'h2'. may be null.
text - the label text for which the id is being produced. may be null.
Returns:
a unique id

getAnchorNames

public Set<String> getAnchorNames()
get the set of anchor names that were either reserved or created.

Returns:
the set of names

getGenerationStrategy

public IdGenerationStrategy getGenerationStrategy()

setGenerationStrategy

public void setGenerationStrategy(IdGenerationStrategy generationStrategy)


Copyright © 2011 FuseSource, Corp.. All Rights Reserved.