/** * Determine if a name is segmented, i.e. if it ends with the correct marker type. * * @param name the name of a packet * @param marker the marker type (the initial byte of the component) * @return true if the name is segmented */ public static boolean isSegmented(Name name, byte marker) { return name.size() > 0 && name.get(-1).getValue().buf().get(0) == marker; }
private ControlParameters decodeParameters(Interest interest) { ControlParameters params = new ControlParameters(); try { params.wireDecode(interest.getName().get(CONTROL_PARAMETERS_NAME_OFFSET).getValue()); params.setFaceId(1); params.setOrigin(0); params.setCost(0); } catch (EncodingException e) { throw new IllegalArgumentException("", e); } return params; }
params.wireDecode(interest.getName().get(CONTROL_PARAMETERS_NAME_OFFSET).getValue()); params.setFaceId(1); params.setOrigin(0);
/** * Helper to encode names using an existing encoding context; could be merged * to Tlv0_1_1WireFormat.java. * * @param name the {@link Name} to encode * @param encoder the current {@link TlvEncoder} context to encode with */ public static void encodeName(final Name name, final TlvEncoder encoder) { int saveLength = encoder.getLength(); for (int i = name.size() - 1; i >= 0; --i) { encoder.writeBlobTlv(Tlv.NameComponent, name.get(i).getValue().buf()); } encoder.writeTypeAndLength(Tlv.Name, encoder.getLength() - saveLength); }
private boolean hasFinalBlockId(Data data) { return data.getMetaInfo().getFinalBlockId().getValue().size() > 0; }