@Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((_nodeKey == null) ? 0 : Arrays.hashCode(_nodeKey.getEncoded()));
   result = prime * result + ((_nodeName == null) ? 0 : _nodeName.hashCode());
   result = prime * result + Arrays.hashCode(_storedNodeKeyID);
   result = prime * result + ((_storedNodeKeyName == null) ? 0 : _storedNodeKeyName.hashCode());
   return result;
 }
  @Test
  public void testSaveAsGone() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testSaveAsGone");

    NDNHandle thandle = NDNHandle.open();
    NDNHandle rhandle = NDNHandle.open();
    NDNHandle shandle = NDNHandle.open();

    try {
      ContentName testName =
          new ContentName(testHelper.getTestNamespace("testSaveAsGone"), collectionObjName);
      CollectionObject c0 = new CollectionObject(testName, empty, SaveType.REPOSITORY, thandle);
      setupNamespace(testName);
      NDNTime t0 = saveAsGoneAndLog("Gone", c0);
      Assert.assertTrue("Should be gone", c0.isGone());
      ContentName goneVersionName = c0.getVersionedName();

      NDNTime t1 = saveAndLog("NotGone", c0, null, small1);
      TestUtils.checkObject(thandle, c0);
      Assert.assertFalse("Should not be gone", c0.isGone());
      Assert.assertTrue(t1.after(t0));

      CollectionObject c1 = new CollectionObject(testName, rhandle);
      NDNTime t2 = waitForDataAndLog(testName.toString(), c1);
      Assert.assertFalse("Read back should not be gone", c1.isGone());
      Assert.assertEquals(t2, t1);

      NDNTime t3 = updateAndLog(goneVersionName.toString(), c1, goneVersionName);
      Assert.assertTrue(VersioningProfile.isVersionOf(c1.getVersionedName(), testName));
      Assert.assertEquals(t3, t0);
      Assert.assertTrue("Read back should be gone.", c1.isGone());

      t0 = saveAsGoneAndLog("GoneAgain", c0);
      Assert.assertTrue("Should be gone", c0.isGone());

      CollectionObject c2 = new CollectionObject(testName, shandle);
      NDNTime t4 = waitForDataAndLog(testName.toString(), c2);
      Assert.assertTrue(
          "Read back of " + c0.getVersionedName() + " should be gone, got " + c2.getVersionedName(),
          c2.isGone());
      Assert.assertEquals(t4, t0);
    } finally {
      thandle.close();
      rhandle.close();
      shandle.close();
      KeyManager.closeDefaultKeyManager();
    }

    Log.info(Log.FAC_TEST, "Completed testSaveAsGone");
  }
  /**
   * Initialize internal policy state, from file if policyFile != null This method is intended to be
   * called at the beginning of a subclass initialize() method to handle the generic policy setup,
   * after which the subclass initialize() should adjust policy (including calling readPolicy) as
   * appropriate. If both "policy file" and "initial namespace" are non-null the policy file takes
   * precedence
   *
   * @param policyFile policy file
   * @param initial namespace
   * @throws RepositoryException
   * @throws FileNotFoundException
   * @throws ContentDecodingException
   * @throws MalformedContentNameStringException
   */
  public PolicyXML startInitPolicy(File policyFile, String nameSpace) throws RepositoryException {
    BasicPolicy policy = new BasicPolicy(null);
    policy.setVersion(getVersion());

    if (null != policyFile) {
      try {
        FileInputStream fis = new FileInputStream(policyFile);
        try {
          policy.updateFromInputStream(fis);
        } finally {
          try {
            fis.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      } catch (FileNotFoundException e) {
        throw new RepositoryException(e.getMessage());
      }
    } else if (null != nameSpace) { // Try setting an initial namespace from the namespace parameter
      ArrayList<ContentName> nameSpaceAL = new ArrayList<ContentName>(1);
      try {
        nameSpaceAL.add(ContentName.fromNative(nameSpace));
      } catch (MalformedContentNameStringException e) {
        Log.warning(Log.FAC_REPO, "Invalid namespace specified: {0}", nameSpace);
      }
      policy.setNamespace(nameSpaceAL);
    }
    return policy.getPolicyXML();
  }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   NodeKey other = (NodeKey) obj;
   if (_nodeKey == null) {
     if (other._nodeKey != null) return false;
   } else if (other._nodeKey == null) {
     return false;
   } else if (!Arrays.equals(_nodeKey.getEncoded(), other._nodeKey.getEncoded())) {
     return false;
   }
   if (_nodeName == null) {
     if (other._nodeName != null) return false;
   } else if (!_nodeName.equals(other._nodeName)) return false;
   if (!Arrays.equals(_storedNodeKeyID, other._storedNodeKeyID)) return false;
   if (_storedNodeKeyName == null) {
     if (other._storedNodeKeyName != null) return false;
   } else if (!_storedNodeKeyName.equals(other._storedNodeKeyName)) return false;
   return true;
 }
 public String toString() {
   if (name == null) return new String("/");
   ContentName n = new ContentName(name);
   return n.toString().replaceFirst("/", "");
 }