public class TextEntitySource extends java.lang.Object implements EntitySource, Describable
Entity reader that loads entities from text data, often stored in a file.
EntitySource.Layout
Constructor and Description |
---|
TextEntitySource()
Construct a new text entity source.
|
TextEntitySource(java.lang.String name)
Construct a new text entity source.
|
Modifier and Type | Method and Description |
---|---|
void |
describeTo(DescriptionWriter writer)
Write this class’s description to a sink.
|
java.nio.file.Path |
getFile()
Get the input file path.
|
EntityFormat |
getFormat()
Get the entity format for the reader.
|
EntitySource.Layout |
getLayout()
Get this entity source’s layout, if one is available.
|
java.util.Map<java.lang.String,java.lang.Object> |
getMetadata()
Get metadata from this entity source.
|
java.lang.String |
getName()
Get the name of this data source.
|
java.util.Set<EntityType> |
getTypes()
Get the entity types produced by this source.
|
java.net.URL |
getURL()
Get the source file for this data source.
|
ObjectStream<Entity> |
openStream()
Open a stream to read entities from this source.
|
void |
setFile(java.nio.file.Path file)
Set the source file for this reader.
|
void |
setFormat(EntityFormat format)
Set the entity format for the reader.
|
void |
setSource(java.lang.CharSequence text)
Set a string from which to read entities.
|
void |
setURL(java.net.URL url)
Set the URL of the input data.
|
com.fasterxml.jackson.databind.JsonNode |
toJSON(java.net.URI base)
Construct a JSON representation of this entity source, suitable for serialization to e.g.
|
java.lang.String |
toString() |
public TextEntitySource()
Construct a new text entity source.
public TextEntitySource(java.lang.String name)
Construct a new text entity source.
name
- The source’s name.public java.lang.String getName()
Get the name of this data source.
getName
in interface EntitySource
@Nonnull public java.util.Set<EntityType> getTypes()
EntitySource
Get the entity types produced by this source.
getTypes
in interface EntitySource
@Nullable public EntitySource.Layout getLayout()
EntitySource
Get this entity source’s layout, if one is available. A source has a layout if it produces a single entity type with a known set of attributes.
getLayout
in interface EntitySource
null
if this source does not know its layout.public void setFile(java.nio.file.Path file)
Set the source file for this reader.
file
- The source file.public void setURL(java.net.URL url)
Set the URL of the input data.
url
- The URL of the input data.public java.nio.file.Path getFile()
Get the input file path.
public java.net.URL getURL()
Get the source file for this data source.
public void setSource(java.lang.CharSequence text)
Set a string from which to read entities.
public void setFormat(EntityFormat format)
Set the entity format for the reader.
format
- The entity format.public EntityFormat getFormat()
Get the entity format for the reader.
public java.util.Map<java.lang.String,java.lang.Object> getMetadata()
EntitySource
Get metadata from this entity source.
getMetadata
in interface EntitySource
public ObjectStream<Entity> openStream() throws java.io.IOException
Open a stream to read entities from this source.
openStream
in interface EntitySource
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public void describeTo(DescriptionWriter writer)
Describable
Write this class’s description to a sink. Anything relevant to this object’s identity should be digested; the idea is that, barring hash collisions, two objects with the same digest are equivalent. Used for things like deterministically generating cache file names.
describeTo
in interface Describable
writer
- The description writer to use.public com.fasterxml.jackson.databind.JsonNode toJSON(@Nullable java.net.URI base)
Construct a JSON representation of this entity source, suitable for serialization to e.g. YAML.
base
- The URI of the YAML file that will be generated, to generate relative URLs.