当前位置: 首页>>代码示例>>Java>>正文


Java Properties.equals方法代码示例

本文整理汇总了Java中java.util.Properties.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Properties.equals方法的具体用法?Java Properties.equals怎么用?Java Properties.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Properties的用法示例。


在下文中一共展示了Properties.equals方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateConfig

import java.util.Properties; //导入方法依赖的package包/类
private static void generateConfig(FileObject prjDir, String cfgFilePath, EditableProperties propsToWrite) throws IOException {
    
    if (propsToWrite == null) {
        // do not create anything if props is null
        return;
    }
    FileObject jwsConfigFO = FileUtil.createData(prjDir, cfgFilePath);
    Properties props = new Properties();
    InputStream is = jwsConfigFO.getInputStream();
    props.load(is);
    is.close();
    if (props.equals(propsToWrite)) {
        // file already exists and props are the same
        return;
    }
    OutputStream os = jwsConfigFO.getOutputStream();
    propsToWrite.store(os);
    os.close();
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:J2SEProjectConfigurations.java

示例2: call

import java.util.Properties; //导入方法依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:ConcurrentLoadAndStoreXML.java

示例3: testLoadWithoutEncoding

import java.util.Properties; //导入方法依赖的package包/类
/**
 * 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");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:LoadAndStoreXML.java

示例4: onRepositoryChange

import java.util.Properties; //导入方法依赖的package包/类
@Override
public synchronized void onRepositoryChange(String namespace, Properties newProperties) {
  if (newProperties.equals(m_configProperties)) {
    return;
  }
  Properties newConfigProperties = new Properties();
  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();
        }
      });

  m_configProperties = newConfigProperties;
  clearConfigCache();

  this.fireConfigChange(new ConfigChangeEvent(m_namespace, changeMap));

  Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:27,代码来源:SimpleConfig.java

示例5: onRepositoryChange

import java.util.Properties; //导入方法依赖的package包/类
@Override
public synchronized void onRepositoryChange(String namespace, Properties newProperties) {
  if (newProperties.equals(m_configProperties.get())) {
    return;
  }
  Properties newConfigProperties = new Properties();
  newConfigProperties.putAll(newProperties);

  Map<String, ConfigChange> actualChanges = updateAndCalcConfigChanges(newConfigProperties);

  //check double checked result
  if (actualChanges.isEmpty()) {
    return;
  }

  this.fireConfigChange(new ConfigChangeEvent(m_namespace, actualChanges));

  Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:20,代码来源:DefaultConfig.java

示例6: onRepositoryChange

import java.util.Properties; //导入方法依赖的package包/类
@Override
public synchronized void onRepositoryChange(String namespace, Properties newProperties) {
  if (newProperties.equals(m_configProperties.get())) {
    return;
  }
  Properties newConfigProperties = new Properties();
  newConfigProperties.putAll(newProperties);

  String oldValue = getContent();

  update(newProperties);

  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);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:27,代码来源:AbstractConfigFile.java

示例7: setCurrentServer

import java.util.Properties; //导入方法依赖的package包/类
public void setCurrentServer(Properties p) {

    // Check for Basic Types, regardless of other properties
    int index = 0;
    final String type = p.getProperty(TYPE_KEY);
    final String dtype = p.getProperty(DYNAMIC_TYPE);
    final String ctype = p.getProperty(P2P_MODE_KEY);
    for (Enumeration<?> e = addressBook.elements(); e.hasMoreElements();) {
      final AddressBookEntry entry = (AddressBookEntry) e.nextElement();
      final Properties ep = entry.getProperties();

      if (ep.equals(p)) {
        setCurrentServer(index);
        return;
      }

      else if (DYNAMIC_TYPE.equals(type) && DYNAMIC_TYPE.equals(ep.getProperty(TYPE_KEY))
          && ep.getProperty(DYNAMIC_TYPE).equals(dtype)) {
        setCurrentServer(index);
        return;
      }
      else if (P2P_TYPE.equals(type) && P2P_TYPE.equals(ep.getProperty(TYPE_KEY))
          && ep.getProperty(P2P_MODE_KEY).equals(ctype)) {
        setCurrentServer(index);
      }

      index++;
    }

    // Some Server we don't know about, add a server entry
    final AddressBookEntry newEntry = buildEntry(p);
    if (newEntry != null) {
      addressBook.addElement(newEntry);
      setCurrentServer(addressBook.indexOf(newEntry));
    }
    saveAddressBook();

  }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:39,代码来源:ServerAddressBook.java

示例8: onRepositoryChange

import java.util.Properties; //导入方法依赖的package包/类
@Override
public void onRepositoryChange(String namespace, Properties newProperties) {
  if (newProperties.equals(m_fileProperties)) {
    return;
  }
  Properties newFileProperties = new Properties();
  newFileProperties.putAll(newProperties);
  updateFileProperties(newFileProperties);
  this.fireRepositoryChange(namespace, newProperties);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:11,代码来源:LocalFileConfigRepository.java

示例9: updateFileProperties

import java.util.Properties; //导入方法依赖的package包/类
private synchronized void updateFileProperties(Properties newProperties) {
  if (newProperties.equals(m_fileProperties)) {
    return;
  }
  this.m_fileProperties = newProperties;
  persistLocalCacheFile(m_baseDir, m_namespace);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:8,代码来源:LocalFileConfigRepository.java

示例10: isPropertiesEqual

import java.util.Properties; //导入方法依赖的package包/类
public static boolean isPropertiesEqual(final Properties p1, final Properties p2) {
    return p1.equals(p2);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:4,代码来源:MixAll.java

示例11: getSystem

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Returns this VM's connection to the distributed system.  If
 * necessary, the connection will be lazily created using the given
 * <code>Properties</code>.  Note that this method uses hydra's
 * configuration to determine the location of log files, etc.
 * Note: "final" was removed so that WANTestBase can override this method.
 * This was part of the xd offheap merge.
 *
 * @see hydra.DistributedConnectionMgr#connect
 * @since 3.0
 */
public /*final*/ InternalDistributedSystem getSystem(Properties props) {
  // Setting the default disk store name is now done in setUp
  if (system == null) {
    system = InternalDistributedSystem.getAnyInstance();
  }
  if (system == null || !system.isConnected()) {
    // Figure out our distributed system properties
    Properties p = getAllDistributedSystemProperties(props);
    lastSystemCreatedInTest = getTestClass();
    if (logPerTest) {
      String testMethod = getTestName();
      String testName = lastSystemCreatedInTest.getName() + '-' + testMethod;
      String oldLogFile = p.getProperty(DistributionConfig.LOG_FILE_NAME);
      p.put(DistributionConfig.LOG_FILE_NAME,
          oldLogFile.replace("system.log", testName+".log"));
      String oldStatFile = p.getProperty(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME);
      p.put(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME,
          oldStatFile.replace("statArchive.gfs", testName+".gfs"));
    }
    system = (InternalDistributedSystem)DistributedSystem.connect(p);
    lastSystemProperties = p;
  } else {
    boolean needNewSystem = false;
    if(!getTestClass().equals(lastSystemCreatedInTest)) {
      Properties newProps = getAllDistributedSystemProperties(props);
      needNewSystem = !newProps.equals(lastSystemProperties);
      if(needNewSystem) {
        getLogWriter().info(
            "Test class has changed and the new DS properties are not an exact match. "
                + "Forcing DS disconnect. Old props = "
                + lastSystemProperties + "new props=" + newProps);
      }
    } else {
      Properties activeProps = system.getProperties();
      for (Iterator iter = props.entrySet().iterator();
           iter.hasNext(); ) {
        Map.Entry entry = (Map.Entry) iter.next();
        String key = (String) entry.getKey();
        String value = (String) entry.getValue();
        if (!value.equals(activeProps.getProperty(key))) {
          needNewSystem = true;
          getLogWriter().info("Forcing DS disconnect. For property " + key
              + " old value = " + activeProps.getProperty(key)
              + " new value = " + value);
          break;
        }
      }
    }
    if(needNewSystem) {
      // the current system does not meet our needs to disconnect and
      // call recursively to get a new system.
      getLogWriter().info("Disconnecting from current DS in order to make a new one");
      disconnectFromDS();
      getSystem(props);
    }
  }
  return system;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:70,代码来源:DistributedTestCase.java

示例12: getSystem

import java.util.Properties; //导入方法依赖的package包/类
/**
 * Returns this VM's connection to the distributed system. If necessary, the connection will be
 * lazily created using the given {@code Properties}.
 *
 * <p>
 * Do not override this method. Override {@link #getDistributedSystemProperties()} instead.
 *
 * <p>
 * Note: "final" was removed so that WANTestBase can override this method. This was part of the xd
 * offheap merge.
 *
 * @since GemFire 3.0
 */
public final InternalDistributedSystem getSystem(final Properties props) {
  // Setting the default disk store name is now done in setUp
  if (system == null) {
    system = InternalDistributedSystem.getAnyInstance();
  }
  if (system == null || !system.isConnected()) {
    // Figure out our distributed system properties
    Properties p = DistributedTestUtils.getAllDistributedSystemProperties(props);
    lastSystemCreatedInTest = getTestClass(); // used to be getDeclaringClass()
    if (logPerTest) {
      String testMethod = getTestMethodName();
      String testName = lastSystemCreatedInTest.getName() + '-' + testMethod;
      String oldLogFile = p.getProperty(LOG_FILE);
      p.put(LOG_FILE, oldLogFile.replace("system.log", testName + ".log"));
      String oldStatFile = p.getProperty(STATISTIC_ARCHIVE_FILE);
      p.put(STATISTIC_ARCHIVE_FILE, oldStatFile.replace("statArchive.gfs", testName + ".gfs"));
    }
    system = (InternalDistributedSystem) DistributedSystem.connect(p);
    lastSystemProperties = p;
  } else {
    boolean needNewSystem = false;
    if (!getTestClass().equals(lastSystemCreatedInTest)) { // used to be getDeclaringClass()
      Properties newProps = DistributedTestUtils.getAllDistributedSystemProperties(props);
      needNewSystem = !newProps.equals(lastSystemProperties);
      if (needNewSystem) {
        LogWriterUtils.getLogWriter()
            .info("Test class has changed and the new DS properties are not an exact match. "
                + "Forcing DS disconnect. Old props = " + lastSystemProperties + "new props="
                + newProps);
      }
    } else {
      Properties activeProps = system.getProperties();
      for (Iterator iter = props.entrySet().iterator(); iter.hasNext();) {
        Map.Entry entry = (Map.Entry) iter.next();
        String key = (String) entry.getKey();
        String value = (String) entry.getValue();
        if (!value.equals(activeProps.getProperty(key))) {
          needNewSystem = true;
          LogWriterUtils.getLogWriter().info("Forcing DS disconnect. For property " + key
              + " old value = " + activeProps.getProperty(key) + " new value = " + value);
          break;
        }
      }
    }
    if (needNewSystem) {
      // the current system does not meet our needs to disconnect and
      // call recursively to get a new system.
      LogWriterUtils.getLogWriter()
          .info("Disconnecting from current DS in order to make a new one");
      disconnectFromDS();
      getSystem(props);
    }
  }
  return system;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:69,代码来源:JUnit4DistributedTestCase.java


注:本文中的java.util.Properties.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。