Compare Revisions

The credentials to download the source code are:
 Username: svnusers
 Password: svnusers

Ignore whitespace Rev 845 → Rev 846

/trunk/javasrc/codec/org/etsi/codec/BasicCodecImpl.java
521,7 → 521,7
 
@Override
public TriMessage encode(final Value template) {
final EncodingContext encodingContext = new EncodingContext(template.getValueEncoding());
final EncodingContext encodingContext = new EncodingContext(template.getType().getTypeEncoding());
encodeValue(encodingContext, template);
encodingContext.finalyze();
TriMessage encodedMessage = new TriMessageImpl(encodingContext.toByteArray());
/trunk/javasrc/codec/org/etsi/codec/DecodingContext.java
27,7 → 27,7
/**
* Codec encoding identifier
*/
private String _valueEncoding;
private String _typeEncoding;
 
/**
* Contextual decoding value
66,7 → 66,7
public DecodingContext(final byte[] messageToDecode, final String valueEncoding) {
_buffer = messageToDecode.clone();
_bitpos = 0;
_valueEncoding = valueEncoding;
_typeEncoding = valueEncoding;
set_commonHeader(null);
set_payloadLength(null);
set_nextHeader(null);
291,10 → 291,10
}
/**
* Accessor for <code>_valueEncoding</code> field
* @return The value of <code>_valueEncoding</code> field
* Accessor for <code>_typeEncoding</code> field
* @return The value of <code>_typeEncoding</code> field
*/
public String getValueEncoding() { return _valueEncoding; }
public String getTypeEncoding() { return _typeEncoding; }
/**
* @param _commonHeader the _commonHeader to set
/trunk/javasrc/codec/org/etsi/codec/EncodingContext.java
38,7 → 38,7
/**
* Codec encoding identifier
*/
private String _valueEncoding;
private String _typeEncoding;
/**
* Mark to modify value later during encoding operations
71,10 → 71,10
private int _markForIPv6ChecksumCalculation;
/**
* Accessor for <code>_valueEncoding</code> field
* @return The value of <code>_valueEncoding</code> field
* Accessor for <code>_typeEncoding</code> field
* @return The value of <code>_typeEncoding</code> field
*/
public String getValueEncoding() { return _valueEncoding; }
public String getTypeEncoding() { return _typeEncoding; }
/**
* Constructor
88,7 → 88,7
* @param valueEncoding The 'variant' value of the TTCN-3 message
*/
public EncodingContext(final String valueEncoding) {
_valueEncoding = valueEncoding;
_typeEncoding = valueEncoding;
_buffer = new ByteArrayOutputStream();
_bitpos = 0;
_markForUpdate = -1;
/trunk/javasrc/codec/org/etsi/its/codec/ItsCodecImpl.java
122,7 → 122,7
 
BitstringValue value = (BitstringValue)decodingHypothesis.newInstance();
 
_logger.info(String.format("Encoding: %s - %s", value.getValueEncodingVariant(), value.getValueEncoding()));
_logger.info(String.format("Encoding: %s - %s", value.getValueEncodingVariant(), value.getType().getTypeEncoding()));
// Extract the length
int length = 0;
if (value.getValueEncodingVariant() != null) {
133,8 → 133,8
} else {
throw new RuntimeException(String.format("Invalid value encoding VARIANT: %s", value.getValueEncodingVariant()));
}
} else if (value.getValueEncoding() != null) {
Matcher matcher = ItsCodecImpl.PatternEncoding.matcher(value.getValueEncoding());
} else if (value.getType().getTypeEncoding() != null) {
Matcher matcher = ItsCodecImpl.PatternEncoding.matcher(value.getType().getTypeEncoding());
if (matcher.find()) {
length = Integer.parseInt(matcher.group(1)); // Length is in bits
} else {
278,19 → 278,19
// Convert the integer value into byte array
length = Integer.parseInt(matcher.group(3));
} else { // Ignore it
if (value.getValueEncoding() != null) {
matcher = ItsCodecImpl.PatternEncoding.matcher(value.getValueEncoding());
if (value.getType().getTypeEncoding() != null) {
matcher = ItsCodecImpl.PatternEncoding.matcher(value.getType().getTypeEncoding());
if (matcher.find()) {
length = Integer.parseInt(matcher.group(1)) * 8; // Length is in bytes
} else {
throw new RuntimeException(String.format("Invalid value encoding: %s", value.getValueEncoding()));
throw new RuntimeException(String.format("Invalid value encoding: %s", value.getType().getTypeEncoding()));
}
} else {
throw new RuntimeException("Variant values are null (1)");
}
}
} else if (value.getValueEncoding() != null) {
Matcher matcher = ItsCodecImpl.PatternEncoding.matcher(value.getValueEncoding());
} else if (value.getType().getTypeEncoding() != null) {
Matcher matcher = ItsCodecImpl.PatternEncoding.matcher(value.getType().getTypeEncoding());
if (matcher.find()) {
length = Integer.parseInt(matcher.group(1)) * 8; // Length is in bytes
} else { // Try with decodingHypothesis type encoding
298,7 → 298,7
if (matcher.find()) {
length = Integer.parseInt(matcher.group(2)) * 8; // Length is in bytes
} else {
throw new RuntimeException(String.format("Invalid value encoding: %s - %s", value.getValueEncoding(), decodingHypothesis.getTypeEncoding()));
throw new RuntimeException(String.format("Invalid value encoding: %s - %s", value.getType().getTypeEncoding(), decodingHypothesis.getTypeEncoding()));
}
}
} else {
317,7 → 317,7
* @param bitstringValue The <code>IntegerValue</code> to encode
*/
public void encodeBitstringValue(EncodingContext encodingContext, final String fieldName, final BitstringValue bitstringValue) {
_logger.entering(this.toString(), "encodeBitstringValue", String.format("<%s> - %s - %s - %s", bitstringValue.getString(), fieldName, bitstringValue.getType().getName(), bitstringValue.getValueEncoding()));
_logger.entering(this.toString(), "encodeBitstringValue", String.format("<%s> - %s - %s - %s", bitstringValue.getString(), fieldName, bitstringValue.getType().getName(), bitstringValue.getType().getTypeEncoding()));
 
try {
encodingContext.setByte(TestAdapterMessageTypeEnum.convert(fieldName));
353,7 → 353,7
* @param boolValue The <code>BooleanValue</code> to encode
*/
public void encodeBooleanValue(EncodingContext encodingContext, final String fieldName, final BooleanValue boolValue) {
_logger.entering(this.toString(), "encodeBooleanValue", String.format("%s - %s - %s", fieldName, boolValue.getType().getName(), boolValue.getValueEncoding()));
_logger.entering(this.toString(), "encodeBooleanValue", String.format("%s - %s - %s", fieldName, boolValue.getType().getName(), boolValue.getType().getTypeEncoding()));
 
try {
encodingContext.setByte(TestAdapterMessageTypeEnum.convert(fieldName));
450,7 → 450,7
* @param intValue The <code>IntegerValue</code> to encode
*/
public void encodeIntegerValue(EncodingContext encodingContext, final String fieldName, final IntegerValue intValue) {
_logger.entering(this.toString(), "encodeIntegerValue", String.format("<%d - %d> - %s - %s - %s", intValue.getInt(), intValue.getBigInt().longValue(), fieldName, intValue.getType().getName(), intValue.getValueEncoding()));
_logger.entering(this.toString(), "encodeIntegerValue", String.format("<%d - %d> - %s - %s - %s", intValue.getInt(), intValue.getBigInt().longValue(), fieldName, intValue.getType().getName(), intValue.getType().getTypeEncoding()));
 
try {
encodingContext.setByte(TestAdapterMessageTypeEnum.convert(fieldName));
489,12 → 489,14
}
 
_logger.info(String.format("Integer value=<%d> - <%s> - <%s>", intValue.getInt(), intValue.getValueEncoding(), intValue.getValueEncodingVariant()));
if (intValue.getValueEncoding() == "MarkForUpdate") {
encodingContext.markForUpdate();
if (intValue.getValueEncoding()!= null) {
if (intValue.getValueEncoding().equals("MarkForUpdate")) {
encodingContext.markForUpdate();
}
if (intValue.getValueEncoding().equals("MarkForNextHeader")) {
encodingContext.markForNextHeader();
}
}
if (intValue.getValueEncoding() == "MarkForNextHeader") {
encodingContext.markForNextHeader();
}
 
if (intValue.getValueEncodingVariant() != null) {
_logger.info(String.format("Encoding type: %s", intValue.getValueEncodingVariant()));
556,7 → 558,7
throw new RuntimeException("BasicCodecImpl.encodeOctetstringValue: Can't send wildcard " + ov.getType().getName());
}
_logger.info(String.format("Octetstring value=length<%d> - <%s> - <%s>", ov.getLength(), ov.getValueEncoding(), ov.getValueEncodingVariant()));
_logger.info(String.format("Octetstring value=length<%d> - <%s> - <%s>", ov.getLength(), ov.getType().getTypeEncoding(), ov.getValueEncodingVariant()));
String variant = ov.getValueEncodingVariant();
if (variant != null) {
if (variant == "MarkForIPv6SrcAddress") {
/trunk/javasrc/codec/org/etsi/its/codec/ttcn/LibItsCam_TypesAndValues/LibItsCam_TypesAndValuesCodec.java
102,7 → 102,7
*/
@Override
public void encodeRecordValue(EncodingContext encodingContext, final RecordValue rv) {
_logger.entering("LibItsCam_TypesAndValuesCodec", "encodeRecordValue", String.format("%s - %s", rv.getType().getName(), rv.getValueEncoding()));
_logger.entering("LibItsCam_TypesAndValuesCodec", "encodeRecordValue", String.format("%s - %s", rv.getType().getName(), rv.getType().getTypeEncoding()));
 
if (rv.getType().getName() == "CamPdu") {
super.encodeRecordValue(encodingContext, rv);
234,7 → 234,7
*/
@Override
public void encodeUnionValue(EncodingContext encodingContext, final UnionValue uv) {
_logger.entering("LibItsCam_TypesAndValuesCodec", "encodeUnionValue", String.format("%s - %s", uv.getType().getName(), uv.getValueEncoding()));
_logger.entering("LibItsCam_TypesAndValuesCodec", "encodeUnionValue", String.format("%s - %s", uv.getType().getName(), uv.getType().getTypeEncoding()));
 
if (uv.getType().getName() == "UtCamEvent") {
try {
/trunk/javasrc/codec/org/etsi/its/codec/ttcn/LibItsCommon_TypesAndValues/LibItsCommon_TypesAndValuesCodec.java
125,13 → 125,13
*/
@Override
public void encodeRecordValue(EncodingContext encodingContext, final RecordValue rv) {
_logger.entering("LibItsCommon_TypesAndValuesCodec", "encodeRecordValue", String.format("%s - %s", rv.getType().getName(), rv.getValueEncoding()));
_logger.entering("LibItsCommon_TypesAndValuesCodec", "encodeRecordValue", String.format("%s - %s", rv.getType().getName(), rv.getType().getTypeEncoding()));
 
if ((rv.getValueEncoding() != null) && (rv.getValueEncoding() != encodingContext.getValueEncoding())) {
if ((rv.getType().getTypeEncoding() != null) && !rv.getType().getTypeEncoding().equals(encodingContext.getTypeEncoding())) {
// Retrieve the correct codec
TciCDProvided codec = getCodec(rv.getValueEncoding());
TciCDProvided codec = getCodec(rv.getType().getTypeEncoding());
if (codec == null) {
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", rv.getValueEncoding()));
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", rv.getType().getTypeEncoding()));
}
// And continue encoding operations
TriMessage value = codec.encode(rv);
182,13 → 182,13
*/
@Override
public void encodeUnionValue(EncodingContext encodingContext, final UnionValue uv) {
_logger.entering("LibItsCommon_TypesAndValuesCodec", "encodeUnionValue", String.format("%s - %s", uv.getType().getName(), uv.getValueEncoding()));
_logger.entering("LibItsCommon_TypesAndValuesCodec", "encodeUnionValue", String.format("%s - %s", uv.getType().getName(), uv.getType().getTypeEncoding()));
 
if ((uv.getValueEncoding() != null) && (uv.getValueEncoding() != encodingContext.getValueEncoding())) {
if ((uv.getType().getTypeEncoding() != null) && !uv.getType().getTypeEncoding().equals(encodingContext.getTypeEncoding())) {
// Retrieve the correct codec
TciCDProvided codec = getCodec(uv.getValueEncoding());
TciCDProvided codec = getCodec(uv.getType().getTypeEncoding());
if (codec == null) {
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", uv.getValueEncoding()));
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", uv.getType().getTypeEncoding()));
}
// And continue encoding operations
TriMessage value = codec.encode(uv);
/trunk/javasrc/codec/org/etsi/its/codec/ttcn/LibItsDenm_TypesAndValues/LibItsDenm_TypesAndValuesCodec.java
109,13 → 109,13
*/
@Override
public void encodeRecordValue(EncodingContext encodingContext, final RecordValue rv) {
_logger.entering("LibItsDenm_TypesAndValuesCodec", "encodeRecordValue", String.format("%s - %s", rv.getType().getName(), rv.getValueEncoding()));
_logger.entering("LibItsDenm_TypesAndValuesCodec", "encodeRecordValue", String.format("%s - %s", rv.getType().getName(), rv.getType().getTypeEncoding()));
 
if ((rv.getValueEncoding() != null) && (rv.getValueEncoding() != encodingContext.getValueEncoding())) {
if ((rv.getType().getTypeEncoding() != null) && !rv.getType().getTypeEncoding().equals(encodingContext.getTypeEncoding())) {
// Retrieve the correct codec
TciCDProvided codec = getCodec(rv.getValueEncoding());
TciCDProvided codec = getCodec(rv.getType().getTypeEncoding());
if (codec == null) {
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", rv.getValueEncoding()));
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", rv.getType().getTypeEncoding()));
}
// And continue encoding operations
TriMessage value = codec.encode(rv);
197,13 → 197,13
*/
@Override
public void encodeUnionValue(EncodingContext encodingContext, final UnionValue uv) {
_logger.entering("LibItsDenm_TypesAndValuesCodec", "encodeUnionValue", String.format("%s - %s", uv.getType().getName(), uv.getValueEncoding()));
_logger.entering("LibItsDenm_TypesAndValuesCodec", "encodeUnionValue", String.format("%s - %s", uv.getType().getName(), uv.getType().getTypeEncoding()));
 
if ((uv.getValueEncoding() != null) && (uv.getValueEncoding() != encodingContext.getValueEncoding())) {
if ((uv.getType().getTypeEncoding() != null) && !uv.getType().getTypeEncoding().equals(encodingContext.getTypeEncoding())) {
// Retrieve the correct codec
TciCDProvided codec = getCodec(uv.getValueEncoding());
TciCDProvided codec = getCodec(uv.getType().getTypeEncoding());
if (codec == null) {
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", uv.getValueEncoding()));
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", uv.getType().getTypeEncoding()));
}
// And continue encoding processing
TriMessage value = codec.encode(uv);
/trunk/javasrc/codec/org/etsi/its/codec/ttcn/LibItsGeoNetworking_TypesAndValues/LibItsGeoNetworking_TypesAndValuesCodec.java
129,11 → 129,11
return;
}
 
if (rv.getValueEncoding() != "LibItsGeoNetworking_TypesAndValues") {
if (!rv.getType().getTypeEncoding().equals("LibItsGeoNetworking_TypesAndValues")) {
// Retrieve the correct codec
TciCDProvided codec = getCodec(rv.getValueEncoding());
TciCDProvided codec = getCodec(rv.getType().getTypeEncoding());
if (codec == null) {
throw new RuntimeException(String.format("Could not retrieve codec for decoding name %s", rv.getValueEncoding()));
throw new RuntimeException(String.format("Could not retrieve codec for decoding name %s", rv.getType().getTypeEncoding()));
}
// And continue encoding operations
TriMessage encoded = codec.encode(rv);
511,7 → 511,7
// Extract type
TestAdapterMessageTypeEnum type = TestAdapterMessageTypeEnum.valueOf(decodingContext.getNextByte());
_logger.info(String.format("(1): type:%s", type));
if ((type == null) || (type.name() != unionValue.getType().getName())) {
if ((type == null) || !type.name().equals(unionValue.getType().getName())) {
// It is not a TLV format, process it as a protocol format
return (UnionValue)decodeProtocolLayer(unionValue.getType(), decodingContext);
}
646,7 → 646,7
_logger.entering(this.toString(), "decodeRecordValue", decodingHypothesis.getName());
RecordValue recordValue = null;
if (decodingHypothesis.getTypeEncoding() != decodingContext.getValueEncoding()) {
if (!decodingHypothesis.getTypeEncoding().equals(decodingContext.getTypeEncoding())) {
// Retrieve the correct codec
TciCDProvided codec = getCodec(decodingHypothesis.getDefiningModule().getModuleName());
if (codec == null) {
702,7 → 702,7
_logger.entering(this.toString(), "decodeUnionValue", String.format("%s - %s", decodingHypothesis.getName(), decodingContext.toString()));
 
UnionValue unionValue = (UnionValue)decodingHypothesis.newInstance();
if (decodingHypothesis.getDefiningModule().getModuleName() != decodingContext.getValueEncoding()) { // FIXME To be tested
if (decodingHypothesis.getDefiningModule().getModuleName() != decodingContext.getTypeEncoding()) { // FIXME To be tested
// Retrieve the correct codec
TciCDProvided codec = getCodec(decodingHypothesis.getTypeEncoding());
if (codec == null) {
/trunk/javasrc/codec/org/etsi/its/codec/ttcn/LibItsIpv6OverGeoNetworking_TypesAndValues/LibItsIpv6OverGeoNetworking_TypesAndValuesCodec.java
352,7 → 352,7
// Extract type
TestAdapterMessageTypeEnum type = TestAdapterMessageTypeEnum.valueOf(decodingContext.peekNextByte());
_logger.info(String.format("(1): type: %s", type));
if ((type == null) || (type.name() != recordValue.getType().getName())) {
if ((type == null) || !type.name().equals(recordValue.getType().getName())) {
// It is not a TLV format, process it as a protocol format
return (RecordValue)decodeProtocolLayer(recordValue.getType(), decodingContext);
}
386,7 → 386,7
// Extract type
TestAdapterMessageTypeEnum type = TestAdapterMessageTypeEnum.valueOf(decodingContext.peekNextByte());
_logger.info(String.format("(1): type: %s", type));
if ((type == null) || (type.name() != unionValue.getType().getName())) {
if ((type == null) || !type.name().equals(unionValue.getType().getName())) {
// It is not a TLV format, process it as a protocol format
return (UnionValue)decodeProtocolLayer(unionValue.getType(), decodingContext);
}
428,7 → 428,7
// Extract type
TestAdapterMessageTypeEnum type = TestAdapterMessageTypeEnum.valueOf(decodingContext.peekNextByte());
_logger.info(String.format("decodeTLVLayer (3): type: %s", type));
if ((type == null) || (type.name() != recordOfValue.getType().getName())) {
if ((type == null) || !type.name().equals(recordOfValue.getType().getName())) {
// It is not a TLV format, process it as a protocol format
return (RecordOfValue)decodeProtocolLayer(recordOfValue.getType(), decodingContext);
}
/trunk/javasrc/codec/org/etsi/its/codec/ttcn/LibIts_Interface/LibIts_InterfaceCodec.java
162,7 → 162,7
 
// Extract type
TestAdapterMessageTypeEnum type = TestAdapterMessageTypeEnum.valueOf(decodingContext.getNextByte()); // Get type
if ((type == null) || (type.name() != recordValue.getType().getName())) {
if ((type == null) || !type.name().equals(recordValue.getType().getName())) {
_logger.severe(String.format("(1): Type mismatch: %s - %s", (type == null) ? "(null)" : type.name(), recordValue.getType().getName()));
return null;
}
169,11 → 169,11
_logger.info(String.format("(1): type:%s", type.name()));
short length = ByteHelper.byteArrayToShort(decodingContext.getNextBytes(2)); // Get Length (2 bytes)
Value recordField = recordValue.getField(recordValue.getFieldNames()[0]);
_logger.info(String.format("(1): recordField:%s - %s", recordField.getType().getName(), recordField.getValueEncoding()));
_logger.info(String.format("(1): recordField:%s - %s", recordField.getType().getName(), recordField.getType().getTypeEncoding()));
// Retrieve the correct codec
TciCDProvided codec;
if ((codec = getCodec(recordField.getValueEncoding())) == null) {
throw new RuntimeException(String.format("Could not retrieve codec for decoding name %s", recordField.getValueEncoding()));
if ((codec = getCodec(recordField.getType().getTypeEncoding())) == null) {
throw new RuntimeException(String.format("Could not retrieve codec for decoding name %s", recordField.getType().getTypeEncoding()));
}
switch (type) {
case CamReq:
259,7 → 259,7
* @return An initialised <code>recordValue</code> instance
*/
private RecordValue decodeIPv6OverGeoNetworkingReqInd(final RecordValue rv, DecodingContext decodingContext) {
_logger.entering("LibIts_InterfaceCodec", "decodeIPv6OverGeoNetworkingReqInd", String.format("%s - %s", rv.getType().getName(), rv.getValueEncoding()));
_logger.entering("LibIts_InterfaceCodec", "decodeIPv6OverGeoNetworkingReqInd", String.format("%s - %s", rv.getType().getName(), rv.getType().getTypeEncoding()));
String[] fields = rv.getFieldNames();
int idx = 0;
274,7 → 274,7
// 3. Retrieve codec for LibItsIpv6OverGeoNetworking_TypesAndValues
TciCDProvided codec = getCodec("LibItsIpv6OverGeoNetworking_TypesAndValues");
if (codec == null) {
throw new RuntimeException(String.format("Could not retrieve codec for decoding name %s", rv.getValueEncoding()));
throw new RuntimeException(String.format("Could not retrieve codec for decoding name %s", rv.getType().getTypeEncoding()));
}
// 4. Decode 'Ipv6Packet p_ipv6Packet' field
decodingContext.getNextBytes(2); // skip packet's length
301,13 → 301,13
*/
@Override
public void encodeRecordValue(EncodingContext encodingContext, final RecordValue rv) {
_logger.entering("LibIts_InterfaceCodec", "encodeRecordValue", String.format("%s - %s", rv.getType().getName(), rv.getValueEncoding()));
_logger.entering("LibIts_InterfaceCodec", "encodeRecordValue", String.format("%s - %s", rv.getType().getName(), rv.getType().getTypeEncoding()));
 
if ((rv.getValueEncoding() != null) && (rv.getValueEncoding() != encodingContext.getValueEncoding())) {
if ((rv.getType().getTypeEncoding() != null) && !rv.getType().getTypeEncoding().equals(encodingContext.getTypeEncoding())) {
// Retrieve the correct codec
TciCDProvided codec = getCodec(rv.getValueEncoding());
TciCDProvided codec = getCodec(rv.getType().getTypeEncoding());
if (codec == null) {
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", rv.getValueEncoding()));
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", rv.getType().getTypeEncoding()));
}
// And continue the encoding operations
TriMessage value = codec.encode(rv);
360,11 → 360,11
public void encodeUnionValue(EncodingContext encodingContext, final UnionValue uv) {
_logger.entering("LibIts_InterfaceCodec", "encodeUnionValue", String.format("%s - %s", uv.getType().getName(), uv.getValueEncoding()));
 
if ((uv.getValueEncoding() != null) && (uv.getValueEncoding() != encodingContext.getValueEncoding())) {
if ((uv.getType().getTypeEncoding() != null) && !uv.getType().getTypeEncoding().equals(encodingContext.getTypeEncoding())) {
// Retrieve the correct codec
TciCDProvided codec = getCodec(uv.getValueEncoding());
TciCDProvided codec = getCodec(uv.getType().getTypeEncoding());
if (codec == null) {
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", uv.getValueEncoding()));
throw new RuntimeException(String.format("Could not retrieve codec for encoding name %s", uv.getType().getTypeEncoding()));
}
// And continue encoding processing
TriMessage value = codec.encode(uv);