@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdEarthRepositoryModelDecoder extends Object implements ILcdModelDecoder
File | Required | Entry point | Description |
---|---|---|---|
tilerepository.cfg | x |
x | The root file of an Earth tile repository. |
tilerepository.ref | x |
The model reference of an Earth tile repository. | |
tilerepository_metadata.xml | The asset model of an Earth tile repository that describes its contents. |
InputStream
, from a http connection or from a file inside a
jar file.
ILcd2DBoundsIndexedModel
.ILcdEarthAssetBasedModelDescriptor
.read-write
mode and its
asset model
is
changed it can be saved by using the asset model's model encoder (e.g. ILcdModel.getModelEncoder()
).ILcdGridReference
or an
ILcdGeodeticReference
.TLcdModelReferenceDecoder
by default).TLcdEarthTileRepository
element.
ILcdModelDecoder decoder = new TLcdEarthRepositoryModelDecoder();
ILcdModel model = decoder.decode("mydirectory/tilerepository.cfg");
TLcdEarthRepositoryModelFactory
,
TLcdEarthTileRepository
Constructor and Description |
---|
TLcdEarthRepositoryModelDecoder()
Constructs a new
TLcdEarthTileRepositoryModelDecoder with the default asset and
tile data codecs. |
Modifier and Type | Method and Description |
---|---|
void |
addAssetCodec(ILcdEarthAssetCodec aCodec)
Adds the specified asset codec.
|
void |
addTileDataCodec(ILcdEarthTileDataCodec aCodec)
Adds the specified tile data codec for its encoded format.
|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
protected TLcdEarthTileRepository |
createRepository(String aRepositoryName,
boolean aReadOnly)
Creates a repository instance by opening the tile repository with the given name.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
Collection<ILcdEarthAssetCodec> |
getAssetCodecs()
Returns the current collection of asset codecs.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
Collection<ILcdEarthTileDataCodec> |
getTileDataCodecs()
Returns the current collection of tile data codecs.
|
boolean |
isOpenRepositoriesReadOnly()
Returns whether the repositories will be opened in read-only mode.
|
boolean |
removeAssetCodec(ILcdEarthAssetCodec aCodec)
Removes the specified asset codec.
|
boolean |
removeTileDataCodec(ILcdEarthTileDataCodec aCodec)
Removes the specified tile data codec for its encoded format.
|
void |
setOpenRepositoriesReadOnly(boolean aOpenRepositoriesReadOnly)
Sets whether the repositories will be opened in read-only mode.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdEarthRepositoryModelDecoder()
TLcdEarthTileRepositoryModelDecoder
with the default asset and
tile data codecs. The repositories will be opened in read-only
mode.public boolean isOpenRepositoriesReadOnly()
true
it will not be possible to edit the decoded repositories (e.g. the methods in the ILcdEarthEditableTileSet
interface will not be usable).
The default value is true
.public void setOpenRepositoriesReadOnly(boolean aOpenRepositoriesReadOnly)
aOpenRepositoriesReadOnly
- true
if the repositories should be opened in
read-only mode, false
if they should be opened in
read-write mode.isOpenRepositoriesReadOnly()
public void addTileDataCodec(ILcdEarthTileDataCodec aCodec)
aCodec
- the tile data codec that should be addedpublic boolean removeTileDataCodec(ILcdEarthTileDataCodec aCodec)
aCodec
- the tile data codec that should be removedpublic Collection<ILcdEarthTileDataCodec> getTileDataCodecs()
public void addAssetCodec(ILcdEarthAssetCodec aCodec)
aCodec
- the asset codec that should be addedpublic boolean removeAssetCodec(ILcdEarthAssetCodec aCodec)
aCodec
- the asset codec that should be removedpublic Collection<ILcdEarthAssetCodec> getAssetCodecs()
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
ILcdModelDecoder
true
for a source name while decode
throws an exception for that same source name.
For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the data source to be verified; typically a file name or a URL.true
if this decoder can likely decode the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String aSourceName) throws IOException
ILcdModelDecoder
decode
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost
always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException,
IllegalArgumentException, ...) on unexpected places, implementations are advised to catch
RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated
in the code snippet below.
public ILcdModel decode( String aSourceName ) throws IOException {
try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
// Perform decoding ...
} catch (RuntimeException e) {
throw new IOException(e);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)
protected TLcdEarthTileRepository createRepository(String aRepositoryName, boolean aReadOnly) throws IOException
TLcdEarthTileRepository
instance.aRepositoryName
- the name of the repository to openaReadOnly
- true
if the repository should be opened in read-only mode,
false
if it should be opened in read-write modeIOException
- if the repository could not be openedTLcdEarthTileRepository.TLcdEarthTileRepository(String, boolean)