com.smartgwt.client.data

## Class MockDataSource

- java.lang.Object
- - com.smartgwt.client.core.BaseClass
  - - com.smartgwt.client.data.DataSource
    - - com.smartgwt.client.data.MockDataSource

- All Implemented Interfaces:
    com.google.gwt.event.shared.HasHandlers, HasDataChangedHandlers, HasHandleErrorHandlers

      public class MockDataSource
      extends DataSource

  A special kind of `client-only DataSource` that can be configured with `"mock data"` - a simple text format for table or tree data.

  MockDataSources are produced by the Reify Mockup Importer when starting from mockup formats that use the mock data format. The docs for the `Reify Mockup Importer` explain various steps for converting a `MockDataSource` to a real DataSource.

  `MockDataSource` is primarily intended as a temporary form of DataSource used during the process of converting a mockup into a real application. Generally, if creating a client-only DataSource in Java, there is no reason to use the mock data format, as the mock data is not especially readable when written as a String literal. The mock data format can be a slightly more compact and readable as compared to declaring `DataSource.cacheData` in XML.

  Note: If a MockDataSource has `addGlobalId` set to true, it will be made available in global scope.

  Unlike other DataSources, if a MockDataSource is created with an ID that is already in use by another DataSource, the existing DataSource will not be `destroy()`'d and the new MockDataSource will not be available by ID.
  Similarly, if a MockDataSource exists and a new DataSource is created with the same ID the MockDataSource will be `destroy()`'d automatically without logging a warning to the developer console.
  This means if application code changes to replace a MockDataSource with a "real" dataSource it will function as expected, without warnings, even if the MockDataSource creation code was not removed, regardless of the order in which the MockDataSource and "real" dataSource are created.

- - ### Field Summary

    - ### Fields inherited from class com.smartgwt.client.core.BaseClass

      `config, configOnly, factoryCreated, factoryProperties, id, scClassName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MockDataSource()`
    `MockDataSource(com.google.gwt.core.client.JavaScriptObject jsObj)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.google.gwt.core.client.JavaScriptObject` | `create()`
    `java.lang.String` | `getMockData()` Data intended for a `ListGrid` or `TreeGrid`, expressed in a simple text format popularized by mockup tools such as balsamiq and now commonly supported in a variety of mockup tools.
    `Record[]` | `getMockDataAsRecord()` Deprecated. in favor of `getMockDataAsRecordArray()`.
    `Record[]` | `getMockDataAsRecordArray()` Data intended for a `ListGrid` or `TreeGrid`, expressed in a simple text format popularized by mockup tools such as balsamiq and now commonly supported in a variety of mockup tools.
    `MockDataFormat` | `getMockDataFormat()` Format of data provided in `mockData`.
    `java.lang.String` | `getMockDataPrimaryKey()` Name of field in `mockData` that should be used as the primary key.
    `MockDataType` | `getMockDataType()` When `mockDataFormat` is "mock", whether `mockData` is in the "grid" or "tree" format.
    `static MockDataSource` | `getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)`
    `static void` | `setDefaultProperties(MockDataSource mockDataSourceProperties)` Class level method to set the default properties of this class.
    `MockDataSource` | `setMockData(Record... mockData)` Data intended for a `ListGrid` or `TreeGrid`, expressed in a simple text format popularized by mockup tools such as balsamiq and now commonly supported in a variety of mockup tools.
    `MockDataSource` | `setMockData(java.lang.String mockData)` Data intended for a `ListGrid` or `TreeGrid`, expressed in a simple text format popularized by mockup tools such as balsamiq and now commonly supported in a variety of mockup tools.
    `MockDataSource` | `setMockDataFormat(MockDataFormat mockDataFormat)` Format of data provided in `mockData`.
    `MockDataSource` | `setMockDataPrimaryKey(java.lang.String mockDataPrimaryKey)` Name of field in `mockData` that should be used as the primary key.
    `MockDataSource` | `setMockDataType(MockDataType mockDataType)` When `mockDataFormat` is "mock", whether `mockData` is in the "grid" or "tree" format.

    - ### Methods inherited from class com.smartgwt.client.data.DataSource

      `addData, addData, addData, addDataChangedHandler, addField, addHandleErrorHandler, addSearchOperator, applyFilter, applyFilter, canFlattenCriteria, clearValueAtDataPath, clearValueAtDataPath, clearValueAtDataPath, clearValueAtDataPath, cloneDSRequest, cloneDSResponse, combineCriteria, combineCriteria, combineCriteria, compareCriteria, compareCriteria, compareCriteria, compareDates, convertCriteria, convertCriteria, convertDataSourceCriteria, convertDataSourceCriteria, convertRelativeDates, convertRelativeDates, convertRelativeDates, convertRelativeDates, copyCriteria, copyRecord, copyRecords, createAlias, downloadFile, downloadFile, downloadFile, evaluateCriterion, execute, exportClientData, exportClientDataStatic, exportData, exportData, exportData, exportData, fetchData, fetchData, fetchData, fetchData, fetchRecord, fetchRecord, fetchRecord, fieldMatchesFilter, fieldMatchesFilter, filterData, filterData, filterData, filterData, flattenCriteria, formatFieldValue, get, get, getAddedAuditFields, getAddGlobalId, getAdvancedCriteriaDescription, getAdvancedCriteriaDescription, getAggregationDescription, getAllowAdvancedCriteria, getAllowAggregation, getAllowDynamicTreeJoins, getAllowRelatedFieldsInCriteria, getAllPathsToRelation, getAllPathsToRelation, getArrayCriteriaForceExact, getAutoCacheAllData, getAutoConvertRelativeDates, getAutoDeriveTitles, getAutoDiscoverTree, getAutoTitle, getCacheAcrossOperationIds, getCacheAllData, getCacheAllOperationId, getCacheData, getCacheMaxAge, getCallbackParam, getCanAggregate, getCanMultiSort, getChildrenField, getClientOnly, getClientOnlyDataSource, getClientOnlyDataSource, getClientOnlyDataSource, getClientOnlyResponse, getCriteriaPolicy, getDataField, getDataFormat, getDataProtocol, getDataSource, getDataSource, getDataTransport, getDataURL, getDeepCloneNonFieldValuesOnEdit, getDeepCloneOnEdit, getDefaultParams, getDefaultPathToRelation, getDefaultPathToRelation, getDefaultTextMatchStyle, getDescription, getDescriptionField, getDiscoverTreeSettings, getDisplayValue, getDropExtraFields, getDropUnknownCriteria, getEnforceSecurityOnClient, getFetchDataURL, getFetchDataURL, getField, getFieldAutoTitle, getFieldCriterion, getFieldDefaultOperator, getFieldDefaultOperator, getFieldForDataPath, getFieldNames, getFieldNames, getFieldOperators, getFieldOperators, getFields, getFieldValue, getFieldValue, getFieldValue, getFieldValue, getFieldValue, getFieldValue, getFieldValue, getFile, getFileURL, getFileURL, getFileURL, getFileVersion, getGlobalNamespaces, getIconField, getIgnoreTextMatchStyleCaseSensitive, getImplicitCriteria, getInfoField, getInheritsFrom, getIsSampleDS, getJsObj, getJsonPrefix, getJsonSuffix, getLegalChildTags, getLoaderURL, getMockDataCriteria, getMockDataRows, getMockMode, getOperationBindings, getPatternEscapeChar, getPatternMultiWildcard, getPatternMultiWildcardAsString, getPatternMultiWildcardAsStringArray, getPatternSingleWildcard, getPatternSingleWildcardAsString, getPatternSingleWildcardAsStringArray, getPluralTitle, getPreventHTTPCaching, getPrimaryKeyField, getPrimaryKeyFieldName, getPrimaryKeyFieldNames, getPrimaryKeyFields, getProgressiveLoading, getQualifyColumnNames, getRecordName, getRecordXPath, getRequestProperties, getRequiredMessage, getResultBatchSize, getResultSetClass, getResultTreeClass, getSampleData, getSchemaNamespace, getSendExtraFields, getSendParentNode, getServiceNamespace, getShortestPathToRelation, getShortestPathToRelation, getShowLocalFieldsOnly, getShowPrompt, getSkipJSONValidation, getSortBy, getSortSpecifiers, getSortSpecifiers, getStrictSQLFiltering, getTagName, getTestData, getTitle, getTitleField, getTranslatePatternOperators, getTrimMilliseconds, getTypeOperators, getTypeOperators, getTypeOperators, getUseFlatFields, getUseHttpProxy, getUseLocalValidators, getUseOfflineStorage, getUseParentFieldOrder, getUseStrictJSON, getUseTestDataFetch, getValidateRelatedRecords, hasAllData, hasCustomTypeOperators, hasCustomTypeOperators, hasCustomTypeOperators, hasFile, hasFileVersion, invalidateCache, invalidateCache, isAdvancedCriteria, isAdvancedCriteria, isCalculated, isCalculated, isCreated, isFlatCriteria, listFiles, listFileVersions, load, load, load, load, loadWithParents, loadWithParents, loadWithParents, loadWithParents, makeFileSpec, onInit, performCustomOperation, performCustomOperation, performCustomOperation, performCustomOperation, processResponse, recordsAreEqual, recordsAsText, recordsAsText, recordsFromText, recordsFromText, recordsFromXML, registerID, removeData, removeData, removeData, removeFile, removeFile, removeFile, removeFileVersion, removeFileVersion, renameFile, renameFile, saveFile, saveFile, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, saveValueViaDataPath, setAddedAuditFields, setAddGlobalId, setAllowAdvancedCriteria, setAllowAggregation, setAllowDynamicTreeJoins, setAllowRelatedFieldsInCriteria, setArrayCriteriaForceExact, setAutoCacheAllData, setAutoConvertRelativeDates, setAutoDeriveTitles, setAutoDiscoverTree, setCacheAcrossOperationIds, setCacheAllData, setCacheAllOperationId, setCacheData, setCacheMaxAge, setCallbackParam, setCanAggregate, setCanMultiSort, setChildrenField, setClientOnly, setCriteriaPolicy, setDataField, setDataFormat, setDataProtocol, setDataTransport, setDataURL, setDeepCloneNonFieldValuesOnEdit, setDeepCloneOnEdit, setDefaultParams, setDefaultProperties, setDefaultTextMatchStyle, setDescription, setDescriptionField, setDiscoverTreeSettings, setDropExtraFields, setDropUnknownCriteria, setEnforceSecurityOnClient, setEnumConstantProperty, setEnumOrdinalProperty, setEnumTranslateStrategy, setFields, setGlobalNamespaces, setHandleErrorCallback, setIconField, setID, setIgnoreTextMatchStyleCaseSensitive, setImplicitCriteria, setInfoField, setInheritsFrom, setInheritsFrom, setIsSampleDS, setJsonPrefix, setJsonSuffix, setLoaderURL, setMockDataCriteria, setMockDataRows, setMockMode, setOperationBindings, setPatternEscapeChar, setPatternMultiWildcard, setPatternMultiWildcard, setPatternSingleWildcard, setPatternSingleWildcard, setPluralTitle, setPreventHTTPCaching, setProgressiveLoading, setQualifyColumnNames, setRecordName, setRecordXPath, setRequestProperties, setRequiredMessage, setResultBatchSize, setResultSetClass, setResultTreeClass, setSampleData, setSendExtraFields, setSendParentNode, setServiceNamespace, setShowLocalFieldsOnly, setShowPrompt, setSkipJSONValidation, setStrictSQLFiltering, setTagName, setTestData, setTitle, setTitleField, setTranslatePatternOperators, setTrimMilliseconds, setTypeOperators, setTypeOperators, setUseFlatFields, setUseHttpProxy, setUseLocalValidators, setUseOfflineStorage, setUseParentFieldOrder, setUseStrictJSON, setUseTestDataFetch, setValidateRelatedRecords, setXmlNamespaces, splitCriteria, splitCriteria, supportsAdvancedCriteria, supportsDynamicTreeJoins, supportsTextMatchStyle, transformRequest, transformResponse, updateCaches, updateCaches, updateData, updateData, updateData, useOfflineResponse, validateData, validateData, validateData, verifyDataSourcePair, viewFile, viewFile, viewFile, xmlSerialize, xmlSerialize, xmlSerialize, xmlSerialize, xmlSerialize`

    - ### Methods inherited from class com.smartgwt.client.core.BaseClass

      `addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getOrCreateJsObj, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoID, setConfig, setConfigOnly, setFactoryCreated, setJavaScriptObject, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.google.gwt.event.shared.HasHandlers

      `fireEvent`

- - ### Constructor Detail

    - #### MockDataSource

          public MockDataSource()

    - #### MockDataSource

          public MockDataSource(com.google.gwt.core.client.JavaScriptObject jsObj)

  - ### Method Detail

    - #### getOrCreateRef

          public static MockDataSource getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)

    - #### create

          public com.google.gwt.core.client.JavaScriptObject create()

      Overrides:
        `create` in class `DataSource`

    - #### setMockData

          public MockDataSource setMockData(java.lang.String mockData)
                                     throws java.lang.IllegalStateException

      Data intended for a `ListGrid` or `TreeGrid`, expressed in a simple text format popularized by mockup tools such as balsamiq and now commonly supported in a variety of mockup tools.

      Balsamiq publishes documentation of the grid format here, with a simple example of using tree-specific formatting here.

      MockData can also be provided as XML, CSV or JSON text by setting `MockDataFormat` to the correct format.

      An alternative format of data consisting of an array of `Records` can also be provided. In this case the records are converted to "grid" `format`.

      Parameters:
        `mockData` - New mockData value. Default value is "md"
      Returns:
        `MockDataSource` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created

    - #### getMockData

          public java.lang.String getMockData()

      Data intended for a `ListGrid` or `TreeGrid`, expressed in a simple text format popularized by mockup tools such as balsamiq and now commonly supported in a variety of mockup tools.

      Balsamiq publishes documentation of the grid format here, with a simple example of using tree-specific formatting here.

      MockData can also be provided as XML, CSV or JSON text by setting `MockDataFormat` to the correct format.

      An alternative format of data consisting of an array of `Records` can also be provided. In this case the records are converted to "grid" `format`.

      Returns:
        Current mockData value. Default value is "md"

    - #### setMockData

          public MockDataSource setMockData(Record... mockData)
                                     throws java.lang.IllegalStateException

      Data intended for a `ListGrid` or `TreeGrid`, expressed in a simple text format popularized by mockup tools such as balsamiq and now commonly supported in a variety of mockup tools.

      Balsamiq publishes documentation of the grid format here, with a simple example of using tree-specific formatting here.

      MockData can also be provided as XML, CSV or JSON text by setting `MockDataFormat` to the correct format.

      An alternative format of data consisting of an array of `Records` can also be provided. In this case the records are converted to "grid" `format`.

      Parameters:
        `mockData` - New mockData value. Default value is "md"
      Returns:
        `MockDataSource` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created

    - #### getMockDataAsRecordArray

          public Record[] getMockDataAsRecordArray()

      Data intended for a `ListGrid` or `TreeGrid`, expressed in a simple text format popularized by mockup tools such as balsamiq and now commonly supported in a variety of mockup tools.

      Balsamiq publishes documentation of the grid format here, with a simple example of using tree-specific formatting here.

      MockData can also be provided as XML, CSV or JSON text by setting `MockDataFormat` to the correct format.

      An alternative format of data consisting of an array of `Records` can also be provided. In this case the records are converted to "grid" `format`.

      Returns:
        Current mockData value. Default value is "md"

    - #### setMockDataFormat

          public MockDataSource setMockDataFormat(MockDataFormat mockDataFormat)
                                           throws java.lang.IllegalStateException

      Format of data provided in `mockData`. See `MockDataFormat`.
      Parameters:
        `mockDataFormat` - New mockDataFormat value. Default value is "mock"
      Returns:
        `MockDataSource` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created

    - #### getMockDataFormat

          public MockDataFormat getMockDataFormat()

      Format of data provided in `mockData`. See `MockDataFormat`.
      Returns:
        Current mockDataFormat value. Default value is "mock"

    - #### setMockDataPrimaryKey

          public MockDataSource setMockDataPrimaryKey(java.lang.String mockDataPrimaryKey)
                                               throws java.lang.IllegalStateException

      Name of field in `mockData` that should be used as the primary key. Otherwise a hidden primary key field will automatically be added with a type of 'sequence'.
      Parameters:
        `mockDataPrimaryKey` - New mockDataPrimaryKey value. Default value is null
      Returns:
        `MockDataSource` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created
      See Also:
        `FieldName`

    - #### getMockDataPrimaryKey

          public java.lang.String getMockDataPrimaryKey()

      Name of field in `mockData` that should be used as the primary key. Otherwise a hidden primary key field will automatically be added with a type of 'sequence'.
      Returns:
        Current mockDataPrimaryKey value. Default value is null
      See Also:
        `FieldName`

    - #### setMockDataType

          public MockDataSource setMockDataType(MockDataType mockDataType)
                                         throws java.lang.IllegalStateException

      When `mockDataFormat` is "mock", whether `mockData` is in the "grid" or "tree" format. See `MockDataType`.

      If not specified, the type will be detected from the data.

      Parameters:
        `mockDataType` - New mockDataType value. Default value is null
      Returns:
        `MockDataSource` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created

    - #### getMockDataType

          public MockDataType getMockDataType()

      When `mockDataFormat` is "mock", whether `mockData` is in the "grid" or "tree" format. See `MockDataType`.

      If not specified, the type will be detected from the data.

      Returns:
        Current mockDataType value. Default value is null

    - #### setDefaultProperties

          public static void setDefaultProperties(MockDataSource mockDataSourceProperties)

      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
        `mockDataSourceProperties` - properties that should be used as new defaults when instances of this class are created
      See Also:
        `SGWTProperties`

    - #### getMockDataAsRecord

          public Record[] getMockDataAsRecord()

      Deprecated. in favor of `getMockDataAsRecordArray()`.
      See `getMockDataAsRecordArray()`.