info.sswap.ontologies.data.impl
Class AttachmentImpl

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

public class AttachmentImpl
extends LiteralData

Implementation of support for "attachments"; i.e., base64 encoding of literal data

Author:
Damian Gessler

Field Summary
 
Fields inherited from class info.sswap.ontologies.data.impl.AbstractData
DataFormatType, sswapDocument, sswapIndividual
 
Constructor Summary
AttachmentImpl(SSWAPIndividual sswapIndividual)
          Enables reading and writing of literal data as base64 "attachments".
 
Method Summary
 java.io.InputStream parse(java.io.InputStream inputStream)
          Uses the default base64 parser if and only if there is a data:hasParser property with the default value (Base64Parser.uri).
 java.io.InputStream readData()
          Read the data, reading nothing (but no error) if there is no data to read.
 java.io.InputStream serialize(java.io.InputStream inputStream)
          Uses the default base64 serializer if and only if there is a data:hasSerializer property with the default value (Base64Serializer.uri).
private  void setFilter(java.net.URI xsdbase64Binary, java.net.URI hasFilterPredicate, java.net.URI base64uri)
          Set the parser or serializer depending on the datatype of the data or the ontology predicate value.
 void writeData(java.io.InputStream inputStream)
          Write to the property data:literalData, creating one if needed
 
Methods inherited from class info.sswap.ontologies.data.impl.AbstractData
getAccessors, getFormats, getIndividual, getParsers, getSerializers, getValidators, hasValue, inputStreamToString, setValue, stringToInputStream, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttachmentImpl

public AttachmentImpl(SSWAPIndividual sswapIndividual)
               throws DataAccessException
Enables reading and writing of literal data as base64 "attachments".

Parameters:
sswapIndividual - the individual holding access to the data
Throws:
DataAccessException - on any data access error
Method Detail

readData

public java.io.InputStream readData()
                             throws java.io.IOException,
                                    DataException
Description copied from class: LiteralData
Read the data, reading nothing (but no error) if there is no data to read.

The data source must be of type data:DataFormat for any meaningful read; otherwise a read "succeeds" with trivial empty content.

Specified by:
readData in interface Data
Overrides:
readData in class LiteralData
Returns:
InputStream a stream to read the data
Throws:
java.io.IOException - on any stream error
DataException - on data error such as parsing, validating, etc.

writeData

public void writeData(java.io.InputStream inputStream)
               throws java.io.IOException,
                      DataException
Description copied from class: LiteralData
Write to the property data:literalData, creating one if needed

Specified by:
writeData in interface Data
Overrides:
writeData in class LiteralData
Parameters:
inputStream - stream from which to read the data to write
Throws:
java.io.IOException - on any stream error
DataException - on data error such as validating, serializing, etc.

parse

public java.io.InputStream parse(java.io.InputStream inputStream)
                          throws java.io.IOException,
                                 ParserException
Uses the default base64 parser if and only if there is a data:hasParser property with the default value (Base64Parser.uri).

For other parsers, override this method to return a parsed input stream suitable for reading.

Specified by:
parse in interface Parser
Overrides:
parse in class AbstractData
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
See Also:
Base64Parser.uri

serialize

public java.io.InputStream serialize(java.io.InputStream inputStream)
                              throws java.io.IOException,
                                     SerializerException
Uses the default base64 serializer if and only if there is a data:hasSerializer property with the default value (Base64Serializer.uri).

For other serializers, override this method to return a serialized input stream suitable for reading by the internal writer.

Specified by:
serialize in interface Serializer
Overrides:
serialize in class AbstractData
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
See Also:
Base64Serializer.uri

setFilter

private void setFilter(java.net.URI xsdbase64Binary,
                       java.net.URI hasFilterPredicate,
                       java.net.URI base64uri)
Set the parser or serializer depending on the datatype of the data or the ontology predicate value.

Parameters:
xsdbase64Binary - the URI of the XSD base64Binary type (e.g., Base64Parser.XSDbase64Binary or Base64Serializer.XSDbase64Binary)
hasFilterPredicate - the URI of the data ontology predicate for associating with a filter (e.g., Ontology.hasParser or Ontology.hasSerializer)
base64uri - the marker URN for base64 encoding or decoding (e.g., Base64Parser.uri or Base64Serializer.uri)
See Also:
Base64Parser, Base64Serializer


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