A Complete, Minimal Example please.

Partial code, no data is not complete.
It must compile and run to be complete.

Minimal means only what is necessary to ask the question not the whole data or whole application.

    Andy

On 17/01/17 17:14, Sidra shah wrote:
I am surprise that when there is no value in BestCategory, it gives me no
error and when the rule executes and value comes in BestCategory, it gives
me now *"RequiredLiteralException*"
The code I used here is

 OntProperty favcat=model2.getOntProperty(ns+ "BestCategory");

RDFNode phFav=indiv.getPropertyValue(favcat);
             if (phFav!=null){
              Literal l1=phFav.asLiteral();

               s1=l1.toString();}

    if (s1=="CatPhysics"){
             JOptionPane.showMessageDialog(null, "Physics");
              }

Best regards

On Tue, Jan 17, 2017 at 5:53 PM, Sidra shah <s.shahcyp...@gmail.com> wrote:

Hello Chris, thanks a lot for your suggestion.

Best regards.

On Tue, Jan 17, 2017 at 5:37 PM, Chris Dollin <
chris.dol...@epimorphics.com> wrote:



On 17/01/17 13:30, Sidra shah wrote:

Hi Lorenz, I am sorry but with much regards, you discussed here the
problem, not the solution  :) :)

I know this if there is no value, there must be Null exception,


This is not true.

but can you suggest me a way where we dodge the compiler


No "dodging" of the compiler is required. Instead, just write
perfectly ordinary code that tests to see if the result of
getPropertyValue is null, and take one action if it isn't and
a different one if it is.

There's nothing special about this. You don't need to use
break (which is for escaping from loops); just an if
with suitable then and else parts.

I know this is more a Java problem, but any help I will appreciate.


Find someone /local/ doing the same or similar course and talk to
them (and have them talk to you) about programming and this
problem. I don't mean copy each other's work; I mean use each
other to understand what the problem is about and how the code
works. Each of you will know things that the other doesn't; share.

Chris

--
"He could not weigh up which was worse and so tried not to think about
either."
                                                /The Spellgrinder's
Apprentice/

Epimorphics Ltd, http://www.epimorphics.com
Registered address: Court Lodge, 105 High Street, Portishead, Bristol
BS20 6PT
Epimorphics Ltd. is a limited company registered in England (number
7016688)




Reply via email to