<commit_before>/**
--| ADAPTIVE RUNTIME PLATFORM |----------------------------------------------------------------------------------------

(C) Copyright 2013-2015 <NAME> t/a Adaptive.me <http://adaptive.me>.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by appli-
-cable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the  License  for the specific language governing
permissions and limitations under the License.

Original author:

    * <NAME>
            <http://github.com/carloslozano>
            <http://twitter.com/adaptivecoder>
            <mailto:<EMAIL>>

Contributors:

    * <NAME>
             <http://github.com/fnva>
             <http://twitter.com/ferran_vila>
             <mailto:<EMAIL>>

    * See source code files for contributors.

Release:

    * @version v2.0.4

-------------------------------------------| aut inveniam viam aut faciam |--------------------------------------------
*/

import Foundation

/**
   Structure representing a service path for one endpoint

   @author fnva
   @since ARP1.0
   @version 1.0
*/
public class ServicePath : NSObject {

    /**
       The methods for calling a path
    */
    var methods : [IServiceMethod]?
    /**
       The path for the endpoint
    */
    var path : String?

    /**
       Default Constructor

       @since ARP1.0
    */
    public override init() {
        super.init()
    }

    /**
       Constructor with parameters

       @param path    The path for the endpoint
       @param methods The methods for calling a path
    */
    public init(path: String, methods: [IServiceMethod]) {
        super.init()
        self.path = path
        self.methods = methods
    }

    /**
       Endpoint's path methods setter

       @return Endpoint's path methods
    */
    public func getMethods() -> [IServiceMethod]? {
        return self.methods
    }

    /**
       Endpoint's path methods setter

       @param methods Endpoint's path methods
    */
    public func setMethods(methods: [IServiceMethod]) {
        self.methods = methods
    }

    /**
       Endpoint's Path Getter

       @return Endpoint's Path
    */
    public func getPath() -> String? {
        return self.path
    }

    /**
       Endpoint's path setter

       @param path Endpoint's path
    */
    public func setPath(path: String) {
        self.path = path
    }


    /**
       JSON Serialization and deserialization support.
    */
    struct Serializer {
        static func fromJSON(json : String) -> ServicePath {
            var data:NSData = json.dataUsingEncoding(NSUTF8StringEncoding)!
            var jsonError: NSError?
            let dict = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &jsonError) as NSDictionary
            return fromDictionary(dict)
        }

        static func fromDictionary(dict : NSDictionary) -> ServicePath {
            var resultObject : ServicePath = ServicePath()

            if let value : AnyObject = dict.objectForKey("methods") {
                if "\(value)" as NSString != "<null>" {
                    var methods : [IServiceMethod] = [IServiceMethod]()
                    for (var i = 0;i < (value as NSArray).count ; i++) {
                        methods.append(IServiceMethod.toEnum(((value as NSDictionary)["value"]) as NSString)
                    }
                    resultObject.methods = methods
                }
            }

            if let value : AnyObject = dict.objectForKey("path") {
                if "\(value)" as NSString != "<null>" {
                    resultObject.path = (value as String)
                }
            }

            return resultObject
        }

        static func toJSON(object: ServicePath) -> String {
            var jsonString : NSMutableString = NSMutableString()
            // Start Object to JSON
            jsonString.appendString("{ ")

            // Fields.
            if (object.methods != nil) {
                // Start array of objects.
                jsonString.appendString("\"methods\": [")

                for var i = 0; i < object.methods!.count; i++ {
                    jsonString.appendString("{ "value": \"\(object.methods![i].toString())\" }")
                    if (i < object.methods!.count-1) {
                        jsonString.appendString(", ");
                    }
                }

                // End array of objects.
                jsonString.appendString("], ");
            } else {
                jsonString.appendString("\"methods\": null, ")
            }
            object.path != nil ? jsonString.appendString("\"path\": \"\(JSONUtil.escapeString(object.path!))\"") : jsonString.appendString("\"path\": null")

            // End Object to JSON
            jsonString.appendString(" }")<commit_msg>ServicePath syntax fix.<commit_after>/**
--| ADAPTIVE RUNTIME PLATFORM |----------------------------------------------------------------------------------------

(C) Copyright 2013-2015 <NAME> t/a Adaptive.me <http://adaptive.me>.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by appli-
-cable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the  License  for the specific language governing
permissions and limitations under the License.

Original author:

    * <NAME>
            <http://github.com/carloslozano>
            <http://twitter.com/adaptivecoder>
            <mailto:<EMAIL>>

Contributors:

    * <NAME>
             <http://github.com/fnva>
             <http://twitter.com/ferran_vila>
             <mailto:<EMAIL>>

    * See source code files for contributors.

Release:

    * @version v2.0.4

-------------------------------------------| aut inveniam viam aut faciam |--------------------------------------------
*/

import Foundation

/**
   Structure representing a service path for one endpoint

   @author fnva
   @since ARP1.0
   @version 1.0
*/
public class ServicePath : NSObject {

    /**
       The methods for calling a path
    */
    var methods : [IServiceMethod]?
    /**
       The path for the endpoint
    */
    var path : String?

    /**
       Default Constructor

       @since ARP1.0
    */
    public override init() {
        super.init()
    }

    /**
       Constructor with parameters

       @param path    The path for the endpoint
       @param methods The methods for calling a path
    */
    public init(path: String, methods: [IServiceMethod]) {
        super.init()
        self.path = path
        self.methods = methods
    }

    /**
       Endpoint's path methods setter

       @return Endpoint's path methods
    */
    public func getMethods() -> [IServiceMethod]? {
        return self.methods
    }

    /**
       Endpoint's path methods setter

       @param methods Endpoint's path methods
    */
    public func setMethods(methods: [IServiceMethod]) {
        self.methods = methods
    }

    /**
       Endpoint's Path Getter

       @return Endpoint's Path
    */
    public func getPath() -> String? {
        return self.path
    }

    /**
       Endpoint's path setter

       @param path Endpoint's path
    */
    public func setPath(path: String) {
        self.path = path
    }


    /**
       JSON Serialization and deserialization support.
    */
    struct Serializer {
        static func fromJSON(json : String) -> ServicePath {
            var data:NSData = json.dataUsingEncoding(NSUTF8StringEncoding)!
            var jsonError: NSError?
            let dict = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &jsonError) as NSDictionary
            return fromDictionary(dict)
        }

        static func fromDictionary(dict : NSDictionary) -> ServicePath {
            var resultObject : ServicePath = ServicePath()

            if let value : AnyObject = dict.objectForKey("methods") {
                if "\(value)" as NSString != "<null>" {
                    var methods : [IServiceMethod] = [IServiceMethod]()
                    for (var i = 0;i < (value as NSArray).count ; i++) {
                        methods.append(IServiceMethod.toEnum(((value as NSDictionary)["value"]) as NSString))
                    }
                    resultObject.methods = methods
                }
            }

            if let value : AnyObject = dict.objectForKey("path") {
                if "\(value)" as NSString != "<null>" {
                    resultObject.path = (value as String)
                }
            }

            return resultObject
        }

        static func toJSON(object: ServicePath) -> String {
            var jsonString : NSMutableString = NSMutableString()
            // Start Object to JSON
            jsonString.appendString("{ ")

            // Fields.
            if (object.methods != nil) {
                // Start array of objects.
                jsonString.appendString("\"methods\": [")

                for var i = 0; i < object.methods!.count; i++ {
                    jsonString.appendString("{ \"value\": \"\(object.methods![i].toString())\" }")
                    if (i < object.methods!.count-1) {
                        jsonString.appendString(", ");
                    }
                }

                // End array of objects.
                jsonString.appendString("], ");
            } else {
                jsonString.appendString("\"methods\": null, ")
            }
            object.path != nil ? jsonString.appendString("\"path\": \"\(JSONUtil.escapeString(object.path!))\"") : jsonString.appendString("\"path\": null")

            // End Object to JSON
            jsonString.appendString(" }")
{'fraction_non_alphanumeric': 0.13780333300847872, 'fraction_numerical': 0.004872819413312543, 'mean_word_length': 1.6489416623644813, 'pattern_counts': {'":': 10, '<': 37, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6810680', 'n_tokens_mistral': 2750, 'n_tokens_neox': 2561, 'n_words': 764}