Package org.jitterbit.util.persist

Examples of org.jitterbit.util.persist.XmlPersistor


     * @throws IOException
     *             if an error occurs
     */
    @Override
    public void saveLayout(OperationGraphLayout layout) throws IOException {
        XmlPersistor xml = XmlPersistor.newRoot("GraphLayout");
        layout.writeTo(xml);
        saveLayout(xml);
    }
View Full Code Here


        String data = layoutFile.read();
        if (data == null) {
            return false;
        }
        try {
            XmlPersistor xml = XmlPersistor.load(data);
            layout.readFrom(xml);
            return true;
        } catch (SAXException ex) {
            throw new IOException("Failed to restore the layout: " + ex.getMessage(), ex);
        }
View Full Code Here

        restoreFromFile(ODBC_FILE);
        restoreFromFile(JDBC_FILE);
    }

    private void persist(DriverDescriptor driver, File file) throws Exception {
        XmlPersistor p = XmlPersistor.newRoot("Driver");
        DriverDescriptorPersistor.persist(driver, p);
        p.store(file);
    }
View Full Code Here

                        "org.postgresql.Driver", new BeginEndQuote("\""));
        persist(driver, JDBC_FILE);
    }

    private void restoreFromFile(File file) throws Exception {
        XmlPersistor p = XmlPersistor.load(file);
        restore(p);
    }
View Full Code Here

        StringKeyValuePairs original = new StringKeyValuePairs();
        original.putString("name", "Dantes");
        original.putInt("number", 34);
        original.putBoolean("escaped", true);
        original.put("nothing", null);
        XmlPersistor xml = XmlPersistor.newRoot("Pairs");
        StringKeyValuePairsPersistor.save(original, xml);
        StringKeyValuePairs restored = StringKeyValuePairsPersistor.restoreFrom(xml);
        assertEquals(original.size(), restored.size());
        assertEquals("Dantes", restored.get("name"));
        assertEquals(34, restored.getInt("number"));
View Full Code Here

    }

    private void store() throws DataCacheException {
        try {
            File file = createFile();
            XmlPersistor persistor = XmlPersistor.newRoot("Drivers");
            for (DriverDescriptor d : driverDescriptors) {
                Persistor driverPersistor = persistor.createChild("Driver");
                DriverDescriptorPersistor.persist(d, driverPersistor);
            }
            persistor.store(file);
        } catch (Exception ex) {
            throw new DataCacheException(DatabaseMessages.getString("DatabaseDriverCache.StoringError"), ex);
        }
    }
View Full Code Here

    }

    private Collection<DriverDescriptor> readFromFile(File file) throws IOException {
        Collection<DriverDescriptor> drivers = Sets.newHashSet();
        try {
            XmlPersistor persistor = XmlPersistor.load(file);
            for (Persistor driverPersistor : persistor.getChildren("Driver")) {
                DriverDescriptor driver = DriverDescriptorPersistor.restore(driverPersistor);
                drivers.add(driver);
            }
        } catch (SAXException ex) {
            oldFormatFile(file, ex);
View Full Code Here

    private static final boolean PRINT_XML = false;
   
    @Test
    public void testSaveAndLoad() {
        LdapStructure original = createOriginalStructure();
        XmlPersistor xml = XmlPersistor.newRoot("LdapStructure");
        original.writeTo(xml);
        if (PRINT_XML) {
            xml.printToConsole();
        }
        LdapStructure restored = createEmptyStructure(original);
        restored.restoreFrom(xml);
        assertTrue(original.equals(restored));
    }
View Full Code Here

        }
    }

    private void persist() {
        try {
            XmlPersistor xml = XmlPersistor.newRoot("BackupLog");
            for (SortedSet<Entry> entries : backups.values()) {
                for (Entry e : entries) {
                    writeEntry(xml, e);
                }
            }
            xml.store(logFile);
        } catch (IOException ex) {
            ErrorLog.log(BackupLog.class, "Failed to update the project backup log file", ex);
        }
    }
View Full Code Here

        child.putString(TYPE, e.type.name());
    }

    private void load() {
        try {
            XmlPersistor xml = XmlPersistor.load(logFile);
            for (Persistor child : xml.getChildren(ENTRY)) {
                loadEntry(child);
            }
        } catch (Exception ex) {
            ErrorLog.log(BackupLog.class, "Failed to load the project backup log file", ex);
        }
View Full Code Here

TOP

Related Classes of org.jitterbit.util.persist.XmlPersistor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.