VersioningProfile implements CCNProfile { public static ContentName addVersion(ContentName name, long version) { byte [] vcomp = null; if (0 == version) { vcomp = FIRST_VERSION_MARKER; } else { vcomp = DataUtils.unsignedLongToByteArray(version, VERSION_MARKER); } return new ContentName(name, vcomp); }  static ContentName addVersion(ContentName name, long version); @Deprecated static ContentName addVersion(ContentName name, CCNTime version); static ContentName addVersion(ContentName name); static byte [] timeToVersionComponent(CCNTime version); static String printAsVersionComponent(CCNTime version); static ContentName updateVersion(ContentName name, long version); static ContentName updateVersion(ContentName name, CCNTime version); static ContentName updateVersion(ContentName name); static int findLastVersionComponent(ContentName name); static boolean containsVersion(ContentName name); static boolean hasTerminalVersion(ContentName name); static boolean isVersionComponent(byte [] nameComponent); static boolean isBaseVersionComponent(byte [] nameComponent); static Tuple<ContentName, byte[]> cutTerminalVersion(ContentName name); static ContentName cutLastVersion(ContentName name); static long getLastVersionAsLong(ContentName name); static byte [] getLastVersionComponent(ContentName name); static long getVersionComponentAsLong(final byte [] versionComponent); static CCNTime getVersionComponentAsTimestamp(byte [] versionComponent); static CCNTime getLastVersionAsTimestamp(ContentName name); static CCNTime getLastVersionAsTimestampIfVersioned(ContentName name); static CCNTime getTerminalVersionAsTimestampIfVersioned(ContentName name); static CCNTime versionLongToTimestamp(long version); static final int baseVersion(); static int compareVersions(
			CCNTime left,
			ContentName right); static int compareVersionComponents(
			byte [] left,
			byte [] right); static boolean isVersionOf(ContentName version, ContentName parent); static boolean isLaterVersionOf(ContentName laterVersion, ContentName earlierVersion); static boolean startsWithLaterVersionOf(ContentName newName, ContentName previousVersion); static int compareTerminalVersions(ContentName laterVersion, ContentName earlierVersion); static Exclude acceptVersions(byte [] startingVersionComponent); static Interest firstBlockLatestVersionInterest(ContentName startingVersion, PublisherPublicKeyDigest publisher); static Interest latestVersionInterest(ContentName startingVersion, Integer additionalNameComponents, PublisherPublicKeyDigest publisher); static ContentObject getLatestVersion(ContentName startingVersion,
											     PublisherPublicKeyDigest publisher,
												 long timeout,
 												 ContentVerifier verifier,
												 CCNHandle handle); static ContentObject getFirstBlockOfLatestVersion(ContentName startingVersion,
															 Long startingSegmentNumber,
															 PublisherPublicKeyDigest publisher,
															 long timeout,
															 ContentVerifier verifier,
															 CCNHandle handle); static ContentObject getAnyLaterVersion(ContentName startingVersion,
											     PublisherPublicKeyDigest publisher,
												 long timeout,
 												 ContentVerifier verifier,
												 CCNHandle handle); static ContentObject getFirstBlockOfAnyLaterVersion(ContentName startingVersion,
			Long startingSegmentNumber,
			PublisherPublicKeyDigest publisher,
			long timeout,
			ContentVerifier verifier,
			CCNHandle handle); static boolean isVersionedFirstSegment(ContentName desiredName, ContentObject potentialFirstSegment, Long startingSegmentNumber); static byte[] versionComponentFromStripped(byte[] bs); static byte[] stripVersionMarker(byte[] version); static final byte VERSION_MARKER; static final byte FF; static final byte O1; static final byte OO; static final byte [] FIRST_VERSION_MARKER; static final byte [] LAST_VERSION_MARKER; static final byte [] MIN_VERSION_MARKER; static final byte [] MAX_VERSION_MARKER; static final byte [] BOTTOM_EXCLUDE_VERSION_MARKER; static final byte [] TOP_EXCLUDE_VERSION_MARKER; }
@Test public void testVersionNameContentNameLong() { Log.info(Log.FAC_TEST, "Starting testVersionNameContentNameLong"); ContentName name; name = VersioningProfile.addVersion(abName, 256); if (!name.equals(new ContentName(new byte[]{ 97 }, new byte[]{ 98 }, new byte[]{ -3, 1, 0 }))) fail("long encode version failed"); name = VersioningProfile.addVersion(abName, 0); if (!name.equals(ab0Name)) fail("long encode version=0 failed"); Log.info(Log.FAC_TEST, "Completed testVersionNameContentNameLong"); }
@Test public void testVersionNameContentName() throws InterruptedException { Log.info(Log.FAC_TEST, "Starting testVersionNameContentName"); ContentName name = VersioningProfile.addVersion(abName); Thread.sleep(10); if (name == VersioningProfile.addVersion(abSegName)) fail("should be different versions"); Log.info(Log.FAC_TEST, "Completed testVersionNameContentName"); }