private static Interest createFreshInterest() { Interest freshInterest = new Interest(new Name("/ndn/abc")) .setMustBeFresh(false).setMinSuffixComponents(4) .setMaxSuffixComponents(6) .setInterestLifetimeMilliseconds(30000).setChildSelector(1) .setMustBeFresh(true); freshInterest.getKeyLocator() .setType(net.named_data.jndn.KeyLocatorType.KEY_LOCATOR_DIGEST); freshInterest.getKeyLocator().setKeyData( new Blob(new int[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F })); freshInterest.getExclude().appendComponent(new Name("abc").get(0)) .appendAny(); freshInterest.getForwardingHint().add(1, new Name("/A")); return(freshInterest); }
private static ArrayList dumpInterest(Interest interest) { ArrayList result = new ArrayList(); ILOG.J2CsMapping.Collections.Collections.Add(result, dump("name:", interest.getName().toUri())); ILOG.J2CsMapping.Collections.Collections.Add(result, dump( "minSuffixComponents:", (interest.getMinSuffixComponents() >= 0) ? (Object)(interest.getMinSuffixComponents()) : (Object)("<none>"))); ILOG.J2CsMapping.Collections.Collections.Add(result, dump( "maxSuffixComponents:", (interest.getMaxSuffixComponents() >= 0) ? (Object)(interest.getMaxSuffixComponents()) : (Object)("<none>"))); if (interest.getKeyLocator().getType() != net.named_data.jndn.KeyLocatorType.NONE) { if (interest.getKeyLocator().getType() == net.named_data.jndn.KeyLocatorType.KEY_LOCATOR_DIGEST) { ILOG.J2CsMapping.Collections.Collections.Add(result, dump("keyLocator: KeyLocatorDigest:", interest .getKeyLocator().getKeyData().toHex())); } else if (interest.getKeyLocator().getType() == net.named_data.jndn.KeyLocatorType.KEYNAME) { ILOG.J2CsMapping.Collections.Collections.Add(result, dump("keyLocator: KeyName:", interest .getKeyLocator().getKeyName().toUri())); } else { ILOG.J2CsMapping.Collections.Collections.Add(result, dump("keyLocator: <unrecognized KeyLocatorType")); } } else { ILOG.J2CsMapping.Collections.Collections.Add(result, dump("keyLocator: <none>")); } ILOG.J2CsMapping.Collections.Collections.Add(result, dump("exclude:", (interest.getExclude().size() > 0) ? interest .getExclude().toUri() : "<none>")); ILOG.J2CsMapping.Collections.Collections.Add(result, dump("childSelector:", (interest.getChildSelector() >= 0) ? (Object)(interest.getChildSelector()) : (Object)("<none>"))); ILOG.J2CsMapping.Collections.Collections.Add(result, dump("mustBeFresh:", (interest.getMustBeFresh()) ? "true" : "false")); ILOG.J2CsMapping.Collections.Collections.Add(result, dump("nonce:", (interest.getNonce().size() == 0) ? "<none>" : interest.getNonce().toHex())); ILOG.J2CsMapping.Collections.Collections.Add(result, dump("lifetimeMilliseconds:", (interest.getInterestLifetimeMilliseconds() < 0) ? "<none>" : "" + (long)interest.getInterestLifetimeMilliseconds())); if (interest.getForwardingHint().size() > 0) { ILOG.J2CsMapping.Collections.Collections.Add(result, dump("forwardingHint:")); for (int i = 0; i < interest.getForwardingHint().size(); ++i) { ILOG.J2CsMapping.Collections.Collections.Add(result, dump(" Preference: " + interest.getForwardingHint().get(i).getPreference() + ", Name: " + interest.getForwardingHint().get(i).getName().toUri())); } } else { ILOG.J2CsMapping.Collections.Collections.Add(result, dump("forwardingHint: <none>")); } return(result); }