/** * Performs a correct deep clone of the properties object by capturing * all properties in the default(s) and placing them directly into the * new Properties object. */ public static Properties clone( Properties props ) { return clone(props, null, false); }
/** * Performs a correct deep clone of the properties object by capturing * all properties in the default(s) and placing them directly into the * new Properties object. */ public static Properties clone( Properties props ) { return clone(props, null, false); }
/** * Performs a correct deep clone of the properties object by capturing * all properties in the default(s) and placing them directly into the * new Properties object. */ public static Properties clone( Properties props, Properties defaults, boolean deepClone ) { Properties result = null; if ( defaults != null ) { if ( deepClone ) { defaults = clone(defaults); } result = new Properties(defaults); } else { result = new Properties(); } putAll(result, props); return result; }
/** * Performs a correct deep clone of the properties object by capturing * all properties in the default(s) and placing them directly into the * new Properties object. */ public static Properties clone( Properties props, Properties defaults, boolean deepClone ) { Properties result = null; if ( defaults != null ) { if ( deepClone ) { defaults = clone(defaults); } result = new Properties(defaults); } else { result = new Properties(); } putAll(result, props); return result; }
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { if(info == null) { info = new Properties(); } else { info = PropertiesUtils.clone(info); } // construct list of driverPropertyInfo objects List<DriverPropertyInfo> driverProps = new LinkedList<DriverPropertyInfo>(); parseURL(url, info); for (String property: JDBCURL.KNOWN_PROPERTIES.keySet()) { DriverPropertyInfo dpi = new DriverPropertyInfo(property, info.getProperty(property)); if (property.equals(BaseDataSource.VDB_NAME)) { dpi.required = true; } dpi.description = JDBCPlugin.Util.getString(property + "_desc"); //$NON-NLS-1$ if (JDBCPlugin.Util.keyExists(property + "_choices")) { //$NON-NLS-1$ dpi.choices = JDBCPlugin.Util.getString(property + "_choices").split(","); //$NON-NLS-1$ //$NON-NLS-2$ } driverProps.add(dpi); } // create an array of DriverPropertyInfo objects DriverPropertyInfo [] propInfo = new DriverPropertyInfo[driverProps.size()]; // copy the elements from the list to the array return driverProps.toArray(propInfo); }
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { if(info == null) { info = new Properties(); } else { info = PropertiesUtils.clone(info); } // construct list of driverPropertyInfo objects List<DriverPropertyInfo> driverProps = new LinkedList<DriverPropertyInfo>(); parseURL(url, info); for (String property: JDBCURL.KNOWN_PROPERTIES.keySet()) { DriverPropertyInfo dpi = new DriverPropertyInfo(property, info.getProperty(property)); if (property.equals(BaseDataSource.VDB_NAME)) { dpi.required = true; } dpi.description = JDBCPlugin.Util.getString(property + "_desc"); //$NON-NLS-1$ if (JDBCPlugin.Util.keyExists(property + "_choices")) { //$NON-NLS-1$ dpi.choices = JDBCPlugin.Util.getString(property + "_choices").split(","); //$NON-NLS-1$ //$NON-NLS-2$ } driverProps.add(dpi); } // create an array of DriverPropertyInfo objects DriverPropertyInfo [] propInfo = new DriverPropertyInfo[driverProps.size()]; // copy the elements from the list to the array return driverProps.toArray(propInfo); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, boolean)} */ @Test public void testCloneModifiableAsModifiable(){ Properties a = make(MAP_A, null, !UNMODIFIABLE); a = PropertiesUtils.clone(a); assertTrue(verifyProps(a, LIST_A)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties)} */ @Test public void testSimpleModifiableClone(){ Properties a = make(MAP_A, null, !UNMODIFIABLE); a = PropertiesUtils.clone(a); assertTrue(verifyProps(a, LIST_A)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, boolean)} */ @Test public void testCloneUnmodifiableAsModifiable(){ Properties a = make(MAP_A, null, UNMODIFIABLE); a = PropertiesUtils.clone(a); assertTrue(verifyProps(a, LIST_A)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties)} */ @Test public void testSimpleModifiableCloneWithModifiableDefaults(){ Properties ab = make(MAP_A, make(MAP_B, null, !UNMODIFIABLE), !UNMODIFIABLE); ab = PropertiesUtils.clone(ab); assertTrue(verifyProps(ab, LIST_AB)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)} */ @Test public void testCloneModAndModAsMod(){ Properties a = make(MAP_A, null, !UNMODIFIABLE); Properties b = make(MAP_B, null, !UNMODIFIABLE); a = PropertiesUtils.clone(a, b, !DEEP_CLONE); assertTrue(verifyProps(a, LIST_AB)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)} */ @Test public void testDeepcloneModAndModAsMod(){ Properties a = make(MAP_A, null, !UNMODIFIABLE); Properties b = make(MAP_B, null, !UNMODIFIABLE); a = PropertiesUtils.clone(a, b, DEEP_CLONE); assertTrue(verifyProps(a, LIST_AB)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)} */ @Test public void testCloneModAndUnmodAsMod(){ Properties a = make(MAP_A, null, !UNMODIFIABLE); Properties b = make(MAP_B, null, UNMODIFIABLE); a = PropertiesUtils.clone(a, b, !DEEP_CLONE); assertTrue(verifyProps(a, LIST_AB)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)} */ @Test public void testCloneUnmodAndUnmodAsMod(){ Properties a = make(MAP_A, null, UNMODIFIABLE); Properties b = make(MAP_B, null, UNMODIFIABLE); a = PropertiesUtils.clone(a, b, !DEEP_CLONE); assertTrue(verifyProps(a, LIST_AB)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)} */ @Test public void testDeepcloneUnmodAndUnmodAsMod(){ Properties a = make(MAP_A, null, UNMODIFIABLE); Properties b = make(MAP_B, null, UNMODIFIABLE); a = PropertiesUtils.clone(a, b, DEEP_CLONE); assertTrue(verifyProps(a, LIST_AB)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties)} */ @Test public void testSimpleModifiableCloneWithUnmodifiableDefaults(){ Properties ab = make(MAP_A, make(MAP_B, null, UNMODIFIABLE), !UNMODIFIABLE); ab = PropertiesUtils.clone(ab); assertTrue(verifyProps(ab, LIST_AB)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, boolean)} */ @Test public void testCloneModifiableWithModifiableAsModifiable(){ Properties ab = make(MAP_A, make(MAP_B, null, !UNMODIFIABLE), !UNMODIFIABLE); ab = PropertiesUtils.clone(ab); assertTrue(verifyProps(ab, LIST_AB)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)} */ @Test public void testDeepcloneModAndUnmodAsMod(){ Properties a = make(MAP_A, null, !UNMODIFIABLE); Properties b = make(MAP_B, null, UNMODIFIABLE); a = PropertiesUtils.clone(a, b, DEEP_CLONE); assertTrue(verifyProps(a, LIST_AB)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)} */ @Test public void testCloneUnmodAndModAsMod(){ Properties a = make(MAP_A, null, UNMODIFIABLE); Properties b = make(MAP_B, null, !UNMODIFIABLE); a = PropertiesUtils.clone(a, b, !DEEP_CLONE); assertTrue(verifyProps(a, LIST_AB)); }
/** * Tests {@link org.teiid.core.util.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)} */ @Test public void testDeepcloneUnmodAndModAsMod(){ Properties a = make(MAP_A, null, UNMODIFIABLE); Properties b = make(MAP_B, null, !UNMODIFIABLE); a = PropertiesUtils.clone(a, b, DEEP_CLONE); assertTrue(verifyProps(a, LIST_AB)); }