|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ix.util.xml.XMLSaver
public class XMLSaver
A utility for saving objects and XML documents to files, conducting
dialogs as required. Objects can be saved in a variety of syntaxes,
not only as XML. The available syntaxes are determined from the
object's class by a FileSyntaxManager
.
XML.fileSyntaxManager()
Field Summary | |
---|---|
protected javax.swing.JFileChooser |
fileChooser
|
protected java.awt.Component |
frame
|
protected java.io.File |
libDir
|
protected java.lang.Class |
outputObjectClass
|
protected XMLTranslator |
xmlt
|
Constructor Summary | |
---|---|
XMLSaver(java.awt.Component frame)
Creates an XMLSaver that uses the default XML translator that is in force at the time this constructor is called. |
|
XMLSaver(java.awt.Component frame,
java.lang.Class outputObjectClass)
|
Method Summary | |
---|---|
protected java.io.File |
agreeFileToWrite()
Asks the user to select a file and, if it already exists, whether to overwrite it. |
protected java.io.File |
chooseFileToWrite()
Asks the user to choose a file. |
XMLTranslator |
getXMLTranslator()
Returns the XMLTranslator that is used by the saveObject method to translate an object to a JDOM document. |
javax.swing.JFileChooser |
makeFileChooser()
Constructs a suitable file-chooser for this XMLSaver's output object class. |
void |
saveDocument(org.jdom.Document doc)
Writes a JDOM Document to a file selected by the user, conducting any necessary dialogs along the way. |
void |
saveObject(java.lang.Object obj)
Writes an object to a file in a form that corresponds to the selected file type or extension, conducting any necessary dialogs along the way. |
void |
setXMLTranslator(XMLTranslator xmlt)
Sets the XMLTranslator that is used by this XMLSaver to translate an object to a JDOM document. |
protected void |
writeDocumentTo(java.io.File file,
org.jdom.Document doc)
Writes the document to the file. |
protected void |
writeObjectToFile(java.lang.Object obj,
java.io.File file)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.File libDir
protected XMLTranslator xmlt
protected javax.swing.JFileChooser fileChooser
protected java.awt.Component frame
protected java.lang.Class outputObjectClass
Constructor Detail |
---|
public XMLSaver(java.awt.Component frame)
XML.defaultTranslator()
public XMLSaver(java.awt.Component frame, java.lang.Class outputObjectClass)
Method Detail |
---|
public XMLTranslator getXMLTranslator()
public void setXMLTranslator(XMLTranslator xmlt)
public void saveObject(java.lang.Object obj)
The default is to Convert the object to a JDOM Document and then call the saveDocument method.
saveDocument(Document)
,
agreeFileToWrite()
protected void writeObjectToFile(java.lang.Object obj, java.io.File file) throws java.io.IOException
java.io.IOException
public void saveDocument(org.jdom.Document doc)
saveObject(Object)
,
agreeFileToWrite()
protected void writeDocumentTo(java.io.File file, org.jdom.Document doc) throws java.io.IOException
java.io.IOException
XML.makePrettyXMLOutputter()
protected java.io.File agreeFileToWrite()
protected java.io.File chooseFileToWrite()
public javax.swing.JFileChooser makeFileChooser()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |