Package opendap.dap
Class BaseType
- java.lang.Object
-
- opendap.dap.DAPNode
-
- opendap.dap.BaseType
-
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
DConstructor,DPrimitive,DVector
public abstract class BaseType extends DAPNode
This abstract class defines the basic data type features for the OPeNDAP data access protocol (DAP) data types. All of the DAP type classes (DFloat64,DArray, etc.) subclass it or one of its two abstract descendents,DVectororDConstructor. These classes and their methods give a user the capacity to set up sophisticated data types. They do not provide sophisticated ways to access and use this data. On the server side, in many cases, the class instances will have no data in them at all until theserializemethod is called to send data to the client. On the client side, most OPeNDAP application programs will unpack the data promptly into whatever local data structure the programmer deems the most useful. Descendents of this class should implement theClientIOinterface. That interface defines adeserializemethod used by a OPeNDAP client to retrieve the variable's declaration and value(s) from a OPeNDAP server.- See Also:
DDS,ClientIO, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class opendap.dap.DAPNode
DAPNode.CloneMap
-
-
Field Summary
-
Fields inherited from class opendap.dap.DAPNode
_nameClear, _nameEncoded, log
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAttributeAlias(String alias, String attributeName)voidaddAttributeContainer(AttributeTable at)voidappendAttribute(String clearname, int type, String value)voidappendAttribute(String clearname, int type, String value, boolean check)AttributeTableappendAttributeContainer(String clearname)voidcheckSemantics()Check semantics.voidcheckSemantics(boolean all)Checks for internal consistency.DAPNodecloneDAG(DAPNode.CloneMap map)Returns a clone of thisBaseType.voiddelAttribute(String clearname)voiddelAttribute(String clearname, int i)intelementCount()Returns the number of variables contained in this object.intelementCount(boolean leaves)Returns the number of variables contained in this object.AttributegetAttribute()AttributegetAttribute(String clearname)Iterable<String>getAttributeNames()AttributeTablegetAttributeTable()StringgetLongName()abstract StringgetTypeName()Returns the OPeNDAP type name of the class instance as aString.booleanhasAttributes()PrimitiveVectornewPrimitiveVector()Constructs a newPrimitiveVectorobject optimized for the particular data type of thisBaseType.voidprintAttributes(OutputStream os)voidprintAttributes(OutputStream os, String pad)voidprintAttributes(PrintWriter pw)voidprintAttributes(PrintWriter pw, String pad)voidprintConstraint(PrintWriter os)voidprintDecl(OutputStream os)Print the variable's declaration.voidprintDecl(OutputStream os, String space)Print the variable's declaration.voidprintDecl(OutputStream os, String space, boolean print_semi)Print the variable's declaration usingOutputStream.voidprintDecl(OutputStream os, String space, boolean print_semi, boolean constrained)Print the variable's declaration usingOutputStream.voidprintDecl(PrintWriter os)Print the variable's declaration.voidprintDecl(PrintWriter os, String space)Print the variable's declaration.voidprintDecl(PrintWriter os, String space, boolean print_semi)Write the variable's declaration in a C-style syntax.voidprintDecl(PrintWriter os, String space, boolean print_semi, boolean constrained)Write the variable's declaration in a C-style syntax.voidprintVal(OutputStream os, String space)Print the variable's value usingOutputStream.voidprintVal(OutputStream os, String space, boolean print_decl_p)Print the variable's value usingOutputStream.voidprintVal(PrintWriter os, String space)Print the variable's value.abstract voidprintVal(PrintWriter os, String space, boolean print_decl_p)Prints the value of the variable, with its declaration.voidprintXML(OutputStream os)voidprintXML(OutputStream os, String pad)voidprintXML(PrintWriter pw)voidprintXML(PrintWriter pw, String pad)voidprintXML(PrintWriter pw, String pad, boolean constrained)voidsetClearName(String clearname)Sets the unencoded name of the class instance.-
Methods inherited from class opendap.dap.DAPNode
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setEncodedName, setParent, setProject, setProject, setProjected
-
-
-
-
Constructor Detail
-
BaseType
public BaseType()
Constructs a newBaseTypewith no name.
-
BaseType
public BaseType(String clearname)
Constructs a newBaseTypewith namen. Name is always assumed to be dap encoded- Parameters:
clearname- the name of the variable.
-
-
Method Detail
-
setClearName
public void setClearName(String clearname)
Sets the unencoded name of the class instance.- Overrides:
setClearNamein classDAPNode- Parameters:
clearname- the unencoded name of the class instance.
-
getTypeName
public abstract String getTypeName()
Returns the OPeNDAP type name of the class instance as aString.- Returns:
- the OPeNDAP type name of the class instance as a
String.
-
elementCount
public int elementCount(boolean leaves)
Returns the number of variables contained in this object. For simple and vector type variables, it always returns 1. To count the number of simple-type variable in the variable tree rooted at this variable, setleavestotrue.- Parameters:
leaves- If true, count all the simple types in the `tree' of variables rooted at this variable.- Returns:
- the number of contained variables.
-
elementCount
public final int elementCount()
Returns the number of variables contained in this object. For simple and vector type variables, it always returns 1.- Returns:
- the number of contained variables.
-
printDecl
public void printDecl(PrintWriter os, String space, boolean print_semi, boolean constrained)
Write the variable's declaration in a C-style syntax. This function is used to create textual representation of the Data Descriptor Structure (DDS). See The OPeNDAP User Manual for information about this structure.- Parameters:
os- ThePrintWriteron which to print the declaration.space- Each line of the declaration will begin with the characters in this string. Usually used for leading spaces.print_semi- a boolean value indicating whether to print a semicolon at the end of the declaration.constrained- a boolean value indicating whether to print the declartion dependent on the projection information. This is only used by Server side code.- See Also:
DDS
-
printDecl
public void printDecl(PrintWriter os, String space, boolean print_semi)
Write the variable's declaration in a C-style syntax. This function is used to create textual representation of the Data Descriptor Structure (DDS). See The OPeNDAP User Manual for information about this structure.- Parameters:
os- ThePrintWriteron which to print the declaration.space- Each line of the declaration will begin with the characters in this string. Usually used for leading spaces.print_semi- a boolean value indicating whether to print a semicolon at the end of the declaration.- See Also:
DDS
-
printDecl
public final void printDecl(PrintWriter os, String space)
Print the variable's declaration. Same asprintDecl(os, space, true).- Parameters:
os- ThePrintWriteron which to print the declaration.space- Each line of the declaration will begin with the characters in this string. Usually used for leading spaces.- See Also:
DDS.print(PrintWriter)
-
printDecl
public final void printDecl(PrintWriter os)
Print the variable's declaration. Same asprintDecl(os, " ", true).- Parameters:
os- ThePrintWriteron which to print the declaration.- See Also:
DDS.print(PrintWriter)
-
printDecl
public final void printDecl(OutputStream os, String space, boolean print_semi, boolean constrained)
Print the variable's declaration usingOutputStream.- Parameters:
os- TheOutputStreamon which to print the declaration.space- Each line of the declaration will begin with the characters in this string. Usually used for leading spaces.print_semi- a boolean value indicating whether to print a semicolon at the end of the declaration.- See Also:
DDS.print(PrintWriter)
-
printDecl
public final void printDecl(OutputStream os, String space, boolean print_semi)
Print the variable's declaration usingOutputStream.- Parameters:
os- TheOutputStreamon which to print the declaration.space- Each line of the declaration will begin with the characters in this string. Usually used for leading spaces.print_semi- a boolean value indicating whether to print a semicolon at the end of the declaration.- See Also:
DDS.print(PrintWriter)
-
printDecl
public final void printDecl(OutputStream os, String space)
Print the variable's declaration. Same asprintDecl(os, space, true).- Parameters:
os- TheOutputStreamon which to print the declaration.space- Each line of the declaration will begin with the characters in this string. Usually used for leading spaces.- See Also:
DDS.print(PrintWriter)
-
printDecl
public void printDecl(OutputStream os)
Print the variable's declaration. Same asprintDecl(os, " ", true).- Parameters:
os- TheOutputStreamon which to print the declaration.- See Also:
DDS.print(PrintWriter)
-
printVal
public abstract void printVal(PrintWriter os, String space, boolean print_decl_p)
Prints the value of the variable, with its declaration. This function is primarily intended for debugging OPeNDAP applications and text-based clients such as geturl.- Parameters:
os- thePrintWriteron which to print the value.space- this value is passed to theprintDeclmethod, and controls the leading spaces of the output.print_decl_p- a boolean value controlling whether the variable declaration is printed as well as the value.
-
printVal
public void printVal(PrintWriter os, String space)
Print the variable's value. Same asprintVal(os, space, true).- Parameters:
os- thePrintWriteron which to print the value.space- this value is passed to theprintDeclmethod, and controls the leading spaces of the output.- See Also:
DataDDS.printVal(PrintWriter)
-
printVal
public void printVal(OutputStream os, String space, boolean print_decl_p)
Print the variable's value usingOutputStream.- Parameters:
os- theOutputStreamon which to print the value.space- this value is passed to theprintDeclmethod, and controls the leading spaces of the output.print_decl_p- a boolean value controlling whether the variable declaration is printed as well as the value.- See Also:
DataDDS.printVal(PrintWriter)
-
printVal
public void printVal(OutputStream os, String space)
Print the variable's value usingOutputStream.- Parameters:
os- theOutputStreamon which to print the value.space- this value is passed to theprintDeclmethod, and controls the leading spaces of the output.- See Also:
DataDDS.printVal(PrintWriter)
-
checkSemantics
public void checkSemantics(boolean all) throws BadSemanticsExceptionChecks for internal consistency. This is important to check for complex constructor classes. For example, anDInt32instance would return false if it had no name defined. ADGridinstance might return false for more complex reasons, such as having Map arrays of the wrong size or shape. This method is used by theDDSclass, and will rarely, if ever, be explicitly called by a OPeNDAP application program. A variable must pass this test before it is sent, but there may be many other stages in a retrieve operation where it would fail.- Parameters:
all- For complex constructor types (DGrid,DSequence,DStructure), this flag indicates whether to check the semantics of the member variables, too.- Throws:
BadSemanticsException- if semantics are bad, explains why.- See Also:
DDS.checkSemantics(boolean)
-
checkSemantics
public final void checkSemantics() throws BadSemanticsExceptionCheck semantics. Same ascheckSemantics(false).- Throws:
BadSemanticsException- if semantics are bad, explains why.- See Also:
checkSemantics(boolean)
-
newPrimitiveVector
public PrimitiveVector newPrimitiveVector()
Constructs a newPrimitiveVectorobject optimized for the particular data type of thisBaseType. For example, aDByteclass would create a newBytePrimitiveVectorin this call. This allows for a very optimized, yet type-safe, implementation ofDVectorfunctionality. For non-primitive types, such asDArray,DGrid,DSequence, andDStructure, the default implementation returns aBaseTypePrimitiveVectorobject which can deserialize an array of complex types.- Returns:
- a new
PrimitiveVectorobject for the variable type.
-
getLongName
public String getLongName()
-
hasAttributes
public boolean hasAttributes()
-
getAttribute
public Attribute getAttribute()
-
getAttributeTable
public AttributeTable getAttributeTable()
-
addAttributeAlias
public void addAttributeAlias(String alias, String attributeName) throws DASException
- Throws:
DASException
-
appendAttribute
public void appendAttribute(String clearname, int type, String value, boolean check) throws DASException
- Throws:
DASException
-
appendAttribute
public void appendAttribute(String clearname, int type, String value) throws DASException
- Throws:
DASException
-
addAttributeContainer
public void addAttributeContainer(AttributeTable at) throws AttributeExistsException
- Throws:
AttributeExistsException
-
appendAttributeContainer
public AttributeTable appendAttributeContainer(String clearname)
-
delAttribute
public void delAttribute(String clearname)
-
delAttribute
public void delAttribute(String clearname, int i) throws DASException
- Throws:
DASException
-
printAttributes
public void printAttributes(OutputStream os)
-
printAttributes
public void printAttributes(OutputStream os, String pad)
-
printAttributes
public void printAttributes(PrintWriter pw)
-
printAttributes
public void printAttributes(PrintWriter pw, String pad)
-
printXML
public void printXML(OutputStream os)
-
printXML
public void printXML(OutputStream os, String pad)
-
printXML
public void printXML(PrintWriter pw)
-
printXML
public void printXML(PrintWriter pw, String pad)
-
printXML
public void printXML(PrintWriter pw, String pad, boolean constrained)
-
printConstraint
public void printConstraint(PrintWriter os)
-
cloneDAG
public DAPNode cloneDAG(DAPNode.CloneMap map) throws CloneNotSupportedException
Returns a clone of thisBaseType. See DAPNode.cloneDAG.- Overrides:
cloneDAGin classDAPNode- Parameters:
map- The set of already cloned nodes.- Returns:
- a clone of this
BaseType. - Throws:
CloneNotSupportedException
-
-