public class MutableAdornedFile
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,org.jdom2.Element> |
adornedWordMap
Map from word ID to adorned word elements.
|
protected org.jdom2.Document |
document
Adorned document.
|
protected static org.jdom2.Namespace |
teiNamespace
TEI name space.
|
protected java.util.List<java.lang.String> |
wordIDs
List of word IDs.
|
protected java.util.Set<java.lang.String> |
wordTagsSet
Set of word tags (typically "w" and "pc").
|
Constructor and Description |
---|
MutableAdornedFile(java.lang.String adornedFileName)
Create mutable adorned file.
|
MutableAdornedFile(java.lang.String adornedFileName,
java.lang.String[] wordTags)
Create mutable adorned file.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addWordElement(java.lang.String id,
java.lang.String siblingID,
java.lang.String text,
boolean blankPrecedes)
Add word element.
|
void |
applyChange(WordChange change)
Apply a change from a change log.
|
void |
applyChanges(java.util.List<WordChange> changes)
Apply changes from a change log.
|
protected void |
compressCElements()
Compress "
|
protected org.jdom2.Element |
createElement(java.lang.String name)
Create an element.
|
protected boolean |
deleteWordElement(java.lang.String id)
Delete a word element.
|
void |
deleteWordElementAttribute(java.lang.String id,
java.lang.String attrName)
Delete a word element attribute.
|
org.jdom2.Element |
getAdornedWord(java.lang.String id)
Get element for a specified word ID.
|
java.util.List<java.lang.String> |
getAdornedWordIDs()
Return list of word IDs.
|
org.jdom2.Document |
getDocument()
Get document.
|
void |
revertChange(WordChange change)
Revert a change from a change log.
|
void |
revertChanges(java.util.List<WordChange> changes)
Revert changes from a change log.
|
void |
setWordElementAttribute(java.lang.String id,
java.lang.String attrName,
java.lang.String attrValue)
Set word element attribute value.
|
void |
setWordElementText(java.lang.String id,
java.lang.String text)
Set word element text.
|
protected java.util.Map<java.lang.String,org.jdom2.Element> adornedWordMap
protected java.util.List<java.lang.String> wordIDs
protected java.util.Set<java.lang.String> wordTagsSet
protected org.jdom2.Document document
protected static org.jdom2.Namespace teiNamespace
public MutableAdornedFile(java.lang.String adornedFileName, java.lang.String[] wordTags) throws java.lang.Exception
adornedFileName
- The adorned file.wordTags
- String array of word tag element
names, typically "w" and "pc".java.lang.Exception
- in case of error.public MutableAdornedFile(java.lang.String adornedFileName) throws java.lang.Exception
adornedFileName
- The adorned file from which to load
word data.java.lang.Exception
- in case of error.
The word elements are assumed to be tagged as
public java.util.List<java.lang.String> getAdornedWordIDs()
public org.jdom2.Element getAdornedWord(java.lang.String id)
id
- Word ID.public org.jdom2.Document getDocument()
public void applyChange(WordChange change)
change
- The change to apply.public void revertChange(WordChange change)
change
- The change to revert.public void applyChanges(java.util.List<WordChange> changes)
changes
- The changes to apply.public void revertChanges(java.util.List<WordChange> changes)
changes
- The changes to revert.protected org.jdom2.Element createElement(java.lang.String name)
name
- Element name.protected boolean deleteWordElement(java.lang.String id)
id
- Word ID of element to delete.public void deleteWordElementAttribute(java.lang.String id, java.lang.String attrName)
id
- Word ID of element for which to delete attribute.attrName
- Name of attribute to delete.public void setWordElementText(java.lang.String id, java.lang.String text)
id
- Word ID of element.text
- The word text.public void setWordElementAttribute(java.lang.String id, java.lang.String attrName, java.lang.String attrValue)
id
- Word ID of element.attrName
- The attribute name.attrValue
- The attribute value.protected void addWordElement(java.lang.String id, java.lang.String siblingID, java.lang.String text, boolean blankPrecedes)
id
- Word ID of element to add.siblingID
- Word ID of sibling element.text
- The word text.protected void compressCElements()
Deleting words may have left sequences of "