Class DtdParser
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.artifactModel.xml.DtdParser
-
public class DtdParser extends java.lang.ObjectThis class is used to read embedded DTDs from XML files and write them back later. This is neccessary due to the fact, that the transformer of w3c.dom loses any information of embedded DTDs.- Author:
- pastuschek
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDOCTYPE
-
Constructor Summary
Constructors Constructor Description DtdParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static DtdcheckForDTD(java.util.List<java.lang.String> stringList)Checks a List of Strings for an embedded DTD.static DtdextractDTD(java.io.File file)Will extract a embedded DTD from an XML file.static DtdextractDTD(java.io.InputStream in)Will extract a embedded DTD from an XML file.private static java.util.List<java.lang.String>readFile(java.io.File file)Reads a file and returns a List of Strings with the content.private static java.util.List<java.lang.String>readFile(java.io.InputStream in)Reads a from an input stream and returns a List of Strings with the content.static voidwriteDtd(java.io.File file, Dtd dtd)Writes the dtd back into a file.
-
-
-
Field Detail
-
DOCTYPE
private static final java.lang.String DOCTYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
extractDTD
public static Dtd extractDTD(java.io.File file) throws java.io.FileNotFoundException
Will extract a embedded DTD from an XML file.- Parameters:
file- The XML file.- Returns:
- A List of Strings with the embedded DTD.
- Throws:
java.io.FileNotFoundException- Thrown if the XML file could not be found.
-
extractDTD
public static Dtd extractDTD(java.io.InputStream in)
Will extract a embedded DTD from an XML file.- Parameters:
in- the input stream- Returns:
- A List of Strings with the embedded DTD.
-
checkForDTD
private static Dtd checkForDTD(java.util.List<java.lang.String> stringList)
Checks a List of Strings for an embedded DTD. If a DTD exists it is returned as a new List of Strings.- Parameters:
stringList- List of Strings that are to be checked for DTD.- Returns:
- A List of Strings with the DTD only (formatting will be maintained).
-
writeDtd
public static void writeDtd(java.io.File file, Dtd dtd) throws java.io.FileNotFoundExceptionWrites the dtd back into a file.- Parameters:
file- The file to change.dtd- The dtd to write into the file.- Throws:
java.io.FileNotFoundException- If file was not found.
-
readFile
private static java.util.List<java.lang.String> readFile(java.io.File file) throws java.io.FileNotFoundExceptionReads a file and returns a List of Strings with the content.- Parameters:
file- The file to be read.- Returns:
- A List of Strings with the content.
- Throws:
java.io.FileNotFoundException- If File was not found.
-
readFile
private static java.util.List<java.lang.String> readFile(java.io.InputStream in)
Reads a from an input stream and returns a List of Strings with the content.- Parameters:
in- the input stream to read- Returns:
- A List of Strings with the content.
-
-