org.weblab_project.core.helper
Interface PoKHelper

All Known Subinterfaces:
AnnotationHelper, AnnotationHelperExtended, PoKHelperExtended

public interface PoKHelper

API to manipulate a unique PieceOfKnowledge object.

In this new version of helpers, a lots of method have been added. They shall be easier to understand and use. No more boolean in parameters, and only the much simpler part of RDF will be used (i.e. no anonymous resources and no reified statements).
Some former methods gone Deprecated.

In this class a lot of abbreviation are used to reduce the length of the methods. Those convention are commons with PoKHelperExtended, ResourceHelper and ResourceHelperExtended.

If you are performing a lots of changes on the same PieceOfKnowledge. Best practice is to first call setAutoCommitMode(boolean) with false parameter, and then at the end of your process to call the commit() method. It will enable to win a lot of time, preventing from serialising and writing the RDF/XML into the data field the PieceOfKnowledge at each writing method call.

Author:
gdupont, ymombrun Copyright EADS 18 Jan 2008
See Also:
PoKHelperExtended, ResourceHelper, ResourceHelperExtended
Date:
2009-06-23

Method Summary
 void commit()
          A call to commit is needed when PoKHelper do not works in "autoCommitMode".
 void createLitStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String litObj)
          Creates a statement having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.
 void createLitStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String litObj, java.lang.String language)
          Creates a statement having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.
 void createResStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String uriObj)
          Creates a statement having uriSubj as subject, uriPred as predicate and uriObj as URI of the object.
 java.util.List<java.lang.String> getLitsOnPredSubj(java.lang.String uriSubj, java.lang.String uriPred)
           
 java.util.List<java.lang.String> getLitsOnPredSubj(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String language)
           
 org.weblab_project.core.model.PieceOfKnowledge getPoK()
          Retrieve the current PieceOfKnowledge which is manipulated.
 java.util.Set<java.lang.String> getPreds()
           
 java.util.Set<java.lang.String> getPredsOnSubj(java.lang.String uriSubj)
           
 java.lang.String getRdfXml()
           
 java.util.List<java.lang.String> getRessOnPredSubj(java.lang.String uriSubj, java.lang.String uriPred)
           
 java.util.Set<java.lang.String> getSubjs()
           
 java.util.Set<java.lang.String> getSubjsOnPred(java.lang.String uriPred)
           
 java.util.Set<java.lang.String> getSubjsOnPredLit(java.lang.String uriPred, java.lang.String litObj)
           
 java.util.Set<java.lang.String> getSubjsOnPredRes(java.lang.String uriPred, java.lang.String uriObj)
           
 boolean hasLitStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String litObj)
           
 boolean hasResStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String uriObj)
           
 boolean isDefinedResource(java.lang.String uri)
          Tests if the given URI is defined as a named resource in the PieceOfKnowledge.
 void loadFromRdfXml(java.lang.String rdfXml)
          Loads an RDF/XML String, to be queried.
 void removeLitStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String litObj)
          Removes every statements having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.
 void removeResStat(java.lang.String uriSubj, java.lang.String uriPred, java.lang.String uriObj)
          Removes every statements having uriSubj as subject, uriPred as predicate and uriObj as URI of the object.
 void removeStatsOnSubj(java.lang.String uriSubj)
          Removes every statements having uriSubj as subject whatever are predicate and object.
 void removeStatsWithLit(java.lang.String litObj)
          Removes every statements having litObj as object literal value whatever are subject and predicate.
 void removeStatsWithPred(java.lang.String uriPred)
          Removes every statements having uriPred as predicate whatever are subject and object.
 void removeStatsWithRes(java.lang.String uriObj)
          Removes every statements having uriObj as object named resource URI value whatever are subject and predicate.
 void setAutoCommitMode(boolean autoCommitMode)
          In auto commit mode, remove and create operations are writing into the PieceOfKnowledge each time they are called.
 void setPoK(org.weblab_project.core.model.PieceOfKnowledge pok)
          Fixes the current PieceOfKnowledge which is manipulated by the helper.
 

Method Detail

commit

void commit()
A call to commit is needed when PoKHelper do not works in "autoCommitMode". Other with this call is not needed.

See Also:
setAutoCommitMode(boolean)

getPoK

org.weblab_project.core.model.PieceOfKnowledge getPoK()
Retrieve the current PieceOfKnowledge which is manipulated. Please not that this will not commit any changes made into the RDF/XML if PoKHelper do not works in "autoCommitMode" and if you did not call commit() method.

Returns:
The loaded PieceOfKnowledge.

setPoK

void setPoK(org.weblab_project.core.model.PieceOfKnowledge pok)
Fixes the current PieceOfKnowledge which is manipulated by the helper. Note that using an PoKHelper without PieceOfKnowledge will throw RuntimeException.

Parameters:
pok - An existing PieceOfKnowledge

setAutoCommitMode

void setAutoCommitMode(boolean autoCommitMode)
In auto commit mode, remove and create operations are writing into the PieceOfKnowledge each time they are called. When performing a lot's of actions on the RDF, best practice is to set auto commit mode to false and to commit at the end of the process.

Parameters:
autoCommitMode - Whether or not to commit any changes (made by create and remove operations) on the PieceOfKnowledge.

getRdfXml

java.lang.String getRdfXml()
Returns:
A valid RDF/XML String of the current changed made.

loadFromRdfXml

void loadFromRdfXml(java.lang.String rdfXml)
                    throws org.weblab_project.core.exception.WebLabCheckedException
Loads an RDF/XML String, to be queried.

Parameters:
rdfXml - A RDF/XML content to be loaded.
Throws:
org.weblab_project.core.exception.WebLabCheckedException - If the rdfXml is not an RDF/XML valid String.

getLitsOnPredSubj

java.util.List<java.lang.String> getLitsOnPredSubj(java.lang.String uriSubj,
                                                   java.lang.String uriPred)
Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
Returns:
A List containing values of every literal that are object of statements having uriPred as predicate and uriSubj as subject in the PieceOfKnowledge.

getLitsOnPredSubj

java.util.List<java.lang.String> getLitsOnPredSubj(java.lang.String uriSubj,
                                                   java.lang.String uriPred,
                                                   java.lang.String language)
Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
language - The xml:lang attribute for this literal.
Returns:
A List containing values in language language of every literal that are object of statements having uriPred as predicate and uriSubj as subject in the PieceOfKnowledge. For more information about language attribute, see http://www.w3.org/TR/REC-xml/#sec-lang-tag.

getPredsOnSubj

java.util.Set<java.lang.String> getPredsOnSubj(java.lang.String uriSubj)
Parameters:
uriSubj - The URI of the subject resource.
Returns:
A Set containing URIs of every named resources that are predicate of any statement having uriSubj as subject in the PieceOfKnowledge.

getRessOnPredSubj

java.util.List<java.lang.String> getRessOnPredSubj(java.lang.String uriSubj,
                                                   java.lang.String uriPred)
Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
Returns:
A List containing URIs of every named resources that are object of statements having uriPred as predicate and uriSubj as subject in the PieceOfKnowledge.

getSubjs

java.util.Set<java.lang.String> getSubjs()
Returns:
A Set containing URIs of every named resources that are subject of any statement in the PieceOfKnowledge.

getSubjsOnPred

java.util.Set<java.lang.String> getSubjsOnPred(java.lang.String uriPred)
Parameters:
uriPred - The URI of the predicate resource.
Returns:
A Set containing URIs of every named resources that are subject of statements having uriPred as predicate in the PieceOfKnowledge.

getSubjsOnPredLit

java.util.Set<java.lang.String> getSubjsOnPredLit(java.lang.String uriPred,
                                                  java.lang.String litObj)
Parameters:
uriPred - The URI of the predicate resource.
litObj - The literal value of the object.
Returns:
A Set containing URIs of every named resources that are subject of statements having uriPred as predicate and litObj as object literal value in the PieceOfKnowledge.

getSubjsOnPredRes

java.util.Set<java.lang.String> getSubjsOnPredRes(java.lang.String uriPred,
                                                  java.lang.String uriObj)
Parameters:
uriPred - The URI of the predicate resource.
uriObj - The URI of the object resource.
Returns:
A Set containing URIs of every named resources that are subject of statements having uriPred as predicate and uriObj as object named resource URI in the PieceOfKnowledge.

hasLitStat

boolean hasLitStat(java.lang.String uriSubj,
                   java.lang.String uriPred,
                   java.lang.String litObj)
Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
litObj - The literal value of the object.
Returns:
Whether or not the PieceOfKnowledge contains at least one statement having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.

hasResStat

boolean hasResStat(java.lang.String uriSubj,
                   java.lang.String uriPred,
                   java.lang.String uriObj)
Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
uriObj - The URI of the object resource.
Returns:
Whether or not the PieceOfKnowledge contains at least one statement having uriSubj as subject, uriPred as predicate and uriObj as URI of the object.

isDefinedResource

boolean isDefinedResource(java.lang.String uri)
Tests if the given URI is defined as a named resource in the PieceOfKnowledge.

Parameters:
uri - The URI to test existence in the PieceOfKnowledge.
Returns:
true if the URI is defined as a named resource URI in the PieceOfKnowledge.

getPreds

java.util.Set<java.lang.String> getPreds()
Returns:
A Set containing URIs of properties that are predicate of any statement in the PieceOfKnowledge.

createLitStat

void createLitStat(java.lang.String uriSubj,
                   java.lang.String uriPred,
                   java.lang.String litObj,
                   java.lang.String language)
Creates a statement having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.

Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
litObj - The literal value of the object.
language - The language of the literal value. See http://www.w3.org/TR/REC-xml/#sec-lang-tag for more information.

createLitStat

void createLitStat(java.lang.String uriSubj,
                   java.lang.String uriPred,
                   java.lang.String litObj)
Creates a statement having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.

Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
litObj - The literal value of the object.

createResStat

void createResStat(java.lang.String uriSubj,
                   java.lang.String uriPred,
                   java.lang.String uriObj)
Creates a statement having uriSubj as subject, uriPred as predicate and uriObj as URI of the object.

Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
uriObj - The URI of the object resource.

removeLitStat

void removeLitStat(java.lang.String uriSubj,
                   java.lang.String uriPred,
                   java.lang.String litObj)
Removes every statements having uriSubj as subject, uriPred as predicate and litObj as literal value of the object.

Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
litObj - The literal value of the object.

removeResStat

void removeResStat(java.lang.String uriSubj,
                   java.lang.String uriPred,
                   java.lang.String uriObj)
Removes every statements having uriSubj as subject, uriPred as predicate and uriObj as URI of the object.

Parameters:
uriSubj - The URI of the subject resource.
uriPred - The URI of the predicate resource.
uriObj - The URI of the object resource.

removeStatsOnSubj

void removeStatsOnSubj(java.lang.String uriSubj)
Removes every statements having uriSubj as subject whatever are predicate and object.

Parameters:
uriSubj - The URI of the subject resource.

removeStatsWithLit

void removeStatsWithLit(java.lang.String litObj)
Removes every statements having litObj as object literal value whatever are subject and predicate.

Parameters:
litObj - The literal value of the object.

removeStatsWithPred

void removeStatsWithPred(java.lang.String uriPred)
Removes every statements having uriPred as predicate whatever are subject and object.

Parameters:
uriPred - The URI of the predicate resource.

removeStatsWithRes

void removeStatsWithRes(java.lang.String uriObj)
Removes every statements having uriObj as object named resource URI value whatever are subject and predicate.

Parameters:
uriObj - The URI of the object resource. The URI of the object resource.


Copyright © 2004-2009. All Rights Reserved.