本文整理汇总了Java中dk.dma.ais.message.AisMessage.getEncoded方法的典型用法代码示例。如果您正苦于以下问题:Java AisMessage.getEncoded方法的具体用法?Java AisMessage.getEncoded怎么用?Java AisMessage.getEncoded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dk.dma.ais.message.AisMessage
的用法示例。
在下文中一共展示了AisMessage.getEncoded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setMessageData
import dk.dma.ais.message.AisMessage; //导入方法依赖的package包/类
/**
* Set the binary encapsulated data from AIS message
*
* @param aisMessage
* @throws SixbitException
*/
public void setMessageData(AisMessage aisMessage) throws SixbitException {
this.msgId = aisMessage.getMsgId();
SixbitEncoder encoder = aisMessage.getEncoded();
sixbitString = new StringBuilder(encoder.encode());
padBits = encoder.getPadBits();
}
示例2: createSentences
import dk.dma.ais.message.AisMessage; //导入方法依赖的package包/类
/**
* Make max 80 chars length sentences from AIS message given sequence number
*
* If all VDM fields are used, 61 chars are left for encoded AIS message
*
* @param aisMessage
* @param sequence
* @return array of sentence parts
* @throws IllegalArgumentException
* @throws SixbitException
*/
public static String[] createSentences(AisMessage aisMessage, int sequence) throws SixbitException {
// Encode the AIS message to get full string
SixbitEncoder encoder = aisMessage.getEncoded();
String encoded = encoder.encode();
int padBits = encoder.getPadBits();
// Number of sentences necessary
int sentenceCount = encoded.length() / DATA_SENTENCE_MAX_LENGTH + 1;
String[] sentences = new String[sentenceCount];
// Split the string
for (int i = 0; i < sentenceCount; i++) {
int start = i * DATA_SENTENCE_MAX_LENGTH;
int end;
int partPadBits = 0;
if (i < sentenceCount - 1) {
end = start + DATA_SENTENCE_MAX_LENGTH;
} else {
end = encoded.length();
partPadBits = padBits;
}
String partEncoded = encoded.substring(start, end);
Vdm vdm = new Vdm();
vdm.setMsgId(aisMessage.getMsgId());
vdm.setTalker("AI");
vdm.setTotal(sentenceCount);
vdm.setNum(i + 1);
vdm.setSequence(sequence);
vdm.setSixbitString(partEncoded);
vdm.setPadBits(partPadBits);
sentences[i] = vdm.getEncoded();
}
return sentences;
}