From fc9fc7c79c6e9f4a35e861fb12965676bf24efad Mon Sep 17 00:00:00 2001 From: Maxim Solodovnik Date: Fri, 27 Oct 2017 10:44:09 +0700 Subject: [PATCH] com.github.openjson library is used instead of outdated org.json, missing @Override are added --- pom.xml | 8 ++--- .../digilabs/jqplot/data/AreaFillData.java | 35 ++++++++++--------- .../br/com/digilabs/jqplot/data/BarData.java | 21 ++++++----- .../com/digilabs/jqplot/data/BubbleData.java | 16 +++++---- .../com/digilabs/jqplot/data/LabeledData.java | 17 +++++---- .../digilabs/jqplot/data/LineSeriesData.java | 23 ++++++------ .../com/digilabs/jqplot/data/LinedData.java | 30 +++++++++------- .../com/digilabs/jqplot/data/MeterData.java | 10 +++--- .../br/com/digilabs/jqplot/data/PieData.java | 18 ++++++---- .../digilabs/jqplot/data/PieDonutData.java | 16 +++++---- .../digilabs/jqplot/test/BarChartTest.java | 7 ++-- 11 files changed, 114 insertions(+), 87 deletions(-) diff --git a/pom.xml b/pom.xml index ac992e2..ee99709 100644 --- a/pom.xml +++ b/pom.xml @@ -57,11 +57,11 @@ junit 4.10 test - + - com.tdunning - json - 1.6 + com.github.openjson + openjson + 1.0.8 diff --git a/src/main/java/br/com/digilabs/jqplot/data/AreaFillData.java b/src/main/java/br/com/digilabs/jqplot/data/AreaFillData.java index 32a340d..1623c96 100644 --- a/src/main/java/br/com/digilabs/jqplot/data/AreaFillData.java +++ b/src/main/java/br/com/digilabs/jqplot/data/AreaFillData.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Inaiat H. Moraes. - * + * * 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 applicable 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. @@ -20,14 +20,14 @@ import java.util.Collection; import java.util.List; -import org.json.JSONArray; +import com.github.openjson.JSONArray; /** * Data Helper to build Area Charts. - * + * * @param * Type of number. Ex.: Double, Integer, Float, etc. - * + * * @author inaiat */ public class AreaFillData extends @@ -47,24 +47,25 @@ public AreaFillData() { /** * Instantiates a new area fill data. - * + * * @param values * the values */ public AreaFillData(List... values) { - for (int i = 0; i < values.length; i++) { - List list = values[i]; - addValue(list); - } + for (int i = 0; i < values.length; i++) { + List list = values[i]; + addValue(list); + } } /* * (non-Javadoc) - * + * * @see br.com.digilabs.jqplot.data.ChartData#getData() */ + @Override public Collection> getData() { - return data; + return data; } /** @@ -72,6 +73,7 @@ public Collection> getData() { * * @return the data */ + @Override public int size() { return data.size(); @@ -79,11 +81,12 @@ public int size() /* * (non-Javadoc) - * + * * @see br.com.digilabs.jqplot.data.ChartData#toJsonString() */ + @Override public String toJsonString() { - JSONArray jsonArray = new JSONArray(data); - return jsonArray.toString(); + JSONArray jsonArray = new JSONArray(data); + return jsonArray.toString(); } } diff --git a/src/main/java/br/com/digilabs/jqplot/data/BarData.java b/src/main/java/br/com/digilabs/jqplot/data/BarData.java index 76cbd0a..9434cf2 100644 --- a/src/main/java/br/com/digilabs/jqplot/data/BarData.java +++ b/src/main/java/br/com/digilabs/jqplot/data/BarData.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Inaiat H. Moraes. - * + * * 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 applicable 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. @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.Collection; -import org.json.JSONArray; +import com.github.openjson.JSONArray; /** @@ -29,7 +29,7 @@ * @author inaiat */ public class BarData extends AbstractCollectionData> { - + /** The Constant serialVersionUID. */ private static final long serialVersionUID = -2087356275172825289L; @@ -41,7 +41,7 @@ public class BarData extends AbstractCollectionData... values) { addValues(values); - } + } /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.ChartData#getData() */ + @Override public Collection> getData() { return data; } @@ -63,6 +64,7 @@ public Collection> getData() { * * @return the data */ + @Override public int size() { int ret = 0; @@ -78,10 +80,11 @@ public int size() /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.ChartData#toJsonString() */ + @Override public String toJsonString() { JSONArray jsonArray = new JSONArray(data); return jsonArray.toString(); - } + } + - } diff --git a/src/main/java/br/com/digilabs/jqplot/data/BubbleData.java b/src/main/java/br/com/digilabs/jqplot/data/BubbleData.java index 498742c..84ede11 100644 --- a/src/main/java/br/com/digilabs/jqplot/data/BubbleData.java +++ b/src/main/java/br/com/digilabs/jqplot/data/BubbleData.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Inaiat H. Moraes. - * + * * 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 applicable 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. @@ -16,11 +16,12 @@ */ package br.com.digilabs.jqplot.data; -import br.com.digilabs.jqplot.data.item.BubbleItem; - import java.util.ArrayList; import java.util.Collection; -import org.json.JSONArray; + +import com.github.openjson.JSONArray; + +import br.com.digilabs.jqplot.data.item.BubbleItem; /** * Data Helper to build Bubble Charts. @@ -39,6 +40,7 @@ public class BubbleData extends AbstractCollectionData /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.ChartData#getData() */ + @Override public Collection getData() { return data; } @@ -48,6 +50,7 @@ public Collection getData() { * * @return the data */ + @Override public int size() { return data.size(); @@ -56,6 +59,7 @@ public int size() /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.ChartData#toJsonString() */ + @Override public String toJsonString() { JSONArray outerArray = new JSONArray(); JSONArray jsonArray = new JSONArray(); diff --git a/src/main/java/br/com/digilabs/jqplot/data/LabeledData.java b/src/main/java/br/com/digilabs/jqplot/data/LabeledData.java index d58df56..88a4d59 100644 --- a/src/main/java/br/com/digilabs/jqplot/data/LabeledData.java +++ b/src/main/java/br/com/digilabs/jqplot/data/LabeledData.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Inaiat H. Moraes. - * + * * 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 applicable 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. @@ -16,13 +16,13 @@ */ package br.com.digilabs.jqplot.data; -import br.com.digilabs.jqplot.data.item.LabeledItem; - import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.json.JSONArray; +import com.github.openjson.JSONArray; + +import br.com.digilabs.jqplot.data.item.LabeledItem; /** * Data Helper to build Labeled Charts. @@ -56,8 +56,9 @@ public LabeledData(LabeledItem... values) { /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.ChartData#toJsonString() */ + @Override public String toJsonString() { - JSONArray jsonArray = new JSONArray(); + JSONArray jsonArray = new JSONArray(); for (LabeledItem labeledItem : data) { JSONArray itemArray = new JSONArray(); itemArray.put(labeledItem.getLabel()); @@ -72,6 +73,7 @@ public String toJsonString() { /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.ChartData#getData() */ + @Override public Collection> getData() { return data; } @@ -81,6 +83,7 @@ public Collection> getData() { * * @return the data */ + @Override public int size() { return data.size(); diff --git a/src/main/java/br/com/digilabs/jqplot/data/LineSeriesData.java b/src/main/java/br/com/digilabs/jqplot/data/LineSeriesData.java index 9fefdb3..ae8e04f 100644 --- a/src/main/java/br/com/digilabs/jqplot/data/LineSeriesData.java +++ b/src/main/java/br/com/digilabs/jqplot/data/LineSeriesData.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Inaiat H. Moraes. - * + * * 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 applicable 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. @@ -20,7 +20,7 @@ import java.util.Collection; import java.util.List; -import org.json.JSONArray; +import com.github.openjson.JSONArray; import br.com.digilabs.jqplot.data.item.LineSeriesItem; @@ -34,22 +34,24 @@ public class LineSeriesData extends AbstractC /** The Constant serialVersionUID. */ private static final long serialVersionUID = -8490476851004459871L; - + /** The data. */ private List>> data = new ArrayList>>(); /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.ChartData#getData() */ + @Override public Collection>> getData() { return data; - } + } /** * Gets the size of the data. * * @return the data */ + @Override public int size() { int ret = 0; @@ -64,8 +66,9 @@ public int size() /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.ChartData#toJsonString() */ - public String toJsonString() { - JSONArray jsonArray = new JSONArray(); + @Override + public String toJsonString() { + JSONArray jsonArray = new JSONArray(); for (Collection> col : data) { JSONArray serie = new JSONArray(); for (LineSeriesItem lineSeriesItem : col) { @@ -75,9 +78,9 @@ public String toJsonString() { serie.put(itemArray); } jsonArray.put(serie); - + } return jsonArray.toString(); } - + } diff --git a/src/main/java/br/com/digilabs/jqplot/data/LinedData.java b/src/main/java/br/com/digilabs/jqplot/data/LinedData.java index c4f82fa..3f2d1f2 100644 --- a/src/main/java/br/com/digilabs/jqplot/data/LinedData.java +++ b/src/main/java/br/com/digilabs/jqplot/data/LinedData.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Inaiat H. Moraes. - * + * * 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 applicable 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. @@ -19,11 +19,12 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.json.JSONArray; + +import com.github.openjson.JSONArray; /** * Data Helper to build Line Charts. - * + * * @param * Type of number. Ex.: Double, Integer, Float, etc. * @author inaiat @@ -44,21 +45,22 @@ public LinedData() { /** * Instantiates a new lined data. - * + * * @param values * the values */ public LinedData(T... values) { - addValues(values); + addValues(values); } /* * (non-Javadoc) - * + * * @see br.com.digilabs.jqplot.data.ChartData#getData() */ + @Override public Collection getData() { - return data; + return data; } /** @@ -66,6 +68,7 @@ public Collection getData() { * * @return the data */ + @Override public int size() { return data.size(); @@ -73,13 +76,14 @@ public int size() /* * (non-Javadoc) - * + * * @see br.com.digilabs.jqplot.data.ChartData#toJsonString() */ + @Override public String toJsonString() { - JSONArray jsonArray = new JSONArray(); - jsonArray.put(data); - return jsonArray.toString(); + JSONArray jsonArray = new JSONArray(); + jsonArray.put(data); + return jsonArray.toString(); } } diff --git a/src/main/java/br/com/digilabs/jqplot/data/MeterData.java b/src/main/java/br/com/digilabs/jqplot/data/MeterData.java index eac15c6..5941158 100644 --- a/src/main/java/br/com/digilabs/jqplot/data/MeterData.java +++ b/src/main/java/br/com/digilabs/jqplot/data/MeterData.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Inaiat H. Moraes. - * + * * 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 applicable 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. @@ -16,7 +16,7 @@ */ package br.com.digilabs.jqplot.data; -import org.json.JSONArray; +import com.github.openjson.JSONArray; /** * Data Helper to build Meter Charts. @@ -43,7 +43,7 @@ public MeterData() { public MeterData(Float value) { super(value); } - + /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.NumberData#toJsonString() */ diff --git a/src/main/java/br/com/digilabs/jqplot/data/PieData.java b/src/main/java/br/com/digilabs/jqplot/data/PieData.java index d676347..4786f7f 100644 --- a/src/main/java/br/com/digilabs/jqplot/data/PieData.java +++ b/src/main/java/br/com/digilabs/jqplot/data/PieData.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Inaiat H. Moraes. - * + * * 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 applicable 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. @@ -16,11 +16,12 @@ */ package br.com.digilabs.jqplot.data; -import br.com.digilabs.jqplot.data.item.LabeledItem; - import java.util.ArrayList; import java.util.Collection; -import org.json.JSONArray; + +import com.github.openjson.JSONArray; + +import br.com.digilabs.jqplot.data.item.LabeledItem; /** * Data Helper to build Pie Charts. @@ -32,13 +33,14 @@ public class PieData extends AbstractCollectionData> data = new ArrayList>(); /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.ChartData#toJsonString() */ + @Override public String toJsonString() { JSONArray outerArray = new JSONArray(); JSONArray jsonArray = new JSONArray(); @@ -55,6 +57,7 @@ public String toJsonString() { /* (non-Javadoc) * @see br.com.digilabs.jqplot.data.ChartData#getData() */ + @Override public Collection> getData() { return data; } @@ -64,6 +67,7 @@ public Collection> getData() { * * @return the data */ + @Override public int size() { return data.size(); diff --git a/src/main/java/br/com/digilabs/jqplot/data/PieDonutData.java b/src/main/java/br/com/digilabs/jqplot/data/PieDonutData.java index fc22565..5295a76 100644 --- a/src/main/java/br/com/digilabs/jqplot/data/PieDonutData.java +++ b/src/main/java/br/com/digilabs/jqplot/data/PieDonutData.java @@ -1,12 +1,12 @@ /* * Copyright 2011 Inaiat H. Moraes. - * + * * 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 applicable 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. @@ -16,11 +16,12 @@ */ package br.com.digilabs.jqplot.data; -import br.com.digilabs.jqplot.data.item.LabeledItem; - import java.util.ArrayList; import java.util.Collection; -import org.json.JSONArray; + +import com.github.openjson.JSONArray; + +import br.com.digilabs.jqplot.data.item.LabeledItem; /** * Data Helper to build Pie Donut Charts. @@ -39,6 +40,7 @@ public class PieDonutData extends AbstractCollectionData>> getData() { return data; } @@ -71,6 +74,7 @@ public Collection>> getData() { * * @return the data */ + @Override public int size() { return data.size(); diff --git a/src/test/java/br/com/digilabs/jqplot/test/BarChartTest.java b/src/test/java/br/com/digilabs/jqplot/test/BarChartTest.java index 51c9072..7ee85cc 100644 --- a/src/test/java/br/com/digilabs/jqplot/test/BarChartTest.java +++ b/src/test/java/br/com/digilabs/jqplot/test/BarChartTest.java @@ -7,12 +7,11 @@ import java.util.Arrays; -import junit.framework.TestCase; - -import org.json.JSONException; +import com.github.openjson.JSONException; import br.com.digilabs.jqplot.JqPlotUtils; import br.com.digilabs.jqplot.chart.BarChart; +import junit.framework.TestCase; /** * @@ -34,7 +33,7 @@ protected void tearDown() throws Exception { super.tearDown(); } - public void testLabeledLine() throws JSONException, org.json.JSONException { + public void testLabeledLine() throws JSONException { BarChart chart = new BarChart(); chart.addValue(Arrays.asList(200, 600, 700, 1000)); chart.addValue(Arrays.asList(200, 600, 700, 1000));