de.hpi.fgis.dude.datasource
Class JSONSource

java.lang.Object
  extended by de.hpi.fgis.dude.util.AbstractCleanable
      extended by de.hpi.fgis.dude.datasource.AbstractDataSource<JSONSource>
          extended by de.hpi.fgis.dude.datasource.JSONSource
All Implemented Interfaces:
DataSource, Cleanable, AutoJsonable, Jsonable, JsonableReader<DuDeObject>, Closeable, Iterable<DuDeObject>

public class JSONSource
extends AbstractDataSource<JSONSource>
implements Jsonable

JSONSource represents files containing Json syntax. The underlying file should contain a Json array of Json records. Each record collects the data of one DuDeObject.

Author:
Matthias Pohl

Nested Class Summary
protected  class JSONSource.JSONSourceIterator
          JSONSourceIterator is used for generating DuDeObjects out of JSONSources.
 
Nested classes/interfaces inherited from class de.hpi.fgis.dude.datasource.AbstractDataSource
AbstractDataSource.AbstractDataSourceIterator<T extends AbstractDataSource<?>>
 
Constructor Summary
protected JSONSource()
          Internal constructor for Jsonable deserialization.
  JSONSource(String identifier, File file)
          Initializes a JSONSource.
 
Method Summary
 void fromJson(DuDeJsonParser<?> jsonParser)
          Initializes the current instance using the passed DuDeJsonParser.
 Iterator<DuDeObject> iterator()
           
 void toJson(DuDeJsonGenerator jsonGenerator)
          Generates the Json code using the passed DuDeJsonGenerator.
 
Methods inherited from class de.hpi.fgis.dude.datasource.AbstractDataSource
addIdAttributes, autoGeneratedIds, close, equals, getExtractedRecordCount, getIdAttributes, getIdentifier, hashCode, setExtractedRecordCount, toString, withIdAttributes
 
Methods inherited from class de.hpi.fgis.dude.util.AbstractCleanable
cleanUp, registerCleanable, registerCloseable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.hpi.fgis.dude.util.Cleanable
cleanUp, registerCleanable, registerCloseable
 

Constructor Detail

JSONSource

protected JSONSource()
Internal constructor for Jsonable deserialization.


JSONSource

public JSONSource(String identifier,
                  File file)
           throws FileNotFoundException
Initializes a JSONSource.

Parameters:
identifier - The identifier of the DataSource instance.
file - The file of which the data will be extracted.
Throws:
FileNotFoundException - If the passed file does not exist.
Method Detail

iterator

public Iterator<DuDeObject> iterator()
Specified by:
iterator in interface Iterable<DuDeObject>
Specified by:
iterator in class AbstractDataSource<JSONSource>

toJson

public void toJson(DuDeJsonGenerator jsonGenerator)
            throws org.codehaus.jackson.JsonGenerationException,
                   IOException
Description copied from interface: Jsonable
Generates the Json code using the passed DuDeJsonGenerator.

Specified by:
toJson in interface Jsonable
Parameters:
jsonGenerator - The DuDeJsonGenerator that is used internally.
Throws:
org.codehaus.jackson.JsonGenerationException - If an error occurs while generating the Json syntax.
IOException - If an error occurs while writing to the output.

fromJson

public void fromJson(DuDeJsonParser<?> jsonParser)
              throws org.codehaus.jackson.JsonParseException,
                     IOException
Description copied from interface: Jsonable
Initializes the current instance using the passed DuDeJsonParser.

Specified by:
fromJson in interface Jsonable
Parameters:
jsonParser - The parser that is used for extracting the data out of the Json.
Throws:
org.codehaus.jackson.JsonParseException - If an error occurs while parsing the Json.
IOException - If an error occurs while reading from the stream.


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.