public class HDSReference extends Object implements Cloneable
It also deals with translating object location information to and from a URL. Other classes ought to use this class to translate between URLs and HDS paths so that the HDS URL format can be changed easily in a single place. The format of a URL representing an HDS location is currently of the form container.sdf#hdspath. This may get changed.
Constructor and Description |
---|
HDSReference(File container)
Constructs a new HDSReference representing the top level object in an
HDS container file.
|
HDSReference(File container,
String path)
Constructs an HDSReference given a container file and an
HDS path string within it.
|
HDSReference(File container,
String[] path)
Constructs an HDSReference given a container file and an HDS path
array within it.
|
HDSReference(HDSObject hobj)
Constructs an HDSReference from an existing HDSObject.
|
HDSReference(String path)
Constructs an HDSRefernce from a 'traditional' HDS pathname.
|
HDSReference(URL url)
Constructs an HDSReference from a URL.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Returns a copy of this object - modifying the returned object will
not affect the original one.
|
File |
getContainerFile()
Returns the container file associated with this HDSReference
(including the '.sdf' extension).
|
String |
getContainerName()
Returns the HDS-style name of the container file associated with
this HDSReference - this does not include the '.sdf'
extension.
|
HDSObject |
getObject(String accessMode)
Opens a new primary HDSObject at the location referenced by this
HDSReference.
|
String[] |
getPath()
Returns the HDS path of this HDSReference as an array of Strings.
|
URL |
getURL()
Returns a URL which describes this HDSReference.
|
String |
pop()
Removes an element from the end of the current path, thus
navigating up the HDS hierarchy.
|
void |
push(String pathEl)
Adds a new path element to the end of the current path, thus
navigating down the HDS hierarchy.
|
String |
toString() |
public HDSReference(File container)
container
- a File object giving the container file
(including the .sdf extension)IllegalArgumentException
- if the filename does not end '.sdf'public HDSReference(File container, String[] path)
container
- a File object giving the container file
(including the .sdf extension)path
- an array of Strings each representing the name
of one level of the HDS pathIllegalArgumentException
- if the filename does not
end in ".sdf"public HDSReference(File container, String path)
container
- a File object giving the container file
(including the .sdf extension)path
- a dot-separated string giving the HDS pathIllegalArgumentException
- if the filename does not end '.sdf'public HDSReference(String path)
path
- a dot-separated string in which the container name
minus its '.sdf' forms the front and the HDS path
proper forms the backpublic HDSReference(URL url)
file:
protocol are supported.url
- a URL describing the location of the HDSObjectUnsupportedOperationException
- if the protocol
of url
is not file
public HDSReference(HDSObject hobj) throws HDSException
hobj
- the object whose location is to be referenced.HDSException
- if an HDS error occurspublic File getContainerFile()
public String getContainerName()
public String[] getPath()
public URL getURL()
public HDSObject getObject(String accessMode) throws HDSException
accessMode
- the HDS access mode for the hdsOpen call -
"READ", "WRITE" or "UPDATE"HDSException
public void push(String pathEl)
pathEl
- the new path element to addpublic String pop()
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.