@LcdService(service=ILcdModelDecoder.class, priority=20000) public final class TLcdMGCPModelDecoder extends Object implements ILcdModelDecoder, ILcdStatusSource
File | Required | Entry point | Description |
---|---|---|---|
*.zip | x | x | A .zip file containing both the metadata file (*.xml) and the shapefiles. |
*.xml | x | x | An xml-file with top level MGCP_Cell tag, containing references to SHP files according to the MGCP Data Packaging (TRD4 v4.5 20190208) specs. |
*.shp | x | The SHP-files, referenced by the xml, containing shapes for a single MGCP feature. |
TLcd2DBoundsIndexedModelList
with a delegate model
for each shp file.ILcdDataModelDescriptor
.ILcdDataObjects
. ILcdModelDecoder decoder = new TLcdMGCPModelDecoder();
ILcdModel model = decoder.decode("file.xml");
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_EXTENSION |
static String |
TYPE_NAME
The model descriptor type for MGCP data, 'MGCP'.
|
Constructor and Description |
---|
TLcdMGCPModelDecoder() |
Modifier and Type | Method and Description |
---|---|
void |
addStatusListener(ILcdStatusListener aListener)
Registers the given listener so it will receive status events from this source.
|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
TLcdModelMetadata |
decodeModelMetadata(String aSourceName)
Decodes metadata for the specified data source.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
void |
removeStatusListener(ILcdStatusListener aListener)
Removes the specified listener so it is no longer notified.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeSource, discoverDataSources
public static final String TYPE_NAME
public static final String DEFAULT_EXTENSION
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)
public TLcdModelMetadata decodeModelMetadata(String aSourceName) throws IOException
ILcdModelDecoder
decodeModelMetadata
in interface ILcdModelDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.IOException
- if the metadata cannot be decoded for some reason.ILcdModelDecoder.canDecodeSource(String)
public void addStatusListener(ILcdStatusListener aListener)
ILcdStatusSource
Registers the given listener so it will receive status events from this source.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source,
you can use a ALcdWeakStatusListener
instance as status listener.
addStatusListener
in interface ILcdStatusSource
aListener
- The listener to be notified when the status has changed.public void removeStatusListener(ILcdStatusListener aListener)
ILcdStatusSource
removeStatusListener
in interface ILcdStatusSource
aListener
- The listener to remove.