Author: rob.stryker(a)jboss.com
Date: 2007-07-26 18:52:48 -0400 (Thu, 26 Jul 2007)
New Revision: 2694
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
Log:
removed two-step file output, replaced with one
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2007-07-26
20:24:23 UTC (rev 2693)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModel.java 2007-07-26
22:52:48 UTC (rev 2694)
@@ -300,7 +300,7 @@
IPath packagesFile = project.append(ArchivesModel.PROJECT_PACKAGES_FILE);
XbPackages packs = getXbPackages(project);
- XMLBinding.savePackagesToFile(packs, packagesFile, monitor);
+ XMLBinding.marshallToFile(packs, packagesFile, monitor);
// get deltas
try {
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java 2007-07-26
20:24:23 UTC (rev 2693)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XMLBinding.java 2007-07-26
22:52:48 UTC (rev 2694)
@@ -37,6 +37,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.Trace;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
@@ -127,6 +128,21 @@
}
return null;
}
+
+ public static void marshallToFile(XbPackages element, IPath filePath, IProgressMonitor
monitor) {
+ OutputStreamWriter writer = null;
+ try {
+ writer = new OutputStreamWriter(new FileOutputStream(filePath.toFile()));
+ XMLBinding.marshall(element, writer, new NullProgressMonitor());
+ } catch( Exception e ) {
+ }
+ finally {
+ try {
+ if( writer != null ) writer.close();
+ } catch( IOException ioe) {}
+ }
+ }
+
public static void marshall (final XbPackages element, final Writer writer, final
IProgressMonitor monitor)
{
if( !initialized) init();
@@ -157,30 +173,6 @@
});
}
-
- public static void savePackagesToFile(XbPackages packages, IPath outputFile,
IProgressMonitor monitor) {
- try {
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
- OutputStreamWriter writer = new OutputStreamWriter(bytesOut);
- XMLBinding.marshall(packages, writer, monitor);
- writer.close();
-
- ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytesOut.toByteArray());
- OutputStream out = new FileOutputStream(outputFile.toFile());
-
- // Transfer bytes from in to out
- byte[] buf = new byte[1024];
- int len;
- while ((len = bytesIn.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- out.close();
- bytesIn.close();
- bytesOut.close();
- } catch( IOException ioe ) {
- }
- }
-
public static String serializePackages(XbPackages packages, IProgressMonitor monitor) {
try {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
Show replies by date