4141
4242import com .sap .prd .mobile .ios .mios .xcodeprojreader .Plist ;
4343
44- // TODO unsupported element types: Date, Data, Integer, Real
44+ // TODO unsupported element types: Date, Data
4545public class JAXBPlistParser
4646{
4747 public Plist load (String projectFile ) throws SAXException , ParserConfigurationException , FileNotFoundException ,
4848 JAXBException
49+ {
50+ return load (new File (projectFile ));
51+ }
52+
53+ public Plist load (File projectFile ) throws SAXException , ParserConfigurationException , FileNotFoundException ,
54+ JAXBException
4955 {
5056 InputSource project = new InputSource (new FileReader (projectFile ));
5157 return unmarshallPlist (project );
@@ -95,12 +101,17 @@ public InputSource resolveEntity(String pid, String sid) throws SAXException
95101 return ss ;
96102 }
97103
98- public void save (Plist plist , String fileName ) throws JAXBException
104+ public void save (Plist plist , String projectFile ) throws JAXBException
105+ {
106+ save (plist , new File (projectFile ));
107+ }
108+
109+ public void save (Plist plist , File projectFile ) throws JAXBException
99110 {
100- marshallPlist (plist , fileName );
111+ marshallPlist (plist , projectFile );
101112 }
102113
103- private void marshallPlist (Plist plist , String projectFile ) throws JAXBException
114+ private void marshallPlist (Plist plist , File projectFile ) throws JAXBException
104115 {
105116 JAXBContext ctx = JAXBContext .newInstance (com .sap .prd .mobile .ios .mios .xcodeprojreader .jaxb .JAXBPlist .class );
106117 Marshaller marshaller = ctx .createMarshaller ();
@@ -110,13 +121,19 @@ private void marshallPlist(Plist plist, String projectFile) throws JAXBException
110121 "com.sun.xml.internal.bind.xmlHeaders" ,
111122 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <!DOCTYPE plist PUBLIC \" -//Apple//DTD PLIST 1.0//EN\" \" http://www.apple.com/DTDs/PropertyList-1.0.dtd\" >" );
112123 marshaller .setProperty (Marshaller .JAXB_FRAGMENT , true );
113- marshaller .marshal (plist , new File (projectFile ));
124+ marshaller .marshal (plist , projectFile );
125+ }
126+
127+ public void convert (String projectFile , String destinationProjectFile ) throws IOException
128+ {
129+ convert (new File (projectFile ), new File (destinationProjectFile ));
114130 }
115131
116- public void convert (String projectFile , File destinationProjectFile ) throws IOException
132+ public void convert (File projectFile , File destinationProjectFile ) throws IOException
117133 {
118134 Process exec = Runtime .getRuntime ().exec (
119- new String [] { "plutil" , "-convert" , "xml1" , "-o" , destinationProjectFile .getAbsolutePath (), projectFile });
135+ new String [] { "plutil" , "-convert" , "xml1" , "-o" , destinationProjectFile .getAbsolutePath (),
136+ projectFile .getAbsolutePath () });
120137 try
121138 {
122139 exec .waitFor ();
0 commit comments