mibble-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mibble-users] SizeConstaint.isCompatible( mibValue) doesn't check t


From: Paul Faid
Subject: Re: [Mibble-users] SizeConstaint.isCompatible( mibValue) doesn't check the size of mibValue.. why not?
Date: Tue, 9 Jan 2007 11:19:07 +1300

Thanks for the quick response.

Your solution worked fine.

Regards
Paul


On 1/8/07, Per Cederberg <address@hidden> wrote:
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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]