|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgsfc.nssdc.cdf.Attribute
public class Attribute
This class contains the methods that are associated with either global or variable attributes.
CDF
,
CDFException
,
Entry
,
Variable
Field Summary |
---|
Method Summary | |
---|---|
static Attribute |
create(CDF myCDF,
java.lang.String name,
long scope)
Creates a new attribute in the given CDF. |
void |
delete()
Deletes this attribute. |
void |
deleteEntry(long entryID)
Deletes an attribute entry for the given entry number. |
void |
deleteEntry(Variable var)
Deletes the attribute entry for the given variable. |
java.util.Vector |
getEntries()
Gets all the entries defined for this attribute. |
Entry |
getEntry(long entryID)
Gets the attribute entry for the given entry number. |
Entry |
getEntry(Variable var)
Gets the attribute entry for the given variable. |
long |
getEntryID(Entry entry)
Gets the entry id for the given entry. |
long |
getID()
Gets the attribute ID of this attribute. |
long |
getMaxEntryNumber()
Gets the largest Entry number for this attribute. |
CDF |
getMyCDF()
Gets the CDF object to which this attribute belongs. |
java.lang.String |
getName()
Gets the name of this attribute. |
long |
getNumEntries()
Gets the number of entries in this attribute. |
long |
getScope()
Gets the scope of this attribute. |
void |
rename(java.lang.String newName)
Renames the current attribute. |
java.lang.String |
toString()
Gets the name of this attribute. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static Attribute create(CDF myCDF, java.lang.String name, long scope) throws CDFException
The following example creates a global attribute called 'Project' and a variable attribute called 'VALIDMIN':
Attribute project, validMin;project = Attribute.create(cdf, "Project", GLOBAL_SCOPE); validMin = Attribute.create(cdf, "VALIDMIN", VARIABLE_SCOPE);
myCDF
- the CDF object to which this attribute belongs name
- the name of the attribute to be created scope
- the attribute's scope - it should be either
GLOBAL_SCOPE or VARIABLE_SCOPE
CDFException
- if a problem occurred in creating an attributepublic void delete() throws CDFException
Vector attrs = cdf.getAttributes(); int n = attrs.size(); for (int i = 0 i < n; i++) ((Attribute)attrs.getElementAt(i)).delete();
Two possible workarounds are:
Vector attrs = cdf.getAttributes(); int n = attrs.size(); for (int i = n-1; i >= 0; i--) ((Attribute)attrs.getElementAt(i)).delete();and
Vector attrs = cdf.getAttributes(); int n = attrs.size(); for (int i = 0 i < n; i++) ((Attribute)attrs.getElementAt(0)).delete();
delete
in interface CDFObject
CDFException
- if there is a problem deleting the attributepublic Entry getEntry(long entryID) throws CDFException
The following example retrieves the first entry of the global attribute 'project'. Please note that a global attribute can have multiple entries (whereas, a variable attribute has only one entry for a particular attribute), and attribute id starts at 0, not 1.
Entry tEntry = project.getEntry(0L)
entryID
- the entry number from which an attribute entry
is retrieved
CDFException
- if an error occurred getting an entry (i.e.
invalid entryID, no attribute entry for entryID)public Entry getEntry(Variable var) throws CDFException
The following example retrieves the 'longitude' variable entry associate with the attribute 'validMin':
vEntry = validMin.getEntry(longitude);
var
- the variable from which an attribute entry is retrieved
CDFException
- if an error occurred getting a variable
attribute entry (e.g. non-existent variable,
no attribute entry for this variable, etc.)public void deleteEntry(long entryID) throws CDFException
The following example deletes the first and second entries of the global attribute 'Project':
project.deleteEntry(0L); project.deleteEntry(1L);
The following example deletes the 'longitude' variable entry associated with the attribute 'validMin':
validMin.deleteEntry(longitude.getID());
entryID
- the ID of the entry to be deleted
CDFException
- if there was a porblem deleting the entrypublic void deleteEntry(Variable var) throws CDFException
The following example deletes the 'longitude' variable entry associated with the attribute 'validMin':
validMin.deleteEntry(longitude);
var
- the variable from which the attribute entry is deleted
CDFException
- if there was a porblem deleting the entrypublic java.util.Vector getEntries() throws CDFException
CDFException
public long getEntryID(Entry entry)
entry
- the entry from which an entry id is retrieved
public void rename(java.lang.String newName) throws CDFException
rename
in interface CDFObject
newName
- the new attribute name
CDFException
- if there was a problem renaming the attributepublic long getNumEntries()
public long getMaxEntryNumber()
public long getID()
public CDF getMyCDF()
public java.lang.String getName()
getName
in interface CDFObject
public java.lang.String toString()
toString
in class java.lang.Object
public long getScope()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |