ThingWorx Edge Java SDK > Application Details > Infotables > Example Using the INFOTABLE Base Type
  
Example Using the INFOTABLE Base Type
The following example shows the procedure for creating a property and service that uses the INFOTABLE base type with annotations. The infotable contains an integer ID and a string value. The property is of base type INFOTABLE. The service takes an infotable as a parameter and returns the same infotable. It is only for demonstration purposes.
// Class Annotations for the property

@ThingWorxPropertyDefinitions(
properties = {
@ThingWorxPropertyDefinition(
name="StringIndex",
description="String Index Property",
baseType="INFOTABLE",
aspects = {
"dataChangeType:NEVER",
"dataChangeThreshold:0",
"cacheTime:-1",
"isPersistent:FALSE",
"isReadOnly:FALSE",
"pushType:VALUE",
"dataShape:StringMap"
}
)
}
)


// This needs to be in the constructor or a method called from the
// constructor.

// First a DataShapeDefinition needs to be added to the VirtualThing
FieldDefinitionCollection fields = new FieldDefinitionCollection();

// Define the fields
fields.addFieldDefinition(new FieldDefinition("ID", BaseTypes.INTEGER));
fields.addFieldDefinition(new FieldDefinition("Value", BaseTypes.STRING));

// Add the DataShapeDefinition to the VirtualThing
this.defineDataShapeDefinition("StringMap", fields);

// Service Definition
@ThingWorxServiceDefinition(
name="StringMapService",
description="Returns the passed in String Map")

@ThingWorxServiceResult(

name=CommonPropertyNames.PROP_RESULT,
baseType="INFOTABLE",
description="",
aspects={"dataShape:StringMap"}
)

public InfoTable StringMapService(
@ThingWorxServiceParameter(
name="value",
baseType="INFOTABLE",
description="",
aspects={"dataShape:StringMap"}) InfoTable value )

throws Exception {
return value;
}