<commit_before>//
//  SObjectData.swift
//
//  Created by <NAME> on 11/05/2016.
//  Copyright © 2016 Salesforce. All rights reserved.
//

import Foundation

class SObjectData: NSObject {
	
    var soupDict: NSDictionary = [:];
	
	override init() {
		super.init()
		for fieldName in self.dynamicType.dataSpec().fieldNames {
			self.updateSoupForFieldName(fieldName, fieldValue: nil)
		}
		self.updateSoupForFieldName("attributes", fieldValue: self.dynamicType.dataSpec().objectType)
	}
	
	convenience init(aSoupDict: [String: AnyObject]?) {
		self.init()
		if let soupDict = aSoupDict {
			for fieldName in soupDict.keys {
				self.updateSoupForFieldName(fieldName, fieldValue: soupDict[fieldName])
			}
		}
	}
	
	func updateSoupForFieldName(fieldName: String, fieldValue: AnyObject?) {
		var mutableSoup: [NSObject : AnyObject] = self.soupDict.mutableCopy() as! [NSObject : AnyObject]
		mutableSoup[fieldName] = fieldValue
		self.soupDict = mutableSoup
	}
	
	func fieldValueForFieldName(fieldName: String) -> AnyObject? {
		return self.nonNullFieldValue(fieldName)
	}
	
	func nonNullFieldValue(fieldName: String) -> AnyObject? {
		return self.soupDict.nonNullObjectForKey(fieldName)
	}
	
	func desc() -> String {
		return String(format: "<%@:%p> %@", self, self, self.soupDict)
	}
	
	// dataSpec is abstract.
	// needs to be override.
    class func dataSpec() -> SObjectDataSpec {
        return SObjectDataSpec()
    }
}

<commit_msg>updated nonNullFieldValue to allow nulls from database<commit_after>//
//  SObjectData.swift
//
//  Created by <NAME> on 11/05/2016.
//  Copyright © 2016 Salesforce. All rights reserved.
//

import Foundation

class SObjectData: NSObject {
	
    var soupDict: NSDictionary = [:];
	
	override init() {
		super.init()
		for fieldName in self.dynamicType.dataSpec().fieldNames {
			self.updateSoupForFieldName(fieldName, fieldValue: nil)
		}
		self.updateSoupForFieldName("attributes", fieldValue: self.dynamicType.dataSpec().objectType)
	}
	
	convenience init(aSoupDict: [String: AnyObject]?) {
		self.init()
		if let soupDict = aSoupDict {
			for fieldName in soupDict.keys {
				self.updateSoupForFieldName(fieldName, fieldValue: soupDict[fieldName])
			}
		}
	}
	
	func updateSoupForFieldName(fieldName: String, fieldValue: AnyObject?) {
		var mutableSoup: [NSObject : AnyObject] = self.soupDict.mutableCopy() as! [NSObject : AnyObject]
		mutableSoup[fieldName] = fieldValue
		self.soupDict = mutableSoup
	}
	
	func fieldValueForFieldName(fieldName: String) -> AnyObject? {
		return self.nonNullFieldValue(fieldName)
	}
	
    func nonNullFieldValue(fieldName: String) -> AnyObject? {
        // checking for null as causing app crash
        let strRetVal = self.soupDict.nonNullObjectForKey(fieldName)
        if strRetVal == nil {
            return ""
        }else{
            return strRetVal
        }
    }
	
	func desc() -> String {
		return String(format: "<%@:%p> %@", self, self, self.soupDict)
	}
	
	// dataSpec is abstract.
	// needs to be override.
    class func dataSpec() -> SObjectDataSpec {
        return SObjectDataSpec()
    }
}


{'fraction_non_alphanumeric': 0.1168284789644013, 'fraction_numerical': 0.007766990291262136, 'mean_word_length': 3.6134328358208956, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '792175', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1006, 'n_words': 225}