Skip to content

Commit

Permalink
Added missing JavaDoc for the iordf module
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Oct 17, 2010
1 parent 2bf085f commit 0f22ddb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/main/org/openscience/cdk/io/rdf/CDKOWLReader.java
Expand Up @@ -48,14 +48,27 @@ public class CDKOWLReader extends DefaultChemObjectReader {

private Reader input;

/**
* Creates a new CDKOWLReader sending output to the given Writer.
*
* @param input {@link Reader} from which is OWL input is taken.
*/
public CDKOWLReader(Reader input) {
this.input = input;
}

/**
* Creates a new CDKOWLReader with an undefined input.
*/
public CDKOWLReader() {
this.input = null;
}

/**
* Returns the {@link IResourceFormat} for this reader.
*
* @return returns a {@link CDKOWLFormat}.
*/
@TestMethod("testGetFormat")
public IResourceFormat getFormat() {
return CDKOWLFormat.getInstance();
Expand All @@ -64,17 +77,22 @@ public IResourceFormat getFormat() {
/**
* This method must not be used; XML reading requires the use of an
* {@link InputStream}. Use {@link #setReader(InputStream)} instead.
*
* @param reader reader to which should be written.
* @deprecated
*/
@TestMethod("testSetReader_Reader")
public void setReader(Reader reader) throws CDKException {
this.input = reader;
}

/** {@inheritDoc} */
@TestMethod("testSetReader_InputStream")
public void setReader(InputStream input) throws CDKException {
this.input = new InputStreamReader(input);
}

/** {@inheritDoc} */
@TestMethod("testAccepts")
public boolean accepts(Class classObject) {
Class[] interfaces = classObject.getInterfaces();
Expand All @@ -86,6 +104,7 @@ public boolean accepts(Class classObject) {
return false;
}

/** {@inheritDoc} */
public IChemObject read(IChemObject object) throws CDKException {
if (object instanceof IMolecule) {
return readMolecule((IMolecule)object);
Expand All @@ -102,6 +121,7 @@ private IMolecule readMolecule(IMolecule mol) throws CDKException {
return mol;
}

/** {@inheritDoc} */
@TestMethod("testClose")
public void close() throws IOException {
input.close();
Expand Down
4 changes: 3 additions & 1 deletion src/main/org/openscience/cdk/io/rdf/CDKOWLWriter.java
Expand Up @@ -61,7 +61,9 @@ public CDKOWLWriter() {
}

/**
* Returns the {@link IResourceFormat} for this writer: {@link CDKOWLFormat}.
* Returns the {@link IResourceFormat} for this writer.
*
* @return returns a {@link CDKOWLFormat}.
*/
public IResourceFormat getFormat() {
return CDKOWLFormat.getInstance();
Expand Down
5 changes: 5 additions & 0 deletions src/main/org/openscience/cdk/libio/jena/CDK.java
Expand Up @@ -25,9 +25,14 @@
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.vocabulary.RDF;

/**
* Helper class to provide a Java API to the CDK OWL ontology, following the design of similar namespace
* classes in the Jena library, like {@link RDF}.
*
* @cdk.module iordf
* @cdk.githash
*/
public class CDK {

Expand Down
25 changes: 25 additions & 0 deletions src/main/org/openscience/cdk/libio/jena/Convertor.java
Expand Up @@ -61,6 +61,12 @@
*/
public class Convertor {

/**
* Converts a {@link IMolecule} into a {@link Model} representation using the CDK OWL.
*
* @param molecule {@link IMolecule} to serialize into a RDF graph.
* @return the RDF graph representing the {@link IMolecule}.
*/
public static Model molecule2Model(IMolecule molecule) {
Model model = createCDKModel();
Resource subject = model.createResource(
Expand Down Expand Up @@ -276,6 +282,12 @@ private static void deserializeIsotopeFields(Resource rdfObject,
isotope.setNaturalAbundance(naturalAbundance.getDouble());
}

/**
* Converts a {@link Resource} object into the matching {@link Order}.
*
* @param rdfOrder Resource for which the matching {@link Order} should be given.
* @return the matching {@link Order}.
*/
public static Order resource2Order(Resource rdfOrder) {
if (rdfOrder.equals(CDK.SINGLEBOND)) {
return Order.SINGLE;
Expand All @@ -289,6 +301,12 @@ public static Order resource2Order(Resource rdfOrder) {
return null;
}

/**
* Create the {@link Resource} matching the given {@link Order}.
*
* @param order bond order to return the matching {@link Resource} for.
* @return the matching {@link Resource}.
*/
public static Resource order2Resource(Order order) {
if (order == Order.SINGLE) {
return CDK.SINGLEBOND;
Expand Down Expand Up @@ -319,6 +337,13 @@ private static void deserializeElectronContainerFields(
bond.setElectronCount(count.getInt());
}

/**
* Converts a {@link Model} into an {@link IMolecule} using the given {@link IChemObjectBuilder}.
*
* @param model RDF graph to deserialize into an {@link IMolecule}.
* @param builder {@link IChemObjectBuilder} used to create new {@link IChemObject}s.
* @return a {@link IMolecule} deserialized from the RDF graph.
*/
public static IMolecule model2Molecule(Model model,
IChemObjectBuilder builder) {
ResIterator mols =
Expand Down

0 comments on commit 0f22ddb

Please sign in to comment.