M - the specific model typepublic class ModelInfo<M extends IModel> extends java.lang.Object implements IModelData
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<ModelImport<M>> |
imports |
private IModelLoader<M> |
loader |
private java.util.Locale |
locale |
private java.net.URI |
location |
private java.lang.String |
name |
private M |
resolved |
private long |
timestamp |
private Version |
version |
| Constructor and Description |
|---|
ModelInfo()
Internal constructor for marking pseudo instances.
|
ModelInfo(M model,
java.net.URI location)
Creates a model information object.
|
ModelInfo(M model,
java.net.URI location,
IModelLoader<M> loader)
Creates a model information object.
|
ModelInfo(java.lang.String name,
Version version,
IModelLoader<M> loader,
java.net.URI location,
java.util.List<ModelImport<M>> imp)
Creates a model information object.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
adjustTimestamp()
Adjusts the timestamp according to the currently resolved instance.
|
static <M extends IModel> |
equals(ModelInfo<M> i1,
ModelInfo<M> i2)
Returns whether
i1 and i2 are equal, i.e., point to the same model. |
static <M extends IModel> |
equals(ModelInfo<M> info,
java.lang.String name,
Version version,
java.net.URI location)
Returns whether
i1 and the explicit given information are equal, i.e., point to the same model. |
java.net.URI |
getCommentsResource()
Returns the URI to the actual comments text resource.
|
private java.net.URI |
getCommentsResource(java.util.Locale locale)
Returns the URI to the actual comments text resource.
|
java.net.URI |
getDefaultCommentsResource()
Returns the URI to the default comments text resource.
|
ModelImport<M> |
getImport(int index)
Returns the model import specified by
index. |
int |
getImportsCount()
Returns the number of imports.
|
IModelLoader<M> |
getLoader()
Stores the responsible loader.
|
java.util.Locale |
getLocale()
Returns the locale used for resolving the related model.
|
java.net.URI |
getLocation()
Returns the physical location of the model.
|
java.lang.String |
getName()
Returns the name of the model.
|
M |
getResolved()
Returns the resolved model.
|
long |
getTimestamp()
Returns the timestamp of the resolution.
|
Version |
getVersion()
Returns the version of the model.
|
boolean |
isContainedIn(java.lang.String path)
Returns whether the location of this information object is contained in
path. |
boolean |
isContainedIn(java.net.URI uri)
Returns whether the location of this information object is contained in
uri. |
boolean |
isOutdated()
Returns whether the represented model is outdated.
|
boolean |
isResolved()
Returns whether the related model was already resolved.
|
java.lang.String |
nameVersionToString()
Returns name and version as a string for output.
|
static <M extends IModel> |
selectContained(java.util.List<ModelInfo<M>> info,
java.net.URI uri)
Selects those information objects out of
info which are contained
in uri. |
static <M extends IModel> |
selectOutdated(java.util.List<ModelInfo<M>> info,
boolean requireResolved,
java.net.URI uri)
Returns the outdated model information objects (due to file change).
|
(package private) void |
setLocale(java.util.Locale locale)
Stores the locale used while resolving the related model.
|
(package private) void |
setResolved(M resolved)
Changes the resolved model.
|
static java.lang.String |
toComparablePath(java.net.URI uri)
Turns the given
uri into a comparable path. |
java.lang.String |
toString()
Returns a textual representation of this instance.
|
(package private) void |
updateModelLoader(IModelLoader<M> loader)
Updates the model loader (only if unset).
|
private java.lang.String name
private Version version
private IModelLoader<M extends IModel> loader
private java.net.URI location
private long timestamp
private java.util.List<ModelImport<M extends IModel>> imports
private java.util.Locale locale
ModelInfo()
public ModelInfo(M model, java.net.URI location)
model - the model to create this object forlocation - the physical location where the model is storedpublic ModelInfo(M model, java.net.URI location, IModelLoader<M> loader)
model - the model to create this object forlocation - the physical location where the model is storedloader - the loader being responsible for resolving the related modelpublic ModelInfo(java.lang.String name,
Version version,
IModelLoader<M> loader,
java.net.URI location,
java.util.List<ModelImport<M>> imp)
name - the name of the modelversion - the version of the model, null signals that no version
was given in the modelloader - the loader being responsible for resolving the related modellocation - the physical location where the model is storedimp - imports and conflicts (may be null)public java.lang.String getName()
getName in interface IModelDatapublic Version getVersion()
getVersion in interface IModelDatapublic java.net.URI getLocation()
public IModelLoader<M> getLoader()
public java.lang.String nameVersionToString()
public java.lang.String toString()
toString in class java.lang.Objectvoid setResolved(M resolved)
resolved - the model, may be null if inconsistent or not yet loadedprivate void adjustTimestamp()
public M getResolved()
public boolean isResolved()
true if it was resolved, false elsepublic long getTimestamp()
public boolean isOutdated()
true if it is outdated and
loading the model is recommended, , false elsepublic int getImportsCount()
public ModelImport<M> getImport(int index)
index. Please
note that this method is primarily intended to support versioned import
resolution. The returned information is in sync with the resolved
model if there is a resolved model, otherwise information is
stored locally (and resolved information there may be incorrect or
null). Depending on the parser, no import restrictions may be
attached (this may only be available in the full model).index - a 0-based index specifying the import to be returnedjava.lang.IndexOutOfBoundsException - if
index<0 || index>=getImportsCount()public boolean isContainedIn(java.net.URI uri)
uri.uri - the URI to be considered as containing URItrue if the location of this information
object is contained, false if not (or any of both
is null). Please note that the opposite must not hold, e.g., if either URL is null.isContainedIn(String),
toComparablePath(URI)public boolean isContainedIn(java.lang.String path)
path.path - the path based on toComparablePath(URI)true if the location of this information
object is contained, false if not (or any of both
is null). Please note that the opposite must not hold, e.g., if either URL is null.public static java.lang.String toComparablePath(java.net.URI uri)
uri into a comparable path.uri - the URI (may be null, shall be normalized)public static <M extends IModel> java.util.List<ModelInfo<M>> selectOutdated(java.util.List<ModelInfo<M>> info, boolean requireResolved, java.net.URI uri)
info if modify is
enabled.M - the specific type of modelinfo - the model information objects to be consideredrequireResolved - true if the information objects
to be returned need to be resolved (isResolved()),
false if just all outdated objects shall be returneduri - an optional URI the results must be contained in (may be null)public static <M extends IModel> java.util.List<ModelInfo<M>> selectContained(java.util.List<ModelInfo<M>> info, java.net.URI uri)
info which are contained
in uri.M - the specific type of modelinfo - the information objects to filteruri - the URI to filter for (may be null)void setLocale(java.util.Locale locale)
locale - the locale used for resolvingpublic java.util.Locale getLocale()
public java.net.URI getCommentsResource()
public java.net.URI getDefaultCommentsResource()
private java.net.URI getCommentsResource(java.util.Locale locale)
locale - the locale to use, may be null for the default localevoid updateModelLoader(IModelLoader<M> loader)
loader - the new loaderpublic static <M extends IModel> boolean equals(ModelInfo<M> i1, ModelInfo<M> i2)
i1 and i2 are equal, i.e., point to the same model.M - the model typei1 - the first model information to be comparedi2 - the second model informationtrue if i1 is equal to i2, false elsepublic static <M extends IModel> boolean equals(ModelInfo<M> info, java.lang.String name, Version version, java.net.URI location)
i1 and the explicit given information are equal, i.e., point to the same model.M - the model typeinfo - the model information to be comparedname - the name of the model to be comparedversion - the version of the model to be comparedlocation - the location to be comparedtrue if i1 is equal to i2, false elseCopyright © 2009 - 2018 SSE. All Rights Reserved.