www.pudn.com > jenaSearch.rar > searchRerult.java, change:2005-06-08,size:1525b


package cyh; 
import com.hp.hpl.jena.rdf.*; 
import com.hp.hpl.jena.rdf.model.*; 
import com.hp.hpl.jena.ontology.*; 
import com.hp.hpl.jena.reasoner.*; 
import com.hp.hpl.jena.vocabulary.*; 
import com.hp.hpl.jena.reasoner.rulesys.*; 
import com.hp.hpl.jena.util.*; 
public class searchRerult { 
    public getInfModel myGet = new getInfModel (); 
    public InfModel model=myGet.getInfModel() ; 
public  ResIterator search(String item,String value){ 
 
    Property searchProperty; 
    ResIterator searchResult=null; 
    getInfModel myGet = new getInfModel (); 
 
    searchProperty=model.getProperty(myGet.itemToProperty(item)); 
    if(item.equals("author") ){ 
    Resource SearchValue; 
    SearchValue=model.createResource(myGet.addNameSpace(value)); 
    searchResult=model.listSubjectsWithProperty(searchProperty,SearchValue); 
    }else if (item.equals("keywords")||item.equals("title")){ 
    String SearchValue=value; 
    searchResult=model.listSubjectsWithProperty(searchProperty,SearchValue); 
    } 
 
     return searchResult; 
} 
 public String getValue(Resource res,String item){ 
       String result=null; 
       Property searchProperty; 
       searchProperty=model.getProperty(myGet.itemToProperty(item)); 
       StmtIterator SearchResult=model.listStatements(res,searchProperty,(RDFNode)null); 
 
       while(SearchResult.hasNext() ){ 
       result=SearchResult.nextStatement().getObject().toString() ; 
       } 
       return myGet.removeType(result);//SearchResult.toString(); 
      } 
 
}