de.hpi.fgis.dude.datasource
Class JSONSource
java.lang.Object
de.hpi.fgis.dude.util.AbstractCleanable
de.hpi.fgis.dude.datasource.AbstractDataSource<JSONSource>
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
Methods inherited from class de.hpi.fgis.dude.datasource.AbstractDataSource |
addIdAttributes, autoGeneratedIds, close, equals, getExtractedRecordCount, getIdAttributes, getIdentifier, hashCode, setExtractedRecordCount, toString, withIdAttributes |
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.
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.