net.named_data.jndn.util
public class SegmentFetcher extends Object implements OnData, OnDataValidationFailed, OnTimeout
| Modifier and Type | Class and Description |
|---|---|
static class |
SegmentFetcher.ErrorCode |
static interface |
SegmentFetcher.OnComplete |
static interface |
SegmentFetcher.OnError |
static interface |
SegmentFetcher.VerifySegment |
| Modifier and Type | Field and Description |
|---|---|
static SegmentFetcher.VerifySegment |
DontVerifySegment
DontVerifySegment may be used in fetch to skip validation of Data packets.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
fetch(Face face,
Interest baseInterest,
KeyChain validatorKeyChain,
SegmentFetcher.OnComplete onComplete,
SegmentFetcher.OnError onError)
Initiate segment fetching.
|
static void |
fetch(Face face,
Interest baseInterest,
SegmentFetcher.VerifySegment verifySegment,
SegmentFetcher.OnComplete onComplete,
SegmentFetcher.OnError onError)
Initiate segment fetching.
|
void |
onData(Interest originalInterest,
Data data)
When a matching data packet is received, onData is called.
|
void |
onDataValidationFailed(Data data,
String reason)
When verifyData fails, onDataValidationFailed is called.
|
void |
onTimeout(Interest interest)
If the interest times out according to the interest lifetime, onTimeout is
called.
|
void |
onVerified(Data data,
Interest originalInterest) |
public static final SegmentFetcher.VerifySegment DontVerifySegment
public static void fetch(Face face, Interest baseInterest, SegmentFetcher.VerifySegment verifySegment, SegmentFetcher.OnComplete onComplete, SegmentFetcher.OnError onError)
face - This calls face.expressInterest to fetch more segments.baseInterest - An Interest for the initial segment of the requested
data, where baseInterest.getName() has the name prefix.
This interest may include a custom InterestLifetime and selectors that will
propagate to all subsequent Interests. The only exception is that the
initial Interest will be forced to include selectors "ChildSelector=1" and
"MustBeFresh=true" which will be turned off in subsequent Interests.verifySegment - When a Data packet is received this calls
verifySegment.verifySegment(data). If it returns false then abort fetching
and call onError.onError with ErrorCode.SEGMENT_VERIFICATION_FAILED. If
data validation is not required, use DontVerifySegment.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onComplete - When all segments are received, call
onComplete.onComplete(content) where content is the concatenation of the
content of all the segments.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onError - Call onError.onError(errorCode, message) for timeout or an
error processing segments.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.public static void fetch(Face face, Interest baseInterest, KeyChain validatorKeyChain, SegmentFetcher.OnComplete onComplete, SegmentFetcher.OnError onError)
face - This calls face.expressInterest to fetch more segments.baseInterest - An Interest for the initial segment of the requested
data, where baseInterest.getName() has the name prefix.
This interest may include a custom InterestLifetime and selectors that will
propagate to all subsequent Interests. The only exception is that the
initial Interest will be forced to include selectors "ChildSelector=1" and
"MustBeFresh=true" which will be turned off in subsequent Interests.validatorKeyChain - When a Data packet is received this calls
validatorKeyChain.verifyData(data). If validation fails then abort
fetching and call onError with SEGMENT_VERIFICATION_FAILED. This does not
make a copy of the KeyChain; the object must remain valid while fetching.
If validatorKeyChain is null, this does not validate the data packet.onComplete - When all segments are received, call
onComplete.onComplete(content) where content is the concatenation of the
content of all the segments.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onError - Call onError.onError(errorCode, message) for timeout or an
error processing segments.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.public void onData(Interest originalInterest, Data data)
OnDatapublic void onDataValidationFailed(Data data, String reason)
OnDataValidationFailedonDataValidationFailed in interface OnDataValidationFaileddata - The data object being verified.reason - The reason for the failed validation.Copyright © 2016. All rights reserved.