protected final List<Record> wrapMessage(DTLSMessage fragment) throws HandshakeException {
  try {
switch (fragment.getContentType()) {
case HANDSHAKE:
      return wrapHandshakeMessage((HandshakeMessage)fragment);
default :
    List<Record> records=new ArrayList<Record>();
  records.add(new Record(fragment.getContentType(),session.getWriteEpoch(),session.getSequenceNumber(),fragment,session));
return records;
}
}
 catch (GeneralSecurityException e) {
throw new HandshakeException("Cannot create record",new AlertMessage(AlertLevel.FATAL,AlertDescription.INTERNAL_ERROR,session.getPeer()));
}
}

protected final List < Record > wrapMessage ( DTLSMessage fragment ) throws HandshakeException { try { switch ( fragment . getContentType ( ) ) { case HANDSHAKE : return wrapHandshakeMessage ( ( HandshakeMessage ) fragment ) ; default : List < Record > records = new ArrayList < Record > ( ) ; records . add ( new Record ( fragment . getContentType ( ) , session . getWriteEpoch ( ) , session . getSequenceNumber ( ) , fragment , session ) ) ; return records ; } } catch ( GeneralSecurityException e ) { throw new HandshakeException ( "Cannot create record" , new AlertMessage ( AlertLevel . FATAL , AlertDescription . INTERNAL_ERROR , session . getPeer ( ) ) ) ; } }
wraps a dtls message fragment into ( potentially multiple ) dtls records . sets the record ' s epoch , sequence number and handles fragmentation for handshake messages .
