public class EvioXMLDictionary extends java.lang.Object implements INameProvider
An assumption in the following class is that each unique tag/num/tagEnd group corresponds to an equally unique name. In other words, 2 different groups cannot have the same name. And 2 different names cannot map to the same group.
An entry with only a tag value and no num is allowed. It will match a tag/num pair if no exact match exists but the tag matches. For such an entry, no additional existence of type, format, or description is allowed.
Similarly, an entry with a range of tags is also allowed. In this case, no num & type is allowed. It will match a tag/num pair if no exact match exists but the tag is in the range (inclusive).
Modifier and Type | Field and Description |
---|---|
java.util.LinkedHashMap<EvioDictionaryEntry,java.lang.String> |
tagNumMap
This is the heart of the dictionary in which a key is composed of a tag/num
pair and other entry data and its corresponding value is a name.
|
java.util.LinkedHashMap<EvioDictionaryEntry,java.lang.String> |
tagOnlyMap
Some dictionary entries have only a tag and no num.
|
java.util.LinkedHashMap<EvioDictionaryEntry,java.lang.String> |
tagRangeMap
Some dictionary entries have only a tag range and no num.
|
NO_NAME_STRING
Constructor and Description |
---|
EvioXMLDictionary(org.w3c.dom.Document domDocument)
Create an EvioXMLDictionary from an xml Document object.
|
EvioXMLDictionary(org.w3c.dom.Document domDocument,
java.lang.String delimiter)
Create an EvioXMLDictionary from an xml Document object.
|
EvioXMLDictionary(java.io.File file)
Create an EvioXMLDictionary from an xml file.
|
EvioXMLDictionary(java.io.File file,
java.lang.String delimiter)
Create an EvioXMLDictionary from an xml file.
|
EvioXMLDictionary(java.lang.String xmlString)
Create an EvioXMLDictionary from an xml string.
|
EvioXMLDictionary(java.lang.String xmlString,
java.lang.String delimiter)
Create an EvioXMLDictionary from an xml string.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDescription(java.lang.Integer tag,
java.lang.Integer num)
Returns the description, if any, associated with the given tag and num.
|
java.lang.String |
getDescription(java.lang.Integer tag,
java.lang.Integer num,
java.lang.Integer tagEnd)
Returns the description, if any, associated with the given tag, num, and tagEnd.
|
java.lang.String |
getDescription(java.lang.String name)
Returns the description, if any, associated with the name of a dictionary entry.
|
java.lang.String |
getFormat(java.lang.Integer tag,
java.lang.Integer num,
java.lang.Integer tagEnd)
Returns the format, if any, associated with the given tag, num, and tagEnd.
|
java.lang.String |
getFormat(int tag,
int num)
Returns the format, if any, associated with the given tag and num.
|
java.lang.String |
getFormat(java.lang.String name)
Returns the format, if any, associated with the name of a dictionary entry.
|
java.util.Map<java.lang.String,EvioDictionaryEntry> |
getMap()
Get the map in which the key is the entry name and the value is an object
containing its data (tag, num, type, etc.).
|
java.lang.String |
getName(BaseStructure structure)
Returns the name of a given evio structure.
|
java.lang.String |
getName(java.lang.Integer tag,
java.lang.Integer num)
Returns the name associated with the given tag, num, and tagEnd.
|
java.lang.String |
getName(java.lang.Integer tag,
java.lang.Integer num,
java.lang.Integer tagEnd)
Returns the name associated with the given tag, num, and tagEnd.
|
java.lang.String |
getName(java.lang.Integer tag,
java.lang.Integer num,
java.lang.Integer tagEnd,
java.lang.Integer pTag,
java.lang.Integer pNum,
java.lang.Integer pTagEnd)
Returns the name associated with the given tag, num, and tagEnd.
|
java.lang.Integer |
getNum(java.lang.String name)
Returns the num corresponding to the name of a dictionary entry.
|
java.lang.Integer |
getTag(java.lang.String name)
Returns the tag corresponding to the name of a dictionary entry.
|
java.lang.Integer |
getTagEnd(java.lang.String name)
Returns the tagEnd corresponding to the name of a dictionary entry.
|
java.lang.Integer[] |
getTagNum(java.lang.String name)
Returns the tag/num/tagEnd values, in an Integer object array,
corresponding to the name of a dictionary entry.
|
DataType |
getType(java.lang.Integer tag,
java.lang.Integer num)
Returns the type, if any, associated with the given tag and num.
|
DataType |
getType(java.lang.Integer tag,
java.lang.Integer num,
java.lang.Integer tagEnd)
Returns the type, if any, associated with the given tag, num, and tagEnd.
|
DataType |
getType(java.lang.String name)
Returns the type, if any, associated with the name of a dictionary entry.
|
int |
size()
Get the number of entries in this dictionary.
|
java.lang.String |
toString()
Get a string representation of the dictionary.
|
java.lang.String |
toXML()
Get an xml representation of the dictionary.
|
public java.util.LinkedHashMap<EvioDictionaryEntry,java.lang.String> tagNumMap
public java.util.LinkedHashMap<EvioDictionaryEntry,java.lang.String> tagOnlyMap
public java.util.LinkedHashMap<EvioDictionaryEntry,java.lang.String> tagRangeMap
public EvioXMLDictionary(java.io.File file)
file
- file containing xml.public EvioXMLDictionary(java.io.File file, java.lang.String delimiter)
file
- file containing xml.delimiter
- character used to separate hierarchical parts of names.public EvioXMLDictionary(java.lang.String xmlString)
xmlString
- string containing xml.public EvioXMLDictionary(java.lang.String xmlString, java.lang.String delimiter)
xmlString
- string containing xml.delimiter
- character used to separate hierarchical parts of names.public EvioXMLDictionary(org.w3c.dom.Document domDocument)
domDocument
- DOM object representing xml dictionary.public EvioXMLDictionary(org.w3c.dom.Document domDocument, java.lang.String delimiter)
domDocument
- DOM object representing xml dictionary.delimiter
- character used to separate hierarchical parts of names.public int size()
public java.util.Map<java.lang.String,EvioDictionaryEntry> getMap()
public java.lang.String getName(BaseStructure structure)
getName
in interface INameProvider
structure
- the structure to find the name of.public java.lang.String getName(java.lang.Integer tag, java.lang.Integer num)
If only a valid tag is given, a search is made for:
All other argument values result in ??? being returned.
tag
- tag of dictionary entry to findnum
- num of dictionary entry to findpublic java.lang.String getName(java.lang.Integer tag, java.lang.Integer num, java.lang.Integer tagEnd, java.lang.Integer pTag, java.lang.Integer pNum, java.lang.Integer pTagEnd)
If only a valid tag is given, a search is made for:
If a valid tag range is given (different valid tag and tagEnd with no num), a search is made for an entry of a tag range. Note: tag and tagEnd being the same value or tagEnd being 0 mean that no range is defined - it's equivalent to only specifying a tag.
Argument values which have no match result in "???" being returned.
Things are actually more complicated due to parent structures. Duplicate entries (same tag, num, and tagEnd) are permitted only as long their parent entries are different. Say, for example, that this dictionary is defined as follows:
<bank name="B1" tag="1" num="1" >
<bank name="sub1" tag="5" num="5" />
<bank name="sub2" tag="5" num="5" />
<leaf name="tagNum" tag="10" num="10" />
<leaf name="tagOnly" tag="20" />
<leaf name="tagRange" tag="30-40" />
</bank>
<bank name="B2" tag="2" num="2" >
<leaf name="tagNum" tag="10" num="10" />
<leaf name="tagOnly" tag="20" />
<leaf name="tagRange" tag="30-40" />
</bank>
You can see that the leaf entries under bank "B1" are identical to those under "B2".
This is permitted since B1 and B2 have different tag & num values so there
is a way to tell the difference between the 2 instances of tagNum, tagOnly and
tagRange.It is not possible to specify parents using the "dictEntry" XML element and consequently duplicates are not allowed if using this form of dictionary definition. Think of things like this: no parents = no duplicates.
tag
- tag of dictionary entry to findnum
- num of dictionary entry to findtagEnd
- tagEnd of dictionary entry to findpTag
- tag of dictionary entry's parentpNum
- num of dictionary entry's parentpTagEnd
- tagEnd of dictionary entry's parentpublic java.lang.String getName(java.lang.Integer tag, java.lang.Integer num, java.lang.Integer tagEnd)
If only a valid tag is given, a search is made for:
If a valid tag range is given (different valid tag and tagEnd with no num), a search is made for an entry of a tag range. Note: tag and tagEnd being the same value or tagEnd being 0 mean that no range is defined - it's equivalent to only specifying a tag.
All other argument values result in ??? being returned.
tag
- tag of dictionary entry to findnum
- num of dictionary entry to findtagEnd
- tagEnd of dictionary entry to findpublic java.lang.String getDescription(java.lang.Integer tag, java.lang.Integer num)
tag
- to find the description ofnum
- to find the description ofpublic java.lang.String getDescription(java.lang.Integer tag, java.lang.Integer num, java.lang.Integer tagEnd)
tag
- to find the description ofnum
- to find the description oftagEnd
- to find the description ofpublic java.lang.String getDescription(java.lang.String name)
name
- dictionary namepublic java.lang.String getFormat(int tag, int num)
tag
- to find the format ofnum
- to find the format ofpublic java.lang.String getFormat(java.lang.Integer tag, java.lang.Integer num, java.lang.Integer tagEnd)
tag
- to find the format ofnum
- to find the format oftagEnd
- to find the format ofpublic java.lang.String getFormat(java.lang.String name)
name
- dictionary namepublic DataType getType(java.lang.Integer tag, java.lang.Integer num)
tag
- to find the type ofnum
- to find the type ofpublic DataType getType(java.lang.Integer tag, java.lang.Integer num, java.lang.Integer tagEnd)
tag
- to find the type ofnum
- to find the type oftagEnd
- to find the type ofpublic DataType getType(java.lang.String name)
name
- dictionary namepublic java.lang.Integer[] getTagNum(java.lang.String name)
If there is an exact match with a tag and num pair, it is returned (last element is null). If not, but there is a match with a tag-only entry, that is returned (last 2 elements are null). If no tag-only match exits, but there is a match with a tag range, that is returned (i.e. second element, the num, is null).
name
- dictionary namepublic java.lang.Integer getTag(java.lang.String name)
name
- dictionary namepublic java.lang.Integer getTagEnd(java.lang.String name)
name
- dictionary namepublic java.lang.Integer getNum(java.lang.String name)
name
- dictionary namepublic java.lang.String toXML()
public java.lang.String toString()
toString
in class java.lang.Object