public class TLcyCompositeModelReferenceParser extends TLcyGenericComposite<ILcdModelReferenceParser> implements ILcdModelReferenceParser
Composite implementation (see composite design pattern) of ILcdModelReferenceParser
.
It keeps a list of associated ILcdModelReferenceParser
s.
When it is asked to parse a model reference, it loops over its associated ILcdModelReferenceParser
s to find one that can parse the input.
The model reference provided by that decoder is returned.
When creating a new TLcyCompositeModelReferenceParser
using the default constructor,
the created instance will only work on/with the registered instances on this composite instance.
When creating a new TLcyCompositeModelReferenceParser
using the constructor specifying an ILcyLucyEnv
instance,
the created composite will work on the Lucy back-end services.
It will use all registered ILcdModelReferenceParser
instances of the Lucy back-end,
adding and/or removing an ILcdModelReferenceParser
will add/remove the parser as service from Lucy, ... .
Parsing an ILcdModelReference
from its string representation using the back-end based implementation can be done by creating a new instance of this class:
//Create a new instance whenever you need it
TLcyCompositeModelReferenceParser parser = new TLcyCompositeModelReferenceParser( aLucyEnv );
try{
ILcdModelReference modelReference = parser.parseModelReference( aModelReferenceAsString );
} catch ( ParseException aException ){
//exception occurred during the parsing
}
//There is no need to keep a reference to the composite instance, you can create a new one
//the next time you would need it
provider = null;
PRIORITY_DEFAULT, PRIORITY_FALLBACK
Constructor and Description |
---|
TLcyCompositeModelReferenceParser()
Default constructor.
|
TLcyCompositeModelReferenceParser(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeModelReferenceParser working on the Lucy back-end. |
Modifier and Type | Method and Description |
---|---|
ILcdModelReference |
parseModelReference(String aModelReferenceAsString)
Returns the
ILcdModelReference that corresponds to the specified string representation. |
add, add, getList, getPriority, iterator, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public TLcyCompositeModelReferenceParser()
Default constructor.
The created instance will only work on the ILcdModelReferenceParser
instances registered to it.
If you want to use all registered ILcdModelReferenceParser
instances of the Lucy back-end, use TLcyCompositeModelReferenceParser(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyCompositeModelReferenceParser(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeModelReferenceParser
working on the Lucy back-end.
It will use all ILcdModelReferenceParser
instances registered to the back-end,
and adding and/or removing ILcdModelReferenceParser
to/from this composite will respectively add/remove it as service from the back-end.
If you want to create a TLcyCompositeModelReferenceParser
which does not use the back-end, use TLcyCompositeModelReferenceParser()
instead.
aLucyEnv
- The Lucy back-endTLcyCompositeModelReferenceParser()
,
ILcyLucyEnv.addService(Object)
public ILcdModelReference parseModelReference(String aModelReferenceAsString) throws ParseException
ILcdModelReferenceParser
ILcdModelReference
that corresponds to the specified string representation.parseModelReference
in interface ILcdModelReferenceParser
aModelReferenceAsString
- the String representation to be converted to an ILcdModelReference
.ILcdModelReference
that corresponds to the specified string, never null
.ParseException
- if this parser cannot convert the specified string into a model reference
(e.g. if the code is not supported or if the code was not valid)