String lastValue = escapeValue(it.next(), true, transformer); final StringBuilder buf = new StringBuilder(lastValue); while (it.hasNext()) && (countTrailingBS(lastValue) / 2) % 2 != 0) buf.append(getDelimiter()); lastValue = escapeValue(it.next(), true, transformer); buf.append(lastValue);
/** * Escapes the given property value. This method is called on saving the * configuration for each property value. It ensures a correct handling of * backslash characters and also takes care that list delimiter characters * in the value are escaped. * * @param value the property value * @param inList a flag whether the value is part of a list * @param transformer the {@code ValueTransformer} * @return the escaped property value */ protected String escapeValue(final Object value, final boolean inList, final ValueTransformer transformer) { String escapedValue = String.valueOf(transformer.transformValue(escapeBackslashs( value, inList))); if (getDelimiter() != 0) { escapedValue = StringUtils.replace(escapedValue, String.valueOf(getDelimiter()), ESCAPE + getDelimiter()); } return escapedValue; }
public static DbDataComparisonConfig createFromProperties(String path) { try { URL url = DbDataComparisonConfigFactory.class.getClassLoader().getResource(path); if (url == null) { url = new File(path).toURI().toURL(); } if (url == null) { throw new IllegalArgumentException("Could not find resource or file at path: " + path); } return createFromProperties(new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class).configure(new Parameters().properties() .setURL(url) .setListDelimiterHandler(new LegacyListDelimiterHandler(',')) ).getConfiguration()); } catch (ConfigurationException e) { throw new RuntimeException(e); } catch (MalformedURLException e) { throw new IllegalArgumentException("Could not find resource or file at path: " + path, e); } }
/** * {@inheritDoc} This implementation performs delimiter escaping for a * single value (which is not part of a list). */ @Override public Object escape(final Object value, final ValueTransformer transformer) { return escapeValue(value, false, transformer); }
protected Collection<String> splitString(final String s, final boolean trim) if (s.indexOf(getDelimiter()) < 0) if (c != getDelimiter() && c != esc) if (c == getDelimiter())
public static DbDataComparisonConfig createFromProperties(String path) { try { URL url = DbDataComparisonConfigFactory.class.getClassLoader().getResource(path); if (url == null) { url = new File(path).toURI().toURL(); } if (url == null) { throw new IllegalArgumentException("Could not find resource or file at path: " + path); } return createFromProperties(new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class).configure(new Parameters().properties() .setURL(url) .setListDelimiterHandler(new LegacyListDelimiterHandler(',')) ).getConfiguration()); } catch (ConfigurationException e) { throw new RuntimeException(e); } catch (MalformedURLException e) { throw new IllegalArgumentException("Could not find resource or file at path: " + path, e); } }
public void execute(DbFileMergerArgs args) { Configuration config; try { config = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) .configure(new Parameters().properties() .setFile(args.getDbMergeConfigFile()) .setListDelimiterHandler(new LegacyListDelimiterHandler(',')) ).getConfiguration(); } catch (ConfigurationException e) { throw new RuntimeException(e); } RichIterable<DbMergeInfo> dbMergeInfos = DbMergeInfo.parseFromProperties(config); RichIterable<TableSyncSide> tableSyncSides = dbMergeInfos.collect(new Function<DbMergeInfo, TableSyncSide>() { @Override public TableSyncSide valueOf(DbMergeInfo dbMergeInfo) { DataSource ds = ds(dbMergeInfo.getDriverClassName(), dbMergeInfo.getUrl(), dbMergeInfo.getUsername(), dbMergeInfo.getPassword()); return new TableSyncSide(ds, PhysicalSchema.parseFromString(dbMergeInfo.getPhysicalSchema())); } }); this.syncSchemaTables(DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType")), tableSyncSides, args.getOutputDir()); }
public void execute(DbFileMergerArgs args) { Configuration config; try { config = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) .configure(new Parameters().properties() .setFile(args.getDbMergeConfigFile()) .setListDelimiterHandler(new LegacyListDelimiterHandler(',')) ).getConfiguration(); } catch (ConfigurationException e) { throw new RuntimeException(e); } RichIterable<DbMergeInfo> dbMergeInfos = DbMergeInfo.parseFromProperties(config); RichIterable<TableSyncSide> tableSyncSides = dbMergeInfos.collect(new Function<DbMergeInfo, TableSyncSide>() { @Override public TableSyncSide valueOf(DbMergeInfo dbMergeInfo) { DataSource ds = ds(dbMergeInfo.getDriverClassName(), dbMergeInfo.getUrl(), dbMergeInfo.getUsername(), dbMergeInfo.getPassword()); return new TableSyncSide(ds, PhysicalSchema.parseFromString(dbMergeInfo.getPhysicalSchema())); } }); this.syncSchemaTables(DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType")), tableSyncSides, args.getOutputDir()); }
public void execute(DbFileMergerArgs args) { PropertiesConfiguration config; RichIterable<DbMergeInfo> dbNameLocationPairs; try { config = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) .configure(new Parameters().properties() .setFile(args.getDbMergeConfigFile()) .setListDelimiterHandler(new LegacyListDelimiterHandler(',')) ) .getConfiguration(); dbNameLocationPairs = DbMergeInfo.parseFromProperties(config); } catch (Exception e) { throw new DeployerRuntimeException("Exception reading configs from file " + args.getDbMergeConfigFile(), e); } DbPlatform dialect = DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType")); this.generateDiffs(dialect, dbNameLocationPairs, args.getOutputDir()); }
public void execute(DbFileMergerArgs args) { PropertiesConfiguration config; RichIterable<DbMergeInfo> dbNameLocationPairs; try { config = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class) .configure(new Parameters().properties() .setFile(args.getDbMergeConfigFile()) .setListDelimiterHandler(new LegacyListDelimiterHandler(',')) ) .getConfiguration(); dbNameLocationPairs = DbMergeInfo.parseFromProperties(config); } catch (Exception e) { throw new DeployerRuntimeException("Exception reading configs from file " + args.getDbMergeConfigFile(), e); } DbPlatform dialect = DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType")); this.generateDiffs(dialect, dbNameLocationPairs, args.getOutputDir()); }