AbstractData

@interface AbstractData : NSObject {
  NSMutableDictionary<TagInfo *, id> *map;
}

Abstract class AbstractData model is the root of Data hierarchy, containing the basic common functions applicable to all Data classes. All Data classes will have AbstractData model as its superclass.

  • map

    Map of contained tagInfo and their value

    Declaration

    Objective-C

    NSMutableDictionary<TagInfo *, id> *map
  • All tags that can be represented

    Declaration

    Objective-C

    @property (readwrite, retain, atomic, nonnull) NSArray<TagInfo *> *allTags;

    Swift

    var allTags: [TagInfo] { get set }
  • Type of represented tags

    Declaration

    Objective-C

    @property (assign, readwrite, atomic, nonnull) Class<Tag> tagType;
  • Initializer

    Declaration

    Objective-C

    - (id _Nonnull)init:(Class<Tag> _Nonnull)tagType;

    Parameters

    tagType

    Type of tags this data represents

  • Initializer

    Declaration

    Objective-C

    - (id _Nonnull)init:(Class<Tag> _Nonnull)tagType
                  regex:(NSString *_Nullable)regex
                rootTag:(NSString *_Nullable)rTag;

    Parameters

    tagType

    Type of tags this data represents

    regex

    for checking RFU

    rTag

    is the tag in the containing object

  • Checks if value for tagInfo is present internally

    Declaration

    Objective-C

    - (BOOL)hasTagInfoValueFor:(TagInfo *_Nonnull)tagInfo;

    Swift

    func hasTagInfoValue(for tagInfo: TagInfo) -> Bool

    Parameters

    tagInfo

    Tag info for which to check presence

    Return Value

    true if value exists else false

  • Get value for tagInfo

    Declaration

    Objective-C

    - (id _Nullable)getTagInfoValueFor:(TagInfo *_Nonnull)tagInfo;

    Swift

    func getTagInfoValue(for tagInfo: TagInfo) -> Any?

    Parameters

    tagInfo

    Tag info for which to get value

    Return Value

    Value if found else nil

  • Set value for tagInfo

    Declaration

    Objective-C

    - (void)setTagInfoValue:(id _Nonnull)value for:(TagInfo * _Nonnull)tagInfo;

    Swift

    func setTagInfoValue(_ value: Any, for tagInfo: TagInfo)

    Parameters

    value

    Value to set

    tagInfo

    Tag info to set the value of

  • Removes value related to tagInfo

    Note

    This method does nothing if the value is not found for tagInfo

    Declaration

    Objective-C

    - (void)removeTagInfoValueFor:(TagInfo *_Nonnull)tagInfo;

    Swift

    func removeTagInfoValue(for tagInfo: TagInfo)

    Parameters

    tagInfo

    Remove value for tagInfo

  • Returns count of total tag info key value pair

    Declaration

    Objective-C

    - (NSInteger)tagInfoCount;

    Swift

    func tagInfoCount() -> Int

    Return Value

    Total number of tag info key value pair

  • Get value for tagInfo

    Declaration

    Objective-C

    - (id _Nullable)getTagInfoValueForTagString:(NSString *_Nonnull)strTagInfo
                                          error:
                                              (NSError *_Nullable *_Nullable)error;

    Swift

    func getTagInfoValue(forTagString strTagInfo: String) throws -> Any

    Parameters

    strTagInfo

    NSString* tag for which to get value

    Return Value

    Value if found else nil

  • Set value for tagInfo

    Declaration

    Objective-C

    - (BOOL)setTagInfoValue:(id _Nonnull)value
               forTagString:(NSString *_Nonnull)strTagInfo
                      error:(NSError *_Nullable *_Nullable)error;

    Swift

    func setTagInfoValue(_ value: Any, forTagString strTagInfo: String) throws

    Parameters

    value

    Value to set

    strTagInfo

    NSString* tag to set the value of

  • Set value in range of tag

    Used for MAI Data, Unrestricted data in push payment data, or unrestricted data in additional data

    Declaration

    Objective-C

    - (BOOL)setValueInTagRange:(id _Nonnull)value
                           low:(int)low
                          high:(int)high
                         error:(NSError *_Nullable *_Nullable)error;

    Swift

    func setValueInTagRange(_ value: Any, low: Int32, high: Int32) throws

    Parameters

    value

    of to be inserted

    low

    lower index inclusive

    high

    higher index exclusive

  • Remove value at specified tag

    Declaration

    Objective-C

    - (void)removeValue:(TagInfo *_Nonnull)tagInfo;

    Swift

    func removeValue(_ tagInfo: TagInfo)

    Parameters

    tagInfo

    specified tag at which to remove value

  • Set RootTag: the root tag that the object belong to

    Declaration

    Objective-C

    - (void)setRootTag:(NSString *_Nullable)rootTag;

    Swift

    func setRootTag(_ rootTag: String?)

    Parameters

    rootTag

    can be null

  • Validate data

    Note

    Throws:
    • MPQRError.missingTag if the value for tag info is not present while the tag was mandatory.
    • MPQRError.invalidTagValue If the value doesn’t match pattern of the tag. And if the length of string representation of the value is out of [1, 99] range

    Declaration

    Objective-C

    - (BOOL)validate:(NSError *_Nullable *_Nullable)err;

    Swift

    func validate() throws
  • Checks internal data for RFU tags

    Note

    Throws RFUTagException if internal data contains an RFU tag

    Declaration

    Objective-C

    - (BOOL)checkForRFU:(NSError *_Nullable *_Nullable)error;

    Swift

    func checkForRFU() throws
  • To check length of the tag

    Declaration

    Objective-C

    - (BOOL)validateLength:(NSString *_Nonnull)value
                   tagInfo:(TagInfo *_Nonnull)tInfo
                     error:(NSError *_Nullable *_Nullable)error;

    Swift

    func validateLength(_ value: String, tagInfo tInfo: TagInfo) throws
  • String representation of the data. It will generate a string which is parseable back to data

    Declaration

    Objective-C

    - (NSString *_Nonnull)description;

    Swift

    func description() -> String
  • Dump internal data in a string representation Useful for debugging purposes

    Declaration

    Objective-C

    - (NSString *_Nonnull)dumpData;

    Swift

    func dumpData() -> String

    Return Value

    String representation of internal data

  • Equality check

    Declaration

    Objective-C

    - (BOOL)isEqual:(id _Nullable)object;

    Swift

    func isEqual(_ object: Any?) -> Bool