2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.json.binding.biojs;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.Iterator;
26 import java.util.Objects;
28 import org.json.simple.JSONArray;
29 import org.json.simple.JSONObject;
30 import org.json.simple.parser.JSONParser;
31 import org.json.simple.parser.ParseException;
33 public class BioJSRepositoryPojo
36 private String description;
38 private String latestReleaseVersion;
40 private Collection<BioJSReleasePojo> releases = new ArrayList<BioJSReleasePojo>();
42 public BioJSRepositoryPojo()
46 public BioJSRepositoryPojo(String jsonString)
51 } catch (ParseException e)
57 @SuppressWarnings("unchecked")
58 private void parse(String jsonString) throws ParseException
60 Objects.requireNonNull(jsonString,
61 "Supplied jsonString must not be null");
62 JSONParser jsonParser = new JSONParser();
63 JSONObject JsonObj = (JSONObject) jsonParser.parse(jsonString);
64 this.description = (String) JsonObj.get("description");
65 this.latestReleaseVersion = (String) JsonObj
66 .get("latestReleaseVersion");
68 JSONArray repositoriesJsonArray = (JSONArray) JsonObj.get("releases");
69 for (Iterator<JSONObject> repoIter = repositoriesJsonArray.iterator(); repoIter
72 JSONObject repoObj = repoIter.next();
73 BioJSReleasePojo repo = new BioJSReleasePojo();
74 repo.setType((String) repoObj.get("type"));
75 repo.setUrl((String) repoObj.get("url"));
76 repo.setVersion((String) repoObj.get("version"));
77 this.getReleases().add(repo);
81 public String getDescription()
86 public void setDescription(String description)
88 this.description = description;
91 public String getLatestReleaseVersion()
93 return latestReleaseVersion;
96 public void setLatestReleaseVersion(String latestReleaseVersion)
98 this.latestReleaseVersion = latestReleaseVersion;
101 public Collection<BioJSReleasePojo> getReleases()
106 public void setReleases(Collection<BioJSReleasePojo> releases)
108 this.releases = releases;