Class FieldInfo
- java.lang.Object
-
- com.supermap.data.FieldInfo
-
public class FieldInfo extends java.lang.ObjectThe FieldInfo class stores the informations of the field such as name, type, default value and length etc. Each field is corresponding to aFieldInfoobject. For a field of a vector dataset, only the Caption property, alias of the field can be modified.The FieldInfo get be get through the FieldInfos.
- Example:
- The following code demonstrates how to add fields for dataset. Suppose a workspace object is opened.
public void fieldInfoTest() { // Gets a dataset from datasource, and adds a field named Pop_2009 DatasetVector dataset = (DatasetVector) datasource.getDatasets().get("World"); // Instantiates a field information object and sets it FieldInfo fieldInfo = new FieldInfo(); fieldInfo.setName("Pop_2009"); fieldInfo.setCaption("Pop_2009"); fieldInfo.setDefaultValue("0"); fieldInfo.setType(FieldType.DOUBLE); fieldInfo.setRequired(true); // Adds the field named Pop_2009 to dataset FieldInfos fieldInfos = dataset.getFieldInfos(); fieldInfos.add(fieldInfo); fieldInfo.dispose(); }
-
-
Constructor Summary
Constructors Constructor and Description FieldInfo()The default constructor, initializes a new instance of the FieldInfo class.FieldInfo(FieldInfo fieldInfo)Constructs a new object identical to the given FieldInfo object.FieldInfo(java.lang.String name, FieldType type)Creates a new FieldInfo object according to the specified arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voiddispose()This method is used to release the resources.java.lang.StringgetCaption()Return the alias of the field.java.lang.StringgetDefaultValue()Returns the default value of the field.intgetMaxLength()Returns the maximum length of the field.java.lang.StringgetName()Returns the name of the field.FieldTypegetType()The type of the field returned.booleanisRequired()Returns a value which specifies when the field is required.booleanisSystemField()Returns a value indicates whether this field is a SuperMap system field, SuperMap system fields use SM as prefix, except SMUserID.booleanisZeroLengthAllowed()Returns a value indicates whether the field allows a length of zero.voidsetCaption(java.lang.String value)Set the alias of the field.voidsetDefaultValue(java.lang.String value)Sets the default value of the field.voidsetMaxLength(int value)Specifies the maximum length of the field.voidsetName(java.lang.String value)Returns the name of the field.voidsetRequired(boolean value)Sets whether the field is required.voidsetType(FieldType value)Sets the type of the field.voidsetZeroLengthAllowed(boolean value)Sets whether the field allows a length of zero. available for text field only.
-
-
-
Constructor Detail
-
FieldInfo
public FieldInfo()
The default constructor, initializes a new instance of the FieldInfo class.
-
FieldInfo
public FieldInfo(FieldInfo fieldInfo)
Constructs a new object identical to the given FieldInfo object.- Parameters:
fieldInfo- The specified FieldInfo object.
-
-
Method Detail
-
isZeroLengthAllowed
public boolean isZeroLengthAllowed()
Returns a value indicates whether the field allows a length of zero. Available for text field (Text, Char and NVarChar) only.- Returns:
- Returns true if the field allows a length of zero. returns false otherwise.
- Default:
- The default is true - the field allows a length of zero.
-
setZeroLengthAllowed
public void setZeroLengthAllowed(boolean value)
Sets whether the field allows a length of zero. available for text field only.- Parameters:
value- a boolean, used to specify whether the field allows a length of zero.
-
getCaption
public java.lang.String getCaption()
Return the alias of the field. For the field in the dataset, all the information of the field cannot be modified except the alias of the field. For the field that is created by the user, all the information of the field can be modified, but make sure the name of the field is not identical with that of another field.
The caption of a field can be not unique, that is, different fields are allowed to have the same caption, but the names of the fields can't be identical, because the name of the field is used to identify the field uniquely.
- Returns:
- the alias of the field.
- Default:
- The default value is "UntitledField".
-
setCaption
public void setCaption(java.lang.String value)
Set the alias of the field. For the field in the dataset, all the information of the field cannot be modified except the alias of the field. For the field that is created by the user, all the information of the field can be modified, but make sure the name of the field is not identical with that of another field.
The caption of a field can be not unique, that is, different fields are allowed to have the same caption, but the names of the fields can't be identical, because the name of the field is used to identify the field uniquely.
- Parameters:
value- the alias of the field.- Example:
- Please refer to the example for the
FieldInfosclass.
-
getDefaultValue
public java.lang.String getDefaultValue()
Returns the default value of the field. When a record is added, if this field is not assigned, the default value will be used.- Returns:
- the default value of the field.
- Default:
- The default is a null string.
-
setDefaultValue
public void setDefaultValue(java.lang.String value)
Sets the default value of the field. When a record is added, if this field is not assigned, the default value will be used.- Parameters:
value- the default value of the field.- Example:
- Please refer to the example for the
FieldInfosclass.
-
getName
public java.lang.String getName()
Returns the name of the field. The name of the field can be composed of the number, letter or underscore, but it should not start with the number or the underline. When you create a new field, do not use "sm" as the prefix of the name of the field, because the system fields of SuperMap all use the "sm" as the prefix, except the smUserID field. In addition, The length of the name of the field should be less than 30 characters, and it is not case sensitive for the name. The name is used to identify a field uniformly, so different fields should have different names.- Returns:
- Field Name
- Default:
- The default value is "UntitledField".
-
setName
public void setName(java.lang.String value)
Returns the name of the field. The name of the field can be composed of the number, letter or underscore, but it should not start with the number or the underline. When you create a new field, do not use "sm" as the prefix of the name of the field, because the system fields of SuperMap all use the "sm" as the prefix, except the smUserID field. In addition, The length of the name of the field should be less than 30 characters, and it is not case sensitive for the name. The name is used to identify a field uniformly, so different fields should have different names.- Parameters:
value- the name of the field.- Example:
- Please refer to the example for the
FieldInfosclass.
-
isRequired
public boolean isRequired()
Returns a value which specifies when the field is required.- Returns:
- if it is a required field, return true.otherwise,false
- Default:
- The default is false,it is a required field
-
setRequired
public void setRequired(boolean value)
Sets whether the field is required.- Parameters:
value- a boolean, whether the field is required.- Example:
- Please refer to the example for the
FieldInfosclass.
-
getMaxLength
public int getMaxLength()
Returns the maximum length of the field. Available for text field only.- Returns:
- the maximum length of the field.
- Default:
- The default value is 255.
-
setMaxLength
public void setMaxLength(int value)
Specifies the maximum length of the field. Available for text field only.- Parameters:
value- the integer value used to set the maximum length of the field.
-
getType
public FieldType getType()
The type of the field returned.
-
setType
public void setType(FieldType value)
Sets the type of the field.- Parameters:
value- the type of the field.- See Also:
FieldType- Example:
- Please refer to the example for the
FieldInfosclass.
-
isSystemField
public boolean isSystemField()
Returns a value indicates whether this field is a SuperMap system field, SuperMap system fields use SM as prefix, except SMUserID.- Returns:
- if it is a SuperMap system field, return true.
- Default:
- The default is false,That is, the current field is not the SuperMap system field.
-
dispose
public void dispose()
This method is used to release the resources. You can call this method to release the resources immediately, or this method will be called when releasing the object automatically. The object can't be used after call this method.
-
-