Java Code Examples for java.util.Properties#equals()
The following examples show how to use
java.util.Properties#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConcurrentLoadAndStoreXML.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public Void call() throws IOException { while (!done) { // store as XML format ByteArrayOutputStream out = new ByteArrayOutputStream(); props.storeToXML(out, null, "UTF-8"); // load from XML format Properties p = new Properties(); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); p.loadFromXML(in); // check that the properties are as expected if (!p.equals(props)) throw new RuntimeException("Properties not equal"); } return null; }
Example 2
Source File: ConcurrentLoadAndStoreXML.java From hottub with GNU General Public License v2.0 | 6 votes |
public Void call() throws IOException { while (!done) { // store as XML format ByteArrayOutputStream out = new ByteArrayOutputStream(); props.storeToXML(out, null, "UTF-8"); // load from XML format Properties p = new Properties(); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); p.loadFromXML(in); // check that the properties are as expected if (!p.equals(props)) throw new RuntimeException("Properties not equal"); } return null; }
Example 3
Source File: ConcurrentLoadAndStoreXML.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public Void call() throws IOException { while (!done) { // store as XML format ByteArrayOutputStream out = new ByteArrayOutputStream(); props.storeToXML(out, null, "UTF-8"); // load from XML format Properties p = new Properties(); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); p.loadFromXML(in); // check that the properties are as expected if (!p.equals(props)) throw new RuntimeException("Properties not equal"); } return null; }
Example 4
Source File: ConcurrentLoadAndStoreXML.java From native-obfuscator with GNU General Public License v3.0 | 6 votes |
public Void call() throws IOException { while (!done) { // store as XML format ByteArrayOutputStream out = new ByteArrayOutputStream(); props.storeToXML(out, null, "UTF-8"); // load from XML format Properties p = new Properties(); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); p.loadFromXML(in); // check that the properties are as expected if (!p.equals(props)) throw new RuntimeException("Properties not equal"); } return null; }
Example 5
Source File: ConcurrentLoadAndStoreXML.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public Void call() throws IOException { while (!done) { // store as XML format ByteArrayOutputStream out = new ByteArrayOutputStream(); props.storeToXML(out, null, "UTF-8"); // load from XML format Properties p = new Properties(); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); p.loadFromXML(in); // check that the properties are as expected if (!p.equals(props)) throw new RuntimeException("Properties not equal"); } return null; }
Example 6
Source File: SimpleConfig.java From apollo with Apache License 2.0 | 6 votes |
@Override public synchronized void onRepositoryChange(String namespace, Properties newProperties) { if (newProperties.equals(m_configProperties)) { return; } Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); newConfigProperties.putAll(newProperties); List<ConfigChange> changes = calcPropertyChanges(namespace, m_configProperties, newConfigProperties); Map<String, ConfigChange> changeMap = Maps.uniqueIndex(changes, new Function<ConfigChange, String>() { @Override public String apply(ConfigChange input) { return input.getPropertyName(); } }); updateConfig(newConfigProperties, m_configRepository.getSourceType()); clearConfigCache(); this.fireConfigChange(new ConfigChangeEvent(m_namespace, changeMap)); Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace); }
Example 7
Source File: AccountImpl.java From java-trader with Apache License 2.0 | 6 votes |
/** * 更新配置属性 * @return true 如果有变化, false 如果相同 */ public boolean update(Map configElem) { boolean result = false; IniFile configIni = null; try{ configIni = new IniFile(new StringReader((String)configElem.get("text"))); }catch(Throwable t) { throw new RuntimeException(t); } IniFile.Section brokerMarginRatioSection = configIni.getSection("brokerMarginRatio"); Properties brokerMarginRatio2 = new Properties(); if( brokerMarginRatioSection!=null ) { brokerMarginRatio2 = brokerMarginRatioSection.getProperties(); } if ( !brokerMarginRatio.equals(brokerMarginRatio2)) { this.brokerMarginRatio = brokerMarginRatio2; result = true; } Properties connectionProps2 = configIni.getSection("connectionProps").getProperties(); if ( !connectionProps2.equals(connectionProps) ) { this.connectionProps = connectionProps2; result = true; } return result; }
Example 8
Source File: ConcurrentLoadAndStoreXML.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public Void call() throws IOException { while (!done) { // store as XML format ByteArrayOutputStream out = new ByteArrayOutputStream(); props.storeToXML(out, null, "UTF-8"); // load from XML format Properties p = new Properties(); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); p.loadFromXML(in); // check that the properties are as expected if (!p.equals(props)) throw new RuntimeException("Properties not equal"); } return null; }
Example 9
Source File: Connection.java From birt with Eclipse Public License 1.0 | 6 votes |
private static Properties adjustDbProfileProperties( Properties dataSourceProperties ) throws OdaException { // first adapts to db profile properties Properties dbProfileProps = PropertyAdapter.adaptToDbProfilePropertyNames( dataSourceProperties ); // use the oda.consumer.propertyProvider extension implemented for the profile's definition type, // to get the effective properties to open a connection String defnType = dbProfileProps.getProperty( IDriverMgmtConstants.PROP_DEFN_TYPE ); Map<String,String> appContext = new HashMap<String, String>(); appContext.put( IPropertyProvider.ODA_CONSUMER_ID, defnType ); Properties adjustedDbProfileProps = ProviderUtil.getEffectiveProperties( dbProfileProps, appContext ); if( dbProfileProps.equals( adjustedDbProfileProps ) ) return dataSourceProperties; // no adjustment is applicable // adapt adjusted db profile properties back to data source properties return PropertyAdapter.adaptToDataSourcePropertyNames( adjustedDbProfileProps ); }
Example 10
Source File: LoadAndStoreXML.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Test loadFromXML with a document that does not have an encoding declaration */ static void testLoadWithoutEncoding() throws IOException { System.out.println("testLoadWithoutEncoding"); Properties expected = new Properties(); expected.put("foo", "bar"); String s = "<?xml version=\"1.0\"?>" + "<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">" + "<properties>" + "<entry key=\"foo\">bar</entry>" + "</properties>"; ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes("UTF-8")); Properties props = new Properties(); props.loadFromXML(in); if (!props.equals(expected)) { System.err.println("loaded: " + props + ", expected: " + expected); throw new RuntimeException("Test failed"); } }
Example 11
Source File: ConcurrentLoadAndStoreXML.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public Void call() throws IOException { while (!done) { // store as XML format ByteArrayOutputStream out = new ByteArrayOutputStream(); props.storeToXML(out, null, "UTF-8"); // load from XML format Properties p = new Properties(); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); p.loadFromXML(in); // check that the properties are as expected if (!p.equals(props)) throw new RuntimeException("Properties not equal"); } return null; }
Example 12
Source File: LocalFileConfigRepository.java From apollo with Apache License 2.0 | 5 votes |
private synchronized void updateFileProperties(Properties newProperties, ConfigSourceType sourceType) { this.m_sourceType = sourceType; if (newProperties.equals(m_fileProperties)) { return; } this.m_fileProperties = newProperties; persistLocalCacheFile(m_baseDir, m_namespace); }
Example 13
Source File: LocalFileConfigRepository.java From apollo with Apache License 2.0 | 5 votes |
@Override public void onRepositoryChange(String namespace, Properties newProperties) { if (newProperties.equals(m_fileProperties)) { return; } Properties newFileProperties = propertiesFactory.getPropertiesInstance(); newFileProperties.putAll(newProperties); updateFileProperties(newFileProperties, m_upstream.getSourceType()); this.fireRepositoryChange(namespace, newProperties); }
Example 14
Source File: AbstractConfigFile.java From apollo with Apache License 2.0 | 5 votes |
@Override public synchronized void onRepositoryChange(String namespace, Properties newProperties) { if (newProperties.equals(m_configProperties.get())) { return; } Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); newConfigProperties.putAll(newProperties); String oldValue = getContent(); update(newProperties); m_sourceType = m_configRepository.getSourceType(); String newValue = getContent(); PropertyChangeType changeType = PropertyChangeType.MODIFIED; if (oldValue == null) { changeType = PropertyChangeType.ADDED; } else if (newValue == null) { changeType = PropertyChangeType.DELETED; } this.fireConfigChange(new ConfigFileChangeEvent(m_namespace, oldValue, newValue, changeType)); Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace); }
Example 15
Source File: PropertyReaderExtensionOperation.java From product-ei with Apache License 2.0 | 5 votes |
@Override protected void runSync(ExtensionContext extensionContext, Element element) throws FaultException { Properties properties = null; String fileLocation = element.getAttribute("location").trim(); String source = fileLocation.split(":")[0]; if (source.equals("file")) { properties = getPropertiesFromLocalFile(fileLocation.split(":")[1]); } else if (source.equals("conf")) { properties = getPropertiesFromConfigRegistryFile(fileLocation.split(":")[1]); } else if (source.equals("gov")) { properties = getPropertiesFromGovernanceFile(fileLocation.split(":")[1]); } else { System.out.println("File Location Error !!"); } NodeList propertyNameList = element.getElementsByTagName("property"); for (int i = 0; i < propertyNameList.getLength() && !properties.equals(null); i++) { Element property = (Element) propertyNameList.item(i); String propertyName = property.getAttribute("name").trim(); String value = properties.getProperty(propertyName, ""); Element to = (Element) property.getElementsByTagName("to").item(0); String variable = to.getAttribute("variable").trim(); extensionContext.readVariable(variable.trim()).setTextContent(value.trim()); } }
Example 16
Source File: HBaseConnectionPool.java From pentaho-hadoop-shims with Apache License 2.0 | 5 votes |
/** * Gets a connection with the given target table and properties * <p/> * Tries to get one with the correct target table and properties, then prefers one without a target table, then one * with a different target table and properties * * @param targetTable * @param targetTableProps * @return * @throws IOException */ public synchronized HBaseConnectionHandle getConnectionHandle( String targetTable, Properties targetTableProps ) throws IOException { HBaseConnectionPoolConnection result = findBestMatch( targetTable, targetTableProps ); if ( result != null ) { availableConnections.remove( result ); } else { result = create(); } boolean targetTableDifferent = targetTable != null && !targetTable.equals( result.getTargetTable() ); boolean propsDifferent = false; Properties resultTargetTableProperties = result.getTargetTableProperties(); if ( targetTableProps == null ) { propsDifferent = resultTargetTableProperties != null; } else { propsDifferent = targetTableProps.equals( resultTargetTableProperties ); } if ( targetTableDifferent || propsDifferent ) { try { result.newTargetTableInternal( targetTable, targetTableProps ); } catch ( Exception e ) { throw new IOException( e ); } } inUseConnections.add( result ); return new HBaseConnectionHandleImpl( this, result ); }
Example 17
Source File: IOUtils.java From openmessaging-storage-dledger with Apache License 2.0 | 4 votes |
public static boolean isPropertiesEqual(final Properties p1, final Properties p2) { return p1.equals(p2); }
Example 18
Source File: MixAll.java From rocketmq with Apache License 2.0 | 4 votes |
public static boolean isPropertiesEqual(final Properties p1, final Properties p2) { return p1.equals(p2); }
Example 19
Source File: MixAll.java From rocketmq-4.3.0 with Apache License 2.0 | 4 votes |
public static boolean isPropertiesEqual(final Properties p1, final Properties p2) { return p1.equals(p2); }
Example 20
Source File: MixAll.java From rocketmq-read with Apache License 2.0 | 2 votes |
/** * properties 是否相等 * @param p1 p1 * @param p2 p2 * @return */ public static boolean isPropertiesEqual(final Properties p1, final Properties p2) { return p1.equals(p2); }