Version: 1.1.1

org.biomoby.shared.extended
Class ServiceInstanceParser

java.lang.Object
  extended by org.biomoby.shared.extended.ServiceInstanceParser

public class ServiceInstanceParser
extends Object

Author:
Eddie Kawas, Wendy Alexander created Oct 18, 2005 This class parses the RDF document that describes the service instance ontology.

An example of how to use this class is below:


               import org.biomoby.shared.MobyService;
               import org.biomoby.shared.Utils;
               import org.biomoby.shared.extended.ServiceInstanceParser;
               
               ...
                     
                          ServiceInstanceParser p = new ServiceInstanceParser(
                                        "http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances");
                        MobyService[] services = p.getMobyServicesFromRDF();
                        if (!p.isRDFValid()) {
                                System.out.println("One or more services in the RDF were invalid");
                                System.out.println("The errors are the following:");
                                System.out.println(Utils.format(p.getErrors(),2));
                                
                        }
                        System.out.println("The valid services are:");
                        for (int i = 0; i < services.length; i++) {
                                System.out.println((services[i]));
                        }
 

This would output the following a textual description of service instances in the document


Constructor Summary
ServiceInstanceParser()
          Default constructor - need to set the URL for the RDF document that describes the service ontology using setURL(String url) or setURL(URL url)
ServiceInstanceParser(String url)
          Parameterized Constructor that takes in a string argument that is the url for the RDF document that describes the service ontology.
ServiceInstanceParser(URL url)
          Parameterized Constructor that takes in a url for the RDF document that describes the service ontology.
 
Method Summary
 String getErrors()
           
 MobyService[] getMobyServicesFromRDF()
           
 MobyService[] getMobyServicesFromRDF(com.hp.hpl.jena.rdf.model.Model model)
           
 MobyService[] getMobyServicesFromRDF(String rdf)
           
 URL getUrl()
           
 boolean isRDFValid()
          Method to check whether an RDF document contained only valid services.
static void main(String[] args)
           
 void setUrl(String url)
           
 void setUrl(URL url)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceInstanceParser

public ServiceInstanceParser()
Default constructor - need to set the URL for the RDF document that describes the service ontology using setURL(String url) or setURL(URL url)


ServiceInstanceParser

public ServiceInstanceParser(String url)
                      throws MobyException
Parameterized Constructor that takes in a string argument that is the url for the RDF document that describes the service ontology.

Parameters:
url - a string representation for the URL that resolves to the RDF document that describes the service ontology
Throws:
MobyException - thrown if the url is malformed

ServiceInstanceParser

public ServiceInstanceParser(URL url)
                      throws MobyException
Parameterized Constructor that takes in a url for the RDF document that describes the service ontology.

Parameters:
url - the URL that resolves to the RDF document that describes the service ontology
Throws:
MobyException - thrown if the url is malformed
Method Detail

getMobyServicesFromRDF

public MobyService[] getMobyServicesFromRDF()
                                     throws MobyException
Returns:
an array of MobyService objects created by parsing the RDF document
Throws:
MobyException - thrown if the location of the RDF document describing the service ontology is invalid or if there is a parsing error

getMobyServicesFromRDF

public MobyService[] getMobyServicesFromRDF(com.hp.hpl.jena.rdf.model.Model model)
                                     throws MobyException
Parameters:
model - a Model containing the Moby services that you would like to extract
Returns:
an array of MobyService objects.
Throws:
MobyException - if there is a parsing error

getMobyServicesFromRDF

public MobyService[] getMobyServicesFromRDF(String rdf)
                                     throws MobyException
Parameters:
rdf - a valid RDF document to be parsed into moby services
Returns:
an array of MobyService objects
Throws:
MobyException - if there are any parsing errors

setUrl

public void setUrl(URL url)
            throws MobyException
Parameters:
url - the URL that resolves to the RDF document that describes the service ontology
Throws:
MobyException - thrown if the url is malformed

setUrl

public void setUrl(String url)
            throws MobyException
Parameters:
url - the string represention of the URL that resolves to the RDF document that describes the service ontology.
Throws:
MobyException - thrown if the url is malformed

getUrl

public URL getUrl()
Returns:
the url used to retrieve the RDF document that describes the service ontology.

isRDFValid

public boolean isRDFValid()
Method to check whether an RDF document contained only valid services.

Returns:
true if the last rdf document contained no invalid services, false otherwise

getErrors

public String getErrors()
Returns:
a string containing any errors obtained by parsing the RDF document. These errors are service specific errors, like unamed inputs, etc.

main

public static void main(String[] args)
                 throws MobyException,
                        MalformedURLException,
                        IOException
Throws:
MobyException
MalformedURLException
IOException

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010