info.sswap.ontologies.data.impl
Class AbstractData

java.lang.Object
  extended by info.sswap.ontologies.data.impl.AbstractData
All Implemented Interfaces:
Data, Parser, Serializer, Validator
Direct Known Subclasses:
LiteralData, ResourceData

public abstract class AbstractData
extends java.lang.Object
implements Data, Parser, Serializer, Validator

emphasize point that in cases: 1. one literal data prop 2. no literal data prop but ind URL that all is automatic: just call readData and writeData

Author:
ddg

Field Summary
protected  SSWAPType DataFormatType
           
protected  SSWAPDocument sswapDocument
           
protected  SSWAPIndividual sswapIndividual
           
 
Constructor Summary
AbstractData(SSWAPIndividual sswapIndividual)
          Constructor to access a literalData property or the individual itself as the data object.
 
Method Summary
 java.util.Set<java.net.URI> getAccessors()
          Return a set of URIs of declared accessors for the data.
 java.util.Set<SSWAPType> getFormats()
          Get explicit and inferred subTypes of data:DataFormat
 SSWAPIndividual getIndividual()
           
private  java.util.Set<java.net.URI> getObjectURIs(java.net.URI objectPredicateURI)
          Returns the URIs that correspond to the objects of an object property.
 java.util.Set<java.net.URI> getParsers()
          Return a set of URIs for declared parsers for the data.
 java.util.Set<java.net.URI> getSerializers()
          Return a set of URIs for declared serializers for the data.
 java.util.Set<java.net.URI> getValidators()
          Return a set of URIs for declared validators for the data.
protected  boolean hasValue(java.net.URI ontologyPredicateURI, java.net.URI value)
          Returns true if any instance of the predicate has the given value; false otherwise.
 java.lang.String inputStreamToString(java.io.InputStream inputStream)
          Convenience method to convert an input stream into a string.
 java.io.InputStream parse(java.io.InputStream inputStream)
          Default implementation just passes inputStream untouched.
 java.io.InputStream serialize(java.io.InputStream inputStream)
          Default implementation just passes inputStream untouched.
protected  void setValue(java.net.URI ontologyPredicateURI, java.net.URI value, boolean on)
          Sets th
 java.io.InputStream stringToInputStream(java.lang.String string)
          Convenience method to convert a string into an input stream.
 java.io.InputStream validate(java.io.InputStream inputStream)
          Default implementation just passes inputStream untouched.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.sswap.ontologies.data.api.Data
readData, writeData
 

Field Detail

DataFormatType

protected final SSWAPType DataFormatType

sswapDocument

protected final SSWAPDocument sswapDocument

sswapIndividual

protected final SSWAPIndividual sswapIndividual
Constructor Detail

AbstractData

public AbstractData(SSWAPIndividual sswapIndividual)
             throws DataException
Constructor to access a literalData property or the individual itself as the data object. Calls setDataElement as part of the initialization.

Parameters:
sswapIndividual - individual to be the subject of data types and properties
Throws:
DataException
Method Detail

parse

public java.io.InputStream parse(java.io.InputStream inputStream)
                          throws java.io.IOException,
                                 ParserException
Default implementation just passes inputStream untouched. Custom implementations may extend this class and override this method. Note that parsing is filter: accepting an input stream to read and returning an input stream for the next downstream step to read.

Specified by:
parse in interface Parser
Parameters:
inputStream - raw (unparsed) stream to be read
Returns:
parsed stream ready for reading
Throws:
java.io.IOException - on any network error
ParserException - on any Parser-specific error

serialize

public java.io.InputStream serialize(java.io.InputStream inputStream)
                              throws java.io.IOException,
                                     SerializerException
Default implementation just passes inputStream untouched. Custom implementations may extend this class and override this method. Note that serializing is filter: accepting an input stream to read and returning an input stream for the next downstream step to read.

Specified by:
serialize in interface Serializer
Parameters:
inputStream - raw (un-serialized) stream to be read
Returns:
serialized stream ready for reading (e.g., for consequent writing to an output stream)
Throws:
java.io.IOException - on any network error
SerializerException - on any Serializer-specific error

validate

public java.io.InputStream validate(java.io.InputStream inputStream)
                             throws java.io.IOException,
                                    ValidatorException
Default implementation just passes inputStream untouched. Custom implementations may extend this class and override this method. Note that validating is filter: accepting an input stream to read and returning an input stream for the next downstream step to read.

Specified by:
validate in interface Validator
Parameters:
inputStream - raw (pre-validated) stream to be read
Returns:
validated stream ready for reading
Throws:
java.io.IOException - on any network error
ValidatorException - on any Validator-specific error

hasValue

protected boolean hasValue(java.net.URI ontologyPredicateURI,
                           java.net.URI value)
Returns true if any instance of the predicate has the given value; false otherwise.

Parameters:
ontologyPredicateURI -
value - base64Parser or base64Serializer
Returns:
parserOrSerializer if set; null otherwise

setValue

protected void setValue(java.net.URI ontologyPredicateURI,
                        java.net.URI value,
                        boolean on)
Sets th

Parameters:
ontologyPredicateURI -
value - base64Parser or base64Serializer

inputStreamToString

public java.lang.String inputStreamToString(java.io.InputStream inputStream)
Convenience method to convert an input stream into a string.

Parameters:
inputStream - stream to read
Returns:
String string representation of the stream, or null on error

stringToInputStream

public java.io.InputStream stringToInputStream(java.lang.String string)
Convenience method to convert a string into an input stream. Implementation is an in-memory input stream which does not need to be closed when done.

Parameters:
string - string to read
Returns:
input stream ready for reading

getFormats

public java.util.Set<SSWAPType> getFormats()
Description copied from interface: Data
Get explicit and inferred subTypes of data:DataFormat

Specified by:
getFormats in interface Data
Returns:
a set of all data types for which this individual belongs.

getAccessors

public java.util.Set<java.net.URI> getAccessors()
Description copied from interface: Data
Return a set of URIs of declared accessors for the data. An accessor is a agent for access to the data; it may be a simple read and stream of the underlying data, or it may wrap user authentication and authorization. Specifics of how an accessor is invoked and how it accesses the data are local to the specific accessor and not specified here.

Accessors are determined by the values of the data:hasAccessor property.

Specified by:
getAccessors in interface Data
Returns:
set of URIs that are the objects of the data:hasAccessor property

getParsers

public java.util.Set<java.net.URI> getParsers()
Description copied from interface: Data
Return a set of URIs for declared parsers for the data. A parser should read the data (given some format) and return it as a more manageable object. Specifics of how a parser is invoked to read the data, how it parses the data, and what it returns are local to the specific parser and not specified here.

Parsers are determined by the values of the data:hasParser property.

Specified by:
getParsers in interface Data
Returns:
set of URIs that are the objects of the data:hasParser property

getSerializers

public java.util.Set<java.net.URI> getSerializers()
Description copied from interface: Data
Return a set of URIs for declared serializers for the data. A serializer should write the data (given some format). Specifics of how a serializer is invoked to write the data and how it formats the data are local to the specific serializer and not specified here.

Serializer are determined by the values of the data:hasSerializer property.

Specified by:
getSerializers in interface Data
Returns:
set of URIs that are the objects of the data:hasSerializer property

getValidators

public java.util.Set<java.net.URI> getValidators()
Description copied from interface: Data
Return a set of URIs for declared validators for the data. A validator should test the data for conformity to a set of standards. Validators may be used both in reading and writing the data. Specifics of how a validator is invoked, how it validates the data, and what it returns are local to the specific validator and not specified here.

Validators are determined by the values of the data:hasValidator property.

Specified by:
getValidators in interface Data
Returns:
set of URIs that are the objects of the data:hasValidator property

getIndividual

public SSWAPIndividual getIndividual()
Specified by:
getIndividual in interface Data
Returns:
the source SSWAPIndividual for this Data object

getObjectURIs

private java.util.Set<java.net.URI> getObjectURIs(java.net.URI objectPredicateURI)
Returns the URIs that correspond to the objects of an object property.

Parameters:
objectPredicateURI - URI of the property for which to return its object
Returns:
the set of URIs (RDF resources, not xsd:anyURI) that are the objects of the argument property


Copyright (c) 2011, iPlant Collaborative, University of Arizona, Cold Spring Harbor Laboratories, University of Texas at Austin.