Package thredds.catalog
Class InvCatalogImpl
- java.lang.Object
-
- thredds.catalog.InvCatalog
-
- thredds.catalog.InvCatalogImpl
-
public class InvCatalogImpl extends InvCatalog
Concrete implementation of a Thredds catalog object. Use this when you are constructing or modifying.- See Also:
InvCatalog
-
-
Field Summary
-
Fields inherited from class thredds.catalog.InvCatalog
baseURI, datasets, dsHash, expires, name, properties, serviceHash, services, topDataset, version
-
-
Constructor Summary
Constructors Constructor Description InvCatalogImpl(String name, String version, URI baseURI)
Construct an InvCatalog.InvCatalogImpl(String name, String version, DateType expires, URI baseURI)
Construct an InvCatalog.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDataset(InvDatasetImpl ds)
Add Dataset (1.0)void
addDatasetByID(InvDatasetImpl ds)
Add Dataset to internal hash.void
addDatasetRoot(DataRootConfig root)
Add Dataset Root, key = path, value = location.void
addProperty(InvProperty p)
Add Property (1.0)void
addService(InvService s)
Add Service (1.0)void
appendErrorMessage(String message, boolean isInvalid)
Append an error message to the message log.boolean
check(StringBuilder out, boolean show)
Check internal data structures.String
dump()
Debugging: dump entire data structure.boolean
equals(Object o)
InvCatalogImpl elements with same values are equal.void
filter(DatasetFilter filter)
Munge this catalog to remove any dataset that doesnt pass through the filter.boolean
finish()
Finish constructing after all elements have been added or modified.URI
getBaseURI()
String
getCreateFrom()
String describing how the catalog was created, for debugging.protected DatasetFilter
getDatasetFilter()
List<DataRootConfig>
getDatasetRoots()
Get dataset roots.String
getLog()
boolean
hasFatalError()
Check if there is a fatal error and catalog should not be used.int
hashCode()
Override Object.hashCode() to implement equals.boolean
isStatic()
boolean
removeDataset(InvDatasetImpl ds)
Remove the given dataset from this catalog if it is a direct child of this catalog.void
removeDatasetByID(InvDatasetImpl ds)
Find the dataset in this catalog by its ID.boolean
replaceDataset(InvDatasetImpl remove, InvDatasetImpl add)
Replace the given dataset if it is a nested dataset.void
setBaseURI(URI baseURI)
Set the catalog base URI.void
setCreateFrom(String createFrom)
Set how the catalog was created, for debugging.void
setDataset(InvDatasetImpl ds)
Deprecated.Use addDataset() instead; datamodel now allows multiple top level datasets.void
setExpires(DateType expiresDate)
Set the expires date after which the catalog is no longer valid.void
setStatic(boolean aStatic)
void
subset(InvDataset ds)
Deprecated.in favor of thredds.catalog.util.DeepCopyUtils.subsetCatalogOnDatasetvoid
writeXML(OutputStream os)
Write the catalog as an XML document to the specified stream.void
writeXML(OutputStream os, boolean raw)
Write the catalog as an XML document to the specified stream.-
Methods inherited from class thredds.catalog.InvCatalog
check, findDatasetByID, findProperty, findService, getDataset, getDatasets, getExpires, getName, getProperties, getServices, getUriString, getVersion, resolveUri
-
-
-
-
Constructor Detail
-
InvCatalogImpl
public InvCatalogImpl(String name, String version, URI baseURI)
Construct an InvCatalog. You must call finish() after all objects are added.- Parameters:
name
- : catalog name.version
- : catalog version.baseURI
- : catalog base URI (external).
-
InvCatalogImpl
public InvCatalogImpl(String name, String version, DateType expires, URI baseURI)
Construct an InvCatalog. You must call finish() after all objects are added.- Parameters:
name
- : catalog name.version
- : catalog version.expires
- : date/time catalog expires.baseURI
- : catalog base URI (external).
-
-
Method Detail
-
subset
public void subset(InvDataset ds)
Deprecated.in favor of thredds.catalog.util.DeepCopyUtils.subsetCatalogOnDatasetMunge this catalog so the given dataset is the top catalog.- Specified by:
subset
in classInvCatalog
- Parameters:
ds
- make this top; must be existing dataset in this catalog.
-
filter
public void filter(DatasetFilter filter)
Munge this catalog to remove any dataset that doesnt pass through the filter.- Specified by:
filter
in classInvCatalog
- Parameters:
filter
- remove datasets that dont pass this filter.
-
getDatasetFilter
protected DatasetFilter getDatasetFilter()
-
finish
public boolean finish()
Finish constructing after all elements have been added or modified. This routine will do any needed internal consistency work. Its ok to call multiple times.- Returns:
- true if successful.
-
addDatasetByID
public void addDatasetByID(InvDatasetImpl ds)
Add Dataset to internal hash.- Parameters:
ds
- : add this dataset if ds.getID() != null- See Also:
InvCatalog.findDatasetByID(java.lang.String)
-
removeDatasetByID
public void removeDatasetByID(InvDatasetImpl ds)
Find the dataset in this catalog by its ID. If found, remove it.- Parameters:
ds
- Remove this dataset from the hash
-
addDataset
public void addDataset(InvDatasetImpl ds)
Add Dataset (1.0)- Parameters:
ds
- add this dataset
-
removeDataset
public boolean removeDataset(InvDatasetImpl ds)
Remove the given dataset from this catalog if it is a direct child of this catalog.- Parameters:
ds
- remove this dataset- Returns:
- true if found and removed
-
replaceDataset
public boolean replaceDataset(InvDatasetImpl remove, InvDatasetImpl add)
Replace the given dataset if it is a nested dataset.- Parameters:
remove
- - the dataset element to be removedadd
- - the dataset element to be added- Returns:
- true on success
-
addProperty
public void addProperty(InvProperty p)
Add Property (1.0)- Parameters:
p
- add this property
-
addService
public void addService(InvService s)
Add Service (1.0)- Parameters:
s
- add this service
-
setDataset
public void setDataset(InvDatasetImpl ds)
Deprecated.Use addDataset() instead; datamodel now allows multiple top level datasets.Add top-level InvDataset to this catalog.
-
getCreateFrom
public String getCreateFrom()
String describing how the catalog was created, for debugging.- Returns:
- how the catalog was created, for debugging
-
setCreateFrom
public void setCreateFrom(String createFrom)
Set how the catalog was created, for debugging.- Parameters:
createFrom
- how the catalog was created, for debugging
-
setBaseURI
public void setBaseURI(URI baseURI)
Set the catalog base URI. Its used to resolve relative URLS.- Parameters:
baseURI
- set to this
-
getBaseURI
public URI getBaseURI()
- Returns:
- the catalog base URI.
-
setExpires
public void setExpires(DateType expiresDate)
Set the expires date after which the catalog is no longer valid.- Parameters:
expiresDate
- aDateType
representing the date after which the catlog is no longer valid.
-
hasFatalError
public boolean hasFatalError()
Check if there is a fatal error and catalog should not be used.- Returns:
- true if catalog not useable.
-
appendErrorMessage
public void appendErrorMessage(String message, boolean isInvalid)
Append an error message to the message log. Call check() to get the log when everything is done.- Parameters:
message
- append this message to logisInvalid
- true if this is a fatal error.
-
check
public boolean check(StringBuilder out, boolean show)
Check internal data structures.- Specified by:
check
in classInvCatalog
- Parameters:
out
- : print errors hereshow
- : print messages for each object (debug)- Returns:
- true if no fatal consistency errors.
-
getLog
public String getLog()
-
dump
public String dump()
Debugging: dump entire data structure.- Returns:
- String representation.
-
writeXML
public void writeXML(OutputStream os) throws IOException
Write the catalog as an XML document to the specified stream.- Parameters:
os
- write to this OutputStream- Throws:
IOException
- on an error.
-
writeXML
public void writeXML(OutputStream os, boolean raw) throws IOException
Write the catalog as an XML document to the specified stream.- Parameters:
os
- write to this OutputStreamraw
- if true, write original (server) version, else write client version- Throws:
IOException
- on an error.
-
getDatasetRoots
public List<DataRootConfig> getDatasetRoots()
Get dataset roots.- Returns:
- List of InvProperty. May be empty, may not be null.
-
addDatasetRoot
public void addDatasetRoot(DataRootConfig root)
Add Dataset Root, key = path, value = location.- Parameters:
root
- add a dataset root
-
equals
public boolean equals(Object o)
InvCatalogImpl elements with same values are equal.
-
hashCode
public int hashCode()
Override Object.hashCode() to implement equals.
-
isStatic
public boolean isStatic()
-
setStatic
public void setStatic(boolean aStatic)
-
-