{"action":"created","comment":{"url":"https://api.github.com/repos/apache/apex-malhar/pulls/comments/89761586","pull_request_review_id":10143196,"id":89761586,"diff_hunk":"@@ -0,0 +1,473 @@\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package com.datatorrent.contrib.parser;\n+\n+import java.text.DateFormat;\n+import java.text.ParseException;\n+import java.text.SimpleDateFormat;\n+import java.util.Date;\n+import java.util.HashMap;\n+import java.util.List;\n+\n+\n+/**\n+ * Helper class with methods to validate data members to corresponding data types.\n+ */\n+public class FixedWidthValidator\n+{\n+  /**\n+   * List of accessors (setters) in order of fields in input JSON\n+   */\n+  List<com.datatorrent.contrib.parser.FixedWidthParser.TypeInfo> setters;\n+  /**\n+   * Schema is read into this object to access fields\n+   */\n+  private FixedWidthSchema schema;\n+  /**\n+   * Input Class for which an object is to be emitted if all validations pass\n+   */\n+  private Class<?> pojoClass;\n+\n+  /**\n+   * Parameterized constructor to initialize data members\n+   * @param schema\n+   * @param pojoClass\n+   * @param setters\n+   */\n+  public FixedWidthValidator(FixedWidthSchema schema, Class<?> pojoClass, List<com.datatorrent.contrib.parser.FixedWidthParser.TypeInfo> setters)\n+  {\n+    this.schema = schema;\n+    this.pojoClass = pojoClass;\n+    this.setters = setters;\n+  }\n+\n+  /**\n+   * Get the Schema\n+   * @return\n+   */\n+  public FixedWidthSchema getSchema()\n+  {\n+    return schema;\n+  }\n+\n+  /**\n+   * Set the Schema\n+   * @param schema\n+   */\n+  public void setSchema(FixedWidthSchema schema)\n+  {\n+    this.schema = schema;\n+  }\n+\n+  /**\n+   * Get the setters\n+   * @return\n+   */\n+  public List<com.datatorrent.contrib.parser.FixedWidthParser.TypeInfo> getSetters()\n+  {\n+    return setters;\n+  }\n+\n+  /**\n+   * Set the Setters\n+   * @param setters\n+   */\n+  public void setSetters(List<FixedWidthParser.TypeInfo> setters)\n+  {\n+    this.setters = setters;\n+  }\n+\n+  /**\n+   * Get the pojoClass\n+   * @return\n+   */\n+  public Class<?> getPojoClass()\n+  {\n+    return pojoClass;\n+  }\n+\n+  /**\n+   * Set the pojoClass\n+   * @param pojoClass\n+   */\n+  public void setPojoClass(Class<?> pojoClass)\n+  {\n+    this.pojoClass = pojoClass;\n+  }\n+\n+  /**\n+   * Function to validate Integer type data and set it in the Object\n+   * using accessors in TypeInfo\n+   * @param value\n+   * @param fieldName\n+   * @param typeInfo\n+   * @param pojoObject\n+   * @param toEmit\n+   */\n+  public void parseandsetIntegerValue(String value, String fieldName, FixedWidthParser.TypeInfo typeInfo, Object pojoObject, HashMap toEmit)\n+  {\n+    try {\n+      if (value != null && !value.isEmpty()) {\n+        int result = Integer.parseInt(value);\n+        toEmit.put(fieldName,result);\n+        if (typeInfo != null && pojoObject != null) {\n+          typeInfo.setter.set(pojoObject, result);\n+        }\n+      }\n+      else\n+        toEmit.put(fieldName,value);\n+\n+    } catch (NumberFormatException e) {\n+      throw new RuntimeException(\"Error parsing\" + value + \" to Integer type\", e);\n+    } catch (Exception e) {\n+      throw new RuntimeException(\"Error setting \" + value + \" in the given class\" + typeInfo.toString(), e);\n+\n+    }\n+  }\n+\n+  /**\n+   * Function to validate Double type data and set it in the Object\n+   * using accessors in TypeInfo\n+   * @param value\n+   * @param fieldName\n+   * @param typeInfo\n+   * @param pojoObject\n+   * @param toEmit\n+   */\n+  public void parseandsetDoubleValue(String value, String fieldName, FixedWidthParser.TypeInfo typeInfo, Object pojoObject, HashMap toEmit)\n+  {\n+    try {\n+\n+      if (value != null && !value.isEmpty()) {\n+        Double result = Double.parseDouble(value);\n+        toEmit.put(fieldName,result);\n+        if (typeInfo != null && pojoObject != null) {\n+          typeInfo.setter.set(pojoObject, result);\n+        }\n+      }\n+      else\n+        toEmit.put(fieldName, value);\n+\n+    } catch (NumberFormatException e) {\n+      throw new RuntimeException(\"Error parsing\" + value + \" to Double type\", e);\n+    } catch (Exception e) {\n+      throw new RuntimeException(\"Error setting \" + value + \" in the given class\" + typeInfo.toString(), e);\n+\n+    }\n+  }\n+\n+  /**\n+   * Function to validate String type data and set it in the Object\n+   * using accessors in TypeInfo\n+   * @param value","path":"contrib/src/main/java/com/datatorrent/contrib/parser/FixedWidthValidator.java","position":179,"original_position":179,"commit_id":"b53d1a7bccea2ab9a61140fbcffb3ff55a8706dc","original_commit_id":"b53d1a7bccea2ab9a61140fbcffb3ff55a8706dc","user":{"login":"chinmaykolhatkar","id":12393897,"avatar_url":"https://avatars.githubusercontent.com/u/12393897?v=3","gravatar_id":"","url":"https://api.github.com/users/chinmaykolhatkar","html_url":"https://github.com/chinmaykolhatkar","followers_url":"https://api.github.com/users/chinmaykolhatkar/followers","following_url":"https://api.github.com/users/chinmaykolhatkar/following{/other_user}","gists_url":"https://api.github.com/users/chinmaykolhatkar/gists{/gist_id}","starred_url":"https://api.github.com/users/chinmaykolhatkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chinmaykolhatkar/subscriptions","organizations_url":"https://api.github.com/users/chinmaykolhatkar/orgs","repos_url":"https://api.github.com/users/chinmaykolhatkar/repos","events_url":"https://api.github.com/users/chinmaykolhatkar/events{/privacy}","received_events_url":"https://api.github.com/users/chinmaykolhatkar/received_events","type":"User","site_admin":false},"body":"Param descriptions are missing.","created_at":"2016-11-28T11:18:55Z","updated_at":"2016-11-28T11:22:38Z","html_url":"https://github.com/apache/apex-malhar/pull/427#discussion_r89761586","pull_request_url":"https://api.github.com/repos/apache/apex-malhar/pulls/427","_links":{"self":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/comments/89761586"},"html":{"href":"https://github.com/apache/apex-malhar/pull/427#discussion_r89761586"},"pull_request":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/427"}}},"pull_request":{"url":"https://api.github.com/repos/apache/apex-malhar/pulls/427","id":86479563,"html_url":"https://github.com/apache/apex-malhar/pull/427","diff_url":"https://github.com/apache/apex-malhar/pull/427.diff","patch_url":"https://github.com/apache/apex-malhar/pull/427.patch","issue_url":"https://api.github.com/repos/apache/apex-malhar/issues/427","number":427,"state":"open","locked":false,"title":"APEXMALHAR-2259 Create Fixed Length Parser Operator","user":{"login":"Hitesh-Scorpio","id":7661135,"avatar_url":"https://avatars.githubusercontent.com/u/7661135?v=3","gravatar_id":"","url":"https://api.github.com/users/Hitesh-Scorpio","html_url":"https://github.com/Hitesh-Scorpio","followers_url":"https://api.github.com/users/Hitesh-Scorpio/followers","following_url":"https://api.github.com/users/Hitesh-Scorpio/following{/other_user}","gists_url":"https://api.github.com/users/Hitesh-Scorpio/gists{/gist_id}","starred_url":"https://api.github.com/users/Hitesh-Scorpio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hitesh-Scorpio/subscriptions","organizations_url":"https://api.github.com/users/Hitesh-Scorpio/orgs","repos_url":"https://api.github.com/users/Hitesh-Scorpio/repos","events_url":"https://api.github.com/users/Hitesh-Scorpio/events{/privacy}","received_events_url":"https://api.github.com/users/Hitesh-Scorpio/received_events","type":"User","site_admin":false},"body":"@chinmaykolhatkar @bhupeshchawda please review\n","created_at":"2016-09-23T09:20:48Z","updated_at":"2016-11-28T11:22:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"28435d1b515859951e0979ac24c9e8c8977fdb97","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/apex-malhar/pulls/427/commits","review_comments_url":"https://api.github.com/repos/apache/apex-malhar/pulls/427/comments","review_comment_url":"https://api.github.com/repos/apache/apex-malhar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/apex-malhar/issues/427/comments","statuses_url":"https://api.github.com/repos/apache/apex-malhar/statuses/b53d1a7bccea2ab9a61140fbcffb3ff55a8706dc","head":{"label":"Hitesh-Scorpio:APEXMALHAR-2259_FixedWidthParser","ref":"APEXMALHAR-2259_FixedWidthParser","sha":"b53d1a7bccea2ab9a61140fbcffb3ff55a8706dc","user":{"login":"Hitesh-Scorpio","id":7661135,"avatar_url":"https://avatars.githubusercontent.com/u/7661135?v=3","gravatar_id":"","url":"https://api.github.com/users/Hitesh-Scorpio","html_url":"https://github.com/Hitesh-Scorpio","followers_url":"https://api.github.com/users/Hitesh-Scorpio/followers","following_url":"https://api.github.com/users/Hitesh-Scorpio/following{/other_user}","gists_url":"https://api.github.com/users/Hitesh-Scorpio/gists{/gist_id}","starred_url":"https://api.github.com/users/Hitesh-Scorpio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hitesh-Scorpio/subscriptions","organizations_url":"https://api.github.com/users/Hitesh-Scorpio/orgs","repos_url":"https://api.github.com/users/Hitesh-Scorpio/repos","events_url":"https://api.github.com/users/Hitesh-Scorpio/events{/privacy}","received_events_url":"https://api.github.com/users/Hitesh-Scorpio/received_events","type":"User","site_admin":false},"repo":{"id":65878565,"name":"apex-malhar","full_name":"Hitesh-Scorpio/apex-malhar","owner":{"login":"Hitesh-Scorpio","id":7661135,"avatar_url":"https://avatars.githubusercontent.com/u/7661135?v=3","gravatar_id":"","url":"https://api.github.com/users/Hitesh-Scorpio","html_url":"https://github.com/Hitesh-Scorpio","followers_url":"https://api.github.com/users/Hitesh-Scorpio/followers","following_url":"https://api.github.com/users/Hitesh-Scorpio/following{/other_user}","gists_url":"https://api.github.com/users/Hitesh-Scorpio/gists{/gist_id}","starred_url":"https://api.github.com/users/Hitesh-Scorpio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hitesh-Scorpio/subscriptions","organizations_url":"https://api.github.com/users/Hitesh-Scorpio/orgs","repos_url":"https://api.github.com/users/Hitesh-Scorpio/repos","events_url":"https://api.github.com/users/Hitesh-Scorpio/events{/privacy}","received_events_url":"https://api.github.com/users/Hitesh-Scorpio/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Hitesh-Scorpio/apex-malhar","description":"Mirror of Apache Apex malhar","fork":true,"url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar","forks_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/forks","keys_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/teams","hooks_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/events","assignees_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/tags","blobs_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/languages","stargazers_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/subscription","commits_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/merges","archive_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/downloads","issues_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/releases{/id}","deployments_url":"https://api.github.com/repos/Hitesh-Scorpio/apex-malhar/deployments","created_at":"2016-08-17T05:30:14Z","updated_at":"2016-08-17T05:30:20Z","pushed_at":"2016-11-28T09:01:20Z","git_url":"git://github.com/Hitesh-Scorpio/apex-malhar.git","ssh_url":"git@github.com:Hitesh-Scorpio/apex-malhar.git","clone_url":"https://github.com/Hitesh-Scorpio/apex-malhar.git","svn_url":"https://github.com/Hitesh-Scorpio/apex-malhar","homepage":"","size":87771,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"e01cf9c447a34791e6de5efb160f91ac20a87df9","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":41348334,"name":"apex-malhar","full_name":"apache/apex-malhar","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/apex-malhar","description":"Mirror of Apache Apex malhar","fork":false,"url":"https://api.github.com/repos/apache/apex-malhar","forks_url":"https://api.github.com/repos/apache/apex-malhar/forks","keys_url":"https://api.github.com/repos/apache/apex-malhar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/apex-malhar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/apex-malhar/teams","hooks_url":"https://api.github.com/repos/apache/apex-malhar/hooks","issue_events_url":"https://api.github.com/repos/apache/apex-malhar/issues/events{/number}","events_url":"https://api.github.com/repos/apache/apex-malhar/events","assignees_url":"https://api.github.com/repos/apache/apex-malhar/assignees{/user}","branches_url":"https://api.github.com/repos/apache/apex-malhar/branches{/branch}","tags_url":"https://api.github.com/repos/apache/apex-malhar/tags","blobs_url":"https://api.github.com/repos/apache/apex-malhar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/apex-malhar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/apex-malhar/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/apex-malhar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/apex-malhar/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/apex-malhar/languages","stargazers_url":"https://api.github.com/repos/apache/apex-malhar/stargazers","contributors_url":"https://api.github.com/repos/apache/apex-malhar/contributors","subscribers_url":"https://api.github.com/repos/apache/apex-malhar/subscribers","subscription_url":"https://api.github.com/repos/apache/apex-malhar/subscription","commits_url":"https://api.github.com/repos/apache/apex-malhar/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/apex-malhar/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/apex-malhar/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/apex-malhar/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/apex-malhar/contents/{+path}","compare_url":"https://api.github.com/repos/apache/apex-malhar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/apex-malhar/merges","archive_url":"https://api.github.com/repos/apache/apex-malhar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/apex-malhar/downloads","issues_url":"https://api.github.com/repos/apache/apex-malhar/issues{/number}","pulls_url":"https://api.github.com/repos/apache/apex-malhar/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/apex-malhar/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/apex-malhar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/apex-malhar/labels{/name}","releases_url":"https://api.github.com/repos/apache/apex-malhar/releases{/id}","deployments_url":"https://api.github.com/repos/apache/apex-malhar/deployments","created_at":"2015-08-25T07:00:05Z","updated_at":"2016-11-25T17:10:49Z","pushed_at":"2016-11-28T10:43:14Z","git_url":"git://github.com/apache/apex-malhar.git","ssh_url":"git@github.com:apache/apex-malhar.git","clone_url":"https://github.com/apache/apex-malhar.git","svn_url":"https://github.com/apache/apex-malhar","homepage":"","size":99674,"stargazers_count":67,"watchers_count":67,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":110,"mirror_url":"git://git.apache.org/incubator-apex-malhar.git","open_issues_count":32,"forks":110,"open_issues":32,"watchers":67,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/427"},"html":{"href":"https://github.com/apache/apex-malhar/pull/427"},"issue":{"href":"https://api.github.com/repos/apache/apex-malhar/issues/427"},"comments":{"href":"https://api.github.com/repos/apache/apex-malhar/issues/427/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/427/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/apex-malhar/pulls/427/commits"},"statuses":{"href":"https://api.github.com/repos/apache/apex-malhar/statuses/b53d1a7bccea2ab9a61140fbcffb3ff55a8706dc"}}}}
{"actor":{"display_login":"chinmaykolhatkar"}}