Hello Tina,

 


> I want to sum 5 with the value already stored in a property.
>
> //Property "Hours" must be started from 1 and then sum 5 with it.
> employee.getPropertyValue(No_of_Hours);
> //Then perform calculations.
>
> The problem is that if I directly use employee.getPropertyValue(), it gives
> me "Exception" (and rightly, because I did not set setPropertyValue()
> first).
That's not true. It returns null if there is no such value - and you
have to handle this in the code indeed.
>
> But the problem is that when I set employee.getPropertyValue(No_of_Hours);
>  to 1 (one), it will always set the value 1(one) and not the recent
> added(sum) value in the property.
>
> employee.setPropertyValue(No_of_Hours, 1); //1 is literal
> employee.getPropertyValue(No_of_Hours);
> //calculations
> My requirement is like: int sum=No_of_Hours+1;
> Then No_of_Hours plus what in the *variable sum*.
>
> So can I use employee.addLiteral(No_of_Hours, 1) instead of
> employee.setPropertyValue().
>
> I hope you have understood what my issue is?
>
> Kindest regards
>
>
>
> On Sun, Oct 16, 2016 at 11:10 AM, Dave Reynolds <dave.e.reyno...@gmail.com>
> wrote:
>
>> On 16/10/16 16:59, tina sani wrote:
>>
>>> Hi
>>>
>>> What is the difference between addLiteral() and setpropertyvalue() when we
>>> want to assign values to an individual.?
>>> For example,
>>>
>>> //myEmployee is an instance.
>>>
>>> myEmplyee.addliteral(property, value)
>>> myEmployee.setpropertyvalue(property, value)
>>>
>>>
>> addLiteral adds a value, so if there is already a value there you will now
>> have multiple values.
>>
>> setPropertyValue removes all existing values before adding the new value
>> so you will only have the new value at the end.
>>
>> Dave
>>
>>
-- 
Lorenz B├╝hmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

Reply via email to