Right. Never send code without compiling it first.
Here is a more syntactically correct version:
public boolean isCompatible(MibValue value) {
Integer size;
if (value instanceof StringValue) {
size = new Integer(value.toString().length());
return values.isCompatible(new NumberValue(size));
}
return false;
}
/Per
Per Cederberg wrote:
> Yes, this is indeed a bit strange. I cannot say that I
> recall the reason for doing it this way. Perhaps it was
> just some temporary solution which I have later added
> documented without remembering why it was written that
> way.
>
> Either way, perhaps you should recompiled Mibble with
> the following implementation instead:
>
> public boolean isCompatible(MibValue value) {
> if (value instanceof StringValue) {
> int len = value.toString().length();
> return values.isCompatible(len);
> }
> return false;
> }
>
> I'll see if I can cram this fix into version 2.8 before
> release.
>
> Best regards,
>
> /Per
>
> Paul Faid wrote:
>> Hi,
>>
>> I'm wondering why the SizeConstraint doesn't check the size of a
>> mibValue when calling isCompatible(), for example why doesn't it check
>> the length of a stringValue.
>>
>> The javaDoc even says it does nothing:
>>
>> public boolean isCompatible(MibValue value)
>>
>> Checks if the specified value is compatible with this constraint.
>> This method will always return false, as no values can be compatible
>> with a size constraint.
>>
>> Am I missing something? Is there some other mechanism for checking
>> that a StringValue complies with the following definition:
>>
>> system-Location OBJECT-TYPE
>> SYNTAX OCTET STRING (SIZE(0..20))
>>
>>
>> While typing this, I'm wondering how the constraints work for numeric
>> ranges. I'll go and try some out.
>>
>> Any help would be appreciated.
>>
>> Cheers
>> Paul
>>
>>
>> _______________________________________________
>> Mibble-users mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/mibble-users
>>
>>
>
>
> _______________________________________________
> Mibble-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/mibble-users
>
>
_______________________________________________
Mibble-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/mibble-users