}
@SuppressWarnings({"unchecked"})
protected DataSm createDataSm(Exchange exchange) {
Message in = exchange.getIn();
DataSm dataSm = new DataSm();
if (in.getHeaders().containsKey(SmppConstants.DATA_CODING)) {
dataSm.setDataCoding(in.getHeader(SmppConstants.DATA_CODING, java.lang.Byte.class));
} else {
dataSm.setDataCoding(config.getDataCoding());
}
if (in.getHeaders().containsKey(SmppConstants.DEST_ADDR)) {
dataSm.setDestAddress(in.getHeader(SmppConstants.DEST_ADDR, String.class));
} else {
dataSm.setDestAddress(config.getDestAddr());
}
if (in.getHeaders().containsKey(SmppConstants.DEST_ADDR_TON)) {
dataSm.setDestAddrTon(in.getHeader(SmppConstants.DEST_ADDR_TON, java.lang.Byte.class));
} else {
dataSm.setDestAddrTon(config.getDestAddrTon());
}
if (in.getHeaders().containsKey(SmppConstants.DEST_ADDR_NPI)) {
dataSm.setDestAddrNpi(in.getHeader(SmppConstants.DEST_ADDR_NPI, java.lang.Byte.class));
} else {
dataSm.setDestAddrNpi(config.getDestAddrNpi());
}
if (in.getHeaders().containsKey(SmppConstants.SOURCE_ADDR)) {
dataSm.setSourceAddr(in.getHeader(SmppConstants.SOURCE_ADDR, String.class));
} else {
dataSm.setSourceAddr(config.getSourceAddr());
}
if (in.getHeaders().containsKey(SmppConstants.SOURCE_ADDR_TON)) {
dataSm.setSourceAddrTon(in.getHeader(SmppConstants.SOURCE_ADDR_TON, java.lang.Byte.class));
} else {
dataSm.setSourceAddrTon(config.getSourceAddrTon());
}
if (in.getHeaders().containsKey(SmppConstants.SOURCE_ADDR_NPI)) {
dataSm.setSourceAddrNpi(in.getHeader(SmppConstants.SOURCE_ADDR_NPI, java.lang.Byte.class));
} else {
dataSm.setSourceAddrNpi(config.getSourceAddrNpi());
}
if (in.getHeaders().containsKey(SmppConstants.SERVICE_TYPE)) {
dataSm.setServiceType(in.getHeader(SmppConstants.SERVICE_TYPE, String.class));
} else {
dataSm.setServiceType(config.getServiceType());
}
if (in.getHeaders().containsKey(SmppConstants.REGISTERED_DELIVERY)) {
dataSm.setRegisteredDelivery(in.getHeader(SmppConstants.REGISTERED_DELIVERY, java.lang.Byte.class));
} else {
dataSm.setRegisteredDelivery(config.getRegisteredDelivery());
}
Map<java.lang.Short, Object> optinalParamater = in.getHeader(SmppConstants.OPTIONAL_PARAMETER, Map.class);
if (optinalParamater != null) {
List<OptionalParameter> optParams = createOptionalParametersByCode(optinalParamater);
dataSm.setOptionalParametes(optParams.toArray(new OptionalParameter[optParams.size()]));
} else {
Map<String, String> optinalParamaters = in.getHeader(SmppConstants.OPTIONAL_PARAMETERS, Map.class);
if (optinalParamaters != null) {
List<OptionalParameter> optParams = createOptionalParametersByName(optinalParamaters);
dataSm.setOptionalParametes(optParams.toArray(new OptionalParameter[optParams.size()]));
} else {
dataSm.setOptionalParametes();
}
}
return dataSm;
}