LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.misc
Class LyXmlPrintWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by leon.misc.LyPrintWriter
              extended by leon.misc.LyXmlPrintWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class LyXmlPrintWriter
extends LyPrintWriter

LyXmlPrintWriter contains utility methods to write XML files.


Field Summary
static java.lang.String __VERSION
           
 
Constructor Summary
LyXmlPrintWriter(java.io.FileOutputStream output)
          Constructor.
LyXmlPrintWriter(java.io.FileOutputStream output, java.lang.String charset)
          Constructor.
 
Method Summary
 void addIndent(boolean closeTag)
          Sets the _closeTag parameter with the given value and calls.
static boolean checkFile(java.lang.String filename, java.lang.String destination)
          Checks if the given filename with the xml extension at the given destination exits.
 void close()
          Close the writer.
static LyXmlPrintWriter getPrintWriter(java.lang.String filename, java.lang.String destination)
          Gets the print writer.
static LyXmlPrintWriter getPrintWriter(java.lang.String filename, java.lang.String destination, java.lang.String type)
          Gets the print writer associated to the given filename with the given extension at the given destination.
 void print(java.lang.String str)
          Utility methods to print, avoid ^M at the end of lines and to indent result.
 boolean removeIndent(boolean closeTag)
          Removes an indentation and if the given value is true and if _closeTag is true, prints '/>'n sets _closeTag to false and return true, else return false.
 
Methods inherited from class leon.misc.LyPrintWriter
addIndent, checkFile, getFilePath, getIndentString, getLinesCount, println, println, printnl, removeIndent, wasChanged
 
Methods inherited from class java.io.PrintWriter
append, append, append, checkError, flush, format, format, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, write, write, write, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values
Constructor Detail

LyXmlPrintWriter

public LyXmlPrintWriter(java.io.FileOutputStream output,
                        java.lang.String charset)
                 throws java.io.UnsupportedEncodingException
Constructor. Calls the super implementation with a buffered writer builds from an output stream writer itself built with the given parameters. Sets _closeTag and LyPrintWriter._changed to false, then starts the print.

Parameters:
output - the output stream where the XML has to be wrote
charset - the name of a supported charset
Throws:
java.io.UnsupportedEncodingException - if the named encoding is not supported

LyXmlPrintWriter

public LyXmlPrintWriter(java.io.FileOutputStream output)
Constructor. Calls the super implementation, sets _closeTag and LyPrintWriter._changed to false, then starts the print.

Parameters:
output - the file where the XML will be wrote
Method Detail

close

public void close()
Close the writer. Only calls the super implementation.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.PrintWriter

checkFile

public static final boolean checkFile(java.lang.String filename,
                                      java.lang.String destination)
Checks if the given filename with the xml extension at the given destination exits.

Parameters:
filename - the name of the file where the XML will be wrote
destination - the path of the file
Returns:
True if it exists, false otherwise.

getPrintWriter

public static final LyXmlPrintWriter getPrintWriter(java.lang.String filename,
                                                    java.lang.String destination)
Gets the print writer. This method only calls getPrintWriter(filename, destination, ".xml")

Parameters:
filename - the name of the file where the XML will be wrote
destination - the path of the file
Returns:
the XML print writer
See Also:
getPrintWriter(String, String, String)

getPrintWriter

public static LyXmlPrintWriter getPrintWriter(java.lang.String filename,
                                              java.lang.String destination,
                                              java.lang.String type)
Gets the print writer associated to the given filename with the given extension at the given destination. If the file ever exist, a backup is made into the filename + type + ".bak" file.

Parameters:
filename - the name of the file where the XML will be wrote
destination - the path of the file
type - the file type (mostly ".xml")
Returns:
the XML print writer

print

public void print(java.lang.String str)
Utility methods to print, avoid ^M at the end of lines and to indent result.
If _closeTag is set to true then print '>' character and set the attribute to false.
If LyPrintWriter._indentNext is set to true, print the number of tabulation of the LyPrintWriter._indent parameter.
Calls the super implementation and set LyPrintWriter._changed to true.

Overrides:
print in class LyPrintWriter

addIndent

public void addIndent(boolean closeTag)
Sets the _closeTag parameter with the given value and calls. LyPrintWriter.addIndent()

Parameters:
closeTag - the new close tag value

removeIndent

public boolean removeIndent(boolean closeTag)
Removes an indentation and if the given value is true and if _closeTag is true, prints '/>'n sets _closeTag to false and return true, else return false.

Parameters:
closeTag - indicates if the end of tag must be print
Returns:
true if '/>' is printed, false otherwise.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com