Package cbsw
Class InventoryBasic
- java.lang.Object
-
- cbsw.InventoryBasic
-
public class InventoryBasic extends java.lang.ObjectAn API for an inventory stored as an XML document.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.w3c.dom.ElementcurrentElementprotected java.lang.StringelementNameprotected org.w3c.dom.DocumentinventoryDocumentprotected org.w3c.dom.ElementinventoryElement
-
Constructor Summary
Constructors Constructor Description InventoryBasic(java.lang.String fileName, java.lang.String elementName)Loads the inventory (.xml) document and locates the named table.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoIndex(java.lang.String indexAttributeName)Indexes the table.org.w3c.dom.DocumentgetDocument()java.lang.StringgetFieldValue(java.lang.String name)Get the value for the named field for the current row.java.lang.StringgetFieldValue(org.w3c.dom.Element el, java.lang.String name)Get the value for the named field in the Element.org.w3c.dom.Elementidentify(java.lang.String id, java.lang.String match, java.lang.String reference, java.lang.String idAttributeName)Prompts for an identify and updates the current element.booleanisCurrentElementNull()voidsetText(org.w3c.dom.Element element, java.lang.String text)voidupdateField(java.lang.String name, java.lang.String value)Update the value for the named field.voidwrite(java.lang.String fileName)Writes the modfied inventory.voidwriteBackup(java.lang.String fileNamePrefix)Writes the current inventory document.
-
-
-
Method Detail
-
getDocument
public org.w3c.dom.Document getDocument()
-
doIndex
public void doIndex(java.lang.String indexAttributeName)
Indexes the table.
An indexing attribute is added to each table row to allow simple searching using the getElementById method.
- Parameters:
indexAttributeName- The name of the indexing attribute.
-
identify
public org.w3c.dom.Element identify(java.lang.String id, java.lang.String match, java.lang.String reference, java.lang.String idAttributeName)Prompts for an identify and updates the current element.
- Parameters:
id- The candidate identifier.match- The identifier must match this regular expression.reference- Identifier of existing element to clone.idAttributeName- The name of the id attribute.- Returns:
- The element.
-
write
public void write(java.lang.String fileName)
Writes the modfied inventory.
- Parameters:
fileName- Path of database XML file.
-
writeBackup
public void writeBackup(java.lang.String fileNamePrefix)
Writes the current inventory document.
A timestamp is appended to the created file name after the provided prefix.
- Parameters:
fileNamePrefix- The file name prefix.
-
updateField
public void updateField(java.lang.String name, java.lang.String value)Update the value for the named field.
- Parameters:
name- Name of the field to update.value- The new value.
-
getFieldValue
public java.lang.String getFieldValue(java.lang.String name)
Get the value for the named field for the current row.
- Parameters:
name- Name of the field.- Returns:
- The value.
-
getFieldValue
public java.lang.String getFieldValue(org.w3c.dom.Element el, java.lang.String name)Get the value for the named field in the Element.
- Parameters:
el- The Element.name- Name of the field.- Returns:
- The value.
-
isCurrentElementNull
public boolean isCurrentElementNull()
-
setText
public void setText(org.w3c.dom.Element element, java.lang.String text)
-
-