@User public class ElementDictionary<E extends TypedElement<E,X>,X extends TypedExtension> extends Object
Element
type. But it can also be used with different
Document
objects of the same class, or even of different classes, instantiated
with E=TypedElement
.
When generated by calling createDictionary()
in the generated
TypedDocument's code, which is the recommended way,
then most consistency checks will be carried out automatically.
The methods of this class realize most of the "validity constraints" w.r.t. ID/IDREF from
[XML 1.0].Modifier and Type | Field and Description |
---|---|
Function<String,E> |
get
Deprecated.
use "e::get" instead.
|
Constructor and Description |
---|
ElementDictionary() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(String id,
E element)
Stores a combination of id key and Element value.
|
boolean |
addIfIdentifiable(E element)
Stores an element if its definition includes an attribute of "ID type", and the
actual value is
!=null . |
boolean |
checkIds(E top,
@Opt MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg)
Test whether all reachable IDREF and IDREFS attribute have a value which corresponds
to some ID attribute in the maps of this ElementDictionary.
|
void |
clear()
Forget all assignments.
|
Map<E,String> |
element2idMap()
Returns an unmodifiable snapshot.
|
Set<E> |
elementSet()
Returns an unmodifiable snapshot of all known elements.
|
String |
freshId()
Returns an id value not yet used.
|
E |
get(@Opt String id)
Returns the element indentified by the given String value, or null if no such exists.
|
Map<String,E> |
idMap()
Returns an unmodifiable snapshot.
|
Set<String> |
idSet()
Returns an unmodifiable snapshot of all known id values.
|
@Deprecated public final Function<String,E extends TypedElement<E,X>> get
@User public void clear()
@User public Set<String> idSet()
@User public Set<E> elementSet()
@User public Map<String,E> idMap()
@User public Map<E,String> element2idMap()
@User public boolean add(String id, E element)
HomonymousIdException
- if one(1) id is used for two(2) different elements.SynonymousIdException
- if two(2) ids are used for one(1) element.
(This can only happen if this method is called directly by the user, not by TDom
generated code.)@User public boolean addIfIdentifiable(E element)
!=null
.
The former is indicated by implementing Identifiable
.
The storing is done by calling add(String,TypedElement)
.HomonymousIdException
- see add(String,TypedElement)
.SynonymousIdException
- see add(String,TypedElement)
.@User @Opt public E get(@Opt @Opt String id)
id
- (maybe null) the id value to look up.@User public String freshId()
@User public boolean checkIds(E top, @Opt @Opt MessageReceiver<? super SimpleMessage<XMLDocumentIdentifier>> msg)
top
- (never null) the element where to startmsg
- (maybe null) the drain of error messages. It it is null, an Exception is thrown
instead of the first error.DanglingIdException
see also the complete user documentation .