# Linked Data Aware Agent Development Framework for Mobile Devices
## 4 Case Study and Discussion
### Using the LDAF-M Framework
#### 4.2.2 Defining Beliefs  
As mentioned before, beliefs of an agent can be obtained dynamically from linked data resources as well as the other data sources defined by the developers. In this context, two different classes are used in defining the belief component of an agent. LinkedDataMetaBelief class which is extended from the MetaBelief class is responsible for representing beliefs coming from the linked data environment. It has a three-parameter constructor, using which a belief coming from a linked data resource is defined. The first parameter is the name given to the belief, while the second parameter is the URI of one of the related RDF documents that includes data that constitutes the content of the belief component. The third parameter is the name of the belief category that the defined belief belongs. The code fragment illustrating this process on an example belief in the auction application is given in Listing 2.  
```
01 getBeliefBase().addGroupName(\"sell_product\");
02 getBeliefBase().addGroupName(\"receive_product\");
03 MetaBelief metaBelief = new LinkedDataMetaBelief(\"sell_product1\",
04\"[[http://rdf.freebase.com/rdf/m.0](http://rdf.freebase.com/rdf/m.0) pd3 pb_]([http://rdf.freebase.com/rdf/m.0](http://rdf.freebase.com/rdf/m.0) pd3 pb_)\",\"sell_product\");
05 getBeliefBase().addMetaBelief(metaBelief);
06 metaBelief = new LinkedDataMetaBelief(\"receive_product1\",
07\"[[http://rdf.freebase.com/rdf/m.0](http://rdf.freebase.com/rdf/m.0) pd3 ftx]([http://rdf.freebase.com/rdf/m.0](http://rdf.freebase.com/rdf/m.0) pd3 ftx)\",\"receive_product\");
08 getBeliefBase().addMetaBelief(metaBelief);
```  
Listing 2: Defining linked data beliefs.  
As shown in Listing 2, initially two belief categories, one for selling and the other for buying, are defined. Then, information about a product that is going to be sold is obtained from an RDF document in the Freebase environment and added as a belief to the agent's belief base. Similarly, another belief about buying a product is also added to the belief base of the agent.  
The other class used in defining beliefs is the UserDefinedMetaBelief class which is extended from the MetaBelief class. This class is responsible for obtaining beliefs from the user defined data resources. It has a two-parameter constructor used in defining beliefs. The first parameter is the name given to the belief and the second parameter is the type of the data that constitutes the content of the belief component. The code fragment illustrating this process on an example belief in the auction application is given in Listing 3. The definition of two beliefs which are about an action and the participant list are given in Listing 3 respectively.  
```
01 MetaBelief metaBelief = new UserDefinedMetaBelief(\"auction\", Auction.class);
02 getBeliefBase().addMetaBelief(metaBelief);
03 metaBelief = new UserDefinedMetaBelief(\"participants\", Vector.class);
04 getBeliefBase().addMetaBelief(metaBelief);
```  
Listing 3: Defining other beliefs.  
Both kinds of beliefs defined above are linked to the belief base of the agent by calling the addMetaBelief method that adds a belief passed to it as a parameter to the belief base of the agent.