repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
iacobcl/MARA
src/objs/stats/reports/ReportPriceStats.java
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // // Path: src/objs/stats/PriceStats.java // public class PriceStats // { // private double min; // private double max; // private ArrayList<CodeDistr> dist; // // public PriceStats() // { // min = 0; // max = 0; // dist = new ArrayList<CodeDistr>(); // } // // public double getMin() { // return min; // } // // public void setMin(double min) { // this.min = min; // } // // public double getMax() { // return max; // } // // public void setMax(double max) { // this.max = max; // } // // public ArrayList<CodeDistr> getDist() { // return dist; // } // // public void setDist(ArrayList<CodeDistr> dist) { // this.dist = dist; // } // // // // // // } // // Path: src/objs/stats/RateStats.java // public class RateStats // { // private int stars; // private ArrayList<CodeDistr> dist; // // public RateStats() // { // stars = 0; // dist = new ArrayList<CodeDistr>(); // } // // // public int getStars() { // return stars; // } // public void setStars(int stars) { // this.stars = stars; // } // public ArrayList<CodeDistr> getDist() { // return dist; // } // public void setDist(ArrayList<CodeDistr> dist) { // this.dist = dist; // } // // // // }
import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import objs.CodeDistr; import objs.stats.PriceStats; import objs.stats.RateStats;
/* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportPriceStats {
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // // Path: src/objs/stats/PriceStats.java // public class PriceStats // { // private double min; // private double max; // private ArrayList<CodeDistr> dist; // // public PriceStats() // { // min = 0; // max = 0; // dist = new ArrayList<CodeDistr>(); // } // // public double getMin() { // return min; // } // // public void setMin(double min) { // this.min = min; // } // // public double getMax() { // return max; // } // // public void setMax(double max) { // this.max = max; // } // // public ArrayList<CodeDistr> getDist() { // return dist; // } // // public void setDist(ArrayList<CodeDistr> dist) { // this.dist = dist; // } // // // // // // } // // Path: src/objs/stats/RateStats.java // public class RateStats // { // private int stars; // private ArrayList<CodeDistr> dist; // // public RateStats() // { // stars = 0; // dist = new ArrayList<CodeDistr>(); // } // // // public int getStars() { // return stars; // } // public void setStars(int stars) { // this.stars = stars; // } // public ArrayList<CodeDistr> getDist() { // return dist; // } // public void setDist(ArrayList<CodeDistr> dist) { // this.dist = dist; // } // // // // } // Path: src/objs/stats/reports/ReportPriceStats.java import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import objs.CodeDistr; import objs.stats.PriceStats; import objs.stats.RateStats; /* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportPriceStats {
public static ArrayList<PriceStats> report;
iacobcl/MARA
src/objs/stats/reports/ReportPriceStats.java
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // // Path: src/objs/stats/PriceStats.java // public class PriceStats // { // private double min; // private double max; // private ArrayList<CodeDistr> dist; // // public PriceStats() // { // min = 0; // max = 0; // dist = new ArrayList<CodeDistr>(); // } // // public double getMin() { // return min; // } // // public void setMin(double min) { // this.min = min; // } // // public double getMax() { // return max; // } // // public void setMax(double max) { // this.max = max; // } // // public ArrayList<CodeDistr> getDist() { // return dist; // } // // public void setDist(ArrayList<CodeDistr> dist) { // this.dist = dist; // } // // // // // // } // // Path: src/objs/stats/RateStats.java // public class RateStats // { // private int stars; // private ArrayList<CodeDistr> dist; // // public RateStats() // { // stars = 0; // dist = new ArrayList<CodeDistr>(); // } // // // public int getStars() { // return stars; // } // public void setStars(int stars) { // this.stars = stars; // } // public ArrayList<CodeDistr> getDist() { // return dist; // } // public void setDist(ArrayList<CodeDistr> dist) { // this.dist = dist; // } // // // // }
import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import objs.CodeDistr; import objs.stats.PriceStats; import objs.stats.RateStats;
/* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportPriceStats { public static ArrayList<PriceStats> report; public ReportPriceStats() { report = new ArrayList<PriceStats>(); } public ArrayList<PriceStats> getReport() { return report; } public void setReport(ArrayList<PriceStats> report) { this.report = report; } public static void print() { try { FileWriter fstream = new FileWriter("reports/price_range_stats/reportpricestats.txt"); BufferedWriter out = new BufferedWriter(fstream); for (int i = 0; i < report.size(); i++) { out.write("[" + report.get(i).getMin() + ", " + report.get(i).getMax() + "]: "); out.newLine();
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // // Path: src/objs/stats/PriceStats.java // public class PriceStats // { // private double min; // private double max; // private ArrayList<CodeDistr> dist; // // public PriceStats() // { // min = 0; // max = 0; // dist = new ArrayList<CodeDistr>(); // } // // public double getMin() { // return min; // } // // public void setMin(double min) { // this.min = min; // } // // public double getMax() { // return max; // } // // public void setMax(double max) { // this.max = max; // } // // public ArrayList<CodeDistr> getDist() { // return dist; // } // // public void setDist(ArrayList<CodeDistr> dist) { // this.dist = dist; // } // // // // // // } // // Path: src/objs/stats/RateStats.java // public class RateStats // { // private int stars; // private ArrayList<CodeDistr> dist; // // public RateStats() // { // stars = 0; // dist = new ArrayList<CodeDistr>(); // } // // // public int getStars() { // return stars; // } // public void setStars(int stars) { // this.stars = stars; // } // public ArrayList<CodeDistr> getDist() { // return dist; // } // public void setDist(ArrayList<CodeDistr> dist) { // this.dist = dist; // } // // // // } // Path: src/objs/stats/reports/ReportPriceStats.java import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import objs.CodeDistr; import objs.stats.PriceStats; import objs.stats.RateStats; /* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportPriceStats { public static ArrayList<PriceStats> report; public ReportPriceStats() { report = new ArrayList<PriceStats>(); } public ArrayList<PriceStats> getReport() { return report; } public void setReport(ArrayList<PriceStats> report) { this.report = report; } public static void print() { try { FileWriter fstream = new FileWriter("reports/price_range_stats/reportpricestats.txt"); BufferedWriter out = new BufferedWriter(fstream); for (int i = 0; i < report.size(); i++) { out.write("[" + report.get(i).getMin() + ", " + report.get(i).getMax() + "]: "); out.newLine();
ArrayList<CodeDistr> codes = report.get(i).getDist();
iacobcl/MARA
src/objs/stats/PosNegCatStats.java
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // }
import objs.CodeDistr;
/* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats; public class PosNegCatStats { private String cat;
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // Path: src/objs/stats/PosNegCatStats.java import objs.CodeDistr; /* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats; public class PosNegCatStats { private String cat;
private CodeDistr pos;
iacobcl/MARA
src/objs/stats/CodesPerCatStats.java
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // }
import java.util.ArrayList; import objs.CodeDistr;
/* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats; public class CodesPerCatStats { private String cat;
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // Path: src/objs/stats/CodesPerCatStats.java import java.util.ArrayList; import objs.CodeDistr; /* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats; public class CodesPerCatStats { private String cat;
private ArrayList<CodeDistr> distr;
iacobcl/MARA
src/objs/stats/reports/ReportCodesPerCatStats.java
// Path: src/objs/stats/CodesPerCatStats.java // public class CodesPerCatStats // { // private String cat; // private ArrayList<CodeDistr> distr; // // // public CodesPerCatStats() // { // cat = new String(); // distr = new ArrayList<CodeDistr>(); // } // // public String getCat() { // return cat; // } // public void setCat(String cat) { // this.cat = cat; // } // public ArrayList<CodeDistr> getDistr() { // return distr; // } // public void setDistr(ArrayList<CodeDistr> distr) { // this.distr = distr; // } // // // // }
import java.util.ArrayList; import objs.stats.CodesPerCatStats;
/* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportCodesPerCatStats {
// Path: src/objs/stats/CodesPerCatStats.java // public class CodesPerCatStats // { // private String cat; // private ArrayList<CodeDistr> distr; // // // public CodesPerCatStats() // { // cat = new String(); // distr = new ArrayList<CodeDistr>(); // } // // public String getCat() { // return cat; // } // public void setCat(String cat) { // this.cat = cat; // } // public ArrayList<CodeDistr> getDistr() { // return distr; // } // public void setDistr(ArrayList<CodeDistr> distr) { // this.distr = distr; // } // // // // } // Path: src/objs/stats/reports/ReportCodesPerCatStats.java import java.util.ArrayList; import objs.stats.CodesPerCatStats; /* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportCodesPerCatStats {
public ArrayList<CodesPerCatStats> report;
iacobcl/MARA
src/objs/stats/reports/ReportDeviceStats.java
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // // Path: src/objs/Device.java // public class Device // { // private String device; // private int count; // private double perc; // // public Device(String device, int count, double perc) { // super(); // this.device = device; // this.count = count; // this.perc = perc; // } // public String getDevice() { // return device; // } // public void setDevice(String device) { // this.device = device; // } // public int getCount() { // return count; // } // public void setCount(int count) { // this.count = count; // } // // public Device() // { // device = new String(); // count = 0; // perc = 0; // } // public double getPerc() { // return perc; // } // public void setPerc(double perc) { // this.perc = perc; // } // // } // // Path: src/objs/stats/DeviceStats.java // public class DeviceStats // { // private String device; // private ArrayList<CodeDistr> dist; // // public String getDevice() // { // return device; // } // // public void setDevice(String device) // { // this.device = device; // } // // public ArrayList<CodeDistr> getDist() // { // return dist; // } // // public void setDist(ArrayList<CodeDistr> dist) // { // this.dist = dist; // } // // public DeviceStats(String device, ArrayList<CodeDistr> dist) // { // this.device = device; // this.dist = dist; // } // // public DeviceStats() // { // device = new String(); // dist = new ArrayList<CodeDistr>(); // } // // // // // }
import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import objs.CodeDistr; import objs.Device; import objs.stats.DeviceStats;
/* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportDeviceStats {
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // // Path: src/objs/Device.java // public class Device // { // private String device; // private int count; // private double perc; // // public Device(String device, int count, double perc) { // super(); // this.device = device; // this.count = count; // this.perc = perc; // } // public String getDevice() { // return device; // } // public void setDevice(String device) { // this.device = device; // } // public int getCount() { // return count; // } // public void setCount(int count) { // this.count = count; // } // // public Device() // { // device = new String(); // count = 0; // perc = 0; // } // public double getPerc() { // return perc; // } // public void setPerc(double perc) { // this.perc = perc; // } // // } // // Path: src/objs/stats/DeviceStats.java // public class DeviceStats // { // private String device; // private ArrayList<CodeDistr> dist; // // public String getDevice() // { // return device; // } // // public void setDevice(String device) // { // this.device = device; // } // // public ArrayList<CodeDistr> getDist() // { // return dist; // } // // public void setDist(ArrayList<CodeDistr> dist) // { // this.dist = dist; // } // // public DeviceStats(String device, ArrayList<CodeDistr> dist) // { // this.device = device; // this.dist = dist; // } // // public DeviceStats() // { // device = new String(); // dist = new ArrayList<CodeDistr>(); // } // // // // // } // Path: src/objs/stats/reports/ReportDeviceStats.java import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import objs.CodeDistr; import objs.Device; import objs.stats.DeviceStats; /* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportDeviceStats {
public static ArrayList<DeviceStats> report;
iacobcl/MARA
src/objs/stats/reports/ReportDeviceStats.java
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // // Path: src/objs/Device.java // public class Device // { // private String device; // private int count; // private double perc; // // public Device(String device, int count, double perc) { // super(); // this.device = device; // this.count = count; // this.perc = perc; // } // public String getDevice() { // return device; // } // public void setDevice(String device) { // this.device = device; // } // public int getCount() { // return count; // } // public void setCount(int count) { // this.count = count; // } // // public Device() // { // device = new String(); // count = 0; // perc = 0; // } // public double getPerc() { // return perc; // } // public void setPerc(double perc) { // this.perc = perc; // } // // } // // Path: src/objs/stats/DeviceStats.java // public class DeviceStats // { // private String device; // private ArrayList<CodeDistr> dist; // // public String getDevice() // { // return device; // } // // public void setDevice(String device) // { // this.device = device; // } // // public ArrayList<CodeDistr> getDist() // { // return dist; // } // // public void setDist(ArrayList<CodeDistr> dist) // { // this.dist = dist; // } // // public DeviceStats(String device, ArrayList<CodeDistr> dist) // { // this.device = device; // this.dist = dist; // } // // public DeviceStats() // { // device = new String(); // dist = new ArrayList<CodeDistr>(); // } // // // // // }
import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import objs.CodeDistr; import objs.Device; import objs.stats.DeviceStats;
/* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportDeviceStats { public static ArrayList<DeviceStats> report; public ReportDeviceStats() { report = new ArrayList<DeviceStats>(); } public ArrayList<DeviceStats> getReport() { return report; } public void setReport(ArrayList<DeviceStats> report) { this.report = report; } public static void printCode(String code) { try { FileWriter fstream = new FileWriter("reports/device_stats/reportdevicestatspercode.txt"); BufferedWriter out = new BufferedWriter(fstream); for (DeviceStats ds : report) { out.write(ds.getDevice() + " ");
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // // Path: src/objs/Device.java // public class Device // { // private String device; // private int count; // private double perc; // // public Device(String device, int count, double perc) { // super(); // this.device = device; // this.count = count; // this.perc = perc; // } // public String getDevice() { // return device; // } // public void setDevice(String device) { // this.device = device; // } // public int getCount() { // return count; // } // public void setCount(int count) { // this.count = count; // } // // public Device() // { // device = new String(); // count = 0; // perc = 0; // } // public double getPerc() { // return perc; // } // public void setPerc(double perc) { // this.perc = perc; // } // // } // // Path: src/objs/stats/DeviceStats.java // public class DeviceStats // { // private String device; // private ArrayList<CodeDistr> dist; // // public String getDevice() // { // return device; // } // // public void setDevice(String device) // { // this.device = device; // } // // public ArrayList<CodeDistr> getDist() // { // return dist; // } // // public void setDist(ArrayList<CodeDistr> dist) // { // this.dist = dist; // } // // public DeviceStats(String device, ArrayList<CodeDistr> dist) // { // this.device = device; // this.dist = dist; // } // // public DeviceStats() // { // device = new String(); // dist = new ArrayList<CodeDistr>(); // } // // // // // } // Path: src/objs/stats/reports/ReportDeviceStats.java import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import objs.CodeDistr; import objs.Device; import objs.stats.DeviceStats; /* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportDeviceStats { public static ArrayList<DeviceStats> report; public ReportDeviceStats() { report = new ArrayList<DeviceStats>(); } public ArrayList<DeviceStats> getReport() { return report; } public void setReport(ArrayList<DeviceStats> report) { this.report = report; } public static void printCode(String code) { try { FileWriter fstream = new FileWriter("reports/device_stats/reportdevicestatspercode.txt"); BufferedWriter out = new BufferedWriter(fstream); for (DeviceStats ds : report) { out.write(ds.getDevice() + " ");
ArrayList<CodeDistr> codes = ds.getDist();
iacobcl/MARA
src/objs/stats/ReqDistrPriceRangeStats.java
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // }
import objs.CodeDistr;
/* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats; public class ReqDistrPriceRangeStats { private float min; private float max;
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // Path: src/objs/stats/ReqDistrPriceRangeStats.java import objs.CodeDistr; /* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats; public class ReqDistrPriceRangeStats { private float min; private float max;
private CodeDistr req;
iacobcl/MARA
src/objs/stats/RefCodeStats.java
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // }
import java.util.ArrayList; import objs.CodeDistr;
/* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats; public class RefCodeStats { private String classCode;
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // Path: src/objs/stats/RefCodeStats.java import java.util.ArrayList; import objs.CodeDistr; /* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats; public class RefCodeStats { private String classCode;
private ArrayList<CodeDistr> dist;
iacobcl/MARA
src/objs/stats/reports/ReportSeqDistr.java
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // // Path: src/objs/SeqDistr.java // public class SeqDistr // { // private String codeA1; //class code for code 1 // private String codeA2; //refined code for code 1 // private String codeB1; //class code for code 2 // private String codeB2; //refined code for code 2 // private int total; // private double perc; // // public SeqDistr() // { // codeA1 = new String(); // codeB1 = new String(); // codeA2 = new String(); // codeB2 = new String(); // total = 0; // perc = 0; // } // // public SeqDistr(String codeA1, String codeA2, String codeB1, String codeB2, int total, double perc) // { // super(); // this.codeA1 = codeA1; // this.codeB1 = codeB1; // this.codeA2 = codeA2; // this.codeB2 = codeB2; // this.total = total; // this.perc = perc; // } // // public String getCodeA2() { // return codeA2; // } // // public void setCodeA2(String codeA2) { // this.codeA2 = codeA2; // } // // public String getCodeB2() { // return codeB2; // } // // public void setCodeB2(String codeB2) { // this.codeB2 = codeB2; // } // // public String getCodeA1() // { // return codeA1; // } // // public void setCodeA(String codeA1) // { // this.codeA1 = codeA1; // } // // public String getCodeB1() // { // return codeB1; // } // // public void setCodeB(String codeB1) // { // this.codeB1 = codeB1; // } // // public int getTotal() // { // return total; // } // // public void setTotal(int total) // { // this.total = total; // } // // public double getPerc() // { // return perc; // } // // public void setPerc(double perc) // { // this.perc = perc; // } // // // // }
import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import objs.CodeDistr; import objs.SeqDistr;
/* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportSeqDistr {
// Path: src/objs/CodeDistr.java // public class CodeDistr // { // // private String code; // private int total; // private double perc; // private int totalrel; // private double percrel; // // public CodeDistr() // { // code = new String(); // total = 0; // perc = 0; // totalrel = 0; // percrel = 0; // } // // public CodeDistr(String c, int t, double p, int totalr, double perrel) // { // code = c; // total = t; // perc = p; // totalrel = totalr; // percrel = perrel; // } // // // public String getCode() { // return code; // } // // // public void setCode(String code) { // this.code = code; // } // // // public int getTotal() { // return total; // } // // // public void setTotal(int total) { // this.total = total; // } // // // public double getPerc() { // return perc; // } // // // public void setPerc(double perc) { // this.perc = perc; // } // // public int getTotalrel() { // return totalrel; // } // // public void setTotalrel(int totalrel) { // this.totalrel = totalrel; // } // // public double getPercrel() { // return percrel; // } // // public void setPercrel(double percrel) { // this.percrel = percrel; // } // // // } // // Path: src/objs/SeqDistr.java // public class SeqDistr // { // private String codeA1; //class code for code 1 // private String codeA2; //refined code for code 1 // private String codeB1; //class code for code 2 // private String codeB2; //refined code for code 2 // private int total; // private double perc; // // public SeqDistr() // { // codeA1 = new String(); // codeB1 = new String(); // codeA2 = new String(); // codeB2 = new String(); // total = 0; // perc = 0; // } // // public SeqDistr(String codeA1, String codeA2, String codeB1, String codeB2, int total, double perc) // { // super(); // this.codeA1 = codeA1; // this.codeB1 = codeB1; // this.codeA2 = codeA2; // this.codeB2 = codeB2; // this.total = total; // this.perc = perc; // } // // public String getCodeA2() { // return codeA2; // } // // public void setCodeA2(String codeA2) { // this.codeA2 = codeA2; // } // // public String getCodeB2() { // return codeB2; // } // // public void setCodeB2(String codeB2) { // this.codeB2 = codeB2; // } // // public String getCodeA1() // { // return codeA1; // } // // public void setCodeA(String codeA1) // { // this.codeA1 = codeA1; // } // // public String getCodeB1() // { // return codeB1; // } // // public void setCodeB(String codeB1) // { // this.codeB1 = codeB1; // } // // public int getTotal() // { // return total; // } // // public void setTotal(int total) // { // this.total = total; // } // // public double getPerc() // { // return perc; // } // // public void setPerc(double perc) // { // this.perc = perc; // } // // // // } // Path: src/objs/stats/reports/ReportSeqDistr.java import java.io.BufferedWriter; import java.io.FileWriter; import java.util.ArrayList; import objs.CodeDistr; import objs.SeqDistr; /* # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you 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. See the License for the # specific language governing permissions and limitations # under the License. */ package objs.stats.reports; public class ReportSeqDistr {
public static ArrayList<SeqDistr> distr;
VEINHORN/ScrollGalleryView
library/src/main/java/com/veinhorn/scrollgalleryview/builder/BasicMediaHelper.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/DefaultVideoLoader.java // public class DefaultVideoLoader implements MediaLoader { // // private String url; // private int mId; // private Bitmap mBitmap; // // // public DefaultVideoLoader(String url, int mId) { // this.url = url; // this.mId = mId; // } // // @Override // public boolean isImage() { // return false; // } // // @Override // public void loadMedia(final Context context, ImageView imageView, SuccessCallback callback) { // loadBitmap(context); // imageView.setImageBitmap(mBitmap); // imageView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // displayVideo(context, url); // } // }); // } // // @Override // public void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback) { // loadBitmap(context); // thumbnailView.setImageBitmap(mBitmap); // callback.onSuccess(); // } // // private void displayVideo(Context context, String url) { // Intent intent = new Intent(context, VideoPlayerActivity.class); // intent.putExtra(Constants.URL, url); // context.startActivity(intent); // } // // private void loadBitmap(Context context) { // if (mBitmap == null) { // mBitmap = ((BitmapDrawable) context.getResources().getDrawable(mId)).getBitmap(); // } // } // }
import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.loader.DefaultVideoLoader;
package com.veinhorn.scrollgalleryview.builder; /** * Basic implementation of MediaHelper which supports adding video */ public abstract class BasicMediaHelper implements MediaHelper { @Override
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/DefaultVideoLoader.java // public class DefaultVideoLoader implements MediaLoader { // // private String url; // private int mId; // private Bitmap mBitmap; // // // public DefaultVideoLoader(String url, int mId) { // this.url = url; // this.mId = mId; // } // // @Override // public boolean isImage() { // return false; // } // // @Override // public void loadMedia(final Context context, ImageView imageView, SuccessCallback callback) { // loadBitmap(context); // imageView.setImageBitmap(mBitmap); // imageView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // displayVideo(context, url); // } // }); // } // // @Override // public void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback) { // loadBitmap(context); // thumbnailView.setImageBitmap(mBitmap); // callback.onSuccess(); // } // // private void displayVideo(Context context, String url) { // Intent intent = new Intent(context, VideoPlayerActivity.class); // intent.putExtra(Constants.URL, url); // context.startActivity(intent); // } // // private void loadBitmap(Context context) { // if (mBitmap == null) { // mBitmap = ((BitmapDrawable) context.getResources().getDrawable(mId)).getBitmap(); // } // } // } // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/BasicMediaHelper.java import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.loader.DefaultVideoLoader; package com.veinhorn.scrollgalleryview.builder; /** * Basic implementation of MediaHelper which supports adding video */ public abstract class BasicMediaHelper implements MediaHelper { @Override
public MediaInfo video(String url, int placeholderViewId) {
VEINHORN/ScrollGalleryView
library/src/main/java/com/veinhorn/scrollgalleryview/builder/BasicMediaHelper.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/DefaultVideoLoader.java // public class DefaultVideoLoader implements MediaLoader { // // private String url; // private int mId; // private Bitmap mBitmap; // // // public DefaultVideoLoader(String url, int mId) { // this.url = url; // this.mId = mId; // } // // @Override // public boolean isImage() { // return false; // } // // @Override // public void loadMedia(final Context context, ImageView imageView, SuccessCallback callback) { // loadBitmap(context); // imageView.setImageBitmap(mBitmap); // imageView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // displayVideo(context, url); // } // }); // } // // @Override // public void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback) { // loadBitmap(context); // thumbnailView.setImageBitmap(mBitmap); // callback.onSuccess(); // } // // private void displayVideo(Context context, String url) { // Intent intent = new Intent(context, VideoPlayerActivity.class); // intent.putExtra(Constants.URL, url); // context.startActivity(intent); // } // // private void loadBitmap(Context context) { // if (mBitmap == null) { // mBitmap = ((BitmapDrawable) context.getResources().getDrawable(mId)).getBitmap(); // } // } // }
import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.loader.DefaultVideoLoader;
package com.veinhorn.scrollgalleryview.builder; /** * Basic implementation of MediaHelper which supports adding video */ public abstract class BasicMediaHelper implements MediaHelper { @Override public MediaInfo video(String url, int placeholderViewId) {
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/DefaultVideoLoader.java // public class DefaultVideoLoader implements MediaLoader { // // private String url; // private int mId; // private Bitmap mBitmap; // // // public DefaultVideoLoader(String url, int mId) { // this.url = url; // this.mId = mId; // } // // @Override // public boolean isImage() { // return false; // } // // @Override // public void loadMedia(final Context context, ImageView imageView, SuccessCallback callback) { // loadBitmap(context); // imageView.setImageBitmap(mBitmap); // imageView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // displayVideo(context, url); // } // }); // } // // @Override // public void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback) { // loadBitmap(context); // thumbnailView.setImageBitmap(mBitmap); // callback.onSuccess(); // } // // private void displayVideo(Context context, String url) { // Intent intent = new Intent(context, VideoPlayerActivity.class); // intent.putExtra(Constants.URL, url); // context.startActivity(intent); // } // // private void loadBitmap(Context context) { // if (mBitmap == null) { // mBitmap = ((BitmapDrawable) context.getResources().getDrawable(mId)).getBitmap(); // } // } // } // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/BasicMediaHelper.java import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.loader.DefaultVideoLoader; package com.veinhorn.scrollgalleryview.builder; /** * Basic implementation of MediaHelper which supports adding video */ public abstract class BasicMediaHelper implements MediaHelper { @Override public MediaInfo video(String url, int placeholderViewId) {
return MediaInfo.mediaLoader(new DefaultVideoLoader(url, placeholderViewId));
VEINHORN/ScrollGalleryView
picasso-loader/src/main/java/com/veinhorn/scrollgalleryview/loader/picasso/PicassoMediaHelper.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/BasicMediaHelper.java // public abstract class BasicMediaHelper implements MediaHelper { // @Override // public MediaInfo video(String url, int placeholderViewId) { // return MediaInfo.mediaLoader(new DefaultVideoLoader(url, placeholderViewId)); // } // }
import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.builder.BasicMediaHelper; import java.util.ArrayList; import java.util.Arrays; import java.util.List;
package com.veinhorn.scrollgalleryview.loader.picasso; public class PicassoMediaHelper extends BasicMediaHelper { @Override
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/BasicMediaHelper.java // public abstract class BasicMediaHelper implements MediaHelper { // @Override // public MediaInfo video(String url, int placeholderViewId) { // return MediaInfo.mediaLoader(new DefaultVideoLoader(url, placeholderViewId)); // } // } // Path: picasso-loader/src/main/java/com/veinhorn/scrollgalleryview/loader/picasso/PicassoMediaHelper.java import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.builder.BasicMediaHelper; import java.util.ArrayList; import java.util.Arrays; import java.util.List; package com.veinhorn.scrollgalleryview.loader.picasso; public class PicassoMediaHelper extends BasicMediaHelper { @Override
public MediaInfo image(String url) {
VEINHORN/ScrollGalleryView
library/src/main/java/com/veinhorn/scrollgalleryview/loader/DefaultVideoLoader.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/Constants.java // public final class Constants { // public static final String ZOOM = "zoom"; // public static final String IS_VIDEO = "isVideo"; // public static final String URL = "url"; // public static final String IS_LOCKED = "isLocked"; // public static final String IMAGE = "image"; // public static final String POSITION = "position"; // // private Constants() { // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/VideoPlayerActivity.java // public class VideoPlayerActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // String url = getIntent().getExtras().getString(Constants.URL); // setContentView(R.layout.video_fragment); // final VideoView videoView = (VideoView) findViewById(R.id.videoView); // videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { // @Override // public void onPrepared(MediaPlayer mp) { // View progress = findViewById(R.id.videoProgress); // progress.setVisibility(View.GONE); // // videoView.requestFocus(); // MediaController vidControl = new MediaController(VideoPlayerActivity.this); // vidControl.setAnchorView(videoView); // videoView.setMediaController(vidControl); // videoView.start(); // } // }); // videoView.setVideoURI(Uri.parse(url)); // } // }
import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.view.View; import android.widget.ImageView; import com.veinhorn.scrollgalleryview.Constants; import com.veinhorn.scrollgalleryview.VideoPlayerActivity;
public DefaultVideoLoader(String url, int mId) { this.url = url; this.mId = mId; } @Override public boolean isImage() { return false; } @Override public void loadMedia(final Context context, ImageView imageView, SuccessCallback callback) { loadBitmap(context); imageView.setImageBitmap(mBitmap); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { displayVideo(context, url); } }); } @Override public void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback) { loadBitmap(context); thumbnailView.setImageBitmap(mBitmap); callback.onSuccess(); } private void displayVideo(Context context, String url) {
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/Constants.java // public final class Constants { // public static final String ZOOM = "zoom"; // public static final String IS_VIDEO = "isVideo"; // public static final String URL = "url"; // public static final String IS_LOCKED = "isLocked"; // public static final String IMAGE = "image"; // public static final String POSITION = "position"; // // private Constants() { // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/VideoPlayerActivity.java // public class VideoPlayerActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // String url = getIntent().getExtras().getString(Constants.URL); // setContentView(R.layout.video_fragment); // final VideoView videoView = (VideoView) findViewById(R.id.videoView); // videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { // @Override // public void onPrepared(MediaPlayer mp) { // View progress = findViewById(R.id.videoProgress); // progress.setVisibility(View.GONE); // // videoView.requestFocus(); // MediaController vidControl = new MediaController(VideoPlayerActivity.this); // vidControl.setAnchorView(videoView); // videoView.setMediaController(vidControl); // videoView.start(); // } // }); // videoView.setVideoURI(Uri.parse(url)); // } // } // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/DefaultVideoLoader.java import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.view.View; import android.widget.ImageView; import com.veinhorn.scrollgalleryview.Constants; import com.veinhorn.scrollgalleryview.VideoPlayerActivity; public DefaultVideoLoader(String url, int mId) { this.url = url; this.mId = mId; } @Override public boolean isImage() { return false; } @Override public void loadMedia(final Context context, ImageView imageView, SuccessCallback callback) { loadBitmap(context); imageView.setImageBitmap(mBitmap); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { displayVideo(context, url); } }); } @Override public void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback) { loadBitmap(context); thumbnailView.setImageBitmap(mBitmap); callback.onSuccess(); } private void displayVideo(Context context, String url) {
Intent intent = new Intent(context, VideoPlayerActivity.class);
VEINHORN/ScrollGalleryView
library/src/main/java/com/veinhorn/scrollgalleryview/loader/DefaultVideoLoader.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/Constants.java // public final class Constants { // public static final String ZOOM = "zoom"; // public static final String IS_VIDEO = "isVideo"; // public static final String URL = "url"; // public static final String IS_LOCKED = "isLocked"; // public static final String IMAGE = "image"; // public static final String POSITION = "position"; // // private Constants() { // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/VideoPlayerActivity.java // public class VideoPlayerActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // String url = getIntent().getExtras().getString(Constants.URL); // setContentView(R.layout.video_fragment); // final VideoView videoView = (VideoView) findViewById(R.id.videoView); // videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { // @Override // public void onPrepared(MediaPlayer mp) { // View progress = findViewById(R.id.videoProgress); // progress.setVisibility(View.GONE); // // videoView.requestFocus(); // MediaController vidControl = new MediaController(VideoPlayerActivity.this); // vidControl.setAnchorView(videoView); // videoView.setMediaController(vidControl); // videoView.start(); // } // }); // videoView.setVideoURI(Uri.parse(url)); // } // }
import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.view.View; import android.widget.ImageView; import com.veinhorn.scrollgalleryview.Constants; import com.veinhorn.scrollgalleryview.VideoPlayerActivity;
this.url = url; this.mId = mId; } @Override public boolean isImage() { return false; } @Override public void loadMedia(final Context context, ImageView imageView, SuccessCallback callback) { loadBitmap(context); imageView.setImageBitmap(mBitmap); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { displayVideo(context, url); } }); } @Override public void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback) { loadBitmap(context); thumbnailView.setImageBitmap(mBitmap); callback.onSuccess(); } private void displayVideo(Context context, String url) { Intent intent = new Intent(context, VideoPlayerActivity.class);
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/Constants.java // public final class Constants { // public static final String ZOOM = "zoom"; // public static final String IS_VIDEO = "isVideo"; // public static final String URL = "url"; // public static final String IS_LOCKED = "isLocked"; // public static final String IMAGE = "image"; // public static final String POSITION = "position"; // // private Constants() { // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/VideoPlayerActivity.java // public class VideoPlayerActivity extends Activity { // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // String url = getIntent().getExtras().getString(Constants.URL); // setContentView(R.layout.video_fragment); // final VideoView videoView = (VideoView) findViewById(R.id.videoView); // videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { // @Override // public void onPrepared(MediaPlayer mp) { // View progress = findViewById(R.id.videoProgress); // progress.setVisibility(View.GONE); // // videoView.requestFocus(); // MediaController vidControl = new MediaController(VideoPlayerActivity.this); // vidControl.setAnchorView(videoView); // videoView.setMediaController(vidControl); // videoView.start(); // } // }); // videoView.setVideoURI(Uri.parse(url)); // } // } // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/DefaultVideoLoader.java import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.view.View; import android.widget.ImageView; import com.veinhorn.scrollgalleryview.Constants; import com.veinhorn.scrollgalleryview.VideoPlayerActivity; this.url = url; this.mId = mId; } @Override public boolean isImage() { return false; } @Override public void loadMedia(final Context context, ImageView imageView, SuccessCallback callback) { loadBitmap(context); imageView.setImageBitmap(mBitmap); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { displayVideo(context, url); } }); } @Override public void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback) { loadBitmap(context); thumbnailView.setImageBitmap(mBitmap); callback.onSuccess(); } private void displayVideo(Context context, String url) { Intent intent = new Intent(context, VideoPlayerActivity.class);
intent.putExtra(Constants.URL, url);
VEINHORN/ScrollGalleryView
library/src/main/java/com/veinhorn/scrollgalleryview/ImageFragment.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/MediaLoader.java // public interface MediaLoader { // // /** // * @return true if implementation load's image, otherwise false // */ // boolean isImage(); // // /** // * Loads image and sets it to imageView. After that implementation can call callback to set imageView's // * scale type to ScaleType.FIT_CENTER. // */ // void loadMedia(Context context, ImageView imageView, SuccessCallback callback); // // /** // * Loads thumbnail image and sets it to thumbnailView. After that implementation can call callback // * to set thumbnailView's scale type to ScaleType.FIT_CENTER. // */ // // void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback); // // /** // * Implementation may call this callback for report to imageView, what it's image was changed // */ // interface SuccessCallback { // void onSuccess(); // } // }
import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.github.chrisbanes.photoview.PhotoView; import com.veinhorn.scrollgalleryview.loader.MediaLoader;
}); } if (onImageLongClickListener != null) { photoView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { onImageLongClickListener.onClick(getPosition()); return true; } }); } viewPager = (HackyViewPager) getActivity().findViewById(R.id.viewPager); if (savedInstanceState != null) { boolean isLocked = savedInstanceState.getBoolean(Constants.IS_LOCKED, false); viewPager.setLocked(isLocked); } loadImageToView(); return rootView; } private int getPosition() { return getArguments().getInt(Constants.POSITION); } private void loadImageToView() { if (mMediaInfo != null) {
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/MediaLoader.java // public interface MediaLoader { // // /** // * @return true if implementation load's image, otherwise false // */ // boolean isImage(); // // /** // * Loads image and sets it to imageView. After that implementation can call callback to set imageView's // * scale type to ScaleType.FIT_CENTER. // */ // void loadMedia(Context context, ImageView imageView, SuccessCallback callback); // // /** // * Loads thumbnail image and sets it to thumbnailView. After that implementation can call callback // * to set thumbnailView's scale type to ScaleType.FIT_CENTER. // */ // // void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback); // // /** // * Implementation may call this callback for report to imageView, what it's image was changed // */ // interface SuccessCallback { // void onSuccess(); // } // } // Path: library/src/main/java/com/veinhorn/scrollgalleryview/ImageFragment.java import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.github.chrisbanes.photoview.PhotoView; import com.veinhorn.scrollgalleryview.loader.MediaLoader; }); } if (onImageLongClickListener != null) { photoView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { onImageLongClickListener.onClick(getPosition()); return true; } }); } viewPager = (HackyViewPager) getActivity().findViewById(R.id.viewPager); if (savedInstanceState != null) { boolean isLocked = savedInstanceState.getBoolean(Constants.IS_LOCKED, false); viewPager.setLocked(isLocked); } loadImageToView(); return rootView; } private int getPosition() { return getArguments().getInt(Constants.POSITION); } private void loadImageToView() { if (mMediaInfo != null) {
mMediaInfo.getLoader().loadMedia(getActivity(), photoView, new MediaLoader.SuccessCallback() {
VEINHORN/ScrollGalleryView
library/src/main/java/com/veinhorn/scrollgalleryview/ScrollGalleryView.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilder.java // public interface GalleryBuilder { // /** // * Sets up settings for gallery // * @param settings contains options for gallery // * @return GalleryBuilder object // */ // GalleryBuilder settings(GallerySettings settings); // // GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener listener); // // GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener listener); // // GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener); // // /** // * Adds single MediaInfo to gallery // * @param media is a single MediaInfo object // * @return GalleryBuilder object // */ // GalleryBuilder add(MediaInfo media); // // /** // * Adds a list of MediaInfos to gallery // * @param medias is a list of MediaInfo objects // * @return GalleryBuilder object // */ // GalleryBuilder add(List<MediaInfo> medias); // // /** // * Builds gallery from provided medias // * @return initialized ScrollGalleryView // */ // ScrollGalleryView build(); // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilderImpl.java // public class GalleryBuilderImpl implements GalleryBuilder { // private ScrollGalleryView galleryView; // private GallerySettings settings; // // private ScrollGalleryView.OnImageClickListener onImageClickListener; // private ScrollGalleryView.OnImageLongClickListener onImageLongClickListener; // private ViewPager.OnPageChangeListener onPageChangeListener; // // private List<MediaInfo> medias; // // public GalleryBuilderImpl(ScrollGalleryView galleryView) { // this.galleryView = galleryView; // this.medias = new ArrayList<>(); // } // // @Override // public GalleryBuilder settings(GallerySettings settings) { // this.settings = settings; // return this; // } // // @Override // public GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener onImageClickListener) { // this.onImageClickListener = onImageClickListener; // return this; // } // // @Override // public GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener onImageLongClickListener) { // this.onImageLongClickListener = onImageLongClickListener; // return this; // } // // @Override // public GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { // this.onPageChangeListener = onPageChangeListener; // return this; // } // // @Override // public GalleryBuilder add(MediaInfo media) { // this.medias.add(media); // return this; // } // // @Override // public GalleryBuilder add(List<MediaInfo> medias) { // this.medias.addAll(medias); // return this; // } // // @Override // public ScrollGalleryView build() { // // check here all parameters // // return galleryView // .setThumbnailSize(settings.getThumbnailSize()) // .setZoom(settings.isZoomEnabled()) // .addOnImageClickListener(onImageClickListener) // .addOnImageLongClickListener(onImageLongClickListener) // .setFragmentManager(settings.getFragmentManager()) // .addOnPageChangeListener(onPageChangeListener) // .addMedia(medias); // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/MediaLoader.java // public interface MediaLoader { // // /** // * @return true if implementation load's image, otherwise false // */ // boolean isImage(); // // /** // * Loads image and sets it to imageView. After that implementation can call callback to set imageView's // * scale type to ScaleType.FIT_CENTER. // */ // void loadMedia(Context context, ImageView imageView, SuccessCallback callback); // // /** // * Loads thumbnail image and sets it to thumbnailView. After that implementation can call callback // * to set thumbnailView's scale type to ScaleType.FIT_CENTER. // */ // // void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback); // // /** // * Implementation may call this callback for report to imageView, what it's image was changed // */ // interface SuccessCallback { // void onSuccess(); // } // }
import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.media.ThumbnailUtils; import android.os.Build; import android.support.transition.Transition; import android.support.transition.TransitionManager; import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.HorizontalScrollView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.veinhorn.scrollgalleryview.builder.GalleryBuilder; import com.veinhorn.scrollgalleryview.builder.GalleryBuilderImpl; import com.veinhorn.scrollgalleryview.loader.MediaLoader; import java.util.ArrayList; import java.util.Collections; import java.util.List;
@Override public void onPageSelected(int position) { scroll(thumbnailsContainer.getChildAt(position)); listener.onPageSelected(position); } @Override public void onPageScrollStateChanged(int state) { listener.onPageScrollStateChanged(state); } }); return this; } public ScrollGalleryView addMedia(MediaInfo mediaInfo) { if (mediaInfo == null) { throw new NullPointerException("Infos may not be null!"); } return addMedia(Collections.singletonList(mediaInfo)); } public ScrollGalleryView addMedia(List<MediaInfo> infos) { if (infos == null) { throw new NullPointerException("Infos may not be null!"); } for (MediaInfo info : infos) { mListOfMedia.add(info); final ImageView thumbnail = addThumbnail(getDefaultThumbnail());
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilder.java // public interface GalleryBuilder { // /** // * Sets up settings for gallery // * @param settings contains options for gallery // * @return GalleryBuilder object // */ // GalleryBuilder settings(GallerySettings settings); // // GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener listener); // // GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener listener); // // GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener); // // /** // * Adds single MediaInfo to gallery // * @param media is a single MediaInfo object // * @return GalleryBuilder object // */ // GalleryBuilder add(MediaInfo media); // // /** // * Adds a list of MediaInfos to gallery // * @param medias is a list of MediaInfo objects // * @return GalleryBuilder object // */ // GalleryBuilder add(List<MediaInfo> medias); // // /** // * Builds gallery from provided medias // * @return initialized ScrollGalleryView // */ // ScrollGalleryView build(); // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilderImpl.java // public class GalleryBuilderImpl implements GalleryBuilder { // private ScrollGalleryView galleryView; // private GallerySettings settings; // // private ScrollGalleryView.OnImageClickListener onImageClickListener; // private ScrollGalleryView.OnImageLongClickListener onImageLongClickListener; // private ViewPager.OnPageChangeListener onPageChangeListener; // // private List<MediaInfo> medias; // // public GalleryBuilderImpl(ScrollGalleryView galleryView) { // this.galleryView = galleryView; // this.medias = new ArrayList<>(); // } // // @Override // public GalleryBuilder settings(GallerySettings settings) { // this.settings = settings; // return this; // } // // @Override // public GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener onImageClickListener) { // this.onImageClickListener = onImageClickListener; // return this; // } // // @Override // public GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener onImageLongClickListener) { // this.onImageLongClickListener = onImageLongClickListener; // return this; // } // // @Override // public GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { // this.onPageChangeListener = onPageChangeListener; // return this; // } // // @Override // public GalleryBuilder add(MediaInfo media) { // this.medias.add(media); // return this; // } // // @Override // public GalleryBuilder add(List<MediaInfo> medias) { // this.medias.addAll(medias); // return this; // } // // @Override // public ScrollGalleryView build() { // // check here all parameters // // return galleryView // .setThumbnailSize(settings.getThumbnailSize()) // .setZoom(settings.isZoomEnabled()) // .addOnImageClickListener(onImageClickListener) // .addOnImageLongClickListener(onImageLongClickListener) // .setFragmentManager(settings.getFragmentManager()) // .addOnPageChangeListener(onPageChangeListener) // .addMedia(medias); // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/MediaLoader.java // public interface MediaLoader { // // /** // * @return true if implementation load's image, otherwise false // */ // boolean isImage(); // // /** // * Loads image and sets it to imageView. After that implementation can call callback to set imageView's // * scale type to ScaleType.FIT_CENTER. // */ // void loadMedia(Context context, ImageView imageView, SuccessCallback callback); // // /** // * Loads thumbnail image and sets it to thumbnailView. After that implementation can call callback // * to set thumbnailView's scale type to ScaleType.FIT_CENTER. // */ // // void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback); // // /** // * Implementation may call this callback for report to imageView, what it's image was changed // */ // interface SuccessCallback { // void onSuccess(); // } // } // Path: library/src/main/java/com/veinhorn/scrollgalleryview/ScrollGalleryView.java import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.media.ThumbnailUtils; import android.os.Build; import android.support.transition.Transition; import android.support.transition.TransitionManager; import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.HorizontalScrollView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.veinhorn.scrollgalleryview.builder.GalleryBuilder; import com.veinhorn.scrollgalleryview.builder.GalleryBuilderImpl; import com.veinhorn.scrollgalleryview.loader.MediaLoader; import java.util.ArrayList; import java.util.Collections; import java.util.List; @Override public void onPageSelected(int position) { scroll(thumbnailsContainer.getChildAt(position)); listener.onPageSelected(position); } @Override public void onPageScrollStateChanged(int state) { listener.onPageScrollStateChanged(state); } }); return this; } public ScrollGalleryView addMedia(MediaInfo mediaInfo) { if (mediaInfo == null) { throw new NullPointerException("Infos may not be null!"); } return addMedia(Collections.singletonList(mediaInfo)); } public ScrollGalleryView addMedia(List<MediaInfo> infos) { if (infos == null) { throw new NullPointerException("Infos may not be null!"); } for (MediaInfo info : infos) { mListOfMedia.add(info); final ImageView thumbnail = addThumbnail(getDefaultThumbnail());
info.getLoader().loadThumbnail(getContext(), thumbnail, new MediaLoader.SuccessCallback() {
VEINHORN/ScrollGalleryView
library/src/main/java/com/veinhorn/scrollgalleryview/ScrollGalleryView.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilder.java // public interface GalleryBuilder { // /** // * Sets up settings for gallery // * @param settings contains options for gallery // * @return GalleryBuilder object // */ // GalleryBuilder settings(GallerySettings settings); // // GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener listener); // // GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener listener); // // GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener); // // /** // * Adds single MediaInfo to gallery // * @param media is a single MediaInfo object // * @return GalleryBuilder object // */ // GalleryBuilder add(MediaInfo media); // // /** // * Adds a list of MediaInfos to gallery // * @param medias is a list of MediaInfo objects // * @return GalleryBuilder object // */ // GalleryBuilder add(List<MediaInfo> medias); // // /** // * Builds gallery from provided medias // * @return initialized ScrollGalleryView // */ // ScrollGalleryView build(); // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilderImpl.java // public class GalleryBuilderImpl implements GalleryBuilder { // private ScrollGalleryView galleryView; // private GallerySettings settings; // // private ScrollGalleryView.OnImageClickListener onImageClickListener; // private ScrollGalleryView.OnImageLongClickListener onImageLongClickListener; // private ViewPager.OnPageChangeListener onPageChangeListener; // // private List<MediaInfo> medias; // // public GalleryBuilderImpl(ScrollGalleryView galleryView) { // this.galleryView = galleryView; // this.medias = new ArrayList<>(); // } // // @Override // public GalleryBuilder settings(GallerySettings settings) { // this.settings = settings; // return this; // } // // @Override // public GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener onImageClickListener) { // this.onImageClickListener = onImageClickListener; // return this; // } // // @Override // public GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener onImageLongClickListener) { // this.onImageLongClickListener = onImageLongClickListener; // return this; // } // // @Override // public GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { // this.onPageChangeListener = onPageChangeListener; // return this; // } // // @Override // public GalleryBuilder add(MediaInfo media) { // this.medias.add(media); // return this; // } // // @Override // public GalleryBuilder add(List<MediaInfo> medias) { // this.medias.addAll(medias); // return this; // } // // @Override // public ScrollGalleryView build() { // // check here all parameters // // return galleryView // .setThumbnailSize(settings.getThumbnailSize()) // .setZoom(settings.isZoomEnabled()) // .addOnImageClickListener(onImageClickListener) // .addOnImageLongClickListener(onImageLongClickListener) // .setFragmentManager(settings.getFragmentManager()) // .addOnPageChangeListener(onPageChangeListener) // .addMedia(medias); // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/MediaLoader.java // public interface MediaLoader { // // /** // * @return true if implementation load's image, otherwise false // */ // boolean isImage(); // // /** // * Loads image and sets it to imageView. After that implementation can call callback to set imageView's // * scale type to ScaleType.FIT_CENTER. // */ // void loadMedia(Context context, ImageView imageView, SuccessCallback callback); // // /** // * Loads thumbnail image and sets it to thumbnailView. After that implementation can call callback // * to set thumbnailView's scale type to ScaleType.FIT_CENTER. // */ // // void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback); // // /** // * Implementation may call this callback for report to imageView, what it's image was changed // */ // interface SuccessCallback { // void onSuccess(); // } // }
import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.media.ThumbnailUtils; import android.os.Build; import android.support.transition.Transition; import android.support.transition.TransitionManager; import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.HorizontalScrollView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.veinhorn.scrollgalleryview.builder.GalleryBuilder; import com.veinhorn.scrollgalleryview.builder.GalleryBuilderImpl; import com.veinhorn.scrollgalleryview.loader.MediaLoader; import java.util.ArrayList; import java.util.Collections; import java.util.List;
public void clearGallery() { // remove all media infos mListOfMedia.clear(); pagerAdapter = new ScreenSlidePagerAdapter( fragmentManager, mListOfMedia, zoomEnabled, innerOnImageClickListener, innerOnImageLongClickListener ); viewPager.setAdapter(pagerAdapter); // remove thumbnails thumbnailsContainer.removeAllViews(); } /** * Remove a media from the gallery * * @param position media's position to remove */ public void removeMedia(int position) { if (position >= mListOfMedia.size() || position < 0) { return; } pagerAdapter.removeItem(position); removeThumbnail(position); }
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilder.java // public interface GalleryBuilder { // /** // * Sets up settings for gallery // * @param settings contains options for gallery // * @return GalleryBuilder object // */ // GalleryBuilder settings(GallerySettings settings); // // GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener listener); // // GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener listener); // // GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener); // // /** // * Adds single MediaInfo to gallery // * @param media is a single MediaInfo object // * @return GalleryBuilder object // */ // GalleryBuilder add(MediaInfo media); // // /** // * Adds a list of MediaInfos to gallery // * @param medias is a list of MediaInfo objects // * @return GalleryBuilder object // */ // GalleryBuilder add(List<MediaInfo> medias); // // /** // * Builds gallery from provided medias // * @return initialized ScrollGalleryView // */ // ScrollGalleryView build(); // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilderImpl.java // public class GalleryBuilderImpl implements GalleryBuilder { // private ScrollGalleryView galleryView; // private GallerySettings settings; // // private ScrollGalleryView.OnImageClickListener onImageClickListener; // private ScrollGalleryView.OnImageLongClickListener onImageLongClickListener; // private ViewPager.OnPageChangeListener onPageChangeListener; // // private List<MediaInfo> medias; // // public GalleryBuilderImpl(ScrollGalleryView galleryView) { // this.galleryView = galleryView; // this.medias = new ArrayList<>(); // } // // @Override // public GalleryBuilder settings(GallerySettings settings) { // this.settings = settings; // return this; // } // // @Override // public GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener onImageClickListener) { // this.onImageClickListener = onImageClickListener; // return this; // } // // @Override // public GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener onImageLongClickListener) { // this.onImageLongClickListener = onImageLongClickListener; // return this; // } // // @Override // public GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { // this.onPageChangeListener = onPageChangeListener; // return this; // } // // @Override // public GalleryBuilder add(MediaInfo media) { // this.medias.add(media); // return this; // } // // @Override // public GalleryBuilder add(List<MediaInfo> medias) { // this.medias.addAll(medias); // return this; // } // // @Override // public ScrollGalleryView build() { // // check here all parameters // // return galleryView // .setThumbnailSize(settings.getThumbnailSize()) // .setZoom(settings.isZoomEnabled()) // .addOnImageClickListener(onImageClickListener) // .addOnImageLongClickListener(onImageLongClickListener) // .setFragmentManager(settings.getFragmentManager()) // .addOnPageChangeListener(onPageChangeListener) // .addMedia(medias); // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/MediaLoader.java // public interface MediaLoader { // // /** // * @return true if implementation load's image, otherwise false // */ // boolean isImage(); // // /** // * Loads image and sets it to imageView. After that implementation can call callback to set imageView's // * scale type to ScaleType.FIT_CENTER. // */ // void loadMedia(Context context, ImageView imageView, SuccessCallback callback); // // /** // * Loads thumbnail image and sets it to thumbnailView. After that implementation can call callback // * to set thumbnailView's scale type to ScaleType.FIT_CENTER. // */ // // void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback); // // /** // * Implementation may call this callback for report to imageView, what it's image was changed // */ // interface SuccessCallback { // void onSuccess(); // } // } // Path: library/src/main/java/com/veinhorn/scrollgalleryview/ScrollGalleryView.java import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.media.ThumbnailUtils; import android.os.Build; import android.support.transition.Transition; import android.support.transition.TransitionManager; import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.HorizontalScrollView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.veinhorn.scrollgalleryview.builder.GalleryBuilder; import com.veinhorn.scrollgalleryview.builder.GalleryBuilderImpl; import com.veinhorn.scrollgalleryview.loader.MediaLoader; import java.util.ArrayList; import java.util.Collections; import java.util.List; public void clearGallery() { // remove all media infos mListOfMedia.clear(); pagerAdapter = new ScreenSlidePagerAdapter( fragmentManager, mListOfMedia, zoomEnabled, innerOnImageClickListener, innerOnImageLongClickListener ); viewPager.setAdapter(pagerAdapter); // remove thumbnails thumbnailsContainer.removeAllViews(); } /** * Remove a media from the gallery * * @param position media's position to remove */ public void removeMedia(int position) { if (position >= mListOfMedia.size() || position < 0) { return; } pagerAdapter.removeItem(position); removeThumbnail(position); }
public static GalleryBuilder from(ScrollGalleryView galleryView) {
VEINHORN/ScrollGalleryView
library/src/main/java/com/veinhorn/scrollgalleryview/ScrollGalleryView.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilder.java // public interface GalleryBuilder { // /** // * Sets up settings for gallery // * @param settings contains options for gallery // * @return GalleryBuilder object // */ // GalleryBuilder settings(GallerySettings settings); // // GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener listener); // // GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener listener); // // GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener); // // /** // * Adds single MediaInfo to gallery // * @param media is a single MediaInfo object // * @return GalleryBuilder object // */ // GalleryBuilder add(MediaInfo media); // // /** // * Adds a list of MediaInfos to gallery // * @param medias is a list of MediaInfo objects // * @return GalleryBuilder object // */ // GalleryBuilder add(List<MediaInfo> medias); // // /** // * Builds gallery from provided medias // * @return initialized ScrollGalleryView // */ // ScrollGalleryView build(); // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilderImpl.java // public class GalleryBuilderImpl implements GalleryBuilder { // private ScrollGalleryView galleryView; // private GallerySettings settings; // // private ScrollGalleryView.OnImageClickListener onImageClickListener; // private ScrollGalleryView.OnImageLongClickListener onImageLongClickListener; // private ViewPager.OnPageChangeListener onPageChangeListener; // // private List<MediaInfo> medias; // // public GalleryBuilderImpl(ScrollGalleryView galleryView) { // this.galleryView = galleryView; // this.medias = new ArrayList<>(); // } // // @Override // public GalleryBuilder settings(GallerySettings settings) { // this.settings = settings; // return this; // } // // @Override // public GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener onImageClickListener) { // this.onImageClickListener = onImageClickListener; // return this; // } // // @Override // public GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener onImageLongClickListener) { // this.onImageLongClickListener = onImageLongClickListener; // return this; // } // // @Override // public GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { // this.onPageChangeListener = onPageChangeListener; // return this; // } // // @Override // public GalleryBuilder add(MediaInfo media) { // this.medias.add(media); // return this; // } // // @Override // public GalleryBuilder add(List<MediaInfo> medias) { // this.medias.addAll(medias); // return this; // } // // @Override // public ScrollGalleryView build() { // // check here all parameters // // return galleryView // .setThumbnailSize(settings.getThumbnailSize()) // .setZoom(settings.isZoomEnabled()) // .addOnImageClickListener(onImageClickListener) // .addOnImageLongClickListener(onImageLongClickListener) // .setFragmentManager(settings.getFragmentManager()) // .addOnPageChangeListener(onPageChangeListener) // .addMedia(medias); // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/MediaLoader.java // public interface MediaLoader { // // /** // * @return true if implementation load's image, otherwise false // */ // boolean isImage(); // // /** // * Loads image and sets it to imageView. After that implementation can call callback to set imageView's // * scale type to ScaleType.FIT_CENTER. // */ // void loadMedia(Context context, ImageView imageView, SuccessCallback callback); // // /** // * Loads thumbnail image and sets it to thumbnailView. After that implementation can call callback // * to set thumbnailView's scale type to ScaleType.FIT_CENTER. // */ // // void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback); // // /** // * Implementation may call this callback for report to imageView, what it's image was changed // */ // interface SuccessCallback { // void onSuccess(); // } // }
import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.media.ThumbnailUtils; import android.os.Build; import android.support.transition.Transition; import android.support.transition.TransitionManager; import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.HorizontalScrollView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.veinhorn.scrollgalleryview.builder.GalleryBuilder; import com.veinhorn.scrollgalleryview.builder.GalleryBuilderImpl; import com.veinhorn.scrollgalleryview.loader.MediaLoader; import java.util.ArrayList; import java.util.Collections; import java.util.List;
// remove all media infos mListOfMedia.clear(); pagerAdapter = new ScreenSlidePagerAdapter( fragmentManager, mListOfMedia, zoomEnabled, innerOnImageClickListener, innerOnImageLongClickListener ); viewPager.setAdapter(pagerAdapter); // remove thumbnails thumbnailsContainer.removeAllViews(); } /** * Remove a media from the gallery * * @param position media's position to remove */ public void removeMedia(int position) { if (position >= mListOfMedia.size() || position < 0) { return; } pagerAdapter.removeItem(position); removeThumbnail(position); } public static GalleryBuilder from(ScrollGalleryView galleryView) {
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilder.java // public interface GalleryBuilder { // /** // * Sets up settings for gallery // * @param settings contains options for gallery // * @return GalleryBuilder object // */ // GalleryBuilder settings(GallerySettings settings); // // GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener listener); // // GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener listener); // // GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener); // // /** // * Adds single MediaInfo to gallery // * @param media is a single MediaInfo object // * @return GalleryBuilder object // */ // GalleryBuilder add(MediaInfo media); // // /** // * Adds a list of MediaInfos to gallery // * @param medias is a list of MediaInfo objects // * @return GalleryBuilder object // */ // GalleryBuilder add(List<MediaInfo> medias); // // /** // * Builds gallery from provided medias // * @return initialized ScrollGalleryView // */ // ScrollGalleryView build(); // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/GalleryBuilderImpl.java // public class GalleryBuilderImpl implements GalleryBuilder { // private ScrollGalleryView galleryView; // private GallerySettings settings; // // private ScrollGalleryView.OnImageClickListener onImageClickListener; // private ScrollGalleryView.OnImageLongClickListener onImageLongClickListener; // private ViewPager.OnPageChangeListener onPageChangeListener; // // private List<MediaInfo> medias; // // public GalleryBuilderImpl(ScrollGalleryView galleryView) { // this.galleryView = galleryView; // this.medias = new ArrayList<>(); // } // // @Override // public GalleryBuilder settings(GallerySettings settings) { // this.settings = settings; // return this; // } // // @Override // public GalleryBuilder onImageClickListener(ScrollGalleryView.OnImageClickListener onImageClickListener) { // this.onImageClickListener = onImageClickListener; // return this; // } // // @Override // public GalleryBuilder onImageLongClickListener(ScrollGalleryView.OnImageLongClickListener onImageLongClickListener) { // this.onImageLongClickListener = onImageLongClickListener; // return this; // } // // @Override // public GalleryBuilder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { // this.onPageChangeListener = onPageChangeListener; // return this; // } // // @Override // public GalleryBuilder add(MediaInfo media) { // this.medias.add(media); // return this; // } // // @Override // public GalleryBuilder add(List<MediaInfo> medias) { // this.medias.addAll(medias); // return this; // } // // @Override // public ScrollGalleryView build() { // // check here all parameters // // return galleryView // .setThumbnailSize(settings.getThumbnailSize()) // .setZoom(settings.isZoomEnabled()) // .addOnImageClickListener(onImageClickListener) // .addOnImageLongClickListener(onImageLongClickListener) // .setFragmentManager(settings.getFragmentManager()) // .addOnPageChangeListener(onPageChangeListener) // .addMedia(medias); // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/loader/MediaLoader.java // public interface MediaLoader { // // /** // * @return true if implementation load's image, otherwise false // */ // boolean isImage(); // // /** // * Loads image and sets it to imageView. After that implementation can call callback to set imageView's // * scale type to ScaleType.FIT_CENTER. // */ // void loadMedia(Context context, ImageView imageView, SuccessCallback callback); // // /** // * Loads thumbnail image and sets it to thumbnailView. After that implementation can call callback // * to set thumbnailView's scale type to ScaleType.FIT_CENTER. // */ // // void loadThumbnail(Context context, ImageView thumbnailView, SuccessCallback callback); // // /** // * Implementation may call this callback for report to imageView, what it's image was changed // */ // interface SuccessCallback { // void onSuccess(); // } // } // Path: library/src/main/java/com/veinhorn/scrollgalleryview/ScrollGalleryView.java import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.drawable.BitmapDrawable; import android.media.ThumbnailUtils; import android.os.Build; import android.support.transition.Transition; import android.support.transition.TransitionManager; import android.support.v4.app.FragmentManager; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.widget.HorizontalScrollView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.veinhorn.scrollgalleryview.builder.GalleryBuilder; import com.veinhorn.scrollgalleryview.builder.GalleryBuilderImpl; import com.veinhorn.scrollgalleryview.loader.MediaLoader; import java.util.ArrayList; import java.util.Collections; import java.util.List; // remove all media infos mListOfMedia.clear(); pagerAdapter = new ScreenSlidePagerAdapter( fragmentManager, mListOfMedia, zoomEnabled, innerOnImageClickListener, innerOnImageLongClickListener ); viewPager.setAdapter(pagerAdapter); // remove thumbnails thumbnailsContainer.removeAllViews(); } /** * Remove a media from the gallery * * @param position media's position to remove */ public void removeMedia(int position) { if (position >= mListOfMedia.size() || position < 0) { return; } pagerAdapter.removeItem(position); removeThumbnail(position); } public static GalleryBuilder from(ScrollGalleryView galleryView) {
return new GalleryBuilderImpl(galleryView);
VEINHORN/ScrollGalleryView
glide-loader/src/main/java/ogbe/ozioma/com/glideimageloader/dsl/DSL.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: glide-loader/src/main/java/ogbe/ozioma/com/glideimageloader/GlideMediaHelper.java // public class GlideMediaHelper extends BasicMediaHelper { // @Override // public MediaInfo image(String url) { // return MediaInfo.mediaLoader(new GlideImageLoader(url)); // } // // @Override // public MediaInfo image(String url, String description) { // return mediaInfo(url, description); // } // // @Override // public List<MediaInfo> images(List<String> urls) { // List<MediaInfo> medias = new ArrayList<>(); // // for (String url : urls) { // medias.add(mediaInfo(url)); // } // // return medias; // } // // @Override // public List<MediaInfo> images(String... urls) { // return images(Arrays.asList(urls)); // } // // private MediaInfo mediaInfo(String url) { // return mediaInfo(url, null); // } // // private MediaInfo mediaInfo(String url, String description) { // if (description != null) { // return MediaInfo.mediaLoader(new GlideImageLoader(url), description); // } // return MediaInfo.mediaLoader(new GlideImageLoader(url)); // } // }
import com.veinhorn.scrollgalleryview.MediaInfo; import java.util.List; import ogbe.ozioma.com.glideimageloader.GlideMediaHelper;
package ogbe.ozioma.com.glideimageloader.dsl; public class DSL { private static GlideMediaHelper mediaHelper = new GlideMediaHelper();
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: glide-loader/src/main/java/ogbe/ozioma/com/glideimageloader/GlideMediaHelper.java // public class GlideMediaHelper extends BasicMediaHelper { // @Override // public MediaInfo image(String url) { // return MediaInfo.mediaLoader(new GlideImageLoader(url)); // } // // @Override // public MediaInfo image(String url, String description) { // return mediaInfo(url, description); // } // // @Override // public List<MediaInfo> images(List<String> urls) { // List<MediaInfo> medias = new ArrayList<>(); // // for (String url : urls) { // medias.add(mediaInfo(url)); // } // // return medias; // } // // @Override // public List<MediaInfo> images(String... urls) { // return images(Arrays.asList(urls)); // } // // private MediaInfo mediaInfo(String url) { // return mediaInfo(url, null); // } // // private MediaInfo mediaInfo(String url, String description) { // if (description != null) { // return MediaInfo.mediaLoader(new GlideImageLoader(url), description); // } // return MediaInfo.mediaLoader(new GlideImageLoader(url)); // } // } // Path: glide-loader/src/main/java/ogbe/ozioma/com/glideimageloader/dsl/DSL.java import com.veinhorn.scrollgalleryview.MediaInfo; import java.util.List; import ogbe.ozioma.com.glideimageloader.GlideMediaHelper; package ogbe.ozioma.com.glideimageloader.dsl; public class DSL { private static GlideMediaHelper mediaHelper = new GlideMediaHelper();
public static MediaInfo image(String url) {
VEINHORN/ScrollGalleryView
picasso-loader/src/main/java/com/veinhorn/scrollgalleryview/loader/picasso/dsl/DSL.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: picasso-loader/src/main/java/com/veinhorn/scrollgalleryview/loader/picasso/PicassoMediaHelper.java // public class PicassoMediaHelper extends BasicMediaHelper { // @Override // public MediaInfo image(String url) { // return mediaInfo(url, null); // } // // @Override // public MediaInfo image(String url, String description) { // return mediaInfo(url, description); // } // // @Override // public List<MediaInfo> images(List<String> urls) { // List<MediaInfo> medias = new ArrayList<>(); // // for (String url : urls) { // medias.add(mediaInfo(url)); // } // // return medias; // } // // @Override // public List<MediaInfo> images(String... urls) { // return images(Arrays.asList(urls)); // } // // private MediaInfo mediaInfo(String url) { // return mediaInfo(url, null); // } // // // TODO: Add null checking for image url // private MediaInfo mediaInfo(String url, String description) { // if (description != null) { // return MediaInfo.mediaLoader(new PicassoImageLoader(url), description); // } // return MediaInfo.mediaLoader(new PicassoImageLoader(url)); // } // }
import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.loader.picasso.PicassoMediaHelper; import java.util.List;
package com.veinhorn.scrollgalleryview.loader.picasso.dsl; public class DSL { private static PicassoMediaHelper mediaHelper = new PicassoMediaHelper();
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: picasso-loader/src/main/java/com/veinhorn/scrollgalleryview/loader/picasso/PicassoMediaHelper.java // public class PicassoMediaHelper extends BasicMediaHelper { // @Override // public MediaInfo image(String url) { // return mediaInfo(url, null); // } // // @Override // public MediaInfo image(String url, String description) { // return mediaInfo(url, description); // } // // @Override // public List<MediaInfo> images(List<String> urls) { // List<MediaInfo> medias = new ArrayList<>(); // // for (String url : urls) { // medias.add(mediaInfo(url)); // } // // return medias; // } // // @Override // public List<MediaInfo> images(String... urls) { // return images(Arrays.asList(urls)); // } // // private MediaInfo mediaInfo(String url) { // return mediaInfo(url, null); // } // // // TODO: Add null checking for image url // private MediaInfo mediaInfo(String url, String description) { // if (description != null) { // return MediaInfo.mediaLoader(new PicassoImageLoader(url), description); // } // return MediaInfo.mediaLoader(new PicassoImageLoader(url)); // } // } // Path: picasso-loader/src/main/java/com/veinhorn/scrollgalleryview/loader/picasso/dsl/DSL.java import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.loader.picasso.PicassoMediaHelper; import java.util.List; package com.veinhorn.scrollgalleryview.loader.picasso.dsl; public class DSL { private static PicassoMediaHelper mediaHelper = new PicassoMediaHelper();
public static MediaInfo image(String url) {
VEINHORN/ScrollGalleryView
glide-loader/src/main/java/ogbe/ozioma/com/glideimageloader/GlideMediaHelper.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/BasicMediaHelper.java // public abstract class BasicMediaHelper implements MediaHelper { // @Override // public MediaInfo video(String url, int placeholderViewId) { // return MediaInfo.mediaLoader(new DefaultVideoLoader(url, placeholderViewId)); // } // }
import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.builder.BasicMediaHelper; import java.util.ArrayList; import java.util.Arrays; import java.util.List;
package ogbe.ozioma.com.glideimageloader; public class GlideMediaHelper extends BasicMediaHelper { @Override
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/BasicMediaHelper.java // public abstract class BasicMediaHelper implements MediaHelper { // @Override // public MediaInfo video(String url, int placeholderViewId) { // return MediaInfo.mediaLoader(new DefaultVideoLoader(url, placeholderViewId)); // } // } // Path: glide-loader/src/main/java/ogbe/ozioma/com/glideimageloader/GlideMediaHelper.java import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.builder.BasicMediaHelper; import java.util.ArrayList; import java.util.Arrays; import java.util.List; package ogbe.ozioma.com.glideimageloader; public class GlideMediaHelper extends BasicMediaHelper { @Override
public MediaInfo image(String url) {
VEINHORN/ScrollGalleryView
fresco-loader/src/main/java/com/ayokunlepaul/frescoloader/dsl/DSL.java
// Path: fresco-loader/src/main/java/com/ayokunlepaul/frescoloader/FrescoMediaHelper.java // public class FrescoMediaHelper extends BasicMediaHelper { // @Override // public MediaInfo image(String url) { // return MediaInfo.mediaLoader(new FrescoImageLoader(url)); // } // // @Override // public MediaInfo image(String url, String description) { // return mediaInfo(url, description); // } // // @Override // public List<MediaInfo> images(List<String> urls) { // List<MediaInfo> medias = new ArrayList<>(); // // for (String url : urls) { // medias.add(mediaInfo(url)); // } // // return medias; // } // // @Override // public List<MediaInfo> images(String... urls) { // return images(Arrays.asList(urls)); // } // // private MediaInfo mediaInfo(String url) { // return mediaInfo(url, null); // } // // private MediaInfo mediaInfo(String url, String description) { // if (description != null) { // return MediaInfo.mediaLoader(new FrescoImageLoader(url), description); // } // return MediaInfo.mediaLoader(new FrescoImageLoader(url)); // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // }
import com.ayokunlepaul.frescoloader.FrescoMediaHelper; import com.veinhorn.scrollgalleryview.MediaInfo; import java.util.List;
package com.ayokunlepaul.frescoloader.dsl; public class DSL { private static FrescoMediaHelper mediaHelper = new FrescoMediaHelper();
// Path: fresco-loader/src/main/java/com/ayokunlepaul/frescoloader/FrescoMediaHelper.java // public class FrescoMediaHelper extends BasicMediaHelper { // @Override // public MediaInfo image(String url) { // return MediaInfo.mediaLoader(new FrescoImageLoader(url)); // } // // @Override // public MediaInfo image(String url, String description) { // return mediaInfo(url, description); // } // // @Override // public List<MediaInfo> images(List<String> urls) { // List<MediaInfo> medias = new ArrayList<>(); // // for (String url : urls) { // medias.add(mediaInfo(url)); // } // // return medias; // } // // @Override // public List<MediaInfo> images(String... urls) { // return images(Arrays.asList(urls)); // } // // private MediaInfo mediaInfo(String url) { // return mediaInfo(url, null); // } // // private MediaInfo mediaInfo(String url, String description) { // if (description != null) { // return MediaInfo.mediaLoader(new FrescoImageLoader(url), description); // } // return MediaInfo.mediaLoader(new FrescoImageLoader(url)); // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // Path: fresco-loader/src/main/java/com/ayokunlepaul/frescoloader/dsl/DSL.java import com.ayokunlepaul.frescoloader.FrescoMediaHelper; import com.veinhorn.scrollgalleryview.MediaInfo; import java.util.List; package com.ayokunlepaul.frescoloader.dsl; public class DSL { private static FrescoMediaHelper mediaHelper = new FrescoMediaHelper();
public static MediaInfo image(String url) {
VEINHORN/ScrollGalleryView
fresco-loader/src/main/java/com/ayokunlepaul/frescoloader/FrescoMediaHelper.java
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/BasicMediaHelper.java // public abstract class BasicMediaHelper implements MediaHelper { // @Override // public MediaInfo video(String url, int placeholderViewId) { // return MediaInfo.mediaLoader(new DefaultVideoLoader(url, placeholderViewId)); // } // }
import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.builder.BasicMediaHelper; import java.util.ArrayList; import java.util.Arrays; import java.util.List;
package com.ayokunlepaul.frescoloader; public class FrescoMediaHelper extends BasicMediaHelper { @Override
// Path: library/src/main/java/com/veinhorn/scrollgalleryview/MediaInfo.java // public class MediaInfo { // private MediaLoader mLoader; // private String description; // // private MediaInfo() { // // } // // private MediaInfo(MediaLoader mediaLoader, String description) { // this.mLoader = mediaLoader; // this.description = description; // } // // /** // * Creates MediaInfo object from MediaLoader // * @param mediaLoader // * @return MediaInfo object // */ // public static MediaInfo mediaLoader(MediaLoader mediaLoader) { // return new MediaInfo().setLoader(mediaLoader); // } // // public static MediaInfo mediaLoader(MediaLoader mediaLoader, String description) { // return new MediaInfo(mediaLoader, description); // } // // public MediaLoader getLoader() { // return mLoader; // } // // public MediaInfo setLoader(MediaLoader loader) { // mLoader = loader; // return this; // } // // public String getDescription() { // return description; // } // } // // Path: library/src/main/java/com/veinhorn/scrollgalleryview/builder/BasicMediaHelper.java // public abstract class BasicMediaHelper implements MediaHelper { // @Override // public MediaInfo video(String url, int placeholderViewId) { // return MediaInfo.mediaLoader(new DefaultVideoLoader(url, placeholderViewId)); // } // } // Path: fresco-loader/src/main/java/com/ayokunlepaul/frescoloader/FrescoMediaHelper.java import com.veinhorn.scrollgalleryview.MediaInfo; import com.veinhorn.scrollgalleryview.builder.BasicMediaHelper; import java.util.ArrayList; import java.util.Arrays; import java.util.List; package com.ayokunlepaul.frescoloader; public class FrescoMediaHelper extends BasicMediaHelper { @Override
public MediaInfo image(String url) {
mikkeliamk/osa
src/fi/mamk/osa/bean/ThumbBean.java
// Path: src/fi/mamk/osa/stripes/OsaActionBeanContext.java // public class OsaActionBeanContext extends ActionBeanContext { // // public User getUser() { // return (User) getRequest().getSession().getAttribute("user"); // } // // public void setUser(User user) { // getRequest().getSession().setAttribute("user", user); // } // // public Gui getGui() { // return (Gui) getRequest().getSession().getAttribute("gui"); // } // // public void setGui(Gui gui) { // getRequest().getSession().setAttribute("gui", gui); // } // // public void setSearch(Search search) { // getRequest().getSession().setAttribute("search", search); // } // // public Search getSearch() { // return (Search) getRequest().getSession().getAttribute("search"); // } // // }
import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.RenderedImage; import java.awt.image.WritableRaster; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Hashtable; import java.util.LinkedHashMap; import javax.imageio.ImageIO; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.log4j.Logger; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.imgscalr.Scalr; import com.sun.media.jai.codec.FileSeekableStream; import com.sun.media.jai.codec.ImageCodec; import com.sun.media.jai.codec.ImageDecoder; import com.sun.media.jai.codec.SeekableStream; import com.sun.media.jai.codec.TIFFDecodeParam; import fi.mamk.osa.stripes.OsaActionBeanContext;
fileOutputStream = new FileOutputStream(thumbnailPathAndName); ImageIO.write(thumb, THUMB_EXTENSION, fileOutputStream); } else { bufferedImage = ImageIO.read(new File(filePath)); thumb = Scalr.resize(bufferedImage, 200); // Scale the original image around the width and height of 150 px, maintaining original aspect ratio fileOutputStream = new FileOutputStream(thumbnailPathAndName); ImageIO.write(thumb, THUMB_EXTENSION, fileOutputStream); } } catch (IOException e) { logger.error("Error creating thumbnail for image file: "+e.getMessage()); } } thumbFile = new File(thumbnailPathAndName); if (thumbFile.canRead()) { try { fileOutputStream.close(); } catch (IOException e) { logger.error("Error creating thumbnail file: "+e.getMessage()); } } return thumbFile; }
// Path: src/fi/mamk/osa/stripes/OsaActionBeanContext.java // public class OsaActionBeanContext extends ActionBeanContext { // // public User getUser() { // return (User) getRequest().getSession().getAttribute("user"); // } // // public void setUser(User user) { // getRequest().getSession().setAttribute("user", user); // } // // public Gui getGui() { // return (Gui) getRequest().getSession().getAttribute("gui"); // } // // public void setGui(Gui gui) { // getRequest().getSession().setAttribute("gui", gui); // } // // public void setSearch(Search search) { // getRequest().getSession().setAttribute("search", search); // } // // public Search getSearch() { // return (Search) getRequest().getSession().getAttribute("search"); // } // // } // Path: src/fi/mamk/osa/bean/ThumbBean.java import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.RenderedImage; import java.awt.image.WritableRaster; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Hashtable; import java.util.LinkedHashMap; import javax.imageio.ImageIO; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.log4j.Logger; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.imgscalr.Scalr; import com.sun.media.jai.codec.FileSeekableStream; import com.sun.media.jai.codec.ImageCodec; import com.sun.media.jai.codec.ImageDecoder; import com.sun.media.jai.codec.SeekableStream; import com.sun.media.jai.codec.TIFFDecodeParam; import fi.mamk.osa.stripes.OsaActionBeanContext; fileOutputStream = new FileOutputStream(thumbnailPathAndName); ImageIO.write(thumb, THUMB_EXTENSION, fileOutputStream); } else { bufferedImage = ImageIO.read(new File(filePath)); thumb = Scalr.resize(bufferedImage, 200); // Scale the original image around the width and height of 150 px, maintaining original aspect ratio fileOutputStream = new FileOutputStream(thumbnailPathAndName); ImageIO.write(thumb, THUMB_EXTENSION, fileOutputStream); } } catch (IOException e) { logger.error("Error creating thumbnail for image file: "+e.getMessage()); } } thumbFile = new File(thumbnailPathAndName); if (thumbFile.canRead()) { try { fileOutputStream.close(); } catch (IOException e) { logger.error("Error creating thumbnail file: "+e.getMessage()); } } return thumbFile; }
public static void createThumbFileAfterUpload(String mimeType, String filename, String dir, OsaActionBeanContext context) {
mikkeliamk/osa
src/fi/mamk/osa/auth/Role.java
// Path: src/fi/mamk/osa/auth/AccessRight.java // public class AccessRight implements Serializable { // // private static final long serialVersionUID = -8302724810061640050L; // // public static final int ACCESSRIGHTLEVEL_DENY_META = -1; // public static final int ACCESSRIGHTLEVEL_READ_META = 10; // public static final int ACCESSRIGHTLEVEL_READ_DOC = 20; // public static final int ACCESSRIGHTLEVEL_WRITE_META = 30; // public static final int ACCESSRIGHTLEVEL_ADD_DOC = 40; // public static final int ACCESSRIGHTLEVEL_RECORDSMANAGEMENT = 50; // public static final int ACCESSRIGHTLEVEL_ADMIN = 100; // public static final int ACCESSRIGHTLEVEL_INSTANCEADMIN = 200; // // public static final String PUBLICITYLEVEL_Confidential = "confidential"; // public static final String PUBLICITYLEVEL_Restricted = "restricted"; // public static final String PUBLICITYLEVEL_Public = "public"; // // /** // * publicityLevel // * 0: access to public data // * 1: access to restricted data // * 2: access to confidential data // */ // public String publicityLevel; // private int accessRightLevel; // private String accessRightPath; // private boolean recursiveRule; // // // publicity level hierarchy // public static final List<String> PUBLICITYLEVEL_LIST = // Collections.unmodifiableList(new Vector<String>() { // private static final long serialVersionUID = 1L; // { // add("public"); // add("restricted"); // add("confidential"); // }}); // // /** // * Constructor // */ // public AccessRight() { // this.publicityLevel = PUBLICITYLEVEL_Public; // this.accessRightLevel = ACCESSRIGHTLEVEL_READ_META; // this.accessRightPath = null; // this.recursiveRule = false; // } // // /** // * Constructor // */ // public AccessRight(String publicityLevel, int accessRightLevel, String accessRightPath) { // this.publicityLevel = publicityLevel; // this.accessRightLevel = accessRightLevel; // this.accessRightPath = accessRightPath; // // if (this.accessRightPath.endsWith("+")) { // this.recursiveRule = true; // } else { // this.recursiveRule = false; // } // } // // /** // * Get all publicity levels below determined level // * (public, restricted, confidential) // * @return // */ // public String getPublicityLevels() { // // String levels = ""; // int index = PUBLICITYLEVEL_LIST.indexOf(this.publicityLevel); // // if (this.getAccessRightLevel() == AccessRight.ACCESSRIGHTLEVEL_DENY_META) { // for (int i=0; i<PUBLICITYLEVEL_LIST.size(); i++) { // if (i >= index) { // if (levels != "") { // levels += " "; // } // levels += PUBLICITYLEVEL_LIST.get(i); // } // } // // } else { // for (int i=0; i<PUBLICITYLEVEL_LIST.size(); i++) { // if (i <= index) { // if (levels != "") { // levels += " "; // } // levels += PUBLICITYLEVEL_LIST.get(i); // } // } // } // return levels; // } // // public String getPublicityLevel() { // return publicityLevel; // } // public void setPublicityLevel(String publicityLevel) { // this.publicityLevel = publicityLevel; // } // public String getAccessRightPath() { // return accessRightPath; // } // public void setAccessRightPath(String accessRightPath) { // this.accessRightPath = accessRightPath; // } // public int getAccessRightLevel() { // return accessRightLevel; // } // public void setAccessRightLevel(int accessRightLevel) { // this.accessRightLevel = accessRightLevel; // } // public boolean isRecursiveRule() { // return recursiveRule; // } // public void setRecursiveRule(boolean recursiveRule) { // this.recursiveRule = recursiveRule; // } // // }
import java.io.Serializable; import java.util.Collections; import java.util.Vector; import org.apache.log4j.Logger; import fi.mamk.osa.auth.AccessRight;
package fi.mamk.osa.auth; /** * Class for setting roles and permissions */ public class Role implements Serializable { private static final long serialVersionUID = -6687757850396871383L; private static final Logger logger = Logger.getLogger(Role.class); public static final String ROLE_PUBLIC = "public"; // role name public String name; // access rights
// Path: src/fi/mamk/osa/auth/AccessRight.java // public class AccessRight implements Serializable { // // private static final long serialVersionUID = -8302724810061640050L; // // public static final int ACCESSRIGHTLEVEL_DENY_META = -1; // public static final int ACCESSRIGHTLEVEL_READ_META = 10; // public static final int ACCESSRIGHTLEVEL_READ_DOC = 20; // public static final int ACCESSRIGHTLEVEL_WRITE_META = 30; // public static final int ACCESSRIGHTLEVEL_ADD_DOC = 40; // public static final int ACCESSRIGHTLEVEL_RECORDSMANAGEMENT = 50; // public static final int ACCESSRIGHTLEVEL_ADMIN = 100; // public static final int ACCESSRIGHTLEVEL_INSTANCEADMIN = 200; // // public static final String PUBLICITYLEVEL_Confidential = "confidential"; // public static final String PUBLICITYLEVEL_Restricted = "restricted"; // public static final String PUBLICITYLEVEL_Public = "public"; // // /** // * publicityLevel // * 0: access to public data // * 1: access to restricted data // * 2: access to confidential data // */ // public String publicityLevel; // private int accessRightLevel; // private String accessRightPath; // private boolean recursiveRule; // // // publicity level hierarchy // public static final List<String> PUBLICITYLEVEL_LIST = // Collections.unmodifiableList(new Vector<String>() { // private static final long serialVersionUID = 1L; // { // add("public"); // add("restricted"); // add("confidential"); // }}); // // /** // * Constructor // */ // public AccessRight() { // this.publicityLevel = PUBLICITYLEVEL_Public; // this.accessRightLevel = ACCESSRIGHTLEVEL_READ_META; // this.accessRightPath = null; // this.recursiveRule = false; // } // // /** // * Constructor // */ // public AccessRight(String publicityLevel, int accessRightLevel, String accessRightPath) { // this.publicityLevel = publicityLevel; // this.accessRightLevel = accessRightLevel; // this.accessRightPath = accessRightPath; // // if (this.accessRightPath.endsWith("+")) { // this.recursiveRule = true; // } else { // this.recursiveRule = false; // } // } // // /** // * Get all publicity levels below determined level // * (public, restricted, confidential) // * @return // */ // public String getPublicityLevels() { // // String levels = ""; // int index = PUBLICITYLEVEL_LIST.indexOf(this.publicityLevel); // // if (this.getAccessRightLevel() == AccessRight.ACCESSRIGHTLEVEL_DENY_META) { // for (int i=0; i<PUBLICITYLEVEL_LIST.size(); i++) { // if (i >= index) { // if (levels != "") { // levels += " "; // } // levels += PUBLICITYLEVEL_LIST.get(i); // } // } // // } else { // for (int i=0; i<PUBLICITYLEVEL_LIST.size(); i++) { // if (i <= index) { // if (levels != "") { // levels += " "; // } // levels += PUBLICITYLEVEL_LIST.get(i); // } // } // } // return levels; // } // // public String getPublicityLevel() { // return publicityLevel; // } // public void setPublicityLevel(String publicityLevel) { // this.publicityLevel = publicityLevel; // } // public String getAccessRightPath() { // return accessRightPath; // } // public void setAccessRightPath(String accessRightPath) { // this.accessRightPath = accessRightPath; // } // public int getAccessRightLevel() { // return accessRightLevel; // } // public void setAccessRightLevel(int accessRightLevel) { // this.accessRightLevel = accessRightLevel; // } // public boolean isRecursiveRule() { // return recursiveRule; // } // public void setRecursiveRule(boolean recursiveRule) { // this.recursiveRule = recursiveRule; // } // // } // Path: src/fi/mamk/osa/auth/Role.java import java.io.Serializable; import java.util.Collections; import java.util.Vector; import org.apache.log4j.Logger; import fi.mamk.osa.auth.AccessRight; package fi.mamk.osa.auth; /** * Class for setting roles and permissions */ public class Role implements Serializable { private static final long serialVersionUID = -6687757850396871383L; private static final Logger logger = Logger.getLogger(Role.class); public static final String ROLE_PUBLIC = "public"; // role name public String name; // access rights
private Vector<AccessRight> roleAccessrights = new Vector<AccessRight>();
mikkeliamk/osa
src/fi/mamk/osa/database/sql/mysql/ConnectionManager.java
// Path: src/fi/mamk/osa/database/sql/DatabaseConfiguration.java // public class DatabaseConfiguration { // // private String dbDriverName = null; // private String dbUser = null; // private String dbPassword = null; // private String dbURI = null; // // private int dbPoolMinSize = 0; // private int dbPoolMaxSize = 0; // private int dbTimeout = 0; // // private static final Logger logger = Logger.getLogger( DatabaseConfiguration.class ); // // /** // * Default constructor // */ // public DatabaseConfiguration() { // // } // // /** // * Constructor // * @param xmlFile // */ // public DatabaseConfiguration(String xmlFile) { // SAXBuilder builder = new SAXBuilder(); // // try { // // InputStream is = new FileInputStream( xmlFile ); // // Document doc = builder.build ( is ); // Element root = doc.getRootElement(); // // dbDriverName = root.getChild("dbDriverName").getTextTrim(); // dbUser = root.getChild("dbUser").getTextTrim(); // dbPassword = root.getChild("dbPassword").getTextTrim(); // dbURI = root.getChild("dbURI").getTextTrim(); // dbPoolMinSize = Integer.parseInt( root.getChild("dbPoolMinSize").getTextTrim() ); // dbPoolMaxSize = Integer.parseInt( root.getChild("dbPoolMaxSize").getTextTrim() ); // dbTimeout = Integer.parseInt( root.getChild("dbTimeout").getTextTrim() ); // logger.info("XXXXXXXXXXXXXX "+dbUser+"\n"); // // } catch ( Exception ex ) { // logger.error( "Could not read configuration file: ", ex ); // } // // } // // public String getDbDriverName() { // return dbDriverName; // } // // public String getDbUser() { // return dbUser; // } // // public String getDbPassword() { // return dbPassword; // } // // public String getDbURI() { // return dbURI; // } // // public int getDbPoolMinSize() { // return dbPoolMinSize; // } // // public int getDbPoolMaxSize() { // return dbPoolMaxSize; // } // // public int getDbTimeout() { // return dbTimeout; // } // // /** // * Function: setDbDriverName // * @param dbDriverName the dbDriverName to set // */ // public void setDbDriverName(String dbDriverName) { // this.dbDriverName = dbDriverName; // } // // /** // * @param dbUser the dbUser to set // */ // public void setDbUser(String dbUser) { // this.dbUser = dbUser; // } // // /** // * @param dbPassword the dbPassword to set // */ // public void setDbPassword(String dbPassword) { // this.dbPassword = dbPassword; // } // // /** // * @param dbURI the dbURI to set // */ // public void setDbURI(String dbURI) { // this.dbURI = dbURI; // } // // /** // * @param dbPoolMinSize the dbPoolMinSize to set // */ // public void setDbPoolMinSize(int dbPoolMinSize) { // this.dbPoolMinSize = dbPoolMinSize; // } // // /** // * @param dbPoolMaxSize the dbPoolMaxSize to set // */ // public void setDbPoolMaxSize(int dbPoolMaxSize) { // this.dbPoolMaxSize = dbPoolMaxSize; // } // // /** // * @param dbTimeout the dbTimeout to set // */ // public void setDbTimeout(int dbTimeout) { // this.dbTimeout = dbTimeout; // } // // @Override // public String toString() { // // ReflectionToStringBuilder tsb = // new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); // return tsb.toString(); // } // } // // Path: src/fi/mamk/osa/database/sql/SQLManager.java // public abstract class SQLManager extends DatabaseManager { // // private static final Logger logger = Logger.getLogger(SQLManager.class); // // public static DataSource dataSource = null; // public static MiniConnectionPoolManager poolManager = null; // // /** // * Get db connection // * @return // * @throws SQLException // */ // public static Connection getConnection() throws SQLException { // if (dataSource != null) { // return dataSource.getConnection(); // } // if (poolManager != null) { // return poolManager.getConnection(); // } // return null; // } // // /** // * Checks the database status. // * // * @return true if database is working properly. // * false if any of needed databases is offline // */ // public abstract boolean testDatabase(); // }
import org.apache.commons.pool.impl.GenericObjectPool; import org.apache.commons.pool.ObjectPool; import org.apache.commons.dbcp.*; import javax.sql.DataSource; import java.sql.*; import java.util.Date; import org.apache.log4j.Logger; import fi.mamk.osa.database.sql.DatabaseConfiguration; import fi.mamk.osa.database.sql.SQLManager;
package fi.mamk.osa.database.sql.mysql; /** * @ inadareishvili */ public class ConnectionManager { private static final Logger logger = Logger.getLogger(ConnectionManager.class); public static DataSource ds = null; private static GenericObjectPool _pool = null; /** * Constructor * @param config configuration from an XML file. */
// Path: src/fi/mamk/osa/database/sql/DatabaseConfiguration.java // public class DatabaseConfiguration { // // private String dbDriverName = null; // private String dbUser = null; // private String dbPassword = null; // private String dbURI = null; // // private int dbPoolMinSize = 0; // private int dbPoolMaxSize = 0; // private int dbTimeout = 0; // // private static final Logger logger = Logger.getLogger( DatabaseConfiguration.class ); // // /** // * Default constructor // */ // public DatabaseConfiguration() { // // } // // /** // * Constructor // * @param xmlFile // */ // public DatabaseConfiguration(String xmlFile) { // SAXBuilder builder = new SAXBuilder(); // // try { // // InputStream is = new FileInputStream( xmlFile ); // // Document doc = builder.build ( is ); // Element root = doc.getRootElement(); // // dbDriverName = root.getChild("dbDriverName").getTextTrim(); // dbUser = root.getChild("dbUser").getTextTrim(); // dbPassword = root.getChild("dbPassword").getTextTrim(); // dbURI = root.getChild("dbURI").getTextTrim(); // dbPoolMinSize = Integer.parseInt( root.getChild("dbPoolMinSize").getTextTrim() ); // dbPoolMaxSize = Integer.parseInt( root.getChild("dbPoolMaxSize").getTextTrim() ); // dbTimeout = Integer.parseInt( root.getChild("dbTimeout").getTextTrim() ); // logger.info("XXXXXXXXXXXXXX "+dbUser+"\n"); // // } catch ( Exception ex ) { // logger.error( "Could not read configuration file: ", ex ); // } // // } // // public String getDbDriverName() { // return dbDriverName; // } // // public String getDbUser() { // return dbUser; // } // // public String getDbPassword() { // return dbPassword; // } // // public String getDbURI() { // return dbURI; // } // // public int getDbPoolMinSize() { // return dbPoolMinSize; // } // // public int getDbPoolMaxSize() { // return dbPoolMaxSize; // } // // public int getDbTimeout() { // return dbTimeout; // } // // /** // * Function: setDbDriverName // * @param dbDriverName the dbDriverName to set // */ // public void setDbDriverName(String dbDriverName) { // this.dbDriverName = dbDriverName; // } // // /** // * @param dbUser the dbUser to set // */ // public void setDbUser(String dbUser) { // this.dbUser = dbUser; // } // // /** // * @param dbPassword the dbPassword to set // */ // public void setDbPassword(String dbPassword) { // this.dbPassword = dbPassword; // } // // /** // * @param dbURI the dbURI to set // */ // public void setDbURI(String dbURI) { // this.dbURI = dbURI; // } // // /** // * @param dbPoolMinSize the dbPoolMinSize to set // */ // public void setDbPoolMinSize(int dbPoolMinSize) { // this.dbPoolMinSize = dbPoolMinSize; // } // // /** // * @param dbPoolMaxSize the dbPoolMaxSize to set // */ // public void setDbPoolMaxSize(int dbPoolMaxSize) { // this.dbPoolMaxSize = dbPoolMaxSize; // } // // /** // * @param dbTimeout the dbTimeout to set // */ // public void setDbTimeout(int dbTimeout) { // this.dbTimeout = dbTimeout; // } // // @Override // public String toString() { // // ReflectionToStringBuilder tsb = // new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); // return tsb.toString(); // } // } // // Path: src/fi/mamk/osa/database/sql/SQLManager.java // public abstract class SQLManager extends DatabaseManager { // // private static final Logger logger = Logger.getLogger(SQLManager.class); // // public static DataSource dataSource = null; // public static MiniConnectionPoolManager poolManager = null; // // /** // * Get db connection // * @return // * @throws SQLException // */ // public static Connection getConnection() throws SQLException { // if (dataSource != null) { // return dataSource.getConnection(); // } // if (poolManager != null) { // return poolManager.getConnection(); // } // return null; // } // // /** // * Checks the database status. // * // * @return true if database is working properly. // * false if any of needed databases is offline // */ // public abstract boolean testDatabase(); // } // Path: src/fi/mamk/osa/database/sql/mysql/ConnectionManager.java import org.apache.commons.pool.impl.GenericObjectPool; import org.apache.commons.pool.ObjectPool; import org.apache.commons.dbcp.*; import javax.sql.DataSource; import java.sql.*; import java.util.Date; import org.apache.log4j.Logger; import fi.mamk.osa.database.sql.DatabaseConfiguration; import fi.mamk.osa.database.sql.SQLManager; package fi.mamk.osa.database.sql.mysql; /** * @ inadareishvili */ public class ConnectionManager { private static final Logger logger = Logger.getLogger(ConnectionManager.class); public static DataSource ds = null; private static GenericObjectPool _pool = null; /** * Constructor * @param config configuration from an XML file. */
public ConnectionManager(DatabaseConfiguration config)
mikkeliamk/osa
src/fi/mamk/osa/database/sql/mysql/ConnectionManager.java
// Path: src/fi/mamk/osa/database/sql/DatabaseConfiguration.java // public class DatabaseConfiguration { // // private String dbDriverName = null; // private String dbUser = null; // private String dbPassword = null; // private String dbURI = null; // // private int dbPoolMinSize = 0; // private int dbPoolMaxSize = 0; // private int dbTimeout = 0; // // private static final Logger logger = Logger.getLogger( DatabaseConfiguration.class ); // // /** // * Default constructor // */ // public DatabaseConfiguration() { // // } // // /** // * Constructor // * @param xmlFile // */ // public DatabaseConfiguration(String xmlFile) { // SAXBuilder builder = new SAXBuilder(); // // try { // // InputStream is = new FileInputStream( xmlFile ); // // Document doc = builder.build ( is ); // Element root = doc.getRootElement(); // // dbDriverName = root.getChild("dbDriverName").getTextTrim(); // dbUser = root.getChild("dbUser").getTextTrim(); // dbPassword = root.getChild("dbPassword").getTextTrim(); // dbURI = root.getChild("dbURI").getTextTrim(); // dbPoolMinSize = Integer.parseInt( root.getChild("dbPoolMinSize").getTextTrim() ); // dbPoolMaxSize = Integer.parseInt( root.getChild("dbPoolMaxSize").getTextTrim() ); // dbTimeout = Integer.parseInt( root.getChild("dbTimeout").getTextTrim() ); // logger.info("XXXXXXXXXXXXXX "+dbUser+"\n"); // // } catch ( Exception ex ) { // logger.error( "Could not read configuration file: ", ex ); // } // // } // // public String getDbDriverName() { // return dbDriverName; // } // // public String getDbUser() { // return dbUser; // } // // public String getDbPassword() { // return dbPassword; // } // // public String getDbURI() { // return dbURI; // } // // public int getDbPoolMinSize() { // return dbPoolMinSize; // } // // public int getDbPoolMaxSize() { // return dbPoolMaxSize; // } // // public int getDbTimeout() { // return dbTimeout; // } // // /** // * Function: setDbDriverName // * @param dbDriverName the dbDriverName to set // */ // public void setDbDriverName(String dbDriverName) { // this.dbDriverName = dbDriverName; // } // // /** // * @param dbUser the dbUser to set // */ // public void setDbUser(String dbUser) { // this.dbUser = dbUser; // } // // /** // * @param dbPassword the dbPassword to set // */ // public void setDbPassword(String dbPassword) { // this.dbPassword = dbPassword; // } // // /** // * @param dbURI the dbURI to set // */ // public void setDbURI(String dbURI) { // this.dbURI = dbURI; // } // // /** // * @param dbPoolMinSize the dbPoolMinSize to set // */ // public void setDbPoolMinSize(int dbPoolMinSize) { // this.dbPoolMinSize = dbPoolMinSize; // } // // /** // * @param dbPoolMaxSize the dbPoolMaxSize to set // */ // public void setDbPoolMaxSize(int dbPoolMaxSize) { // this.dbPoolMaxSize = dbPoolMaxSize; // } // // /** // * @param dbTimeout the dbTimeout to set // */ // public void setDbTimeout(int dbTimeout) { // this.dbTimeout = dbTimeout; // } // // @Override // public String toString() { // // ReflectionToStringBuilder tsb = // new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); // return tsb.toString(); // } // } // // Path: src/fi/mamk/osa/database/sql/SQLManager.java // public abstract class SQLManager extends DatabaseManager { // // private static final Logger logger = Logger.getLogger(SQLManager.class); // // public static DataSource dataSource = null; // public static MiniConnectionPoolManager poolManager = null; // // /** // * Get db connection // * @return // * @throws SQLException // */ // public static Connection getConnection() throws SQLException { // if (dataSource != null) { // return dataSource.getConnection(); // } // if (poolManager != null) { // return poolManager.getConnection(); // } // return null; // } // // /** // * Checks the database status. // * // * @return true if database is working properly. // * false if any of needed databases is offline // */ // public abstract boolean testDatabase(); // }
import org.apache.commons.pool.impl.GenericObjectPool; import org.apache.commons.pool.ObjectPool; import org.apache.commons.dbcp.*; import javax.sql.DataSource; import java.sql.*; import java.util.Date; import org.apache.log4j.Logger; import fi.mamk.osa.database.sql.DatabaseConfiguration; import fi.mamk.osa.database.sql.SQLManager;
{ super.finalize(); } catch(Throwable ex) { logger.error( "ConnectionManager finalize failed to disconnect from mysql: ", ex ); } } /** * connectToDB - Connect to the MySql DB! */ private void connectToDB( DatabaseConfiguration config ) { try { java.lang.Class.forName( config.getDbDriverName() ).newInstance(); } catch(Exception e) { logger.error("Error when attempting to obtain DB Driver: " + config.getDbDriverName() + " on " + new Date().toString(), e); } logger.debug("Trying to connect to database..."); //System.out.println(config.getDbURI()); try {
// Path: src/fi/mamk/osa/database/sql/DatabaseConfiguration.java // public class DatabaseConfiguration { // // private String dbDriverName = null; // private String dbUser = null; // private String dbPassword = null; // private String dbURI = null; // // private int dbPoolMinSize = 0; // private int dbPoolMaxSize = 0; // private int dbTimeout = 0; // // private static final Logger logger = Logger.getLogger( DatabaseConfiguration.class ); // // /** // * Default constructor // */ // public DatabaseConfiguration() { // // } // // /** // * Constructor // * @param xmlFile // */ // public DatabaseConfiguration(String xmlFile) { // SAXBuilder builder = new SAXBuilder(); // // try { // // InputStream is = new FileInputStream( xmlFile ); // // Document doc = builder.build ( is ); // Element root = doc.getRootElement(); // // dbDriverName = root.getChild("dbDriverName").getTextTrim(); // dbUser = root.getChild("dbUser").getTextTrim(); // dbPassword = root.getChild("dbPassword").getTextTrim(); // dbURI = root.getChild("dbURI").getTextTrim(); // dbPoolMinSize = Integer.parseInt( root.getChild("dbPoolMinSize").getTextTrim() ); // dbPoolMaxSize = Integer.parseInt( root.getChild("dbPoolMaxSize").getTextTrim() ); // dbTimeout = Integer.parseInt( root.getChild("dbTimeout").getTextTrim() ); // logger.info("XXXXXXXXXXXXXX "+dbUser+"\n"); // // } catch ( Exception ex ) { // logger.error( "Could not read configuration file: ", ex ); // } // // } // // public String getDbDriverName() { // return dbDriverName; // } // // public String getDbUser() { // return dbUser; // } // // public String getDbPassword() { // return dbPassword; // } // // public String getDbURI() { // return dbURI; // } // // public int getDbPoolMinSize() { // return dbPoolMinSize; // } // // public int getDbPoolMaxSize() { // return dbPoolMaxSize; // } // // public int getDbTimeout() { // return dbTimeout; // } // // /** // * Function: setDbDriverName // * @param dbDriverName the dbDriverName to set // */ // public void setDbDriverName(String dbDriverName) { // this.dbDriverName = dbDriverName; // } // // /** // * @param dbUser the dbUser to set // */ // public void setDbUser(String dbUser) { // this.dbUser = dbUser; // } // // /** // * @param dbPassword the dbPassword to set // */ // public void setDbPassword(String dbPassword) { // this.dbPassword = dbPassword; // } // // /** // * @param dbURI the dbURI to set // */ // public void setDbURI(String dbURI) { // this.dbURI = dbURI; // } // // /** // * @param dbPoolMinSize the dbPoolMinSize to set // */ // public void setDbPoolMinSize(int dbPoolMinSize) { // this.dbPoolMinSize = dbPoolMinSize; // } // // /** // * @param dbPoolMaxSize the dbPoolMaxSize to set // */ // public void setDbPoolMaxSize(int dbPoolMaxSize) { // this.dbPoolMaxSize = dbPoolMaxSize; // } // // /** // * @param dbTimeout the dbTimeout to set // */ // public void setDbTimeout(int dbTimeout) { // this.dbTimeout = dbTimeout; // } // // @Override // public String toString() { // // ReflectionToStringBuilder tsb = // new ReflectionToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE); // return tsb.toString(); // } // } // // Path: src/fi/mamk/osa/database/sql/SQLManager.java // public abstract class SQLManager extends DatabaseManager { // // private static final Logger logger = Logger.getLogger(SQLManager.class); // // public static DataSource dataSource = null; // public static MiniConnectionPoolManager poolManager = null; // // /** // * Get db connection // * @return // * @throws SQLException // */ // public static Connection getConnection() throws SQLException { // if (dataSource != null) { // return dataSource.getConnection(); // } // if (poolManager != null) { // return poolManager.getConnection(); // } // return null; // } // // /** // * Checks the database status. // * // * @return true if database is working properly. // * false if any of needed databases is offline // */ // public abstract boolean testDatabase(); // } // Path: src/fi/mamk/osa/database/sql/mysql/ConnectionManager.java import org.apache.commons.pool.impl.GenericObjectPool; import org.apache.commons.pool.ObjectPool; import org.apache.commons.dbcp.*; import javax.sql.DataSource; import java.sql.*; import java.util.Date; import org.apache.log4j.Logger; import fi.mamk.osa.database.sql.DatabaseConfiguration; import fi.mamk.osa.database.sql.SQLManager; { super.finalize(); } catch(Throwable ex) { logger.error( "ConnectionManager finalize failed to disconnect from mysql: ", ex ); } } /** * connectToDB - Connect to the MySql DB! */ private void connectToDB( DatabaseConfiguration config ) { try { java.lang.Class.forName( config.getDbDriverName() ).newInstance(); } catch(Exception e) { logger.error("Error when attempting to obtain DB Driver: " + config.getDbDriverName() + " on " + new Date().toString(), e); } logger.debug("Trying to connect to database..."); //System.out.println(config.getDbURI()); try {
SQLManager.dataSource = setupDataSource(
mikkeliamk/osa
src/fi/mamk/osa/bean/DataStream.java
// Path: src/fi/mamk/osa/bean/MetaDataElement.java // public static enum MetaDataType { // string, // String // date, // Date // integer, // Integer // link, // // relation, // Object relationships // select; // Enum value // // public static MetaDataType getEnum(String s) { // if (string.name().equalsIgnoreCase(s)) // return string; // else if (date.name().equalsIgnoreCase(s)) // return date; // else if (integer.name().equalsIgnoreCase(s)) // return integer; // else if (link.name().equalsIgnoreCase(s)) // return link; // else if (relation.name().equalsIgnoreCase(s)) // return relation; // else if (select.name().equalsIgnoreCase(s)) // return select; // else if (s.startsWith("text") || s.startsWith("time")) // return string; // throw new IllegalArgumentException("No Enum specified for this string"); // } // }
import java.io.InputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Vector; import java.util.Map.Entry; import org.apache.log4j.Logger; import fi.mamk.osa.bean.MetaDataElement.MetaDataType;
// Constructor public DataStream(LinkedHashMap<String, MetaDataElement> elements) { this.lhmElements = elements; } public ChecksumType getChecksumType() { return this.eChecksumType; } public void setChecksumType(ChecksumType value) { this.eChecksumType = value; } public ControlGroup getControlGroup() { return this.eControlGroup; } public void setControlGroup(ControlGroup value) { this.eControlGroup = value; } public String getCreateDate() { return this.createDate; } public void setCreateDate(String date) { this.createDate = date; } public String getDataStreamID() { return this.dsID; } public void setDataStreamID(String id) { this.dsID = id; } public LinkedHashMap<String, MetaDataElement> getMetaDataElements() { return this.lhmElements; } public void setMetaDataElements(LinkedHashMap<String, MetaDataElement> elements) { this.lhmElements = elements; } public void setMetaDataElement(MetaDataElement newElement) { if (lhmElements.containsKey(newElement.getName())) { MetaDataElement element = lhmElements.get(newElement.getName()); element.getValues().add(newElement.getValue()); lhmElements.put(newElement.getName(), element); } else { lhmElements.put(newElement.getName(), newElement); } }
// Path: src/fi/mamk/osa/bean/MetaDataElement.java // public static enum MetaDataType { // string, // String // date, // Date // integer, // Integer // link, // // relation, // Object relationships // select; // Enum value // // public static MetaDataType getEnum(String s) { // if (string.name().equalsIgnoreCase(s)) // return string; // else if (date.name().equalsIgnoreCase(s)) // return date; // else if (integer.name().equalsIgnoreCase(s)) // return integer; // else if (link.name().equalsIgnoreCase(s)) // return link; // else if (relation.name().equalsIgnoreCase(s)) // return relation; // else if (select.name().equalsIgnoreCase(s)) // return select; // else if (s.startsWith("text") || s.startsWith("time")) // return string; // throw new IllegalArgumentException("No Enum specified for this string"); // } // } // Path: src/fi/mamk/osa/bean/DataStream.java import java.io.InputStream; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Vector; import java.util.Map.Entry; import org.apache.log4j.Logger; import fi.mamk.osa.bean.MetaDataElement.MetaDataType; // Constructor public DataStream(LinkedHashMap<String, MetaDataElement> elements) { this.lhmElements = elements; } public ChecksumType getChecksumType() { return this.eChecksumType; } public void setChecksumType(ChecksumType value) { this.eChecksumType = value; } public ControlGroup getControlGroup() { return this.eControlGroup; } public void setControlGroup(ControlGroup value) { this.eControlGroup = value; } public String getCreateDate() { return this.createDate; } public void setCreateDate(String date) { this.createDate = date; } public String getDataStreamID() { return this.dsID; } public void setDataStreamID(String id) { this.dsID = id; } public LinkedHashMap<String, MetaDataElement> getMetaDataElements() { return this.lhmElements; } public void setMetaDataElements(LinkedHashMap<String, MetaDataElement> elements) { this.lhmElements = elements; } public void setMetaDataElement(MetaDataElement newElement) { if (lhmElements.containsKey(newElement.getName())) { MetaDataElement element = lhmElements.get(newElement.getName()); element.getValues().add(newElement.getValue()); lhmElements.put(newElement.getName(), element); } else { lhmElements.put(newElement.getName(), newElement); } }
public void setMetaDataElement(String name, String visibleName, String value, MetaDataType eType) {
mikkeliamk/osa
src/fi/mamk/osa/database/sql/mysql/MySQLDataModel.java
// Path: src/fi/mamk/osa/database/sql/DataModel.java // public abstract class DataModel { // // public abstract HashMap<String,String> getResourceColumns(); // public abstract HashMap<String,String> getSimpleTables(); // public abstract HashMap<String,HashMap<String,String>> getComplexTables(); // // } // // Path: src/fi/mamk/osa/database/sql/SQLManager.java // public abstract class SQLManager extends DatabaseManager { // // private static final Logger logger = Logger.getLogger(SQLManager.class); // // public static DataSource dataSource = null; // public static MiniConnectionPoolManager poolManager = null; // // /** // * Get db connection // * @return // * @throws SQLException // */ // public static Connection getConnection() throws SQLException { // if (dataSource != null) { // return dataSource.getConnection(); // } // if (poolManager != null) { // return poolManager.getConnection(); // } // return null; // } // // /** // * Checks the database status. // * // * @return true if database is working properly. // * false if any of needed databases is offline // */ // public abstract boolean testDatabase(); // }
import java.sql.Connection; import java.sql.ResultSet; import java.util.HashMap; import java.util.Vector; import org.apache.log4j.Logger; import fi.mamk.osa.database.sql.DataModel; import fi.mamk.osa.database.sql.SQLManager;
package fi.mamk.osa.database.sql.mysql; //import fi.mamk.osa.bean.OsaResourceBean; /** * A Class that binds xml Schema to a database * @author Jussi Juvén */ public class MySQLDataModel extends DataModel { private static final Logger logger = Logger.getLogger(MySQLDataModel.class); public HashMap<String,String> resourceColumns = new HashMap<String, String>(); public HashMap<String,String> simpleTables = new HashMap<String, String>(); public HashMap<String,HashMap<String,String>> complexTables = new HashMap<String,HashMap<String,String>>(); /** * Default Constructor for a Datamodel * * @param xmlFile xml Schema file to parse * @throws java.lang.Exception */ public MySQLDataModel() throws Exception { // if(!this.loadSchemaFromBean((null))) { // throw new Exception("Unable to load Schema from bean"); // } logger.debug("Checking database..."); if(!this.checkDatabase()) { throw new Exception("database error"); } logger.debug("Database checked. - OK"); } /** * Checks database against loaded Schema. * * @return success * @throws java.lang.Exception */ private boolean checkDatabase() { boolean retval = true; Connection con = null; try {
// Path: src/fi/mamk/osa/database/sql/DataModel.java // public abstract class DataModel { // // public abstract HashMap<String,String> getResourceColumns(); // public abstract HashMap<String,String> getSimpleTables(); // public abstract HashMap<String,HashMap<String,String>> getComplexTables(); // // } // // Path: src/fi/mamk/osa/database/sql/SQLManager.java // public abstract class SQLManager extends DatabaseManager { // // private static final Logger logger = Logger.getLogger(SQLManager.class); // // public static DataSource dataSource = null; // public static MiniConnectionPoolManager poolManager = null; // // /** // * Get db connection // * @return // * @throws SQLException // */ // public static Connection getConnection() throws SQLException { // if (dataSource != null) { // return dataSource.getConnection(); // } // if (poolManager != null) { // return poolManager.getConnection(); // } // return null; // } // // /** // * Checks the database status. // * // * @return true if database is working properly. // * false if any of needed databases is offline // */ // public abstract boolean testDatabase(); // } // Path: src/fi/mamk/osa/database/sql/mysql/MySQLDataModel.java import java.sql.Connection; import java.sql.ResultSet; import java.util.HashMap; import java.util.Vector; import org.apache.log4j.Logger; import fi.mamk.osa.database.sql.DataModel; import fi.mamk.osa.database.sql.SQLManager; package fi.mamk.osa.database.sql.mysql; //import fi.mamk.osa.bean.OsaResourceBean; /** * A Class that binds xml Schema to a database * @author Jussi Juvén */ public class MySQLDataModel extends DataModel { private static final Logger logger = Logger.getLogger(MySQLDataModel.class); public HashMap<String,String> resourceColumns = new HashMap<String, String>(); public HashMap<String,String> simpleTables = new HashMap<String, String>(); public HashMap<String,HashMap<String,String>> complexTables = new HashMap<String,HashMap<String,String>>(); /** * Default Constructor for a Datamodel * * @param xmlFile xml Schema file to parse * @throws java.lang.Exception */ public MySQLDataModel() throws Exception { // if(!this.loadSchemaFromBean((null))) { // throw new Exception("Unable to load Schema from bean"); // } logger.debug("Checking database..."); if(!this.checkDatabase()) { throw new Exception("database error"); } logger.debug("Database checked. - OK"); } /** * Checks database against loaded Schema. * * @return success * @throws java.lang.Exception */ private boolean checkDatabase() { boolean retval = true; Connection con = null; try {
con = SQLManager.dataSource.getConnection();
mikkeliamk/osa
src/fi/mamk/osa/bean/ContentBean.java
// Path: src/fi/mamk/osa/bean/MetaDataElement.java // public static enum MetaDataType { // string, // String // date, // Date // integer, // Integer // link, // // relation, // Object relationships // select; // Enum value // // public static MetaDataType getEnum(String s) { // if (string.name().equalsIgnoreCase(s)) // return string; // else if (date.name().equalsIgnoreCase(s)) // return date; // else if (integer.name().equalsIgnoreCase(s)) // return integer; // else if (link.name().equalsIgnoreCase(s)) // return link; // else if (relation.name().equalsIgnoreCase(s)) // return relation; // else if (select.name().equalsIgnoreCase(s)) // return select; // else if (s.startsWith("text") || s.startsWith("time")) // return string; // throw new IllegalArgumentException("No Enum specified for this string"); // } // }
import org.apache.log4j.Logger; import fi.mamk.osa.bean.MetaDataElement.MetaDataType;
package fi.mamk.osa.bean; /** * Class for content datastream */ public class ContentBean extends DataStream { private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(ContentBean.class); public static final String CONTENT_DSID = "CONTENT"; public static final String CONTENT_LABEL = "Content Record"; private String strContent = "content"; // Constructor public ContentBean(String PID) { super(PID); dsID = ContentBean.CONTENT_DSID; } public void setContent(String value) {
// Path: src/fi/mamk/osa/bean/MetaDataElement.java // public static enum MetaDataType { // string, // String // date, // Date // integer, // Integer // link, // // relation, // Object relationships // select; // Enum value // // public static MetaDataType getEnum(String s) { // if (string.name().equalsIgnoreCase(s)) // return string; // else if (date.name().equalsIgnoreCase(s)) // return date; // else if (integer.name().equalsIgnoreCase(s)) // return integer; // else if (link.name().equalsIgnoreCase(s)) // return link; // else if (relation.name().equalsIgnoreCase(s)) // return relation; // else if (select.name().equalsIgnoreCase(s)) // return select; // else if (s.startsWith("text") || s.startsWith("time")) // return string; // throw new IllegalArgumentException("No Enum specified for this string"); // } // } // Path: src/fi/mamk/osa/bean/ContentBean.java import org.apache.log4j.Logger; import fi.mamk.osa.bean.MetaDataElement.MetaDataType; package fi.mamk.osa.bean; /** * Class for content datastream */ public class ContentBean extends DataStream { private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(ContentBean.class); public static final String CONTENT_DSID = "CONTENT"; public static final String CONTENT_LABEL = "Content Record"; private String strContent = "content"; // Constructor public ContentBean(String PID) { super(PID); dsID = ContentBean.CONTENT_DSID; } public void setContent(String value) {
this.setMetaDataElement(strContent, strContent, value, MetaDataType.string);
mikkeliamk/osa
src/fi/mamk/osa/ui/SearchConfiguration.java
// Path: src/fi/mamk/osa/solr/SolrField.java // public class SolrField implements Serializable { // // private static final long serialVersionUID = 3391525129053148122L; // private String name; // private Integer boost; // private Integer ngramBoost; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Integer getBoost() { // return boost; // } // // public void setBoost(Integer boost) { // this.boost = boost; // } // // public Integer getNgramBoost() { // return ngramBoost; // } // // public void setNgramBoost(Integer ngramBoost) { // this.ngramBoost = ngramBoost; // } // // }
import java.util.Collection; import java.util.Date; import java.util.LinkedHashMap; import java.util.Vector; import fi.mamk.osa.solr.SolrField;
package fi.mamk.osa.ui; public class SearchConfiguration { private LinkedHashMap<String, SearchFormField> searchForm = new LinkedHashMap<String, SearchFormField>();
// Path: src/fi/mamk/osa/solr/SolrField.java // public class SolrField implements Serializable { // // private static final long serialVersionUID = 3391525129053148122L; // private String name; // private Integer boost; // private Integer ngramBoost; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Integer getBoost() { // return boost; // } // // public void setBoost(Integer boost) { // this.boost = boost; // } // // public Integer getNgramBoost() { // return ngramBoost; // } // // public void setNgramBoost(Integer ngramBoost) { // this.ngramBoost = ngramBoost; // } // // } // Path: src/fi/mamk/osa/ui/SearchConfiguration.java import java.util.Collection; import java.util.Date; import java.util.LinkedHashMap; import java.util.Vector; import fi.mamk.osa.solr.SolrField; package fi.mamk.osa.ui; public class SearchConfiguration { private LinkedHashMap<String, SearchFormField> searchForm = new LinkedHashMap<String, SearchFormField>();
private Vector<SolrField> freetextField = new Vector<SolrField>();
mikkeliamk/osa
src/fi/mamk/osa/bean/CaptureBean.java
// Path: src/fi/mamk/osa/bean/MetaDataElement.java // public static enum MetaDataType { // string, // String // date, // Date // integer, // Integer // link, // // relation, // Object relationships // select; // Enum value // // public static MetaDataType getEnum(String s) { // if (string.name().equalsIgnoreCase(s)) // return string; // else if (date.name().equalsIgnoreCase(s)) // return date; // else if (integer.name().equalsIgnoreCase(s)) // return integer; // else if (link.name().equalsIgnoreCase(s)) // return link; // else if (relation.name().equalsIgnoreCase(s)) // return relation; // else if (select.name().equalsIgnoreCase(s)) // return select; // else if (s.startsWith("text") || s.startsWith("time")) // return string; // throw new IllegalArgumentException("No Enum specified for this string"); // } // }
import org.apache.log4j.Logger; import fi.mamk.osa.bean.MetaDataElement.MetaDataType;
/** * Returns the value of isPartOf-relation * @return */ public String getParent() { String parent = null; MetaDataElement element = this.getMetaDataElements().get(CaptureBean.RELATION_IsPartOf); if (element != null) { parent = element.getValue(); } return parent; } public String getPublicityLevel() { String parent = null; MetaDataElement element = this.getMetaDataElements().get(CaptureBean.PUBLICITY_LEVEL); if (element != null) { parent = element.getValue(); } return parent; } /** * set metadata to capture datastream * @param name name of the relation * @param value value of the relation * @param eType type of metadata */
// Path: src/fi/mamk/osa/bean/MetaDataElement.java // public static enum MetaDataType { // string, // String // date, // Date // integer, // Integer // link, // // relation, // Object relationships // select; // Enum value // // public static MetaDataType getEnum(String s) { // if (string.name().equalsIgnoreCase(s)) // return string; // else if (date.name().equalsIgnoreCase(s)) // return date; // else if (integer.name().equalsIgnoreCase(s)) // return integer; // else if (link.name().equalsIgnoreCase(s)) // return link; // else if (relation.name().equalsIgnoreCase(s)) // return relation; // else if (select.name().equalsIgnoreCase(s)) // return select; // else if (s.startsWith("text") || s.startsWith("time")) // return string; // throw new IllegalArgumentException("No Enum specified for this string"); // } // } // Path: src/fi/mamk/osa/bean/CaptureBean.java import org.apache.log4j.Logger; import fi.mamk.osa.bean.MetaDataElement.MetaDataType; /** * Returns the value of isPartOf-relation * @return */ public String getParent() { String parent = null; MetaDataElement element = this.getMetaDataElements().get(CaptureBean.RELATION_IsPartOf); if (element != null) { parent = element.getValue(); } return parent; } public String getPublicityLevel() { String parent = null; MetaDataElement element = this.getMetaDataElements().get(CaptureBean.PUBLICITY_LEVEL); if (element != null) { parent = element.getValue(); } return parent; } /** * set metadata to capture datastream * @param name name of the relation * @param value value of the relation * @param eType type of metadata */
public void setMetaDataElement(String name, String visibleName, String value, MetaDataType eType) {
mikkeliamk/osa
src/fi/mamk/osa/ui/SearchFormField.java
// Path: src/fi/mamk/osa/solr/SolrField.java // public class SolrField implements Serializable { // // private static final long serialVersionUID = 3391525129053148122L; // private String name; // private Integer boost; // private Integer ngramBoost; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Integer getBoost() { // return boost; // } // // public void setBoost(Integer boost) { // this.boost = boost; // } // // public Integer getNgramBoost() { // return ngramBoost; // } // // public void setNgramBoost(Integer ngramBoost) { // this.ngramBoost = ngramBoost; // } // // }
import java.io.Serializable; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Vector; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import fi.mamk.osa.solr.SolrField;
package fi.mamk.osa.ui; /**A Class to wrap a field in search form * * @author JJuven * */ public class SearchFormField implements Serializable { private static final long serialVersionUID = 4939420544493749919L; public static enum Type {textarea,text,select,date,radio,checkbox,hidden,custom_yearslider}; private String name; private Type type; private String messageKey; private boolean editable = true; private boolean required = false; private boolean generated = false; private boolean visible = true; private boolean autocomplete = false; private Vector<FormOption> options = null; private LinkedHashMap<String, SearchFormField> subFields = new LinkedHashMap<String, SearchFormField>();
// Path: src/fi/mamk/osa/solr/SolrField.java // public class SolrField implements Serializable { // // private static final long serialVersionUID = 3391525129053148122L; // private String name; // private Integer boost; // private Integer ngramBoost; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Integer getBoost() { // return boost; // } // // public void setBoost(Integer boost) { // this.boost = boost; // } // // public Integer getNgramBoost() { // return ngramBoost; // } // // public void setNgramBoost(Integer ngramBoost) { // this.ngramBoost = ngramBoost; // } // // } // Path: src/fi/mamk/osa/ui/SearchFormField.java import java.io.Serializable; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Vector; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import fi.mamk.osa.solr.SolrField; package fi.mamk.osa.ui; /**A Class to wrap a field in search form * * @author JJuven * */ public class SearchFormField implements Serializable { private static final long serialVersionUID = 4939420544493749919L; public static enum Type {textarea,text,select,date,radio,checkbox,hidden,custom_yearslider}; private String name; private Type type; private String messageKey; private boolean editable = true; private boolean required = false; private boolean generated = false; private boolean visible = true; private boolean autocomplete = false; private Vector<FormOption> options = null; private LinkedHashMap<String, SearchFormField> subFields = new LinkedHashMap<String, SearchFormField>();
private Vector<SolrField> solrFields = new Vector<SolrField>();
mikkeliamk/osa
src/fi/mamk/osa/auth/AuthenticationManager.java
// Path: src/fi/mamk/osa/auth/LdapManager.java // public static enum EntryType { // USER, // ROLE // }
import java.util.HashMap; import java.util.List; import java.util.Vector; import fi.mamk.osa.auth.LdapManager.EntryType;
return status; } public boolean updateUser(String dn, String organization, String userGroup, Vector<String> fedoraRoles) { return false; } public boolean resetUserPassword(String usrDn, String pw) { return false; } public boolean createGroup(String groupName, String groupOrganization){ boolean status = false; return status; } public boolean createRole(String roleName, String roleOrganization, Vector<AccessRight> accessRights){ boolean status = false; return status; } public boolean updateRole(String dn, String roleName, Vector<AccessRight> accessrights) { return false; } public boolean createOrganization(String oName, String oDesc, String confFile, String afName, String alName, String aMail, String contact, String displayName){ boolean status = false; return status; } public List<User> getUsers(String organization){ return null; } public String modifyAttributes(String dn, String jsonmod){ String result = ""; return result; }
// Path: src/fi/mamk/osa/auth/LdapManager.java // public static enum EntryType { // USER, // ROLE // } // Path: src/fi/mamk/osa/auth/AuthenticationManager.java import java.util.HashMap; import java.util.List; import java.util.Vector; import fi.mamk.osa.auth.LdapManager.EntryType; return status; } public boolean updateUser(String dn, String organization, String userGroup, Vector<String> fedoraRoles) { return false; } public boolean resetUserPassword(String usrDn, String pw) { return false; } public boolean createGroup(String groupName, String groupOrganization){ boolean status = false; return status; } public boolean createRole(String roleName, String roleOrganization, Vector<AccessRight> accessRights){ boolean status = false; return status; } public boolean updateRole(String dn, String roleName, Vector<AccessRight> accessrights) { return false; } public boolean createOrganization(String oName, String oDesc, String confFile, String afName, String alName, String aMail, String contact, String displayName){ boolean status = false; return status; } public List<User> getUsers(String organization){ return null; } public String modifyAttributes(String dn, String jsonmod){ String result = ""; return result; }
public void deleteEntry(String dn, EntryType entryType) {
drifted-in/planisphere-core
src/main/java/in/drifted/planisphere/resources/loader/MilkyWayLoader.java
// Path: src/main/java/in/drifted/planisphere/model/Coord.java // public final class Coord { // // private Double x; // private Double y; // // public Coord() { // } // // public Coord(Double x, Double y) { // this.x = x; // this.y = y; // } // // public void setLocation(Double x, Double y) { // this.x = x; // this.y = y; // } // // public Double getX() { // return x; // } // // public Double getY() { // return y; // } // } // // Path: src/main/java/in/drifted/planisphere/model/MilkyWay.java // public final class MilkyWay { // // private List<Coord> darkNorth; // private List<Coord> darkSouth; // private List<Coord> brightNorth; // private List<Coord> brightSouth; // // public List<Coord> getDarkNorth() { // return darkNorth; // } // // public void setDarkNorth(List<Coord> darkNorth) { // this.darkNorth = darkNorth; // } // // public List<Coord> getDarkSouth() { // return darkSouth; // } // // public void setDarkSouth(List<Coord> darkSouth) { // this.darkSouth = darkSouth; // } // // public List<Coord> getBrightNorth() { // return brightNorth; // } // // public void setBrightNorth(List<Coord> brightNorth) { // this.brightNorth = brightNorth; // } // // public List<Coord> getBrightSouth() { // return brightSouth; // } // // public void setBrightSouth(List<Coord> brightSouth) { // this.brightSouth = brightSouth; // } // }
import in.drifted.planisphere.model.Coord; import in.drifted.planisphere.model.MilkyWay; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.List;
/* * Copyright (c) 2012-present Jan Tošovský <jan.tosovsky.cz@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package in.drifted.planisphere.resources.loader; public final class MilkyWayLoader { public static MilkyWay getMilkyWay(List<String> filePathList) throws IOException { MilkyWay milkyWay = new MilkyWay(); int i = 0; Double ngp = Math.toRadians(27.4); for (String filePath : filePathList) {
// Path: src/main/java/in/drifted/planisphere/model/Coord.java // public final class Coord { // // private Double x; // private Double y; // // public Coord() { // } // // public Coord(Double x, Double y) { // this.x = x; // this.y = y; // } // // public void setLocation(Double x, Double y) { // this.x = x; // this.y = y; // } // // public Double getX() { // return x; // } // // public Double getY() { // return y; // } // } // // Path: src/main/java/in/drifted/planisphere/model/MilkyWay.java // public final class MilkyWay { // // private List<Coord> darkNorth; // private List<Coord> darkSouth; // private List<Coord> brightNorth; // private List<Coord> brightSouth; // // public List<Coord> getDarkNorth() { // return darkNorth; // } // // public void setDarkNorth(List<Coord> darkNorth) { // this.darkNorth = darkNorth; // } // // public List<Coord> getDarkSouth() { // return darkSouth; // } // // public void setDarkSouth(List<Coord> darkSouth) { // this.darkSouth = darkSouth; // } // // public List<Coord> getBrightNorth() { // return brightNorth; // } // // public void setBrightNorth(List<Coord> brightNorth) { // this.brightNorth = brightNorth; // } // // public List<Coord> getBrightSouth() { // return brightSouth; // } // // public void setBrightSouth(List<Coord> brightSouth) { // this.brightSouth = brightSouth; // } // } // Path: src/main/java/in/drifted/planisphere/resources/loader/MilkyWayLoader.java import in.drifted.planisphere.model.Coord; import in.drifted.planisphere.model.MilkyWay; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.List; /* * Copyright (c) 2012-present Jan Tošovský <jan.tosovsky.cz@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package in.drifted.planisphere.resources.loader; public final class MilkyWayLoader { public static MilkyWay getMilkyWay(List<String> filePathList) throws IOException { MilkyWay milkyWay = new MilkyWay(); int i = 0; Double ngp = Math.toRadians(27.4); for (String filePath : filePathList) {
List<Coord> dataSet = new LinkedList<>();
drifted-in/planisphere-core
src/main/java/in/drifted/planisphere/renderer/svg/PathUtil.java
// Path: src/main/java/in/drifted/planisphere/model/Coord.java // public final class Coord { // // private Double x; // private Double y; // // public Coord() { // } // // public Coord(Double x, Double y) { // this.x = x; // this.y = y; // } // // public void setLocation(Double x, Double y) { // this.x = x; // this.y = y; // } // // public Double getX() { // return x; // } // // public Double getY() { // return y; // } // }
import in.drifted.planisphere.model.Coord; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.NumberFormat; import java.util.List; import java.util.Locale;
/* * Copyright (c) 2012-present Jan Tošovský <jan.tosovsky.cz@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package in.drifted.planisphere.renderer.svg; public class PathUtil { private static final NumberFormat NUMBER_FORMAT = new DecimalFormat("###.##", new DecimalFormatSymbols(Locale.ENGLISH));
// Path: src/main/java/in/drifted/planisphere/model/Coord.java // public final class Coord { // // private Double x; // private Double y; // // public Coord() { // } // // public Coord(Double x, Double y) { // this.x = x; // this.y = y; // } // // public void setLocation(Double x, Double y) { // this.x = x; // this.y = y; // } // // public Double getX() { // return x; // } // // public Double getY() { // return y; // } // } // Path: src/main/java/in/drifted/planisphere/renderer/svg/PathUtil.java import in.drifted.planisphere.model.Coord; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.NumberFormat; import java.util.List; import java.util.Locale; /* * Copyright (c) 2012-present Jan Tošovský <jan.tosovsky.cz@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package in.drifted.planisphere.renderer.svg; public class PathUtil { private static final NumberFormat NUMBER_FORMAT = new DecimalFormat("###.##", new DecimalFormatSymbols(Locale.ENGLISH));
public static String getPathData(List<Coord> coordList, Boolean append) {
drifted-in/planisphere-core
src/main/java/in/drifted/planisphere/Settings.java
// Path: src/main/java/in/drifted/planisphere/util/ResourceUtil.java // public class ResourceUtil { // // public static Collection<String> getResourceCollection(Class clazz, String path) throws IOException { // // Collection<String> resourceCollection = new HashSet<>(); // // URL dirUrl = clazz.getResource(path); // // if (dirUrl == null) { // // try ( // InputStream in = ResourceUtil.class.getResourceAsStream(path); // BufferedReader br = new BufferedReader(new InputStreamReader(in))) { // // String line; // while ((line = br.readLine()) != null) { // resourceCollection.add(line); // } // } // // } else { // // switch (dirUrl.getProtocol()) { // // case "file": // try { // resourceCollection.addAll(Arrays.asList(new File(dirUrl.toURI()).list())); // // } catch (URISyntaxException e) { // throw new IOException(e); // } // break; // // case "jar": // String jarPath = dirUrl.getPath().substring(5, dirUrl.getPath().indexOf("!")); // JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8")); // Enumeration<JarEntry> entries = jar.entries(); // while (entries.hasMoreElements()) { // String name = "/" + entries.nextElement().getName(); // if (name.startsWith(path)) { // resourceCollection.add(name.substring(path.length() + 1)); // } // } // } // } // // return resourceCollection; // } // }
import in.drifted.planisphere.util.ResourceUtil; import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; import java.util.TreeSet;
Collection<String> templateNameCollection = new HashSet<>(); templateNameCollection.addAll(getTemplateNameCollection(MEDIA_PRINT)); templateNameCollection.addAll(getTemplateNameCollection(MEDIA_SCREEN)); return templateNameCollection; } public static Collection<String> getTemplateNameCollection(String media) throws IOException { Collection<String> templateNameCollection = new HashSet<>(); Properties templatesProperties = new Properties(); templatesProperties.load(Settings.class.getResourceAsStream(Settings.FILE_PATH_TEMPLATES_PROPERTIES)); String templateSpec = templatesProperties.getProperty(media).replace("_mode", ""); if (templateSpec.contains("|")) { templateNameCollection = Arrays.asList(templateSpec.split("\\|")); } else { templateNameCollection.add(templateSpec); } return templateNameCollection; } public static Collection<String> getColorSchemeCollection(String templateName) throws IOException { Collection<String> colorSchemeCollection = new HashSet<>();
// Path: src/main/java/in/drifted/planisphere/util/ResourceUtil.java // public class ResourceUtil { // // public static Collection<String> getResourceCollection(Class clazz, String path) throws IOException { // // Collection<String> resourceCollection = new HashSet<>(); // // URL dirUrl = clazz.getResource(path); // // if (dirUrl == null) { // // try ( // InputStream in = ResourceUtil.class.getResourceAsStream(path); // BufferedReader br = new BufferedReader(new InputStreamReader(in))) { // // String line; // while ((line = br.readLine()) != null) { // resourceCollection.add(line); // } // } // // } else { // // switch (dirUrl.getProtocol()) { // // case "file": // try { // resourceCollection.addAll(Arrays.asList(new File(dirUrl.toURI()).list())); // // } catch (URISyntaxException e) { // throw new IOException(e); // } // break; // // case "jar": // String jarPath = dirUrl.getPath().substring(5, dirUrl.getPath().indexOf("!")); // JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8")); // Enumeration<JarEntry> entries = jar.entries(); // while (entries.hasMoreElements()) { // String name = "/" + entries.nextElement().getName(); // if (name.startsWith(path)) { // resourceCollection.add(name.substring(path.length() + 1)); // } // } // } // } // // return resourceCollection; // } // } // Path: src/main/java/in/drifted/planisphere/Settings.java import in.drifted.planisphere.util.ResourceUtil; import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; import java.util.TreeSet; Collection<String> templateNameCollection = new HashSet<>(); templateNameCollection.addAll(getTemplateNameCollection(MEDIA_PRINT)); templateNameCollection.addAll(getTemplateNameCollection(MEDIA_SCREEN)); return templateNameCollection; } public static Collection<String> getTemplateNameCollection(String media) throws IOException { Collection<String> templateNameCollection = new HashSet<>(); Properties templatesProperties = new Properties(); templatesProperties.load(Settings.class.getResourceAsStream(Settings.FILE_PATH_TEMPLATES_PROPERTIES)); String templateSpec = templatesProperties.getProperty(media).replace("_mode", ""); if (templateSpec.contains("|")) { templateNameCollection = Arrays.asList(templateSpec.split("\\|")); } else { templateNameCollection.add(templateSpec); } return templateNameCollection; } public static Collection<String> getColorSchemeCollection(String templateName) throws IOException { Collection<String> colorSchemeCollection = new HashSet<>();
for (String fileName : ResourceUtil.getResourceCollection(Settings.class, "/in/drifted/planisphere/resources/templates/core")) {
drifted-in/planisphere-core
src/main/java/in/drifted/planisphere/resources/loader/ConstellationNameListLoader.java
// Path: src/main/java/in/drifted/planisphere/model/ConstellationName.java // public final class ConstellationName { // // private final String id; // private final String abbreviation; // private final String latin; // private final Coord coord; // // public ConstellationName(String abbreviation, String latin, Coord coord) { // this.abbreviation = abbreviation; // this.latin = latin; // this.id = generateId(latin); // this.coord = coord; // } // // private String generateId(String name) { // String[] fragments = name.split(" "); // StringBuilder strId = new StringBuilder(); // for (int i = 0; i < fragments.length; i++) { // String candidate = fragments[i].toLowerCase(); // if (i > 0) { // candidate = candidate.substring(0, 1).toUpperCase() + candidate.substring(1); // } // strId.append(candidate); // } // return strId.toString(); // } // // public String getId() { // return id; // } // // public String getAbbreviation() { // return this.abbreviation; // } // // public Coord getCoord() { // return this.coord; // } // // public String getLatin() { // return this.latin; // } // } // // Path: src/main/java/in/drifted/planisphere/model/Coord.java // public final class Coord { // // private Double x; // private Double y; // // public Coord() { // } // // public Coord(Double x, Double y) { // this.x = x; // this.y = y; // } // // public void setLocation(Double x, Double y) { // this.x = x; // this.y = y; // } // // public Double getX() { // return x; // } // // public Double getY() { // return y; // } // }
import in.drifted.planisphere.model.ConstellationName; import in.drifted.planisphere.model.Coord; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List;
/* * Copyright (c) 2012-present Jan Tošovský <jan.tosovsky.cz@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package in.drifted.planisphere.resources.loader; public final class ConstellationNameListLoader { public static List<ConstellationName> getConstellationNameList(String filePath) throws IOException { List<ConstellationName> constellationNameList = new ArrayList<>(); try ( InputStream inputStream = ConstellationNameListLoader.class.getResourceAsStream(filePath); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"))) { String strLine; while ((strLine = reader.readLine()) != null) { if (!strLine.isEmpty() && !strLine.startsWith("#")) { String[] values = strLine.split(",");
// Path: src/main/java/in/drifted/planisphere/model/ConstellationName.java // public final class ConstellationName { // // private final String id; // private final String abbreviation; // private final String latin; // private final Coord coord; // // public ConstellationName(String abbreviation, String latin, Coord coord) { // this.abbreviation = abbreviation; // this.latin = latin; // this.id = generateId(latin); // this.coord = coord; // } // // private String generateId(String name) { // String[] fragments = name.split(" "); // StringBuilder strId = new StringBuilder(); // for (int i = 0; i < fragments.length; i++) { // String candidate = fragments[i].toLowerCase(); // if (i > 0) { // candidate = candidate.substring(0, 1).toUpperCase() + candidate.substring(1); // } // strId.append(candidate); // } // return strId.toString(); // } // // public String getId() { // return id; // } // // public String getAbbreviation() { // return this.abbreviation; // } // // public Coord getCoord() { // return this.coord; // } // // public String getLatin() { // return this.latin; // } // } // // Path: src/main/java/in/drifted/planisphere/model/Coord.java // public final class Coord { // // private Double x; // private Double y; // // public Coord() { // } // // public Coord(Double x, Double y) { // this.x = x; // this.y = y; // } // // public void setLocation(Double x, Double y) { // this.x = x; // this.y = y; // } // // public Double getX() { // return x; // } // // public Double getY() { // return y; // } // } // Path: src/main/java/in/drifted/planisphere/resources/loader/ConstellationNameListLoader.java import in.drifted.planisphere.model.ConstellationName; import in.drifted.planisphere.model.Coord; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; /* * Copyright (c) 2012-present Jan Tošovský <jan.tosovsky.cz@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package in.drifted.planisphere.resources.loader; public final class ConstellationNameListLoader { public static List<ConstellationName> getConstellationNameList(String filePath) throws IOException { List<ConstellationName> constellationNameList = new ArrayList<>(); try ( InputStream inputStream = ConstellationNameListLoader.class.getResourceAsStream(filePath); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"))) { String strLine; while ((strLine = reader.readLine()) != null) { if (!strLine.isEmpty() && !strLine.startsWith("#")) { String[] values = strLine.split(",");
Coord coord = new Coord(Double.parseDouble(values[0]) / 1000.0, Double.parseDouble(values[1]) / 100.0);
drifted-in/planisphere-core
src/main/java/in/drifted/planisphere/renderer/svg/BezierCircle.java
// Path: src/main/java/in/drifted/planisphere/model/Coord.java // public final class Coord { // // private Double x; // private Double y; // // public Coord() { // } // // public Coord(Double x, Double y) { // this.x = x; // this.y = y; // } // // public void setLocation(Double x, Double y) { // this.x = x; // this.y = y; // } // // public Double getX() { // return x; // } // // public Double getY() { // return y; // } // }
import in.drifted.planisphere.model.Coord; import java.util.Iterator; import java.util.LinkedList; import java.util.List;
/* * Copyright (c) 2012-present Jan Tošovský <jan.tosovsky.cz@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package in.drifted.planisphere.renderer.svg; public final class BezierCircle { private static final Double KAPPA = 0.5522847498;
// Path: src/main/java/in/drifted/planisphere/model/Coord.java // public final class Coord { // // private Double x; // private Double y; // // public Coord() { // } // // public Coord(Double x, Double y) { // this.x = x; // this.y = y; // } // // public void setLocation(Double x, Double y) { // this.x = x; // this.y = y; // } // // public Double getX() { // return x; // } // // public Double getY() { // return y; // } // } // Path: src/main/java/in/drifted/planisphere/renderer/svg/BezierCircle.java import in.drifted.planisphere.model.Coord; import java.util.Iterator; import java.util.LinkedList; import java.util.List; /* * Copyright (c) 2012-present Jan Tošovský <jan.tosovsky.cz@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package in.drifted.planisphere.renderer.svg; public final class BezierCircle { private static final Double KAPPA = 0.5522847498;
private final List<Coord> pointList = new LinkedList<>();
drifted-in/planisphere-core
src/main/java/in/drifted/planisphere/util/SubsetUtil.java
// Path: src/main/java/in/drifted/planisphere/l10n/LocalizationUtil.java // public final class LocalizationUtil { // // private static final String LOCALE_BUNDLE = "in.drifted.planisphere.resources.localizations.messages"; // private static final Control UNICODE_CONTROL = new UnicodeControl(); // private ResourceBundle resources; // private ResourceBundle resourcesFallback; // // public LocalizationUtil(Locale locale) { // // try { // resources = ResourceBundle.getBundle(LOCALE_BUNDLE, locale, UNICODE_CONTROL); // resourcesFallback = ResourceBundle.getBundle(LOCALE_BUNDLE, Locale.ENGLISH, UNICODE_CONTROL); // // } catch (MissingResourceException e) { // resources = ResourceBundle.getBundle(LOCALE_BUNDLE, Locale.ENGLISH, UNICODE_CONTROL); // resourcesFallback = resources; // } // } // // public Collection<String> getKeyCollection() { // return resources.keySet(); // } // // public String getValue(String key) { // switch (key) { // case "year": // return String.valueOf(Calendar.getInstance().get(Calendar.YEAR)); // default: // if (resources.containsKey(key)) { // return resources.getString(key); // } else if (resourcesFallback.containsKey(key)) { // return resourcesFallback.getString(key); // } else { // return key; // } // } // } // // public String getValue(String key, Double latitude) { // switch (key) { // case "latitudeValue": // String strNorth = getValue("cardinalPointNorth"); // String strSouth = getValue("cardinalPointSouth"); // return Math.abs(latitude.intValue()) + " " + ((latitude < 0) ? strSouth : strNorth); // default: // return getValue(key); // } // } // // public String translate(String content, Double latitude) { // String[] chunksRaw = content.split("\\$\\{"); // if (chunksRaw.length <= 1) { // return content; // } // List<String> chunkList = new LinkedList<>(); // for (String chunk : chunksRaw) { // if (!chunk.contains("}")) { // if (chunk.length() > 0) { // chunkList.add(chunk); // } // } else { // int index = chunk.indexOf("}"); // String key = chunk.substring(0, index); // chunkList.add(getValue(key, latitude)); // if (index != chunk.length() - 1) { // chunkList.add(chunk.substring(index + 1)); // } // } // } // // StringBuilder contentUpdated = new StringBuilder(); // for (String chunk : chunkList) { // contentUpdated.append(chunk); // } // // return contentUpdated.toString(); // } // }
import in.drifted.planisphere.l10n.LocalizationUtil; import java.text.DateFormatSymbols; import java.util.Collection; import java.util.HashSet; import java.util.Locale;
/* * Copyright (c) 2012-present Jan Tošovský <jan.tosovsky.cz@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package in.drifted.planisphere.util; public class SubsetUtil { public static String getFontForgeSelectionScript(Locale locale) { /* Method Used for subsetting this huge font for non-latin languages: https://github.com/android/platform_frameworks_base/blob/master/data/fonts/DroidSansFallback.ttf 1. Generate script and copy it from e.g. debug window into the clipboard 2. Open FontForge | File | Open... and choose DroidSansFallback.ttf 3. Choose File | Execute script... 4. Insert the script to the dialog area and press Ok 5. Choose Edit | Selection | Invert Selection 6. Choose Encoding | Detach & Remove glyphs... (removing glyphs takes quite long) 7. Choose Element | Font Info... | OS/2 | Misc. | Embeddable and select 'Installable Font' 8. Choose File | Generate Fonts... 9. Store the final file in the following path: \in\drifted\planisphere\core\src\main\resources\in\drifted\planisphere\resources\fonts\droid-sans-[locale].ttf */ StringBuilder sb = new StringBuilder("Select(32, 127)\n"); for (Integer codePoint : getCodePointCollection(locale)) { sb.append("SelectMoreSingletons("); sb.append(codePoint); sb.append(")\n"); } return sb.toString(); } private static Collection<Integer> getCodePointCollection(Locale locale) { Collection<Integer> codePointCollection = new HashSet<>();
// Path: src/main/java/in/drifted/planisphere/l10n/LocalizationUtil.java // public final class LocalizationUtil { // // private static final String LOCALE_BUNDLE = "in.drifted.planisphere.resources.localizations.messages"; // private static final Control UNICODE_CONTROL = new UnicodeControl(); // private ResourceBundle resources; // private ResourceBundle resourcesFallback; // // public LocalizationUtil(Locale locale) { // // try { // resources = ResourceBundle.getBundle(LOCALE_BUNDLE, locale, UNICODE_CONTROL); // resourcesFallback = ResourceBundle.getBundle(LOCALE_BUNDLE, Locale.ENGLISH, UNICODE_CONTROL); // // } catch (MissingResourceException e) { // resources = ResourceBundle.getBundle(LOCALE_BUNDLE, Locale.ENGLISH, UNICODE_CONTROL); // resourcesFallback = resources; // } // } // // public Collection<String> getKeyCollection() { // return resources.keySet(); // } // // public String getValue(String key) { // switch (key) { // case "year": // return String.valueOf(Calendar.getInstance().get(Calendar.YEAR)); // default: // if (resources.containsKey(key)) { // return resources.getString(key); // } else if (resourcesFallback.containsKey(key)) { // return resourcesFallback.getString(key); // } else { // return key; // } // } // } // // public String getValue(String key, Double latitude) { // switch (key) { // case "latitudeValue": // String strNorth = getValue("cardinalPointNorth"); // String strSouth = getValue("cardinalPointSouth"); // return Math.abs(latitude.intValue()) + " " + ((latitude < 0) ? strSouth : strNorth); // default: // return getValue(key); // } // } // // public String translate(String content, Double latitude) { // String[] chunksRaw = content.split("\\$\\{"); // if (chunksRaw.length <= 1) { // return content; // } // List<String> chunkList = new LinkedList<>(); // for (String chunk : chunksRaw) { // if (!chunk.contains("}")) { // if (chunk.length() > 0) { // chunkList.add(chunk); // } // } else { // int index = chunk.indexOf("}"); // String key = chunk.substring(0, index); // chunkList.add(getValue(key, latitude)); // if (index != chunk.length() - 1) { // chunkList.add(chunk.substring(index + 1)); // } // } // } // // StringBuilder contentUpdated = new StringBuilder(); // for (String chunk : chunkList) { // contentUpdated.append(chunk); // } // // return contentUpdated.toString(); // } // } // Path: src/main/java/in/drifted/planisphere/util/SubsetUtil.java import in.drifted.planisphere.l10n.LocalizationUtil; import java.text.DateFormatSymbols; import java.util.Collection; import java.util.HashSet; import java.util.Locale; /* * Copyright (c) 2012-present Jan Tošovský <jan.tosovsky.cz@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package in.drifted.planisphere.util; public class SubsetUtil { public static String getFontForgeSelectionScript(Locale locale) { /* Method Used for subsetting this huge font for non-latin languages: https://github.com/android/platform_frameworks_base/blob/master/data/fonts/DroidSansFallback.ttf 1. Generate script and copy it from e.g. debug window into the clipboard 2. Open FontForge | File | Open... and choose DroidSansFallback.ttf 3. Choose File | Execute script... 4. Insert the script to the dialog area and press Ok 5. Choose Edit | Selection | Invert Selection 6. Choose Encoding | Detach & Remove glyphs... (removing glyphs takes quite long) 7. Choose Element | Font Info... | OS/2 | Misc. | Embeddable and select 'Installable Font' 8. Choose File | Generate Fonts... 9. Store the final file in the following path: \in\drifted\planisphere\core\src\main\resources\in\drifted\planisphere\resources\fonts\droid-sans-[locale].ttf */ StringBuilder sb = new StringBuilder("Select(32, 127)\n"); for (Integer codePoint : getCodePointCollection(locale)) { sb.append("SelectMoreSingletons("); sb.append(codePoint); sb.append(")\n"); } return sb.toString(); } private static Collection<Integer> getCodePointCollection(Locale locale) { Collection<Integer> codePointCollection = new HashSet<>();
LocalizationUtil localizationUtil = new LocalizationUtil(locale);
googleinterns/cloudsearch-ai
indexer/ai/src/test/java/com/google/cloudsearch/ai/TestCategoryExtractionSkill.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.FileReader; import java.io.IOException;
} return schema; } /** * Returns the skill configuration file based on input configName. * @param configName * @return */ private JSONObject getTestConfig(String configName) { JSONParser parser = new JSONParser(); JSONObject config = null; try { config = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/CategoryExtraction/"+configName+".json")); for(Object obj : (JSONArray)config.get("aiSkillSet")) { return (JSONObject) obj; } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } /** * Test the behaviour when the skill config has an empty skill name. * @throws InvalidConfigException */ @Test
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/test/java/com/google/cloudsearch/ai/TestCategoryExtractionSkill.java import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.FileReader; import java.io.IOException; } return schema; } /** * Returns the skill configuration file based on input configName. * @param configName * @return */ private JSONObject getTestConfig(String configName) { JSONParser parser = new JSONParser(); JSONObject config = null; try { config = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/CategoryExtraction/"+configName+".json")); for(Object obj : (JSONArray)config.get("aiSkillSet")) { return (JSONObject) obj; } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } /** * Test the behaviour when the skill config has an empty skill name. * @throws InvalidConfigException */ @Test
public void testParse() throws InvalidConfigException {
googleinterns/cloudsearch-ai
indexer/ai/src/main/java/com/google/cloudsearch/ai/StandardSkillCategoryExtraction.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloud.language.v1.*; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.Multimap; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger;
package com.google.cloudsearch.ai; /** * Class StandardSkillCategoryExtraction implements the methods required for * invoking Natural Language API's Category extraction and populating the * structured Data for CloudSearch. */ class StandardSkillCategoryExtraction extends BaseAISkill { private String inputLanguage = ""; private double categoryConfidence = 0.0; LanguageServiceClient languageService; private Logger log = Logger.getLogger(StandardSkillCategoryExtraction.class.getName()); /** * Constructor * @param aiSkill The JSON Object in Configuration containing Category Extraction skill * related information. * @param schema The CloudSearch Schema. * @throws InvalidConfigException */
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/StandardSkillCategoryExtraction.java import com.google.cloud.language.v1.*; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.Multimap; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger; package com.google.cloudsearch.ai; /** * Class StandardSkillCategoryExtraction implements the methods required for * invoking Natural Language API's Category extraction and populating the * structured Data for CloudSearch. */ class StandardSkillCategoryExtraction extends BaseAISkill { private String inputLanguage = ""; private double categoryConfidence = 0.0; LanguageServiceClient languageService; private Logger log = Logger.getLogger(StandardSkillCategoryExtraction.class.getName()); /** * Constructor * @param aiSkill The JSON Object in Configuration containing Category Extraction skill * related information. * @param schema The CloudSearch Schema. * @throws InvalidConfigException */
public StandardSkillCategoryExtraction(JSONObject aiSkill, JSONObject schema) throws InvalidConfigException {
googleinterns/cloudsearch-ai
indexer/ai/src/main/java/com/google/cloudsearch/ai/AISkill.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import java.util.List; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.Multimap; import org.json.simple.JSONArray; import org.json.simple.JSONObject;
package com.google.cloudsearch.ai; /** Interface for all Skills. */ public interface AISkill { public void setAISkillName(String aiSkillName); public String getAISkillName();
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/AISkill.java import java.util.List; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.Multimap; import org.json.simple.JSONArray; import org.json.simple.JSONObject; package com.google.cloudsearch.ai; /** Interface for all Skills. */ public interface AISkill { public void setAISkillName(String aiSkillName); public String getAISkillName();
public void parseAISkillName(String aiSkillName) throws InvalidConfigException;
googleinterns/cloudsearch-ai
indexer/ai/src/main/java/com/google/cloudsearch/ai/CustomSkill.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.Multimap; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import org.apache.log4j.Logger;
package com.google.cloudsearch.ai; /** * Class Custom Skill provides the support for invoking * custom function written in Cloud Functions. */ public class CustomSkill extends BaseAISkill { private JSONObject input = new JSONObject(); private String cloudFunctionURL = ""; HttpURLConnection connection; private Logger log = Logger.getLogger(StandardSkillCategoryExtraction.class.getName()); /** * Constructor * @param aiSkill The JSON Object in Configuration containing Category Extraction skill related * information. * @param schema The CloudSearch Schema. * @throws InvalidConfigException */
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/CustomSkill.java import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.Multimap; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import org.apache.log4j.Logger; package com.google.cloudsearch.ai; /** * Class Custom Skill provides the support for invoking * custom function written in Cloud Functions. */ public class CustomSkill extends BaseAISkill { private JSONObject input = new JSONObject(); private String cloudFunctionURL = ""; HttpURLConnection connection; private Logger log = Logger.getLogger(StandardSkillCategoryExtraction.class.getName()); /** * Constructor * @param aiSkill The JSON Object in Configuration containing Category Extraction skill related * information. * @param schema The CloudSearch Schema. * @throws InvalidConfigException */
public CustomSkill(JSONObject aiSkill, JSONObject schema) throws InvalidConfigException {
googleinterns/cloudsearch-ai
indexer/ai/src/test/java/com/google/cloudsearch/ai/TestAISkillDriver.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.IOException; import org.json.simple.parser.ParseException;
package com.google.cloudsearch.ai; /** * Test AI Skill Driver */ public class TestAISkillDriver { @Rule public final ExpectedException exception = ExpectedException.none(); /** * Test the behaviour of the initialize() function using non-existing files or * Invalid file names. * @throws Exception */ @Test public void testInitializeInvalidFileName() throws Exception { exception.expect(IOException.class); AISkillDriver.initialize("file1", "file2"); } /** * Test the behaviour of the initialize() function for a non JSON file. * @throws Exception */ @Test public void testInitializeInvalidFileType() throws Exception { exception.expect(ParseException.class); String file_path = "./src/test/java/com/google/cloudsearch/ai/testFiles/AISkillDriver/NonJSONFile.txt"; AISkillDriver.initialize(file_path, file_path); } /** * Test the behaviour of initialize() function for Invalid JSON file. * @throws Exception */ @Test public void testInitializeInvalidJSONFile() throws Exception {
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/test/java/com/google/cloudsearch/ai/TestAISkillDriver.java import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.IOException; import org.json.simple.parser.ParseException; package com.google.cloudsearch.ai; /** * Test AI Skill Driver */ public class TestAISkillDriver { @Rule public final ExpectedException exception = ExpectedException.none(); /** * Test the behaviour of the initialize() function using non-existing files or * Invalid file names. * @throws Exception */ @Test public void testInitializeInvalidFileName() throws Exception { exception.expect(IOException.class); AISkillDriver.initialize("file1", "file2"); } /** * Test the behaviour of the initialize() function for a non JSON file. * @throws Exception */ @Test public void testInitializeInvalidFileType() throws Exception { exception.expect(ParseException.class); String file_path = "./src/test/java/com/google/cloudsearch/ai/testFiles/AISkillDriver/NonJSONFile.txt"; AISkillDriver.initialize(file_path, file_path); } /** * Test the behaviour of initialize() function for Invalid JSON file. * @throws Exception */ @Test public void testInitializeInvalidJSONFile() throws Exception {
exception.expect(InvalidConfigException.class);
googleinterns/cloudsearch-ai
indexer/ai/src/test/java/com/google/cloudsearch/ai/TestEntityExtractionSkill.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.FileReader; import java.io.IOException;
} return schema; } /** * Returns the skill configuration file based on input configName. * @param configName * @return */ private JSONObject getTestConfig(String configName) { JSONParser parser = new JSONParser(); JSONObject config = null; try { config = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/EntityExtraction/"+configName+".json")); for(Object obj : (JSONArray)config.get("aiSkillSet")) { return (JSONObject) obj; } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } /** * Test the behaviour when the skill config has an empty skill name. * @throws InvalidConfigException */ @Test
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/test/java/com/google/cloudsearch/ai/TestEntityExtractionSkill.java import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.FileReader; import java.io.IOException; } return schema; } /** * Returns the skill configuration file based on input configName. * @param configName * @return */ private JSONObject getTestConfig(String configName) { JSONParser parser = new JSONParser(); JSONObject config = null; try { config = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/EntityExtraction/"+configName+".json")); for(Object obj : (JSONArray)config.get("aiSkillSet")) { return (JSONObject) obj; } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } /** * Test the behaviour when the skill config has an empty skill name. * @throws InvalidConfigException */ @Test
public void testParse() throws InvalidConfigException {
googleinterns/cloudsearch-ai
indexer/ai/src/main/java/com/google/cloudsearch/ai/AISkillSet.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloudsearch.exceptions.InvalidConfigException; import org.apache.log4j.BasicConfigurator; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger;
package com.google.cloudsearch.ai; /** * Generates a set of skills based on the configuration. */ public class AISkillSet { private List<AISkill> skills; private Logger log = Logger.getLogger(AISkillSet.class); /** * Constructor * @param skillSet The aiSkillSet object from the Configuration. * @param schema CloudSearch Schema * @throws InvalidConfigException Throws exception if the config in invalid. */
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/AISkillSet.java import com.google.cloudsearch.exceptions.InvalidConfigException; import org.apache.log4j.BasicConfigurator; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; package com.google.cloudsearch.ai; /** * Generates a set of skills based on the configuration. */ public class AISkillSet { private List<AISkill> skills; private Logger log = Logger.getLogger(AISkillSet.class); /** * Constructor * @param skillSet The aiSkillSet object from the Configuration. * @param schema CloudSearch Schema * @throws InvalidConfigException Throws exception if the config in invalid. */
public AISkillSet(JSONObject skillSet, JSONObject schema) throws InvalidConfigException {
googleinterns/cloudsearch-ai
connector/src/main/java/com/google/com/covid/LocalRepository.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/AISkillDriver.java // public class AISkillDriver { // // private static AISkillSet skillSet; // private static Logger log = Logger.getLogger(AISkillDriver.class.getName()); // // /** // * Initialize the Driver // * @param aiConfigName File path of the Configuration // * @param schemaName File path of CloudSearch Schema // * @throws Exception Throws Exception if skill setup fails // */ // public static void initialize(String aiConfigName, String schemaName) throws Exception { // JSONParser parser = new JSONParser(); // JSONObject schema = (JSONObject) parser.parse(new FileReader(schemaName)); // JSONObject aiConfig = (JSONObject) parser.parse(new FileReader(aiConfigName)); // skillSet = new AISkillSet(aiConfig, schema); // for(AISkill skill : skillSet.getSkills()) { // skill.setupSkill(); // } // } // // /** // * Populates the structured Data by executing the skills. // * @param structuredData Multimap for storing the structured data. // * @param contentOrURI CloudStorage URI or File content in String format. // */ // public static void populateStructuredData(String contentOrURI, Multimap<String, Object> structuredData) { // List<AISkill> skillList = (List<AISkill>) skillSet.getSkills(); // if(skillList == null) { // log.error("No skills Specified. Initialize the driver before calling populateStructuredData."); // return; // } // skillList.forEach(skill -> { // skill.executeSkill(contentOrURI, structuredData); // }); // } // // /** // * Handles skill shutdown. // */ // public static void closeSkillDriver() throws NullPointerException { // List<AISkill> skillList = (List<AISkill>) skillSet.getSkills(); // if(skillList == null) { // log.error("AISkill List is not initialized. Call AISkillDriver.initialize() before calling closeSkillDriver()"); // return; // } // skillList.forEach(skill -> { // skill.shutdownSkill(); // }); // } // }
import com.google.api.client.http.ByteArrayContent; import com.google.api.services.cloudsearch.v1.model.Item; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import com.google.common.primitives.Longs; import com.google.enterprise.cloudsearch.sdk.CheckpointCloseableIterable; import com.google.enterprise.cloudsearch.sdk.CheckpointCloseableIterableImpl; import com.google.enterprise.cloudsearch.sdk.RepositoryException; import com.google.enterprise.cloudsearch.sdk.config.ConfigValue; import com.google.enterprise.cloudsearch.sdk.config.Configuration; import com.google.enterprise.cloudsearch.sdk.indexing.Acl; import com.google.enterprise.cloudsearch.sdk.indexing.IndexingItemBuilder; import com.google.enterprise.cloudsearch.sdk.indexing.IndexingService; import com.google.enterprise.cloudsearch.sdk.indexing.template.ApiOperation; import com.google.enterprise.cloudsearch.sdk.indexing.template.Repository; import com.google.enterprise.cloudsearch.sdk.indexing.template.RepositoryContext; import com.google.enterprise.cloudsearch.sdk.indexing.template.RepositoryDoc; import com.google.cloudsearch.ai.AISkillDriver; import javax.annotation.Nullable; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; import java.util.logging.Logger; import java.util.stream.IntStream; import com.opencsv.*;
package com.google.com.covid; public class LocalRepository implements Repository { private static Logger log = Logger.getLogger(LocalRepository.class.getName()); private List<String> allFileNames = new ArrayList<String>(); private String aiConfigName = null; private String schemaName = null;
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/AISkillDriver.java // public class AISkillDriver { // // private static AISkillSet skillSet; // private static Logger log = Logger.getLogger(AISkillDriver.class.getName()); // // /** // * Initialize the Driver // * @param aiConfigName File path of the Configuration // * @param schemaName File path of CloudSearch Schema // * @throws Exception Throws Exception if skill setup fails // */ // public static void initialize(String aiConfigName, String schemaName) throws Exception { // JSONParser parser = new JSONParser(); // JSONObject schema = (JSONObject) parser.parse(new FileReader(schemaName)); // JSONObject aiConfig = (JSONObject) parser.parse(new FileReader(aiConfigName)); // skillSet = new AISkillSet(aiConfig, schema); // for(AISkill skill : skillSet.getSkills()) { // skill.setupSkill(); // } // } // // /** // * Populates the structured Data by executing the skills. // * @param structuredData Multimap for storing the structured data. // * @param contentOrURI CloudStorage URI or File content in String format. // */ // public static void populateStructuredData(String contentOrURI, Multimap<String, Object> structuredData) { // List<AISkill> skillList = (List<AISkill>) skillSet.getSkills(); // if(skillList == null) { // log.error("No skills Specified. Initialize the driver before calling populateStructuredData."); // return; // } // skillList.forEach(skill -> { // skill.executeSkill(contentOrURI, structuredData); // }); // } // // /** // * Handles skill shutdown. // */ // public static void closeSkillDriver() throws NullPointerException { // List<AISkill> skillList = (List<AISkill>) skillSet.getSkills(); // if(skillList == null) { // log.error("AISkill List is not initialized. Call AISkillDriver.initialize() before calling closeSkillDriver()"); // return; // } // skillList.forEach(skill -> { // skill.shutdownSkill(); // }); // } // } // Path: connector/src/main/java/com/google/com/covid/LocalRepository.java import com.google.api.client.http.ByteArrayContent; import com.google.api.services.cloudsearch.v1.model.Item; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import com.google.common.primitives.Longs; import com.google.enterprise.cloudsearch.sdk.CheckpointCloseableIterable; import com.google.enterprise.cloudsearch.sdk.CheckpointCloseableIterableImpl; import com.google.enterprise.cloudsearch.sdk.RepositoryException; import com.google.enterprise.cloudsearch.sdk.config.ConfigValue; import com.google.enterprise.cloudsearch.sdk.config.Configuration; import com.google.enterprise.cloudsearch.sdk.indexing.Acl; import com.google.enterprise.cloudsearch.sdk.indexing.IndexingItemBuilder; import com.google.enterprise.cloudsearch.sdk.indexing.IndexingService; import com.google.enterprise.cloudsearch.sdk.indexing.template.ApiOperation; import com.google.enterprise.cloudsearch.sdk.indexing.template.Repository; import com.google.enterprise.cloudsearch.sdk.indexing.template.RepositoryContext; import com.google.enterprise.cloudsearch.sdk.indexing.template.RepositoryDoc; import com.google.cloudsearch.ai.AISkillDriver; import javax.annotation.Nullable; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; import java.util.logging.Logger; import java.util.stream.IntStream; import com.opencsv.*; package com.google.com.covid; public class LocalRepository implements Repository { private static Logger log = Logger.getLogger(LocalRepository.class.getName()); private List<String> allFileNames = new ArrayList<String>(); private String aiConfigName = null; private String schemaName = null;
private AISkillDriver skillDriver = null;
googleinterns/cloudsearch-ai
connector/src/main/java/com/google/com/covid/LocalRepository.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/AISkillDriver.java // public class AISkillDriver { // // private static AISkillSet skillSet; // private static Logger log = Logger.getLogger(AISkillDriver.class.getName()); // // /** // * Initialize the Driver // * @param aiConfigName File path of the Configuration // * @param schemaName File path of CloudSearch Schema // * @throws Exception Throws Exception if skill setup fails // */ // public static void initialize(String aiConfigName, String schemaName) throws Exception { // JSONParser parser = new JSONParser(); // JSONObject schema = (JSONObject) parser.parse(new FileReader(schemaName)); // JSONObject aiConfig = (JSONObject) parser.parse(new FileReader(aiConfigName)); // skillSet = new AISkillSet(aiConfig, schema); // for(AISkill skill : skillSet.getSkills()) { // skill.setupSkill(); // } // } // // /** // * Populates the structured Data by executing the skills. // * @param structuredData Multimap for storing the structured data. // * @param contentOrURI CloudStorage URI or File content in String format. // */ // public static void populateStructuredData(String contentOrURI, Multimap<String, Object> structuredData) { // List<AISkill> skillList = (List<AISkill>) skillSet.getSkills(); // if(skillList == null) { // log.error("No skills Specified. Initialize the driver before calling populateStructuredData."); // return; // } // skillList.forEach(skill -> { // skill.executeSkill(contentOrURI, structuredData); // }); // } // // /** // * Handles skill shutdown. // */ // public static void closeSkillDriver() throws NullPointerException { // List<AISkill> skillList = (List<AISkill>) skillSet.getSkills(); // if(skillList == null) { // log.error("AISkill List is not initialized. Call AISkillDriver.initialize() before calling closeSkillDriver()"); // return; // } // skillList.forEach(skill -> { // skill.shutdownSkill(); // }); // } // }
import com.google.api.client.http.ByteArrayContent; import com.google.api.services.cloudsearch.v1.model.Item; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import com.google.common.primitives.Longs; import com.google.enterprise.cloudsearch.sdk.CheckpointCloseableIterable; import com.google.enterprise.cloudsearch.sdk.CheckpointCloseableIterableImpl; import com.google.enterprise.cloudsearch.sdk.RepositoryException; import com.google.enterprise.cloudsearch.sdk.config.ConfigValue; import com.google.enterprise.cloudsearch.sdk.config.Configuration; import com.google.enterprise.cloudsearch.sdk.indexing.Acl; import com.google.enterprise.cloudsearch.sdk.indexing.IndexingItemBuilder; import com.google.enterprise.cloudsearch.sdk.indexing.IndexingService; import com.google.enterprise.cloudsearch.sdk.indexing.template.ApiOperation; import com.google.enterprise.cloudsearch.sdk.indexing.template.Repository; import com.google.enterprise.cloudsearch.sdk.indexing.template.RepositoryContext; import com.google.enterprise.cloudsearch.sdk.indexing.template.RepositoryDoc; import com.google.cloudsearch.ai.AISkillDriver; import javax.annotation.Nullable; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; import java.util.logging.Logger; import java.util.stream.IntStream; import com.opencsv.*;
package com.google.com.covid; public class LocalRepository implements Repository { private static Logger log = Logger.getLogger(LocalRepository.class.getName()); private List<String> allFileNames = new ArrayList<String>(); private String aiConfigName = null; private String schemaName = null; private AISkillDriver skillDriver = null; private Map<String, Multimap<String, String >> idMap = new HashMap<>(); @Override public void init(RepositoryContext repositoryContext) throws RepositoryException { //Read and store file paths from the resource folder ConfigValue<String> folderName = Configuration.getValue("resources.names",null,Configuration.STRING_PARSER); File[] files = getFileNames(folderName.get()); for (File f : files) { allFileNames.add(f.getPath()); } readMetadata("covid_metadata.csv"); //Get the Skill Configuration name ConfigValue<String> aiSkillConfig = Configuration.getValue("enrichment.config", null, Configuration.STRING_PARSER); aiConfigName = aiSkillConfig.get(); //Get the schema name ConfigValue<String> schemaConfig = Configuration.getValue("enrichment.schema", null, Configuration.STRING_PARSER); schemaName = schemaConfig.get(); //Initialize AI Skill Driver try { AISkillDriver.initialize(aiConfigName, schemaName); }
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/AISkillDriver.java // public class AISkillDriver { // // private static AISkillSet skillSet; // private static Logger log = Logger.getLogger(AISkillDriver.class.getName()); // // /** // * Initialize the Driver // * @param aiConfigName File path of the Configuration // * @param schemaName File path of CloudSearch Schema // * @throws Exception Throws Exception if skill setup fails // */ // public static void initialize(String aiConfigName, String schemaName) throws Exception { // JSONParser parser = new JSONParser(); // JSONObject schema = (JSONObject) parser.parse(new FileReader(schemaName)); // JSONObject aiConfig = (JSONObject) parser.parse(new FileReader(aiConfigName)); // skillSet = new AISkillSet(aiConfig, schema); // for(AISkill skill : skillSet.getSkills()) { // skill.setupSkill(); // } // } // // /** // * Populates the structured Data by executing the skills. // * @param structuredData Multimap for storing the structured data. // * @param contentOrURI CloudStorage URI or File content in String format. // */ // public static void populateStructuredData(String contentOrURI, Multimap<String, Object> structuredData) { // List<AISkill> skillList = (List<AISkill>) skillSet.getSkills(); // if(skillList == null) { // log.error("No skills Specified. Initialize the driver before calling populateStructuredData."); // return; // } // skillList.forEach(skill -> { // skill.executeSkill(contentOrURI, structuredData); // }); // } // // /** // * Handles skill shutdown. // */ // public static void closeSkillDriver() throws NullPointerException { // List<AISkill> skillList = (List<AISkill>) skillSet.getSkills(); // if(skillList == null) { // log.error("AISkill List is not initialized. Call AISkillDriver.initialize() before calling closeSkillDriver()"); // return; // } // skillList.forEach(skill -> { // skill.shutdownSkill(); // }); // } // } // Path: connector/src/main/java/com/google/com/covid/LocalRepository.java import com.google.api.client.http.ByteArrayContent; import com.google.api.services.cloudsearch.v1.model.Item; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; import com.google.common.primitives.Longs; import com.google.enterprise.cloudsearch.sdk.CheckpointCloseableIterable; import com.google.enterprise.cloudsearch.sdk.CheckpointCloseableIterableImpl; import com.google.enterprise.cloudsearch.sdk.RepositoryException; import com.google.enterprise.cloudsearch.sdk.config.ConfigValue; import com.google.enterprise.cloudsearch.sdk.config.Configuration; import com.google.enterprise.cloudsearch.sdk.indexing.Acl; import com.google.enterprise.cloudsearch.sdk.indexing.IndexingItemBuilder; import com.google.enterprise.cloudsearch.sdk.indexing.IndexingService; import com.google.enterprise.cloudsearch.sdk.indexing.template.ApiOperation; import com.google.enterprise.cloudsearch.sdk.indexing.template.Repository; import com.google.enterprise.cloudsearch.sdk.indexing.template.RepositoryContext; import com.google.enterprise.cloudsearch.sdk.indexing.template.RepositoryDoc; import com.google.cloudsearch.ai.AISkillDriver; import javax.annotation.Nullable; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; import java.util.logging.Logger; import java.util.stream.IntStream; import com.opencsv.*; package com.google.com.covid; public class LocalRepository implements Repository { private static Logger log = Logger.getLogger(LocalRepository.class.getName()); private List<String> allFileNames = new ArrayList<String>(); private String aiConfigName = null; private String schemaName = null; private AISkillDriver skillDriver = null; private Map<String, Multimap<String, String >> idMap = new HashMap<>(); @Override public void init(RepositoryContext repositoryContext) throws RepositoryException { //Read and store file paths from the resource folder ConfigValue<String> folderName = Configuration.getValue("resources.names",null,Configuration.STRING_PARSER); File[] files = getFileNames(folderName.get()); for (File f : files) { allFileNames.add(f.getPath()); } readMetadata("covid_metadata.csv"); //Get the Skill Configuration name ConfigValue<String> aiSkillConfig = Configuration.getValue("enrichment.config", null, Configuration.STRING_PARSER); aiConfigName = aiSkillConfig.get(); //Get the schema name ConfigValue<String> schemaConfig = Configuration.getValue("enrichment.schema", null, Configuration.STRING_PARSER); schemaName = schemaConfig.get(); //Initialize AI Skill Driver try { AISkillDriver.initialize(aiConfigName, schemaName); }
catch(InvalidConfigException e){
googleinterns/cloudsearch-ai
indexer/ai/src/main/java/com/google/cloudsearch/ai/StandardSkillEntityExtraction.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloud.language.v1.*; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.Multimap; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger;
package com.google.cloudsearch.ai; /** * Class StandardSkillEntityExtraction implements the methods required for * invoking Natural Language API's Entity extraction and populating the * structured Data for CloudSearch. */ public class StandardSkillEntityExtraction extends BaseAISkill { private double salienceFilter = 0.0; private List<String> typeFilter = new ArrayList<String>(); private String inputLanguage = ""; private EncodingType inputEncoding = EncodingType.NONE; LanguageServiceClient languageService; private Logger log = Logger.getLogger(StandardSkillEntityExtraction.class.getName()); /** * Constructor * @param aiSkill The JSON Object in Configuration containing Entity Extraction skill * related information. * @param schema The CloudSearch Schema. * @throws InvalidConfigException */
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/StandardSkillEntityExtraction.java import com.google.cloud.language.v1.*; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.Multimap; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger; package com.google.cloudsearch.ai; /** * Class StandardSkillEntityExtraction implements the methods required for * invoking Natural Language API's Entity extraction and populating the * structured Data for CloudSearch. */ public class StandardSkillEntityExtraction extends BaseAISkill { private double salienceFilter = 0.0; private List<String> typeFilter = new ArrayList<String>(); private String inputLanguage = ""; private EncodingType inputEncoding = EncodingType.NONE; LanguageServiceClient languageService; private Logger log = Logger.getLogger(StandardSkillEntityExtraction.class.getName()); /** * Constructor * @param aiSkill The JSON Object in Configuration containing Entity Extraction skill * related information. * @param schema The CloudSearch Schema. * @throws InvalidConfigException */
public StandardSkillEntityExtraction(JSONObject aiSkill, JSONObject schema) throws InvalidConfigException {
googleinterns/cloudsearch-ai
indexer/ai/src/main/java/com/google/cloudsearch/ai/StandardSkillSentimentExtraction.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloud.language.v1.*; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.Multimap; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger;
package com.google.cloudsearch.ai; /** * Class StandardSkillSentimentExtraction implements the methods required for * invoking Natural Language API's Sentiment extraction and populating the * structured Data for CloudSearch. */ public class StandardSkillSentimentExtraction extends BaseAISkill { private String inputLanguage = ""; private double sentimentScorePositive = 0.2; private double sentimentScoreNegative = -0.2; private double sentimentMagnitudeThreshold = 2.0; private String sentimentMagnitudeIgnore = "no"; LanguageServiceClient languageService; private Logger log = Logger.getLogger(StandardSkillEntityExtraction.class.getName()); /** * Constructor * @param aiSkill The JSON Object in Configuration containing Sentiment Extraction skill * related information. * @param schema The CloudSearch Schema. * @throws InvalidConfigException */
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/StandardSkillSentimentExtraction.java import com.google.cloud.language.v1.*; import com.google.cloudsearch.exceptions.InvalidConfigException; import com.google.common.collect.Multimap; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.io.IOException; import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger; package com.google.cloudsearch.ai; /** * Class StandardSkillSentimentExtraction implements the methods required for * invoking Natural Language API's Sentiment extraction and populating the * structured Data for CloudSearch. */ public class StandardSkillSentimentExtraction extends BaseAISkill { private String inputLanguage = ""; private double sentimentScorePositive = 0.2; private double sentimentScoreNegative = -0.2; private double sentimentMagnitudeThreshold = 2.0; private String sentimentMagnitudeIgnore = "no"; LanguageServiceClient languageService; private Logger log = Logger.getLogger(StandardSkillEntityExtraction.class.getName()); /** * Constructor * @param aiSkill The JSON Object in Configuration containing Sentiment Extraction skill * related information. * @param schema The CloudSearch Schema. * @throws InvalidConfigException */
public StandardSkillSentimentExtraction(JSONObject aiSkill, JSONObject schema) throws InvalidConfigException {
googleinterns/cloudsearch-ai
indexer/ai/src/test/java/com/google/cloudsearch/ai/TestSentimentExtractionSkill.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.FileReader; import java.io.IOException;
} return schema; } /** * Returns the skill configuration file based on input configName. * @param configName * @return */ private JSONObject getTestConfig(String configName) { JSONParser parser = new JSONParser(); JSONObject config = null; try { config = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/SentimentExtraction/"+configName+".json")); for(Object obj : (JSONArray)config.get("aiSkillSet")) { return (JSONObject) obj; } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } /** * Test the behaviour when the skill config has an empty skill name. * @throws InvalidConfigException */ @Test
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/test/java/com/google/cloudsearch/ai/TestSentimentExtractionSkill.java import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.FileReader; import java.io.IOException; } return schema; } /** * Returns the skill configuration file based on input configName. * @param configName * @return */ private JSONObject getTestConfig(String configName) { JSONParser parser = new JSONParser(); JSONObject config = null; try { config = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/SentimentExtraction/"+configName+".json")); for(Object obj : (JSONArray)config.get("aiSkillSet")) { return (JSONObject) obj; } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } /** * Test the behaviour when the skill config has an empty skill name. * @throws InvalidConfigException */ @Test
public void testParse() throws InvalidConfigException {
googleinterns/cloudsearch-ai
indexer/ai/src/test/java/com/google/cloudsearch/ai/TestBaseAISkill.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.FileReader; import java.io.IOException;
private JSONObject getTestSchema() { JSONParser parser = new JSONParser(); JSONObject schema = null; try { schema = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/BaseAISkill/sampleSchema.json")); } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return schema; } private JSONObject getTestConfig(String configName) { JSONParser parser = new JSONParser(); JSONObject config = null; try { config = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/BaseAISkill/"+configName+".json")); for(Object obj : (JSONArray)config.get("aiSkillSet")) { return (JSONObject) obj; } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } @Test
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/test/java/com/google/cloudsearch/ai/TestBaseAISkill.java import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.FileReader; import java.io.IOException; private JSONObject getTestSchema() { JSONParser parser = new JSONParser(); JSONObject schema = null; try { schema = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/BaseAISkill/sampleSchema.json")); } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return schema; } private JSONObject getTestConfig(String configName) { JSONParser parser = new JSONParser(); JSONObject config = null; try { config = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/BaseAISkill/"+configName+".json")); for(Object obj : (JSONArray)config.get("aiSkillSet")) { return (JSONObject) obj; } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } @Test
public void testOutputField() throws InvalidConfigException {
googleinterns/cloudsearch-ai
indexer/ai/src/test/java/com/google/cloudsearch/ai/TestCustomSkill.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.FileReader; import java.io.IOException;
} return schema; } /** * Returns the skill configuration file based on input configName. * @param configName * @return */ private JSONObject getTestConfig(String configName) { JSONParser parser = new JSONParser(); JSONObject config = null; try { config = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/CustomSkill/"+configName+".json")); for(Object obj : (JSONArray)config.get("aiSkillSet")) { return (JSONObject) obj; } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } /** * Test the behaviour of custom skill when a filter is specified. * @throws InvalidConfigException */ @Test
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/test/java/com/google/cloudsearch/ai/TestCustomSkill.java import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.io.FileReader; import java.io.IOException; } return schema; } /** * Returns the skill configuration file based on input configName. * @param configName * @return */ private JSONObject getTestConfig(String configName) { JSONParser parser = new JSONParser(); JSONObject config = null; try { config = (JSONObject) parser.parse(new FileReader("./src/test/java/com/google/cloudsearch/ai/testFiles/CustomSkill/"+configName+".json")); for(Object obj : (JSONArray)config.get("aiSkillSet")) { return (JSONObject) obj; } } catch (IOException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } return null; } /** * Test the behaviour of custom skill when a filter is specified. * @throws InvalidConfigException */ @Test
public void testFilter() throws InvalidConfigException {
googleinterns/cloudsearch-ai
indexer/ai/src/main/java/com/google/cloudsearch/ai/BaseAISkill.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloud.language.v1.*; import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.util.*;
* @param schema CloudSearch schema * @return */ private boolean isValidPropertyName(String propertyName, JSONObject schema) { if(isSchemaInfoStored == false) { this.storeSchemaInfo(schema); } return (this.schemaInfo.get(propertyName) != null); } /** * @param aiSkillName Name of the AI Skill */ @Override public void setAISkillName(String aiSkillName) { this.aiSkillName = aiSkillName; } /** * @return Returns skill name */ @Override public String getAISkillName() { return this.aiSkillName; } /** * * @param aiSkillName Name of the AI Skill * @throws InvalidConfigException throws exception if name not specified in the configuration. */ @Override
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/main/java/com/google/cloudsearch/ai/BaseAISkill.java import com.google.cloud.language.v1.*; import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.util.*; * @param schema CloudSearch schema * @return */ private boolean isValidPropertyName(String propertyName, JSONObject schema) { if(isSchemaInfoStored == false) { this.storeSchemaInfo(schema); } return (this.schemaInfo.get(propertyName) != null); } /** * @param aiSkillName Name of the AI Skill */ @Override public void setAISkillName(String aiSkillName) { this.aiSkillName = aiSkillName; } /** * @return Returns skill name */ @Override public String getAISkillName() { return this.aiSkillName; } /** * * @param aiSkillName Name of the AI Skill * @throws InvalidConfigException throws exception if name not specified in the configuration. */ @Override
public void parseAISkillName(String aiSkillName) throws InvalidConfigException {
googleinterns/cloudsearch-ai
indexer/ai/src/test/java/com/google/cloudsearch/ai/TestAISkillSet.java
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // }
import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.json.simple.JSONObject;
package com.google.cloudsearch.ai; /** * Test class AISkillSet. */ public class TestAISkillSet { @Rule public final ExpectedException exception = ExpectedException.none(); /** * Test Constructor when the passed JSONObject is not in desired format. * @throws InvalidConfigException */ @Test
// Path: indexer/ai/src/main/java/com/google/cloudsearch/exceptions/InvalidConfigException.java // public class InvalidConfigException extends Exception { // public InvalidConfigException(String e){ // super(e); // } // } // Path: indexer/ai/src/test/java/com/google/cloudsearch/ai/TestAISkillSet.java import com.google.cloudsearch.exceptions.InvalidConfigException; import org.json.simple.JSONArray; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.json.simple.JSONObject; package com.google.cloudsearch.ai; /** * Test class AISkillSet. */ public class TestAISkillSet { @Rule public final ExpectedException exception = ExpectedException.none(); /** * Test Constructor when the passed JSONObject is not in desired format. * @throws InvalidConfigException */ @Test
public void testConstructor() throws InvalidConfigException {
baloise/egitblit
com.baloise.egitblit.plugin/srcTest/com/baloise/egitblit/pref/CloneProtocolTest.java
// Path: com.baloise.egitblit.plugin/src/com/baloise/egitblit/gitblit/GitBlitServer.java // public class GitBlitServer { // // Static fields // public static final String GITBLIT_CTX_PATH = "gitblit/r/"; // // // Server settings // // huh?! public & not final? No getter/setter mania inside the plugin :-) This are plain values which are not computed or validated while assigning // public String url; // public String user; // public String password; // public CloneSettings cloneSettings; // // // Status / Confiig fields // public boolean active = true; // public boolean serverError = false; // // private List<GitBlitRepository> projectList; // // public GitBlitServer(String url, boolean active, String user, String pwd, CloneSettings cls) { // this.url = url; // this.user = user; // this.password = pwd; // this.active = active; // this.cloneSettings = cls; // } // // public GitBlitServer(String url, String user, String pwd, CloneSettings cls) { // this(url, true, user, pwd, cls); // } // // public GitBlitServer(String url, boolean active, String user, String pwd) { // this(url, active, user, pwd, new CloneSettings()); // } // // public GitBlitServer() { // this(null, true, null, null); // } // // public void setCloneSettings(CloneSettings set) { // this.cloneSettings = set; // } // // public String getCloneURL(String gburl) throws GitBlitExplorerException{ // CloneProtocol cp = cloneSettings.getCloneProtocol(); // if(cp == null){ // return null; // } // // try{ // URL url = new URL(gburl); // String curl = cp.schema + "://"; // String chost = url.getHost(); // String cpath = url.getFile(); // Integer cport = this.cloneSettings.getPort(); // String cuser = this.user; // // --- File protocol ---------------------------------------------- // if(cp == CloneProtocol.File){ // // No host // chost = chost == null ? "" : chost; // cport = null; // no port // cuser = null; // No user/pwd // curl += "/"; // } // // // --- Git + SSH -------------------------------------------------- // if(cp == CloneProtocol.GIT || cp == CloneProtocol.SSH){ // // No ctx root / path // // @Todo: check if this is valid for GIT protocol as well // int pos = url.getPath().indexOf(GITBLIT_CTX_PATH); // if(pos > 0){ // cpath = url.getFile().substring(pos + GITBLIT_CTX_PATH.length()); // } // else{ // // Just in case... and for git protocol as well(?!) // pos = url.getPath().lastIndexOf("/"); // cpath = url.getFile().substring(pos + 1); // //Activator.logWarn("Preparing clone URL for SSH protocol: Unexpected context path in URL '" + gburl + "'. Expected path contains '" + GITBLIT_CTX_PATH + "'."); // } // } // // if(cp != CloneProtocol.SSH){ // // Currently, user will be added for ssh only // cuser = null; // } // // // --- Assembling ------------------------------------------------- // if(cuser != null){ // curl += cuser; // curl += "@"; // // Do not add password because of clipboard // } // // curl += chost; // // if(cport != null && cport != CloneSettings.NO_PORT){ // curl += ":" + cport; // } // if(cpath.startsWith("/") == false){ // curl += "/"; // } // // curl += cpath; // return curl; // } // catch(Exception e){ // throw new GitBlitExplorerException("Error while preparing clone url",e); // } // } // // public void addProject(GitBlitRepository proj) { // this.projectList.add(proj); // } // // public List<GitBlitRepository> getProjects() { // return this.projectList; // } // // public boolean removeProject(GitBlitRepository proj) { // return this.projectList.remove(proj); // } // // public void clearProjects() { // this.projectList.clear(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((url == null) ? 0 : url.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if(this == obj) return true; // if(obj == null) return false; // if(getClass() != obj.getClass()) return false; // GitBlitServer other = (GitBlitServer)obj; // if(url == null){ // if(other.url != null) return false; // } // else if(!url.equals(other.url)) return false; // return true; // } // }
import java.util.ArrayList; import java.util.List; import org.junit.Assert; import org.junit.Test; import com.baloise.egitblit.gitblit.GitBlitServer;
package com.baloise.egitblit.pref; public class CloneProtocolTest{ class TestCase{ public final String exprectedURL; public final String projectURL;
// Path: com.baloise.egitblit.plugin/src/com/baloise/egitblit/gitblit/GitBlitServer.java // public class GitBlitServer { // // Static fields // public static final String GITBLIT_CTX_PATH = "gitblit/r/"; // // // Server settings // // huh?! public & not final? No getter/setter mania inside the plugin :-) This are plain values which are not computed or validated while assigning // public String url; // public String user; // public String password; // public CloneSettings cloneSettings; // // // Status / Confiig fields // public boolean active = true; // public boolean serverError = false; // // private List<GitBlitRepository> projectList; // // public GitBlitServer(String url, boolean active, String user, String pwd, CloneSettings cls) { // this.url = url; // this.user = user; // this.password = pwd; // this.active = active; // this.cloneSettings = cls; // } // // public GitBlitServer(String url, String user, String pwd, CloneSettings cls) { // this(url, true, user, pwd, cls); // } // // public GitBlitServer(String url, boolean active, String user, String pwd) { // this(url, active, user, pwd, new CloneSettings()); // } // // public GitBlitServer() { // this(null, true, null, null); // } // // public void setCloneSettings(CloneSettings set) { // this.cloneSettings = set; // } // // public String getCloneURL(String gburl) throws GitBlitExplorerException{ // CloneProtocol cp = cloneSettings.getCloneProtocol(); // if(cp == null){ // return null; // } // // try{ // URL url = new URL(gburl); // String curl = cp.schema + "://"; // String chost = url.getHost(); // String cpath = url.getFile(); // Integer cport = this.cloneSettings.getPort(); // String cuser = this.user; // // --- File protocol ---------------------------------------------- // if(cp == CloneProtocol.File){ // // No host // chost = chost == null ? "" : chost; // cport = null; // no port // cuser = null; // No user/pwd // curl += "/"; // } // // // --- Git + SSH -------------------------------------------------- // if(cp == CloneProtocol.GIT || cp == CloneProtocol.SSH){ // // No ctx root / path // // @Todo: check if this is valid for GIT protocol as well // int pos = url.getPath().indexOf(GITBLIT_CTX_PATH); // if(pos > 0){ // cpath = url.getFile().substring(pos + GITBLIT_CTX_PATH.length()); // } // else{ // // Just in case... and for git protocol as well(?!) // pos = url.getPath().lastIndexOf("/"); // cpath = url.getFile().substring(pos + 1); // //Activator.logWarn("Preparing clone URL for SSH protocol: Unexpected context path in URL '" + gburl + "'. Expected path contains '" + GITBLIT_CTX_PATH + "'."); // } // } // // if(cp != CloneProtocol.SSH){ // // Currently, user will be added for ssh only // cuser = null; // } // // // --- Assembling ------------------------------------------------- // if(cuser != null){ // curl += cuser; // curl += "@"; // // Do not add password because of clipboard // } // // curl += chost; // // if(cport != null && cport != CloneSettings.NO_PORT){ // curl += ":" + cport; // } // if(cpath.startsWith("/") == false){ // curl += "/"; // } // // curl += cpath; // return curl; // } // catch(Exception e){ // throw new GitBlitExplorerException("Error while preparing clone url",e); // } // } // // public void addProject(GitBlitRepository proj) { // this.projectList.add(proj); // } // // public List<GitBlitRepository> getProjects() { // return this.projectList; // } // // public boolean removeProject(GitBlitRepository proj) { // return this.projectList.remove(proj); // } // // public void clearProjects() { // this.projectList.clear(); // } // // @Override // public int hashCode() { // final int prime = 31; // int result = 1; // result = prime * result + ((url == null) ? 0 : url.hashCode()); // return result; // } // // @Override // public boolean equals(Object obj) { // if(this == obj) return true; // if(obj == null) return false; // if(getClass() != obj.getClass()) return false; // GitBlitServer other = (GitBlitServer)obj; // if(url == null){ // if(other.url != null) return false; // } // else if(!url.equals(other.url)) return false; // return true; // } // } // Path: com.baloise.egitblit.plugin/srcTest/com/baloise/egitblit/pref/CloneProtocolTest.java import java.util.ArrayList; import java.util.List; import org.junit.Assert; import org.junit.Test; import com.baloise.egitblit.gitblit.GitBlitServer; package com.baloise.egitblit.pref; public class CloneProtocolTest{ class TestCase{ public final String exprectedURL; public final String projectURL;
public final GitBlitServer server;
baloise/egitblit
com.baloise.egitblit.plugin/src/com/baloise/egitblit/gitblit/GitBlitServer.java
// Path: com.baloise.egitblit.plugin/src/com/baloise/egitblit/common/GitBlitExplorerException.java // public class GitBlitExplorerException extends Exception { // // private static final long serialVersionUID = 1L; // // public GitBlitExplorerException() { // super(); // } // // public GitBlitExplorerException(String arg0, Throwable arg1) { // super(arg0, arg1); // } // // public GitBlitExplorerException(String arg0) { // super(arg0); // } // // public GitBlitExplorerException(Throwable arg0) { // super(arg0); // } // } // // Path: com.baloise.egitblit.plugin/src/com/baloise/egitblit/pref/CloneProtocol.java // public enum CloneProtocol{ // HTTPS("https", 8443, 0), // HTTP("http", 8080, 1), // SSH("ssh", 29418, 2), // GIT("git", 9418, 3), // File("file", null, 4), // FTP("ftp", 21, 5), // SFTP("sftp", 29418, 6); // // public final String schema; // public final Integer defaultPort; // public final int index; // // CloneProtocol(String schema, Integer defPort, int index){ // this.schema = schema; // this.defaultPort = defPort; // this.index = index; // } // // public static CloneProtocol getByIndex(int index){ // CloneProtocol items[] = values(); // if(index < 0 || index > items.length){ // return null; // } // for(CloneProtocol item : items){ // if(item.index == index){ // return item; // } // } // return null; // } // // public static String[] getDisplayValues(){ // CloneProtocol items[] = values(); // String res[] = new String[items.length]; // for(CloneProtocol item : items){ // res[item.index] = item.schema; // } // return res; // } // // public static CloneProtocol getValue(String schema){ // if(schema == null || schema.trim().isEmpty()){ // return null; // } // CloneProtocol items[] = values(); // for(CloneProtocol item : items){ // if(item.schema.equalsIgnoreCase(schema)){ // return item; // } // } // return null; // } // } // // Path: com.baloise.egitblit.plugin/src/com/baloise/egitblit/pref/CloneSettings.java // public class CloneSettings{ // // private boolean enabled; // private CloneProtocol cloneProtocol; // private Integer port; // public final static Integer NO_PORT = -1; // // public CloneSettings(){ // this(false); // } // // public CloneSettings(CloneProtocol pro, Integer port){ // setCloneProtocol(pro); // setPort(port); // setEnabled(true); // } // // public CloneSettings(boolean enabled){ // this(CloneProtocol.HTTPS, CloneProtocol.HTTPS.defaultPort); // setEnabled(enabled); // } // // public boolean isEnabled(){ // return this.enabled; // } // // public void setEnabled(boolean enabled){ // this.enabled = enabled; // } // // public CloneProtocol getCloneProtocol(){ // return cloneProtocol; // } // // public void setCloneProtocol(CloneProtocol cloneProtocol){ // this.cloneProtocol = cloneProtocol; // } // // public Integer getPort(){ // return port; // } // // public void setPort(Integer port){ // if(port == null || port < 0){ // this.port = NO_PORT; // return; // } // this.port = port; // } // }
import java.net.URL; import java.util.List; import com.baloise.egitblit.common.GitBlitExplorerException; import com.baloise.egitblit.pref.CloneProtocol; import com.baloise.egitblit.pref.CloneSettings;
package com.baloise.egitblit.gitblit; /** * Represents one Config Entry (one GitBlit Repo entry) * * @author MicBag */ public class GitBlitServer { // Static fields public static final String GITBLIT_CTX_PATH = "gitblit/r/"; // Server settings // huh?! public & not final? No getter/setter mania inside the plugin :-) This are plain values which are not computed or validated while assigning public String url; public String user; public String password;
// Path: com.baloise.egitblit.plugin/src/com/baloise/egitblit/common/GitBlitExplorerException.java // public class GitBlitExplorerException extends Exception { // // private static final long serialVersionUID = 1L; // // public GitBlitExplorerException() { // super(); // } // // public GitBlitExplorerException(String arg0, Throwable arg1) { // super(arg0, arg1); // } // // public GitBlitExplorerException(String arg0) { // super(arg0); // } // // public GitBlitExplorerException(Throwable arg0) { // super(arg0); // } // } // // Path: com.baloise.egitblit.plugin/src/com/baloise/egitblit/pref/CloneProtocol.java // public enum CloneProtocol{ // HTTPS("https", 8443, 0), // HTTP("http", 8080, 1), // SSH("ssh", 29418, 2), // GIT("git", 9418, 3), // File("file", null, 4), // FTP("ftp", 21, 5), // SFTP("sftp", 29418, 6); // // public final String schema; // public final Integer defaultPort; // public final int index; // // CloneProtocol(String schema, Integer defPort, int index){ // this.schema = schema; // this.defaultPort = defPort; // this.index = index; // } // // public static CloneProtocol getByIndex(int index){ // CloneProtocol items[] = values(); // if(index < 0 || index > items.length){ // return null; // } // for(CloneProtocol item : items){ // if(item.index == index){ // return item; // } // } // return null; // } // // public static String[] getDisplayValues(){ // CloneProtocol items[] = values(); // String res[] = new String[items.length]; // for(CloneProtocol item : items){ // res[item.index] = item.schema; // } // return res; // } // // public static CloneProtocol getValue(String schema){ // if(schema == null || schema.trim().isEmpty()){ // return null; // } // CloneProtocol items[] = values(); // for(CloneProtocol item : items){ // if(item.schema.equalsIgnoreCase(schema)){ // return item; // } // } // return null; // } // } // // Path: com.baloise.egitblit.plugin/src/com/baloise/egitblit/pref/CloneSettings.java // public class CloneSettings{ // // private boolean enabled; // private CloneProtocol cloneProtocol; // private Integer port; // public final static Integer NO_PORT = -1; // // public CloneSettings(){ // this(false); // } // // public CloneSettings(CloneProtocol pro, Integer port){ // setCloneProtocol(pro); // setPort(port); // setEnabled(true); // } // // public CloneSettings(boolean enabled){ // this(CloneProtocol.HTTPS, CloneProtocol.HTTPS.defaultPort); // setEnabled(enabled); // } // // public boolean isEnabled(){ // return this.enabled; // } // // public void setEnabled(boolean enabled){ // this.enabled = enabled; // } // // public CloneProtocol getCloneProtocol(){ // return cloneProtocol; // } // // public void setCloneProtocol(CloneProtocol cloneProtocol){ // this.cloneProtocol = cloneProtocol; // } // // public Integer getPort(){ // return port; // } // // public void setPort(Integer port){ // if(port == null || port < 0){ // this.port = NO_PORT; // return; // } // this.port = port; // } // } // Path: com.baloise.egitblit.plugin/src/com/baloise/egitblit/gitblit/GitBlitServer.java import java.net.URL; import java.util.List; import com.baloise.egitblit.common.GitBlitExplorerException; import com.baloise.egitblit.pref.CloneProtocol; import com.baloise.egitblit.pref.CloneSettings; package com.baloise.egitblit.gitblit; /** * Represents one Config Entry (one GitBlit Repo entry) * * @author MicBag */ public class GitBlitServer { // Static fields public static final String GITBLIT_CTX_PATH = "gitblit/r/"; // Server settings // huh?! public & not final? No getter/setter mania inside the plugin :-) This are plain values which are not computed or validated while assigning public String url; public String user; public String password;
public CloneSettings cloneSettings;
liuling07/QiQuYingServer
src/com/lling/qiqu/commons/ResponseInfo.java
// Path: src/com/lling/qiqu/enums/CodeRespEnum.java // public enum CodeRespEnum { // // CODE_SUCCESS("200", "success"), // CODE_SERVER_EXCEPTION("500", "server exception"), // CODE_PARAM_INVALUD("501", "request parameters is invalud"), // CODE_SOURCE_EXISTS("502", "such source exists"), // CODE_NO_SOURCE_EXISTS("503", "no such source exists"), // CODE_OTHER_ERROR("504", "other error happened"); // // private String code; // private String desc; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // private CodeRespEnum(String code, String desc) { // this.code = code; // this.desc = desc; // } // // public static String getDescByCode(String code){ // for(CodeRespEnum codeRespEnum : CodeRespEnum.values()){ // if(codeRespEnum.getCode().equals(code)){ // return codeRespEnum.getDesc(); // } // } // return ""; // } // // // // }
import java.io.Serializable; import com.lling.qiqu.enums.CodeRespEnum;
package com.lling.qiqu.commons; /** * @ClassName: ResponseInfo * @Description: http接口返回数据封装类 * @author lling * @date 2015-5-30 */ public class ResponseInfo implements Serializable{ private static final long serialVersionUID = 1L; private String code; private String desc; private Object data; public String getCode() { return code; } public void setCode(String code) { this.code = code;
// Path: src/com/lling/qiqu/enums/CodeRespEnum.java // public enum CodeRespEnum { // // CODE_SUCCESS("200", "success"), // CODE_SERVER_EXCEPTION("500", "server exception"), // CODE_PARAM_INVALUD("501", "request parameters is invalud"), // CODE_SOURCE_EXISTS("502", "such source exists"), // CODE_NO_SOURCE_EXISTS("503", "no such source exists"), // CODE_OTHER_ERROR("504", "other error happened"); // // private String code; // private String desc; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // private CodeRespEnum(String code, String desc) { // this.code = code; // this.desc = desc; // } // // public static String getDescByCode(String code){ // for(CodeRespEnum codeRespEnum : CodeRespEnum.values()){ // if(codeRespEnum.getCode().equals(code)){ // return codeRespEnum.getDesc(); // } // } // return ""; // } // // // // } // Path: src/com/lling/qiqu/commons/ResponseInfo.java import java.io.Serializable; import com.lling.qiqu.enums.CodeRespEnum; package com.lling.qiqu.commons; /** * @ClassName: ResponseInfo * @Description: http接口返回数据封装类 * @author lling * @date 2015-5-30 */ public class ResponseInfo implements Serializable{ private static final long serialVersionUID = 1L; private String code; private String desc; private Object data; public String getCode() { return code; } public void setCode(String code) { this.code = code;
this.setDesc(CodeRespEnum.getDescByCode(code));
liuling07/QiQuYingServer
src/com/lling/qiqu/service/impl/CommentServieImpl.java
// Path: src/com/lling/qiqu/dao/ICommentDAO.java // public interface ICommentDAO { // // /** // * 根据jokeid分页获取评论列表 // * @param limit // * @param jokeId // * @return // */ // public PageResult<Comment> getCommentsByJokeId(Limit limit, int jokeId); // // /** // * 根据jokeid获取评论列表 // * @param jokeId // * @return // */ // public List<Comment> getCommentsByJokeId(int jokeId); // // /** // * 添加评论 // * @param comment // */ // public Integer addComment(Comment comment); // // } // // Path: src/com/lling/qiqu/service/ICommentService.java // public interface ICommentService { // // }
import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.lling.qiqu.dao.ICommentDAO; import com.lling.qiqu.service.ICommentService;
package com.lling.qiqu.service.impl; @Service("commentServie") public class CommentServieImpl implements ICommentService {
// Path: src/com/lling/qiqu/dao/ICommentDAO.java // public interface ICommentDAO { // // /** // * 根据jokeid分页获取评论列表 // * @param limit // * @param jokeId // * @return // */ // public PageResult<Comment> getCommentsByJokeId(Limit limit, int jokeId); // // /** // * 根据jokeid获取评论列表 // * @param jokeId // * @return // */ // public List<Comment> getCommentsByJokeId(int jokeId); // // /** // * 添加评论 // * @param comment // */ // public Integer addComment(Comment comment); // // } // // Path: src/com/lling/qiqu/service/ICommentService.java // public interface ICommentService { // // } // Path: src/com/lling/qiqu/service/impl/CommentServieImpl.java import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.lling.qiqu.dao.ICommentDAO; import com.lling.qiqu.service.ICommentService; package com.lling.qiqu.service.impl; @Service("commentServie") public class CommentServieImpl implements ICommentService {
private ICommentDAO commentDAO;
liuling07/QiQuYingServer
src/com/lling/qiqu/controllers/admin/SafeCodeController.java
// Path: src/com/lling/qiqu/commons/Constants.java // public class Constants { // //session中当前用户的key // public static final String KEY_CURR_USER = "curr_user"; // //session中验证码的key // public static final String KEY_SAFE_CODE = "safe_code"; // } // // Path: src/com/lling/qiqu/commons/ResponseInfo.java // public class ResponseInfo implements Serializable{ // // private static final long serialVersionUID = 1L; // private String code; // private String desc; // private Object data; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // this.setDesc(CodeRespEnum.getDescByCode(code)); // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } // // // } // // Path: src/com/lling/qiqu/enums/CodeRespEnum.java // public enum CodeRespEnum { // // CODE_SUCCESS("200", "success"), // CODE_SERVER_EXCEPTION("500", "server exception"), // CODE_PARAM_INVALUD("501", "request parameters is invalud"), // CODE_SOURCE_EXISTS("502", "such source exists"), // CODE_NO_SOURCE_EXISTS("503", "no such source exists"), // CODE_OTHER_ERROR("504", "other error happened"); // // private String code; // private String desc; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // private CodeRespEnum(String code, String desc) { // this.code = code; // this.desc = desc; // } // // public static String getDescByCode(String code){ // for(CodeRespEnum codeRespEnum : CodeRespEnum.values()){ // if(codeRespEnum.getCode().equals(code)){ // return codeRespEnum.getDesc(); // } // } // return ""; // } // // // // }
import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; import java.util.Random; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lling.qiqu.commons.Constants; import com.lling.qiqu.commons.ResponseInfo; import com.lling.qiqu.enums.CodeRespEnum;
//生成随机类 Random random = new Random(); //设定背景色 g.setColor(getRandColor(200,250)); g.fillRect(0,0,width-1,height-1); //设定字体 g.setFont(new Font("Times New Roman",Font.PLAIN,18)); //随机产生155条干扰线,使图像中的认证码不易被其他程序探测到 g.setColor(getRandColor(160,200)); for(int i=0;i<155;i++){ int x = random.nextInt(width); int y = random.nextInt(height); int x1 = random.nextInt(12); int y1 = random.nextInt(12); g.drawLine(x,y,x+x1,y+y1); } //随机产生4位认证码 String sRand = ""; for(int i=0;i<4;i++){ String rand = String.valueOf(str.charAt(random.nextInt(62))) ; sRand = sRand + rand; //将认证码显示到图像中 g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); g.drawString(rand,13*i+6,16); } //将认证码存入session中
// Path: src/com/lling/qiqu/commons/Constants.java // public class Constants { // //session中当前用户的key // public static final String KEY_CURR_USER = "curr_user"; // //session中验证码的key // public static final String KEY_SAFE_CODE = "safe_code"; // } // // Path: src/com/lling/qiqu/commons/ResponseInfo.java // public class ResponseInfo implements Serializable{ // // private static final long serialVersionUID = 1L; // private String code; // private String desc; // private Object data; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // this.setDesc(CodeRespEnum.getDescByCode(code)); // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } // // // } // // Path: src/com/lling/qiqu/enums/CodeRespEnum.java // public enum CodeRespEnum { // // CODE_SUCCESS("200", "success"), // CODE_SERVER_EXCEPTION("500", "server exception"), // CODE_PARAM_INVALUD("501", "request parameters is invalud"), // CODE_SOURCE_EXISTS("502", "such source exists"), // CODE_NO_SOURCE_EXISTS("503", "no such source exists"), // CODE_OTHER_ERROR("504", "other error happened"); // // private String code; // private String desc; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // private CodeRespEnum(String code, String desc) { // this.code = code; // this.desc = desc; // } // // public static String getDescByCode(String code){ // for(CodeRespEnum codeRespEnum : CodeRespEnum.values()){ // if(codeRespEnum.getCode().equals(code)){ // return codeRespEnum.getDesc(); // } // } // return ""; // } // // // // } // Path: src/com/lling/qiqu/controllers/admin/SafeCodeController.java import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; import java.util.Random; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lling.qiqu.commons.Constants; import com.lling.qiqu.commons.ResponseInfo; import com.lling.qiqu.enums.CodeRespEnum; //生成随机类 Random random = new Random(); //设定背景色 g.setColor(getRandColor(200,250)); g.fillRect(0,0,width-1,height-1); //设定字体 g.setFont(new Font("Times New Roman",Font.PLAIN,18)); //随机产生155条干扰线,使图像中的认证码不易被其他程序探测到 g.setColor(getRandColor(160,200)); for(int i=0;i<155;i++){ int x = random.nextInt(width); int y = random.nextInt(height); int x1 = random.nextInt(12); int y1 = random.nextInt(12); g.drawLine(x,y,x+x1,y+y1); } //随机产生4位认证码 String sRand = ""; for(int i=0;i<4;i++){ String rand = String.valueOf(str.charAt(random.nextInt(62))) ; sRand = sRand + rand; //将认证码显示到图像中 g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); g.drawString(rand,13*i+6,16); } //将认证码存入session中
session.setAttribute(Constants.KEY_SAFE_CODE, sRand);
liuling07/QiQuYingServer
src/com/lling/qiqu/controllers/admin/SafeCodeController.java
// Path: src/com/lling/qiqu/commons/Constants.java // public class Constants { // //session中当前用户的key // public static final String KEY_CURR_USER = "curr_user"; // //session中验证码的key // public static final String KEY_SAFE_CODE = "safe_code"; // } // // Path: src/com/lling/qiqu/commons/ResponseInfo.java // public class ResponseInfo implements Serializable{ // // private static final long serialVersionUID = 1L; // private String code; // private String desc; // private Object data; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // this.setDesc(CodeRespEnum.getDescByCode(code)); // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } // // // } // // Path: src/com/lling/qiqu/enums/CodeRespEnum.java // public enum CodeRespEnum { // // CODE_SUCCESS("200", "success"), // CODE_SERVER_EXCEPTION("500", "server exception"), // CODE_PARAM_INVALUD("501", "request parameters is invalud"), // CODE_SOURCE_EXISTS("502", "such source exists"), // CODE_NO_SOURCE_EXISTS("503", "no such source exists"), // CODE_OTHER_ERROR("504", "other error happened"); // // private String code; // private String desc; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // private CodeRespEnum(String code, String desc) { // this.code = code; // this.desc = desc; // } // // public static String getDescByCode(String code){ // for(CodeRespEnum codeRespEnum : CodeRespEnum.values()){ // if(codeRespEnum.getCode().equals(code)){ // return codeRespEnum.getDesc(); // } // } // return ""; // } // // // // }
import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; import java.util.Random; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lling.qiqu.commons.Constants; import com.lling.qiqu.commons.ResponseInfo; import com.lling.qiqu.enums.CodeRespEnum;
g.setColor(getRandColor(160,200)); for(int i=0;i<155;i++){ int x = random.nextInt(width); int y = random.nextInt(height); int x1 = random.nextInt(12); int y1 = random.nextInt(12); g.drawLine(x,y,x+x1,y+y1); } //随机产生4位认证码 String sRand = ""; for(int i=0;i<4;i++){ String rand = String.valueOf(str.charAt(random.nextInt(62))) ; sRand = sRand + rand; //将认证码显示到图像中 g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); g.drawString(rand,13*i+6,16); } //将认证码存入session中 session.setAttribute(Constants.KEY_SAFE_CODE, sRand); //图像生效 g.dispose(); response.reset(); OutputStream out = response.getOutputStream(); //输出图像到页面 ImageIO.write(image, "JPEG", out); out.close(); } @ResponseBody @RequestMapping(value="/checkcode")
// Path: src/com/lling/qiqu/commons/Constants.java // public class Constants { // //session中当前用户的key // public static final String KEY_CURR_USER = "curr_user"; // //session中验证码的key // public static final String KEY_SAFE_CODE = "safe_code"; // } // // Path: src/com/lling/qiqu/commons/ResponseInfo.java // public class ResponseInfo implements Serializable{ // // private static final long serialVersionUID = 1L; // private String code; // private String desc; // private Object data; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // this.setDesc(CodeRespEnum.getDescByCode(code)); // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } // // // } // // Path: src/com/lling/qiqu/enums/CodeRespEnum.java // public enum CodeRespEnum { // // CODE_SUCCESS("200", "success"), // CODE_SERVER_EXCEPTION("500", "server exception"), // CODE_PARAM_INVALUD("501", "request parameters is invalud"), // CODE_SOURCE_EXISTS("502", "such source exists"), // CODE_NO_SOURCE_EXISTS("503", "no such source exists"), // CODE_OTHER_ERROR("504", "other error happened"); // // private String code; // private String desc; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // private CodeRespEnum(String code, String desc) { // this.code = code; // this.desc = desc; // } // // public static String getDescByCode(String code){ // for(CodeRespEnum codeRespEnum : CodeRespEnum.values()){ // if(codeRespEnum.getCode().equals(code)){ // return codeRespEnum.getDesc(); // } // } // return ""; // } // // // // } // Path: src/com/lling/qiqu/controllers/admin/SafeCodeController.java import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; import java.util.Random; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lling.qiqu.commons.Constants; import com.lling.qiqu.commons.ResponseInfo; import com.lling.qiqu.enums.CodeRespEnum; g.setColor(getRandColor(160,200)); for(int i=0;i<155;i++){ int x = random.nextInt(width); int y = random.nextInt(height); int x1 = random.nextInt(12); int y1 = random.nextInt(12); g.drawLine(x,y,x+x1,y+y1); } //随机产生4位认证码 String sRand = ""; for(int i=0;i<4;i++){ String rand = String.valueOf(str.charAt(random.nextInt(62))) ; sRand = sRand + rand; //将认证码显示到图像中 g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); g.drawString(rand,13*i+6,16); } //将认证码存入session中 session.setAttribute(Constants.KEY_SAFE_CODE, sRand); //图像生效 g.dispose(); response.reset(); OutputStream out = response.getOutputStream(); //输出图像到页面 ImageIO.write(image, "JPEG", out); out.close(); } @ResponseBody @RequestMapping(value="/checkcode")
public ResponseInfo checkCode(@RequestParam(value = "code", required = true) String code, HttpSession session) {
liuling07/QiQuYingServer
src/com/lling/qiqu/controllers/admin/SafeCodeController.java
// Path: src/com/lling/qiqu/commons/Constants.java // public class Constants { // //session中当前用户的key // public static final String KEY_CURR_USER = "curr_user"; // //session中验证码的key // public static final String KEY_SAFE_CODE = "safe_code"; // } // // Path: src/com/lling/qiqu/commons/ResponseInfo.java // public class ResponseInfo implements Serializable{ // // private static final long serialVersionUID = 1L; // private String code; // private String desc; // private Object data; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // this.setDesc(CodeRespEnum.getDescByCode(code)); // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } // // // } // // Path: src/com/lling/qiqu/enums/CodeRespEnum.java // public enum CodeRespEnum { // // CODE_SUCCESS("200", "success"), // CODE_SERVER_EXCEPTION("500", "server exception"), // CODE_PARAM_INVALUD("501", "request parameters is invalud"), // CODE_SOURCE_EXISTS("502", "such source exists"), // CODE_NO_SOURCE_EXISTS("503", "no such source exists"), // CODE_OTHER_ERROR("504", "other error happened"); // // private String code; // private String desc; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // private CodeRespEnum(String code, String desc) { // this.code = code; // this.desc = desc; // } // // public static String getDescByCode(String code){ // for(CodeRespEnum codeRespEnum : CodeRespEnum.values()){ // if(codeRespEnum.getCode().equals(code)){ // return codeRespEnum.getDesc(); // } // } // return ""; // } // // // // }
import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; import java.util.Random; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lling.qiqu.commons.Constants; import com.lling.qiqu.commons.ResponseInfo; import com.lling.qiqu.enums.CodeRespEnum;
int x1 = random.nextInt(12); int y1 = random.nextInt(12); g.drawLine(x,y,x+x1,y+y1); } //随机产生4位认证码 String sRand = ""; for(int i=0;i<4;i++){ String rand = String.valueOf(str.charAt(random.nextInt(62))) ; sRand = sRand + rand; //将认证码显示到图像中 g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); g.drawString(rand,13*i+6,16); } //将认证码存入session中 session.setAttribute(Constants.KEY_SAFE_CODE, sRand); //图像生效 g.dispose(); response.reset(); OutputStream out = response.getOutputStream(); //输出图像到页面 ImageIO.write(image, "JPEG", out); out.close(); } @ResponseBody @RequestMapping(value="/checkcode") public ResponseInfo checkCode(@RequestParam(value = "code", required = true) String code, HttpSession session) { ResponseInfo responseInfo = new ResponseInfo(); String safeCode = (String) session.getAttribute(Constants.KEY_SAFE_CODE); if(safeCode != null && safeCode.equalsIgnoreCase(code)) {
// Path: src/com/lling/qiqu/commons/Constants.java // public class Constants { // //session中当前用户的key // public static final String KEY_CURR_USER = "curr_user"; // //session中验证码的key // public static final String KEY_SAFE_CODE = "safe_code"; // } // // Path: src/com/lling/qiqu/commons/ResponseInfo.java // public class ResponseInfo implements Serializable{ // // private static final long serialVersionUID = 1L; // private String code; // private String desc; // private Object data; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // this.setDesc(CodeRespEnum.getDescByCode(code)); // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } // // // } // // Path: src/com/lling/qiqu/enums/CodeRespEnum.java // public enum CodeRespEnum { // // CODE_SUCCESS("200", "success"), // CODE_SERVER_EXCEPTION("500", "server exception"), // CODE_PARAM_INVALUD("501", "request parameters is invalud"), // CODE_SOURCE_EXISTS("502", "such source exists"), // CODE_NO_SOURCE_EXISTS("503", "no such source exists"), // CODE_OTHER_ERROR("504", "other error happened"); // // private String code; // private String desc; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // private CodeRespEnum(String code, String desc) { // this.code = code; // this.desc = desc; // } // // public static String getDescByCode(String code){ // for(CodeRespEnum codeRespEnum : CodeRespEnum.values()){ // if(codeRespEnum.getCode().equals(code)){ // return codeRespEnum.getDesc(); // } // } // return ""; // } // // // // } // Path: src/com/lling/qiqu/controllers/admin/SafeCodeController.java import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; import java.util.Random; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lling.qiqu.commons.Constants; import com.lling.qiqu.commons.ResponseInfo; import com.lling.qiqu.enums.CodeRespEnum; int x1 = random.nextInt(12); int y1 = random.nextInt(12); g.drawLine(x,y,x+x1,y+y1); } //随机产生4位认证码 String sRand = ""; for(int i=0;i<4;i++){ String rand = String.valueOf(str.charAt(random.nextInt(62))) ; sRand = sRand + rand; //将认证码显示到图像中 g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110))); g.drawString(rand,13*i+6,16); } //将认证码存入session中 session.setAttribute(Constants.KEY_SAFE_CODE, sRand); //图像生效 g.dispose(); response.reset(); OutputStream out = response.getOutputStream(); //输出图像到页面 ImageIO.write(image, "JPEG", out); out.close(); } @ResponseBody @RequestMapping(value="/checkcode") public ResponseInfo checkCode(@RequestParam(value = "code", required = true) String code, HttpSession session) { ResponseInfo responseInfo = new ResponseInfo(); String safeCode = (String) session.getAttribute(Constants.KEY_SAFE_CODE); if(safeCode != null && safeCode.equalsIgnoreCase(code)) {
responseInfo.setCode(CodeRespEnum.CODE_SUCCESS.getCode());
liuling07/QiQuYingServer
src/com/lling/qiqu/service/impl/CollectionServiceImpl.java
// Path: src/com/lling/qiqu/dao/ICollectionDAO.java // public interface ICollectionDAO { // // } // // Path: src/com/lling/qiqu/service/ICollectionService.java // public interface ICollectionService { // // }
import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.lling.qiqu.dao.ICollectionDAO; import com.lling.qiqu.service.ICollectionService;
package com.lling.qiqu.service.impl; @Service("collectionService") public class CollectionServiceImpl implements ICollectionService {
// Path: src/com/lling/qiqu/dao/ICollectionDAO.java // public interface ICollectionDAO { // // } // // Path: src/com/lling/qiqu/service/ICollectionService.java // public interface ICollectionService { // // } // Path: src/com/lling/qiqu/service/impl/CollectionServiceImpl.java import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.lling.qiqu.dao.ICollectionDAO; import com.lling.qiqu.service.ICollectionService; package com.lling.qiqu.service.impl; @Service("collectionService") public class CollectionServiceImpl implements ICollectionService {
private ICollectionDAO collectionDAO;
liuling07/QiQuYingServer
src/com/lling/qiqu/controllers/UserController.java
// Path: src/com/lling/qiqu/commons/ResponseInfo.java // public class ResponseInfo implements Serializable{ // // private static final long serialVersionUID = 1L; // private String code; // private String desc; // private Object data; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // this.setDesc(CodeRespEnum.getDescByCode(code)); // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } // // // } // // Path: src/com/lling/qiqu/service/IUserService.java // public interface IUserService { // // /** // * 查询所有管理员用户 // * @return // */ // public List<User> findAllAdminUsers(); // // /** // * 根据用户id查找用户 // */ // public User getUserById(int userId); // // // /** // * 添加腾讯QQ登录的用户 // * @param openId // * @param portraitUrl // * @param nickName // * @param sex // */ // public ResponseInfo addTencentUser(String openId, String portraitUrl, String nickName, String sex); // // /** // * 添加新浪微博登录的用户 // * @param uid // * @param portraitUrl // * @param nickName // * @return // */ // public ResponseInfo addSinaUser(String uid, String portraitUrl, String nickName); // /** // * 用户注册 // * @param userName // * @param password // * @param nickName // * @return // */ // public ResponseInfo regist(String userName, String password); // // /** // * 用户登录 // * @param userName // * @param password // * @return // */ // public ResponseInfo login(String userName, String password); // // /** // * 获取七牛上传token // * @return // */ // public ResponseInfo getQiNiuKeyAndToken(); // // /** // * 设置用户头像 // * @param userId // * @param portraitURL // * @return // */ // public ResponseInfo setPortrait(String userId, String portraitURL); // // /** // * 设置用户昵称和性别 // * @param userId // * @param nickName // * @param sex // * @return // */ // public ResponseInfo setNickAndSex(String userId, String nickName, String sex); // // /** // * 用户提交意见反馈 // * @param contactWay // * @param content // * @param imgUrl // * @return // */ // public ResponseInfo feedBack(String contactWay, String content, String imgUrl); // // /** // * 检验用户是否存在 // * @param phone // * @return // */ // public ResponseInfo checkExeist(String phone); // // /** // * 重置密码 // * @param phone // * @param password // * @return // */ // public ResponseInfo resetPassword(String phone, String password); // // /** // * 管理员用户登录 // * @param userName // * @param password // * @return // */ // public ResponseInfo adminLogin(String userName, String password, HttpSession session); // }
import javax.annotation.Resource; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lling.qiqu.commons.ResponseInfo; import com.lling.qiqu.service.IUserService;
package com.lling.qiqu.controllers; /** * @ClassName: UserController * @Description: 用户控制器 * @author lling * @date 2015-5-31 */ /** * @ClassName: UserController * @Description: * @author lling * @date 2015年7月10日 */ @Controller @RequestMapping("/user") public class UserController { @Resource
// Path: src/com/lling/qiqu/commons/ResponseInfo.java // public class ResponseInfo implements Serializable{ // // private static final long serialVersionUID = 1L; // private String code; // private String desc; // private Object data; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // this.setDesc(CodeRespEnum.getDescByCode(code)); // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } // // // } // // Path: src/com/lling/qiqu/service/IUserService.java // public interface IUserService { // // /** // * 查询所有管理员用户 // * @return // */ // public List<User> findAllAdminUsers(); // // /** // * 根据用户id查找用户 // */ // public User getUserById(int userId); // // // /** // * 添加腾讯QQ登录的用户 // * @param openId // * @param portraitUrl // * @param nickName // * @param sex // */ // public ResponseInfo addTencentUser(String openId, String portraitUrl, String nickName, String sex); // // /** // * 添加新浪微博登录的用户 // * @param uid // * @param portraitUrl // * @param nickName // * @return // */ // public ResponseInfo addSinaUser(String uid, String portraitUrl, String nickName); // /** // * 用户注册 // * @param userName // * @param password // * @param nickName // * @return // */ // public ResponseInfo regist(String userName, String password); // // /** // * 用户登录 // * @param userName // * @param password // * @return // */ // public ResponseInfo login(String userName, String password); // // /** // * 获取七牛上传token // * @return // */ // public ResponseInfo getQiNiuKeyAndToken(); // // /** // * 设置用户头像 // * @param userId // * @param portraitURL // * @return // */ // public ResponseInfo setPortrait(String userId, String portraitURL); // // /** // * 设置用户昵称和性别 // * @param userId // * @param nickName // * @param sex // * @return // */ // public ResponseInfo setNickAndSex(String userId, String nickName, String sex); // // /** // * 用户提交意见反馈 // * @param contactWay // * @param content // * @param imgUrl // * @return // */ // public ResponseInfo feedBack(String contactWay, String content, String imgUrl); // // /** // * 检验用户是否存在 // * @param phone // * @return // */ // public ResponseInfo checkExeist(String phone); // // /** // * 重置密码 // * @param phone // * @param password // * @return // */ // public ResponseInfo resetPassword(String phone, String password); // // /** // * 管理员用户登录 // * @param userName // * @param password // * @return // */ // public ResponseInfo adminLogin(String userName, String password, HttpSession session); // } // Path: src/com/lling/qiqu/controllers/UserController.java import javax.annotation.Resource; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lling.qiqu.commons.ResponseInfo; import com.lling.qiqu.service.IUserService; package com.lling.qiqu.controllers; /** * @ClassName: UserController * @Description: 用户控制器 * @author lling * @date 2015-5-31 */ /** * @ClassName: UserController * @Description: * @author lling * @date 2015年7月10日 */ @Controller @RequestMapping("/user") public class UserController { @Resource
private IUserService userServie;
liuling07/QiQuYingServer
src/com/lling/qiqu/controllers/UserController.java
// Path: src/com/lling/qiqu/commons/ResponseInfo.java // public class ResponseInfo implements Serializable{ // // private static final long serialVersionUID = 1L; // private String code; // private String desc; // private Object data; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // this.setDesc(CodeRespEnum.getDescByCode(code)); // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } // // // } // // Path: src/com/lling/qiqu/service/IUserService.java // public interface IUserService { // // /** // * 查询所有管理员用户 // * @return // */ // public List<User> findAllAdminUsers(); // // /** // * 根据用户id查找用户 // */ // public User getUserById(int userId); // // // /** // * 添加腾讯QQ登录的用户 // * @param openId // * @param portraitUrl // * @param nickName // * @param sex // */ // public ResponseInfo addTencentUser(String openId, String portraitUrl, String nickName, String sex); // // /** // * 添加新浪微博登录的用户 // * @param uid // * @param portraitUrl // * @param nickName // * @return // */ // public ResponseInfo addSinaUser(String uid, String portraitUrl, String nickName); // /** // * 用户注册 // * @param userName // * @param password // * @param nickName // * @return // */ // public ResponseInfo regist(String userName, String password); // // /** // * 用户登录 // * @param userName // * @param password // * @return // */ // public ResponseInfo login(String userName, String password); // // /** // * 获取七牛上传token // * @return // */ // public ResponseInfo getQiNiuKeyAndToken(); // // /** // * 设置用户头像 // * @param userId // * @param portraitURL // * @return // */ // public ResponseInfo setPortrait(String userId, String portraitURL); // // /** // * 设置用户昵称和性别 // * @param userId // * @param nickName // * @param sex // * @return // */ // public ResponseInfo setNickAndSex(String userId, String nickName, String sex); // // /** // * 用户提交意见反馈 // * @param contactWay // * @param content // * @param imgUrl // * @return // */ // public ResponseInfo feedBack(String contactWay, String content, String imgUrl); // // /** // * 检验用户是否存在 // * @param phone // * @return // */ // public ResponseInfo checkExeist(String phone); // // /** // * 重置密码 // * @param phone // * @param password // * @return // */ // public ResponseInfo resetPassword(String phone, String password); // // /** // * 管理员用户登录 // * @param userName // * @param password // * @return // */ // public ResponseInfo adminLogin(String userName, String password, HttpSession session); // }
import javax.annotation.Resource; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lling.qiqu.commons.ResponseInfo; import com.lling.qiqu.service.IUserService;
package com.lling.qiqu.controllers; /** * @ClassName: UserController * @Description: 用户控制器 * @author lling * @date 2015-5-31 */ /** * @ClassName: UserController * @Description: * @author lling * @date 2015年7月10日 */ @Controller @RequestMapping("/user") public class UserController { @Resource private IUserService userServie; private Logger logger = Logger.getLogger(this.getClass()); /** * 获取七牛token * @return */ @ResponseBody @RequestMapping(value="/get_key_token", method=RequestMethod.GET)
// Path: src/com/lling/qiqu/commons/ResponseInfo.java // public class ResponseInfo implements Serializable{ // // private static final long serialVersionUID = 1L; // private String code; // private String desc; // private Object data; // // public String getCode() { // return code; // } // public void setCode(String code) { // this.code = code; // this.setDesc(CodeRespEnum.getDescByCode(code)); // } // public String getDesc() { // return desc; // } // public void setDesc(String desc) { // this.desc = desc; // } // public Object getData() { // return data; // } // public void setData(Object data) { // this.data = data; // } // // // } // // Path: src/com/lling/qiqu/service/IUserService.java // public interface IUserService { // // /** // * 查询所有管理员用户 // * @return // */ // public List<User> findAllAdminUsers(); // // /** // * 根据用户id查找用户 // */ // public User getUserById(int userId); // // // /** // * 添加腾讯QQ登录的用户 // * @param openId // * @param portraitUrl // * @param nickName // * @param sex // */ // public ResponseInfo addTencentUser(String openId, String portraitUrl, String nickName, String sex); // // /** // * 添加新浪微博登录的用户 // * @param uid // * @param portraitUrl // * @param nickName // * @return // */ // public ResponseInfo addSinaUser(String uid, String portraitUrl, String nickName); // /** // * 用户注册 // * @param userName // * @param password // * @param nickName // * @return // */ // public ResponseInfo regist(String userName, String password); // // /** // * 用户登录 // * @param userName // * @param password // * @return // */ // public ResponseInfo login(String userName, String password); // // /** // * 获取七牛上传token // * @return // */ // public ResponseInfo getQiNiuKeyAndToken(); // // /** // * 设置用户头像 // * @param userId // * @param portraitURL // * @return // */ // public ResponseInfo setPortrait(String userId, String portraitURL); // // /** // * 设置用户昵称和性别 // * @param userId // * @param nickName // * @param sex // * @return // */ // public ResponseInfo setNickAndSex(String userId, String nickName, String sex); // // /** // * 用户提交意见反馈 // * @param contactWay // * @param content // * @param imgUrl // * @return // */ // public ResponseInfo feedBack(String contactWay, String content, String imgUrl); // // /** // * 检验用户是否存在 // * @param phone // * @return // */ // public ResponseInfo checkExeist(String phone); // // /** // * 重置密码 // * @param phone // * @param password // * @return // */ // public ResponseInfo resetPassword(String phone, String password); // // /** // * 管理员用户登录 // * @param userName // * @param password // * @return // */ // public ResponseInfo adminLogin(String userName, String password, HttpSession session); // } // Path: src/com/lling/qiqu/controllers/UserController.java import javax.annotation.Resource; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.lling.qiqu.commons.ResponseInfo; import com.lling.qiqu.service.IUserService; package com.lling.qiqu.controllers; /** * @ClassName: UserController * @Description: 用户控制器 * @author lling * @date 2015-5-31 */ /** * @ClassName: UserController * @Description: * @author lling * @date 2015年7月10日 */ @Controller @RequestMapping("/user") public class UserController { @Resource private IUserService userServie; private Logger logger = Logger.getLogger(this.getClass()); /** * 获取七牛token * @return */ @ResponseBody @RequestMapping(value="/get_key_token", method=RequestMethod.GET)
public ResponseInfo getQiNiuKeyAndToken() {
liuling07/QiQuYingServer
src/com/lling/qiqu/test/Test.java
// Path: src/com/lling/qiqu/utils/UrlBase64Coder.java // public class UrlBase64Coder { // // public final static String ENCODING = "UTF-8"; // // // 加密 // public static String encoded(String data) throws UnsupportedEncodingException { // byte[] b = Base64.encodeBase64URLSafe(data.getBytes(ENCODING)); // return new String(b, ENCODING); // } // // // // 解密 // public static String decode(String data) throws UnsupportedEncodingException { // byte[] b = Base64.decodeBase64(data.getBytes(ENCODING)); // return new String(b, ENCODING); // } // }
import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import javax.imageio.ImageIO; import com.lling.qiqu.utils.UrlBase64Coder;
package com.lling.qiqu.test; public class Test { /** * @param args */ public static void main(String[] args) { // String s = HttpConnHelper.doHttpGetRequest("http://7xixxm.com2.z0.glb.clouddn.com/ed8fc103-7fbd-40cc-8f38-b0f8393645e0.jpg?imageInfo"); String s; try {
// Path: src/com/lling/qiqu/utils/UrlBase64Coder.java // public class UrlBase64Coder { // // public final static String ENCODING = "UTF-8"; // // // 加密 // public static String encoded(String data) throws UnsupportedEncodingException { // byte[] b = Base64.encodeBase64URLSafe(data.getBytes(ENCODING)); // return new String(b, ENCODING); // } // // // // 解密 // public static String decode(String data) throws UnsupportedEncodingException { // byte[] b = Base64.decodeBase64(data.getBytes(ENCODING)); // return new String(b, ENCODING); // } // } // Path: src/com/lling/qiqu/test/Test.java import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import javax.imageio.ImageIO; import com.lling.qiqu.utils.UrlBase64Coder; package com.lling.qiqu.test; public class Test { /** * @param args */ public static void main(String[] args) { // String s = HttpConnHelper.doHttpGetRequest("http://7xixxm.com2.z0.glb.clouddn.com/ed8fc103-7fbd-40cc-8f38-b0f8393645e0.jpg?imageInfo"); String s; try {
s = UrlBase64Coder.encoded("http://7xnqm4.com1.z0.glb.clouddn.com/watermark.png");
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/support/tracker/XCalendarMouseTracker.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/XCalendarEvent.java // public interface XCalendarEvent { // // Event getSource(); // // boolean isDoit(); void setDoit(boolean doit); // }
import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.XCalendarEvent; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.bus.internal.*;
this.y = y; } /** * */ public void reset() { this.state = 0; this.x = this.y = -1; } public void reset(XCalendarMouseTracker rhs) { this.state = rhs.state; this.x = rhs.x; this.y = rhs.y; } /** * */ @Override public String toString() { return new StringBuilder() .append("x:" + x).append("y:" + y) .append("entered:" + isEntered()) .append("pressed:" + isPressed()).toString(); } /** * */
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/XCalendarEvent.java // public interface XCalendarEvent { // // Event getSource(); // // boolean isDoit(); void setDoit(boolean doit); // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/support/tracker/XCalendarMouseTracker.java import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.XCalendarEvent; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.bus.internal.*; this.y = y; } /** * */ public void reset() { this.state = 0; this.x = this.y = -1; } public void reset(XCalendarMouseTracker rhs) { this.state = rhs.state; this.x = rhs.x; this.y = rhs.y; } /** * */ @Override public String toString() { return new StringBuilder() .append("x:" + x).append("y:" + y) .append("entered:" + isEntered()) .append("pressed:" + isPressed()).toString(); } /** * */
public boolean track(final XCalendarEvent event) {
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/utility/graphics/Fonts.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/util/collection/map/ConcurrentMultiKeyMap.java // public class ConcurrentMultiKeyMap<K1, K2, V> { // // // private final ConcurrentMap<K1, ConcurrentMap<K2, V>> map; // // /** // * // */ // public ConcurrentMultiKeyMap() { // this.map = new ConcurrentHashMap<>(); // } // // public ConcurrentMultiKeyMap(int capacity) { // this.map = new ConcurrentHashMap<>(capacity); // } // // /** // * // */ // public int size() { // return map.size(); // } // // public void clear() { // this.map.clear(); // } // // public Set<K1> keySet() { // return this.map.keySet(); // } // // public boolean isEmpty() { // return this.map.isEmpty(); // } // // public V get(final K1 k1, final K2 k2) { // ConcurrentMap<K2, V> m = this.map.get(k1); // return m == null ? null : m.get(k2); // } // // public boolean containsKey(K1 k1, K2 k2) { // ConcurrentMap<K2, V> m = this.map.get(k1); // return m == null ? false : m.containsKey(k2); // } // // public ConcurrentMap<K2, V> get(final K1 k1) { // return this.map.get(k1); // } // // public ConcurrentMap<K2, V> remove(final K1 k1) { // return this.map.remove(k1); // } // // public void puts(final K1 k1, Map<K2, V> values) { // this.map.put(k1, new ConcurrentHashMap<>(values)); // } // // /** // * // */ // public V remove(final K1 k1, final K2 k2) { // AtomicReference<V> r = new AtomicReference<>(null); // this.map.computeIfPresent(k1, (k, v) -> { // r.set(v.remove(k2)); return v.size() == 0 ? null : v; // }); // return r.get(); // } // // public V put(final K1 k1, final K2 k2, final V value) { // AtomicReference<V> r = new AtomicReference<>(null); // this.map.compute(k1, (k, v) -> { // if(v == null) v = new ConcurrentHashMap<>(); // r.set(v.put(k2, value)); return v; // }); // return r.get(); // } // // public V putIfAbsent(final K1 k1, final K2 k2, final V value) { // AtomicReference<V> r = new AtomicReference<>(null); // this.map.compute(k1, (k, v) -> { // if(v == null) v = new ConcurrentHashMap<>(); // r.set(v.putIfAbsent(k2, value)); return v; // }); // return r.get(); // } // // public boolean remove(final K1 k1, final K2 k2, final V value) { // AtomicBoolean r = new AtomicBoolean(false); // this.map.computeIfPresent(k1, (k, v) -> { // r.set(v.remove(k2, value)); return v.size() == 0 ? null : v; // }); // return r.get(); // } // }
import cn.nextop.thorin.rcp.support.util.collection.map.ConcurrentMultiKeyMap; import com.patrikdufresne.fontawesome.FontAwesome; import org.eclipse.jface.resource.FontDescriptor; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.Display; import java.util.function.Supplier;
package cn.nextop.thorin.rcp.support.swt.utility.graphics; /** * * @author Jingqi Xu */ public final class Fonts { // public static final Font SYSTEM = Display.getDefault().getSystemFont(); public static final Font AWESOME = FontAwesome.getFont(Math.max(10, getHeight(SYSTEM))); //
// Path: src/main/java/cn/nextop/thorin/rcp/support/util/collection/map/ConcurrentMultiKeyMap.java // public class ConcurrentMultiKeyMap<K1, K2, V> { // // // private final ConcurrentMap<K1, ConcurrentMap<K2, V>> map; // // /** // * // */ // public ConcurrentMultiKeyMap() { // this.map = new ConcurrentHashMap<>(); // } // // public ConcurrentMultiKeyMap(int capacity) { // this.map = new ConcurrentHashMap<>(capacity); // } // // /** // * // */ // public int size() { // return map.size(); // } // // public void clear() { // this.map.clear(); // } // // public Set<K1> keySet() { // return this.map.keySet(); // } // // public boolean isEmpty() { // return this.map.isEmpty(); // } // // public V get(final K1 k1, final K2 k2) { // ConcurrentMap<K2, V> m = this.map.get(k1); // return m == null ? null : m.get(k2); // } // // public boolean containsKey(K1 k1, K2 k2) { // ConcurrentMap<K2, V> m = this.map.get(k1); // return m == null ? false : m.containsKey(k2); // } // // public ConcurrentMap<K2, V> get(final K1 k1) { // return this.map.get(k1); // } // // public ConcurrentMap<K2, V> remove(final K1 k1) { // return this.map.remove(k1); // } // // public void puts(final K1 k1, Map<K2, V> values) { // this.map.put(k1, new ConcurrentHashMap<>(values)); // } // // /** // * // */ // public V remove(final K1 k1, final K2 k2) { // AtomicReference<V> r = new AtomicReference<>(null); // this.map.computeIfPresent(k1, (k, v) -> { // r.set(v.remove(k2)); return v.size() == 0 ? null : v; // }); // return r.get(); // } // // public V put(final K1 k1, final K2 k2, final V value) { // AtomicReference<V> r = new AtomicReference<>(null); // this.map.compute(k1, (k, v) -> { // if(v == null) v = new ConcurrentHashMap<>(); // r.set(v.put(k2, value)); return v; // }); // return r.get(); // } // // public V putIfAbsent(final K1 k1, final K2 k2, final V value) { // AtomicReference<V> r = new AtomicReference<>(null); // this.map.compute(k1, (k, v) -> { // if(v == null) v = new ConcurrentHashMap<>(); // r.set(v.putIfAbsent(k2, value)); return v; // }); // return r.get(); // } // // public boolean remove(final K1 k1, final K2 k2, final V value) { // AtomicBoolean r = new AtomicBoolean(false); // this.map.computeIfPresent(k1, (k, v) -> { // r.set(v.remove(k2, value)); return v.size() == 0 ? null : v; // }); // return r.get(); // } // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/utility/graphics/Fonts.java import cn.nextop.thorin.rcp.support.util.collection.map.ConcurrentMultiKeyMap; import com.patrikdufresne.fontawesome.FontAwesome; import org.eclipse.jface.resource.FontDescriptor; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.Display; import java.util.function.Supplier; package cn.nextop.thorin.rcp.support.swt.utility.graphics; /** * * @author Jingqi Xu */ public final class Fonts { // public static final Font SYSTEM = Display.getDefault().getSystemFont(); public static final Font AWESOME = FontAwesome.getFont(Math.max(10, getHeight(SYSTEM))); //
protected static final ConcurrentMultiKeyMap<Class<?>, String, Font> FONTS = new ConcurrentMultiKeyMap<>();
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/XCalendarThemeFactory.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/impl/XCalendarThemeEn.java // public class XCalendarThemeEn extends XCalendarTheme { // // // private static final String[][] MONTH = { { "Jan", "Feb", "Mar", "Apr" }, // { "May", "Jun", "Jul", "Aug" }, // { "Sep", "Oct", "Nov", "Dec" } }; // // private static final String[] MONTH_OF_YEAR_NAME = { "", "January", "February", "March", // "April", "May", "June", "July", "August", // "September", "October", "November", "December" }; // // private static final String[] DAY_OF_WEEK_NAME = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; // // /** // * // */ // @Override public String[][] getMonthTheme(){ return MONTH; } // @Override public String[] getDayOfWeekTheme() { return DAY_OF_WEEK_NAME; }; // @Override public String[] getMonthOfYearTheme() { return MONTH_OF_YEAR_NAME; } // @Override public String header(int month, int year) { return getMonthOfYearTheme()[month] + " "+ year; } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/impl/XCalendarThemeJp.java // public class XCalendarThemeJp extends XCalendarTheme { // // // private static final String[][] MONTH = { { "1月", "2月", "3月", "4月" }, // { "5月", "6月", "7月", "8月" }, // { "9月", "10月", "11月", "12月" } }; // // private static final String[] MONTH_OF_YEAR_NAME = { "", "1月", "2月", "3月", // "4月", "5月", "6月", "7月", // "8月", "9月", "10月", "11月", "12月" }; // // private static final String[] DAY_OF_WEEK_NAME = { "日", "月", "火", "水", "木", "金", "土" }; // // /** // * // */ // @Override public String[][] getMonthTheme(){ return MONTH; } // @Override public String[] getDayOfWeekTheme() { return DAY_OF_WEEK_NAME; }; // @Override public String[] getMonthOfYearTheme() { return MONTH_OF_YEAR_NAME; } // @Override public String header(int month, int year) { return year + "年" + getMonthOfYearTheme()[month] + "月"; } // }
import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme.impl.XCalendarThemeEn; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme.impl.XCalendarThemeJp; import java.util.HashMap; import java.util.Locale; import java.util.Map;
package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme; /** * * @author Baoyi Chen */ public class XCalendarThemeFactory { // private Map<Locale, XCalendarTheme> map = new HashMap<>(); /** * */ public XCalendarThemeFactory() {
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/impl/XCalendarThemeEn.java // public class XCalendarThemeEn extends XCalendarTheme { // // // private static final String[][] MONTH = { { "Jan", "Feb", "Mar", "Apr" }, // { "May", "Jun", "Jul", "Aug" }, // { "Sep", "Oct", "Nov", "Dec" } }; // // private static final String[] MONTH_OF_YEAR_NAME = { "", "January", "February", "March", // "April", "May", "June", "July", "August", // "September", "October", "November", "December" }; // // private static final String[] DAY_OF_WEEK_NAME = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; // // /** // * // */ // @Override public String[][] getMonthTheme(){ return MONTH; } // @Override public String[] getDayOfWeekTheme() { return DAY_OF_WEEK_NAME; }; // @Override public String[] getMonthOfYearTheme() { return MONTH_OF_YEAR_NAME; } // @Override public String header(int month, int year) { return getMonthOfYearTheme()[month] + " "+ year; } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/impl/XCalendarThemeJp.java // public class XCalendarThemeJp extends XCalendarTheme { // // // private static final String[][] MONTH = { { "1月", "2月", "3月", "4月" }, // { "5月", "6月", "7月", "8月" }, // { "9月", "10月", "11月", "12月" } }; // // private static final String[] MONTH_OF_YEAR_NAME = { "", "1月", "2月", "3月", // "4月", "5月", "6月", "7月", // "8月", "9月", "10月", "11月", "12月" }; // // private static final String[] DAY_OF_WEEK_NAME = { "日", "月", "火", "水", "木", "金", "土" }; // // /** // * // */ // @Override public String[][] getMonthTheme(){ return MONTH; } // @Override public String[] getDayOfWeekTheme() { return DAY_OF_WEEK_NAME; }; // @Override public String[] getMonthOfYearTheme() { return MONTH_OF_YEAR_NAME; } // @Override public String header(int month, int year) { return year + "年" + getMonthOfYearTheme()[month] + "月"; } // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/XCalendarThemeFactory.java import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme.impl.XCalendarThemeEn; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme.impl.XCalendarThemeJp; import java.util.HashMap; import java.util.Locale; import java.util.Map; package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme; /** * * @author Baoyi Chen */ public class XCalendarThemeFactory { // private Map<Locale, XCalendarTheme> map = new HashMap<>(); /** * */ public XCalendarThemeFactory() {
register(Locale.ENGLISH, new XCalendarThemeEn());
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/XCalendarThemeFactory.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/impl/XCalendarThemeEn.java // public class XCalendarThemeEn extends XCalendarTheme { // // // private static final String[][] MONTH = { { "Jan", "Feb", "Mar", "Apr" }, // { "May", "Jun", "Jul", "Aug" }, // { "Sep", "Oct", "Nov", "Dec" } }; // // private static final String[] MONTH_OF_YEAR_NAME = { "", "January", "February", "March", // "April", "May", "June", "July", "August", // "September", "October", "November", "December" }; // // private static final String[] DAY_OF_WEEK_NAME = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; // // /** // * // */ // @Override public String[][] getMonthTheme(){ return MONTH; } // @Override public String[] getDayOfWeekTheme() { return DAY_OF_WEEK_NAME; }; // @Override public String[] getMonthOfYearTheme() { return MONTH_OF_YEAR_NAME; } // @Override public String header(int month, int year) { return getMonthOfYearTheme()[month] + " "+ year; } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/impl/XCalendarThemeJp.java // public class XCalendarThemeJp extends XCalendarTheme { // // // private static final String[][] MONTH = { { "1月", "2月", "3月", "4月" }, // { "5月", "6月", "7月", "8月" }, // { "9月", "10月", "11月", "12月" } }; // // private static final String[] MONTH_OF_YEAR_NAME = { "", "1月", "2月", "3月", // "4月", "5月", "6月", "7月", // "8月", "9月", "10月", "11月", "12月" }; // // private static final String[] DAY_OF_WEEK_NAME = { "日", "月", "火", "水", "木", "金", "土" }; // // /** // * // */ // @Override public String[][] getMonthTheme(){ return MONTH; } // @Override public String[] getDayOfWeekTheme() { return DAY_OF_WEEK_NAME; }; // @Override public String[] getMonthOfYearTheme() { return MONTH_OF_YEAR_NAME; } // @Override public String header(int month, int year) { return year + "年" + getMonthOfYearTheme()[month] + "月"; } // }
import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme.impl.XCalendarThemeEn; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme.impl.XCalendarThemeJp; import java.util.HashMap; import java.util.Locale; import java.util.Map;
package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme; /** * * @author Baoyi Chen */ public class XCalendarThemeFactory { // private Map<Locale, XCalendarTheme> map = new HashMap<>(); /** * */ public XCalendarThemeFactory() { register(Locale.ENGLISH, new XCalendarThemeEn());
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/impl/XCalendarThemeEn.java // public class XCalendarThemeEn extends XCalendarTheme { // // // private static final String[][] MONTH = { { "Jan", "Feb", "Mar", "Apr" }, // { "May", "Jun", "Jul", "Aug" }, // { "Sep", "Oct", "Nov", "Dec" } }; // // private static final String[] MONTH_OF_YEAR_NAME = { "", "January", "February", "March", // "April", "May", "June", "July", "August", // "September", "October", "November", "December" }; // // private static final String[] DAY_OF_WEEK_NAME = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; // // /** // * // */ // @Override public String[][] getMonthTheme(){ return MONTH; } // @Override public String[] getDayOfWeekTheme() { return DAY_OF_WEEK_NAME; }; // @Override public String[] getMonthOfYearTheme() { return MONTH_OF_YEAR_NAME; } // @Override public String header(int month, int year) { return getMonthOfYearTheme()[month] + " "+ year; } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/impl/XCalendarThemeJp.java // public class XCalendarThemeJp extends XCalendarTheme { // // // private static final String[][] MONTH = { { "1月", "2月", "3月", "4月" }, // { "5月", "6月", "7月", "8月" }, // { "9月", "10月", "11月", "12月" } }; // // private static final String[] MONTH_OF_YEAR_NAME = { "", "1月", "2月", "3月", // "4月", "5月", "6月", "7月", // "8月", "9月", "10月", "11月", "12月" }; // // private static final String[] DAY_OF_WEEK_NAME = { "日", "月", "火", "水", "木", "金", "土" }; // // /** // * // */ // @Override public String[][] getMonthTheme(){ return MONTH; } // @Override public String[] getDayOfWeekTheme() { return DAY_OF_WEEK_NAME; }; // @Override public String[] getMonthOfYearTheme() { return MONTH_OF_YEAR_NAME; } // @Override public String header(int month, int year) { return year + "年" + getMonthOfYearTheme()[month] + "月"; } // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/XCalendarThemeFactory.java import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme.impl.XCalendarThemeEn; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme.impl.XCalendarThemeJp; import java.util.HashMap; import java.util.Locale; import java.util.Map; package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme; /** * * @author Baoyi Chen */ public class XCalendarThemeFactory { // private Map<Locale, XCalendarTheme> map = new HashMap<>(); /** * */ public XCalendarThemeFactory() { register(Locale.ENGLISH, new XCalendarThemeEn());
register(Locale.JAPANESE, new XCalendarThemeJp());
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/XCalendarConfig.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/XCalendarLayout.java // public interface XCalendarLayout { // // /** // * // */ // void layout(XCalendar calendar); // // void layout(XCalendar calendar, Composite parent, Rectangle bounds); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/impl/XCalendarDefaultLayout.java // public class XCalendarDefaultLayout implements XCalendarLayout { // // // private Composite prevParent; // private Rectangle prevBounds; // // /** // * // */ // @Override // public void layout(XCalendar popup) { // layout(popup, this.prevParent, this.prevBounds); // } // // /** // * // */ // @Override // public void layout(XCalendar popup, Composite parent, Rectangle bounds) { // // // this.prevParent = parent; // this.prevBounds = bounds; // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // int x = theme.getMargin(), y = theme.getMargin(); // int m = theme.getMargin(), w = theme.getWidth() - 2 * m; // // // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(int i = 0; i < widgets.size(); i++) { // final XCalendarWidget v = widgets.get(i); // final Pair<Point> points = v.locate(x, y, w, m); // v.setBounds(x, y, points.getV1().x, points.getV1().y); // x = points.getV2().x; y = points.getV2().y; // } // // // // final Shell shell = popup.getShell(); // shell.setSize(new Point(theme.getWidth(), y + m)); setLocation(popup); // } // // /** // * // */ // protected void setLocation(final XCalendar popup) { // // // final Shell shell = popup.getShell(); // final Display display = popup.getDisplay(); // final Rectangle r1 = display.map(prevParent, null, prevBounds); // final Rectangle r2 = popup.getMonitor().getClientArea(); // Client area // // // // final int margin = 2; // final Point size = shell.getSize(); // int x = r1.x, y = r1.y + r1.height + margin; // if(y + size.y > r2.y + r2.height) y = r1.y - size.y - margin; // if(x < r2.x) x = r2.x; else if(x + size.x > r2.x + r2.width) x = r2.x + r2.width - size.x; // shell.setLocation(x, y); // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/XCalendarRender.java // public interface XCalendarRender { // void render(XCalendar popup, GC gc); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/impl/XCalendarDefaultRender.java // public class XCalendarDefaultRender implements XCalendarRender { // // public void render(XCalendar popup, GC gc) { // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // final Transform t = new Transform(gc.getDevice()); // // // // try (final XCalendarFrame frame = new XCalendarFrame(gc, t)) { // // // Rectangle area = new Rectangle((area = popup.getClientArea()).x, area.y, area.width - 1, area.height - 1); // gc.setAdvanced(true); // gc.setAntialias(SWT.ON); // gc.setBackground(theme.getBackground(true, false, false, false)); // gc.fillRectangle(area); gc.setForeground(theme.getGrid(true)); gc.drawRectangle(area); // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(XCalendarWidget widget:widgets) widget.render(frame); // } // } // }
import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.XCalendarLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.impl.XCalendarDefaultLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.XCalendarRender; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.impl.XCalendarDefaultRender;
package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config; /** * * @author Jingqi Xu */ public class XCalendarConfig { // protected XCalendarLayout layout;
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/XCalendarLayout.java // public interface XCalendarLayout { // // /** // * // */ // void layout(XCalendar calendar); // // void layout(XCalendar calendar, Composite parent, Rectangle bounds); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/impl/XCalendarDefaultLayout.java // public class XCalendarDefaultLayout implements XCalendarLayout { // // // private Composite prevParent; // private Rectangle prevBounds; // // /** // * // */ // @Override // public void layout(XCalendar popup) { // layout(popup, this.prevParent, this.prevBounds); // } // // /** // * // */ // @Override // public void layout(XCalendar popup, Composite parent, Rectangle bounds) { // // // this.prevParent = parent; // this.prevBounds = bounds; // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // int x = theme.getMargin(), y = theme.getMargin(); // int m = theme.getMargin(), w = theme.getWidth() - 2 * m; // // // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(int i = 0; i < widgets.size(); i++) { // final XCalendarWidget v = widgets.get(i); // final Pair<Point> points = v.locate(x, y, w, m); // v.setBounds(x, y, points.getV1().x, points.getV1().y); // x = points.getV2().x; y = points.getV2().y; // } // // // // final Shell shell = popup.getShell(); // shell.setSize(new Point(theme.getWidth(), y + m)); setLocation(popup); // } // // /** // * // */ // protected void setLocation(final XCalendar popup) { // // // final Shell shell = popup.getShell(); // final Display display = popup.getDisplay(); // final Rectangle r1 = display.map(prevParent, null, prevBounds); // final Rectangle r2 = popup.getMonitor().getClientArea(); // Client area // // // // final int margin = 2; // final Point size = shell.getSize(); // int x = r1.x, y = r1.y + r1.height + margin; // if(y + size.y > r2.y + r2.height) y = r1.y - size.y - margin; // if(x < r2.x) x = r2.x; else if(x + size.x > r2.x + r2.width) x = r2.x + r2.width - size.x; // shell.setLocation(x, y); // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/XCalendarRender.java // public interface XCalendarRender { // void render(XCalendar popup, GC gc); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/impl/XCalendarDefaultRender.java // public class XCalendarDefaultRender implements XCalendarRender { // // public void render(XCalendar popup, GC gc) { // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // final Transform t = new Transform(gc.getDevice()); // // // // try (final XCalendarFrame frame = new XCalendarFrame(gc, t)) { // // // Rectangle area = new Rectangle((area = popup.getClientArea()).x, area.y, area.width - 1, area.height - 1); // gc.setAdvanced(true); // gc.setAntialias(SWT.ON); // gc.setBackground(theme.getBackground(true, false, false, false)); // gc.fillRectangle(area); gc.setForeground(theme.getGrid(true)); gc.drawRectangle(area); // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(XCalendarWidget widget:widgets) widget.render(frame); // } // } // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/XCalendarConfig.java import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.XCalendarLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.impl.XCalendarDefaultLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.XCalendarRender; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.impl.XCalendarDefaultRender; package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config; /** * * @author Jingqi Xu */ public class XCalendarConfig { // protected XCalendarLayout layout;
protected XCalendarRender render;
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/XCalendarConfig.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/XCalendarLayout.java // public interface XCalendarLayout { // // /** // * // */ // void layout(XCalendar calendar); // // void layout(XCalendar calendar, Composite parent, Rectangle bounds); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/impl/XCalendarDefaultLayout.java // public class XCalendarDefaultLayout implements XCalendarLayout { // // // private Composite prevParent; // private Rectangle prevBounds; // // /** // * // */ // @Override // public void layout(XCalendar popup) { // layout(popup, this.prevParent, this.prevBounds); // } // // /** // * // */ // @Override // public void layout(XCalendar popup, Composite parent, Rectangle bounds) { // // // this.prevParent = parent; // this.prevBounds = bounds; // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // int x = theme.getMargin(), y = theme.getMargin(); // int m = theme.getMargin(), w = theme.getWidth() - 2 * m; // // // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(int i = 0; i < widgets.size(); i++) { // final XCalendarWidget v = widgets.get(i); // final Pair<Point> points = v.locate(x, y, w, m); // v.setBounds(x, y, points.getV1().x, points.getV1().y); // x = points.getV2().x; y = points.getV2().y; // } // // // // final Shell shell = popup.getShell(); // shell.setSize(new Point(theme.getWidth(), y + m)); setLocation(popup); // } // // /** // * // */ // protected void setLocation(final XCalendar popup) { // // // final Shell shell = popup.getShell(); // final Display display = popup.getDisplay(); // final Rectangle r1 = display.map(prevParent, null, prevBounds); // final Rectangle r2 = popup.getMonitor().getClientArea(); // Client area // // // // final int margin = 2; // final Point size = shell.getSize(); // int x = r1.x, y = r1.y + r1.height + margin; // if(y + size.y > r2.y + r2.height) y = r1.y - size.y - margin; // if(x < r2.x) x = r2.x; else if(x + size.x > r2.x + r2.width) x = r2.x + r2.width - size.x; // shell.setLocation(x, y); // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/XCalendarRender.java // public interface XCalendarRender { // void render(XCalendar popup, GC gc); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/impl/XCalendarDefaultRender.java // public class XCalendarDefaultRender implements XCalendarRender { // // public void render(XCalendar popup, GC gc) { // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // final Transform t = new Transform(gc.getDevice()); // // // // try (final XCalendarFrame frame = new XCalendarFrame(gc, t)) { // // // Rectangle area = new Rectangle((area = popup.getClientArea()).x, area.y, area.width - 1, area.height - 1); // gc.setAdvanced(true); // gc.setAntialias(SWT.ON); // gc.setBackground(theme.getBackground(true, false, false, false)); // gc.fillRectangle(area); gc.setForeground(theme.getGrid(true)); gc.drawRectangle(area); // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(XCalendarWidget widget:widgets) widget.render(frame); // } // } // }
import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.XCalendarLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.impl.XCalendarDefaultLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.XCalendarRender; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.impl.XCalendarDefaultRender;
package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config; /** * * @author Jingqi Xu */ public class XCalendarConfig { // protected XCalendarLayout layout; protected XCalendarRender render; /** * */ public XCalendarConfig() {
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/XCalendarLayout.java // public interface XCalendarLayout { // // /** // * // */ // void layout(XCalendar calendar); // // void layout(XCalendar calendar, Composite parent, Rectangle bounds); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/impl/XCalendarDefaultLayout.java // public class XCalendarDefaultLayout implements XCalendarLayout { // // // private Composite prevParent; // private Rectangle prevBounds; // // /** // * // */ // @Override // public void layout(XCalendar popup) { // layout(popup, this.prevParent, this.prevBounds); // } // // /** // * // */ // @Override // public void layout(XCalendar popup, Composite parent, Rectangle bounds) { // // // this.prevParent = parent; // this.prevBounds = bounds; // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // int x = theme.getMargin(), y = theme.getMargin(); // int m = theme.getMargin(), w = theme.getWidth() - 2 * m; // // // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(int i = 0; i < widgets.size(); i++) { // final XCalendarWidget v = widgets.get(i); // final Pair<Point> points = v.locate(x, y, w, m); // v.setBounds(x, y, points.getV1().x, points.getV1().y); // x = points.getV2().x; y = points.getV2().y; // } // // // // final Shell shell = popup.getShell(); // shell.setSize(new Point(theme.getWidth(), y + m)); setLocation(popup); // } // // /** // * // */ // protected void setLocation(final XCalendar popup) { // // // final Shell shell = popup.getShell(); // final Display display = popup.getDisplay(); // final Rectangle r1 = display.map(prevParent, null, prevBounds); // final Rectangle r2 = popup.getMonitor().getClientArea(); // Client area // // // // final int margin = 2; // final Point size = shell.getSize(); // int x = r1.x, y = r1.y + r1.height + margin; // if(y + size.y > r2.y + r2.height) y = r1.y - size.y - margin; // if(x < r2.x) x = r2.x; else if(x + size.x > r2.x + r2.width) x = r2.x + r2.width - size.x; // shell.setLocation(x, y); // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/XCalendarRender.java // public interface XCalendarRender { // void render(XCalendar popup, GC gc); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/impl/XCalendarDefaultRender.java // public class XCalendarDefaultRender implements XCalendarRender { // // public void render(XCalendar popup, GC gc) { // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // final Transform t = new Transform(gc.getDevice()); // // // // try (final XCalendarFrame frame = new XCalendarFrame(gc, t)) { // // // Rectangle area = new Rectangle((area = popup.getClientArea()).x, area.y, area.width - 1, area.height - 1); // gc.setAdvanced(true); // gc.setAntialias(SWT.ON); // gc.setBackground(theme.getBackground(true, false, false, false)); // gc.fillRectangle(area); gc.setForeground(theme.getGrid(true)); gc.drawRectangle(area); // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(XCalendarWidget widget:widgets) widget.render(frame); // } // } // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/XCalendarConfig.java import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.XCalendarLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.impl.XCalendarDefaultLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.XCalendarRender; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.impl.XCalendarDefaultRender; package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config; /** * * @author Jingqi Xu */ public class XCalendarConfig { // protected XCalendarLayout layout; protected XCalendarRender render; /** * */ public XCalendarConfig() {
this.layout = new XCalendarDefaultLayout();
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/XCalendarConfig.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/XCalendarLayout.java // public interface XCalendarLayout { // // /** // * // */ // void layout(XCalendar calendar); // // void layout(XCalendar calendar, Composite parent, Rectangle bounds); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/impl/XCalendarDefaultLayout.java // public class XCalendarDefaultLayout implements XCalendarLayout { // // // private Composite prevParent; // private Rectangle prevBounds; // // /** // * // */ // @Override // public void layout(XCalendar popup) { // layout(popup, this.prevParent, this.prevBounds); // } // // /** // * // */ // @Override // public void layout(XCalendar popup, Composite parent, Rectangle bounds) { // // // this.prevParent = parent; // this.prevBounds = bounds; // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // int x = theme.getMargin(), y = theme.getMargin(); // int m = theme.getMargin(), w = theme.getWidth() - 2 * m; // // // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(int i = 0; i < widgets.size(); i++) { // final XCalendarWidget v = widgets.get(i); // final Pair<Point> points = v.locate(x, y, w, m); // v.setBounds(x, y, points.getV1().x, points.getV1().y); // x = points.getV2().x; y = points.getV2().y; // } // // // // final Shell shell = popup.getShell(); // shell.setSize(new Point(theme.getWidth(), y + m)); setLocation(popup); // } // // /** // * // */ // protected void setLocation(final XCalendar popup) { // // // final Shell shell = popup.getShell(); // final Display display = popup.getDisplay(); // final Rectangle r1 = display.map(prevParent, null, prevBounds); // final Rectangle r2 = popup.getMonitor().getClientArea(); // Client area // // // // final int margin = 2; // final Point size = shell.getSize(); // int x = r1.x, y = r1.y + r1.height + margin; // if(y + size.y > r2.y + r2.height) y = r1.y - size.y - margin; // if(x < r2.x) x = r2.x; else if(x + size.x > r2.x + r2.width) x = r2.x + r2.width - size.x; // shell.setLocation(x, y); // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/XCalendarRender.java // public interface XCalendarRender { // void render(XCalendar popup, GC gc); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/impl/XCalendarDefaultRender.java // public class XCalendarDefaultRender implements XCalendarRender { // // public void render(XCalendar popup, GC gc) { // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // final Transform t = new Transform(gc.getDevice()); // // // // try (final XCalendarFrame frame = new XCalendarFrame(gc, t)) { // // // Rectangle area = new Rectangle((area = popup.getClientArea()).x, area.y, area.width - 1, area.height - 1); // gc.setAdvanced(true); // gc.setAntialias(SWT.ON); // gc.setBackground(theme.getBackground(true, false, false, false)); // gc.fillRectangle(area); gc.setForeground(theme.getGrid(true)); gc.drawRectangle(area); // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(XCalendarWidget widget:widgets) widget.render(frame); // } // } // }
import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.XCalendarLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.impl.XCalendarDefaultLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.XCalendarRender; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.impl.XCalendarDefaultRender;
package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config; /** * * @author Jingqi Xu */ public class XCalendarConfig { // protected XCalendarLayout layout; protected XCalendarRender render; /** * */ public XCalendarConfig() { this.layout = new XCalendarDefaultLayout();
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/XCalendarLayout.java // public interface XCalendarLayout { // // /** // * // */ // void layout(XCalendar calendar); // // void layout(XCalendar calendar, Composite parent, Rectangle bounds); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/layout/impl/XCalendarDefaultLayout.java // public class XCalendarDefaultLayout implements XCalendarLayout { // // // private Composite prevParent; // private Rectangle prevBounds; // // /** // * // */ // @Override // public void layout(XCalendar popup) { // layout(popup, this.prevParent, this.prevBounds); // } // // /** // * // */ // @Override // public void layout(XCalendar popup, Composite parent, Rectangle bounds) { // // // this.prevParent = parent; // this.prevBounds = bounds; // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // int x = theme.getMargin(), y = theme.getMargin(); // int m = theme.getMargin(), w = theme.getWidth() - 2 * m; // // // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(int i = 0; i < widgets.size(); i++) { // final XCalendarWidget v = widgets.get(i); // final Pair<Point> points = v.locate(x, y, w, m); // v.setBounds(x, y, points.getV1().x, points.getV1().y); // x = points.getV2().x; y = points.getV2().y; // } // // // // final Shell shell = popup.getShell(); // shell.setSize(new Point(theme.getWidth(), y + m)); setLocation(popup); // } // // /** // * // */ // protected void setLocation(final XCalendar popup) { // // // final Shell shell = popup.getShell(); // final Display display = popup.getDisplay(); // final Rectangle r1 = display.map(prevParent, null, prevBounds); // final Rectangle r2 = popup.getMonitor().getClientArea(); // Client area // // // // final int margin = 2; // final Point size = shell.getSize(); // int x = r1.x, y = r1.y + r1.height + margin; // if(y + size.y > r2.y + r2.height) y = r1.y - size.y - margin; // if(x < r2.x) x = r2.x; else if(x + size.x > r2.x + r2.width) x = r2.x + r2.width - size.x; // shell.setLocation(x, y); // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/XCalendarRender.java // public interface XCalendarRender { // void render(XCalendar popup, GC gc); // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/render/impl/XCalendarDefaultRender.java // public class XCalendarDefaultRender implements XCalendarRender { // // public void render(XCalendar popup, GC gc) { // final XCalendarModel model = popup.getModel(); // final XCalendarTheme theme = model.getTheme(); // final Transform t = new Transform(gc.getDevice()); // // // // try (final XCalendarFrame frame = new XCalendarFrame(gc, t)) { // // // Rectangle area = new Rectangle((area = popup.getClientArea()).x, area.y, area.width - 1, area.height - 1); // gc.setAdvanced(true); // gc.setAntialias(SWT.ON); // gc.setBackground(theme.getBackground(true, false, false, false)); // gc.fillRectangle(area); gc.setForeground(theme.getGrid(true)); gc.drawRectangle(area); // // List<XCalendarWidget> widgets = popup.getWidgets(); // for(XCalendarWidget widget:widgets) widget.render(frame); // } // } // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/config/XCalendarConfig.java import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.XCalendarLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.layout.impl.XCalendarDefaultLayout; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.XCalendarRender; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config.render.impl.XCalendarDefaultRender; package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.config; /** * * @author Jingqi Xu */ public class XCalendarConfig { // protected XCalendarLayout layout; protected XCalendarRender render; /** * */ public XCalendarConfig() { this.layout = new XCalendarDefaultLayout();
this.render = new XCalendarDefaultRender();
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/XCalendarTheme.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/utility/graphics/Fonts.java // public final class Fonts { // // // public static final Font SYSTEM = Display.getDefault().getSystemFont(); // public static final Font AWESOME = FontAwesome.getFont(Math.max(10, getHeight(SYSTEM))); // // // // protected static final ConcurrentMultiKeyMap<Class<?>, String, Font> FONTS = new ConcurrentMultiKeyMap<>(); // // /** // * Font // */ // public static Font getSystemFont() { // return SYSTEM; // } // // public static Font getAwesomeFont() { // return AWESOME; // } // // /** // * // */ // public static final int getHeight(Font font) { // return font.getFontData()[0].getHeight(); // } // // public static final Font bold(final Font font) { // FontDescriptor fd = FontDescriptor.createFrom(font); // return fd.setStyle(SWT.BOLD).createFont(Display.getDefault()); // } // // public static final Font size(Font font, int delta) { // FontDescriptor fd = FontDescriptor.createFrom(font); // int height = fd.getFontData()[0].getHeight() + delta; // return fd.setHeight(height).createFont(Display.getDefault()); // } // // /** // * // */ // public static Font getFont(Class<?> clazz, String key, Supplier<Font> font) { // Font r = FONTS.get(clazz, key); if(r != null) return r; // Font existing = FONTS.putIfAbsent(clazz, key, r = font.get()); // if (existing != null) { r.dispose(); r = existing; } return r; // Dispose // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/utility/graphics/Colors.java // public static final Color getColor(int r, int g, int b) { // final String key = new StringBuilder(12).append(r).append(":").append(g).append(":").append(b).toString(); // Color c = COLORS.get(key); if (c == null) COLORS.put(key, c = new Color(getDefault(), r, g, b)); return c; // }
import cn.nextop.thorin.rcp.support.swt.utility.graphics.Fonts; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import static cn.nextop.thorin.rcp.support.swt.utility.graphics.Colors.getColor;
package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme; /** * * @author Jingqi Xu */ public abstract class XCalendarTheme { private static final String[][] HOUR = { { "00", "01", "02", "03" }, { "04", "05", "06", "07" }, { "08", "09", "10", "11" }, { "12", "13", "14", "15" }, { "16", "17", "18", "19" }, { "20", "21", "22", "23" } }; private static final String[][] MINUTE = { { "00", "05", "10", "15" }, { "20", "25", "30", "35" }, { "40", "45", "50", "55" } }; private static final String[][] SECOND = { { "00", "05", "10", "15" }, { "20", "25", "30", "35" }, { "40", "45", "50", "55" } }; // protected int arc = 8; protected int margin = 5; protected int width = 220;
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/utility/graphics/Fonts.java // public final class Fonts { // // // public static final Font SYSTEM = Display.getDefault().getSystemFont(); // public static final Font AWESOME = FontAwesome.getFont(Math.max(10, getHeight(SYSTEM))); // // // // protected static final ConcurrentMultiKeyMap<Class<?>, String, Font> FONTS = new ConcurrentMultiKeyMap<>(); // // /** // * Font // */ // public static Font getSystemFont() { // return SYSTEM; // } // // public static Font getAwesomeFont() { // return AWESOME; // } // // /** // * // */ // public static final int getHeight(Font font) { // return font.getFontData()[0].getHeight(); // } // // public static final Font bold(final Font font) { // FontDescriptor fd = FontDescriptor.createFrom(font); // return fd.setStyle(SWT.BOLD).createFont(Display.getDefault()); // } // // public static final Font size(Font font, int delta) { // FontDescriptor fd = FontDescriptor.createFrom(font); // int height = fd.getFontData()[0].getHeight() + delta; // return fd.setHeight(height).createFont(Display.getDefault()); // } // // /** // * // */ // public static Font getFont(Class<?> clazz, String key, Supplier<Font> font) { // Font r = FONTS.get(clazz, key); if(r != null) return r; // Font existing = FONTS.putIfAbsent(clazz, key, r = font.get()); // if (existing != null) { r.dispose(); r = existing; } return r; // Dispose // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/utility/graphics/Colors.java // public static final Color getColor(int r, int g, int b) { // final String key = new StringBuilder(12).append(r).append(":").append(g).append(":").append(b).toString(); // Color c = COLORS.get(key); if (c == null) COLORS.put(key, c = new Color(getDefault(), r, g, b)); return c; // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/XCalendarTheme.java import cn.nextop.thorin.rcp.support.swt.utility.graphics.Fonts; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import static cn.nextop.thorin.rcp.support.swt.utility.graphics.Colors.getColor; package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme; /** * * @author Jingqi Xu */ public abstract class XCalendarTheme { private static final String[][] HOUR = { { "00", "01", "02", "03" }, { "04", "05", "06", "07" }, { "08", "09", "10", "11" }, { "12", "13", "14", "15" }, { "16", "17", "18", "19" }, { "20", "21", "22", "23" } }; private static final String[][] MINUTE = { { "00", "05", "10", "15" }, { "20", "25", "30", "35" }, { "40", "45", "50", "55" } }; private static final String[][] SECOND = { { "00", "05", "10", "15" }, { "20", "25", "30", "35" }, { "40", "45", "50", "55" } }; // protected int arc = 8; protected int margin = 5; protected int width = 220;
protected Font font = Fonts.getSystemFont();
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/XCalendarTheme.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/utility/graphics/Fonts.java // public final class Fonts { // // // public static final Font SYSTEM = Display.getDefault().getSystemFont(); // public static final Font AWESOME = FontAwesome.getFont(Math.max(10, getHeight(SYSTEM))); // // // // protected static final ConcurrentMultiKeyMap<Class<?>, String, Font> FONTS = new ConcurrentMultiKeyMap<>(); // // /** // * Font // */ // public static Font getSystemFont() { // return SYSTEM; // } // // public static Font getAwesomeFont() { // return AWESOME; // } // // /** // * // */ // public static final int getHeight(Font font) { // return font.getFontData()[0].getHeight(); // } // // public static final Font bold(final Font font) { // FontDescriptor fd = FontDescriptor.createFrom(font); // return fd.setStyle(SWT.BOLD).createFont(Display.getDefault()); // } // // public static final Font size(Font font, int delta) { // FontDescriptor fd = FontDescriptor.createFrom(font); // int height = fd.getFontData()[0].getHeight() + delta; // return fd.setHeight(height).createFont(Display.getDefault()); // } // // /** // * // */ // public static Font getFont(Class<?> clazz, String key, Supplier<Font> font) { // Font r = FONTS.get(clazz, key); if(r != null) return r; // Font existing = FONTS.putIfAbsent(clazz, key, r = font.get()); // if (existing != null) { r.dispose(); r = existing; } return r; // Dispose // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/utility/graphics/Colors.java // public static final Color getColor(int r, int g, int b) { // final String key = new StringBuilder(12).append(r).append(":").append(g).append(":").append(b).toString(); // Color c = COLORS.get(key); if (c == null) COLORS.put(key, c = new Color(getDefault(), r, g, b)); return c; // }
import cn.nextop.thorin.rcp.support.swt.utility.graphics.Fonts; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import static cn.nextop.thorin.rcp.support.swt.utility.graphics.Colors.getColor;
package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme; /** * * @author Jingqi Xu */ public abstract class XCalendarTheme { private static final String[][] HOUR = { { "00", "01", "02", "03" }, { "04", "05", "06", "07" }, { "08", "09", "10", "11" }, { "12", "13", "14", "15" }, { "16", "17", "18", "19" }, { "20", "21", "22", "23" } }; private static final String[][] MINUTE = { { "00", "05", "10", "15" }, { "20", "25", "30", "35" }, { "40", "45", "50", "55" } }; private static final String[][] SECOND = { { "00", "05", "10", "15" }, { "20", "25", "30", "35" }, { "40", "45", "50", "55" } }; // protected int arc = 8; protected int margin = 5; protected int width = 220; protected Font font = Fonts.getSystemFont(); protected Font bold = Fonts.getFont(XCalendarTheme.class, "bold", () -> Fonts.bold(this.font));
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/utility/graphics/Fonts.java // public final class Fonts { // // // public static final Font SYSTEM = Display.getDefault().getSystemFont(); // public static final Font AWESOME = FontAwesome.getFont(Math.max(10, getHeight(SYSTEM))); // // // // protected static final ConcurrentMultiKeyMap<Class<?>, String, Font> FONTS = new ConcurrentMultiKeyMap<>(); // // /** // * Font // */ // public static Font getSystemFont() { // return SYSTEM; // } // // public static Font getAwesomeFont() { // return AWESOME; // } // // /** // * // */ // public static final int getHeight(Font font) { // return font.getFontData()[0].getHeight(); // } // // public static final Font bold(final Font font) { // FontDescriptor fd = FontDescriptor.createFrom(font); // return fd.setStyle(SWT.BOLD).createFont(Display.getDefault()); // } // // public static final Font size(Font font, int delta) { // FontDescriptor fd = FontDescriptor.createFrom(font); // int height = fd.getFontData()[0].getHeight() + delta; // return fd.setHeight(height).createFont(Display.getDefault()); // } // // /** // * // */ // public static Font getFont(Class<?> clazz, String key, Supplier<Font> font) { // Font r = FONTS.get(clazz, key); if(r != null) return r; // Font existing = FONTS.putIfAbsent(clazz, key, r = font.get()); // if (existing != null) { r.dispose(); r = existing; } return r; // Dispose // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/utility/graphics/Colors.java // public static final Color getColor(int r, int g, int b) { // final String key = new StringBuilder(12).append(r).append(":").append(g).append(":").append(b).toString(); // Color c = COLORS.get(key); if (c == null) COLORS.put(key, c = new Color(getDefault(), r, g, b)); return c; // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/model/theme/XCalendarTheme.java import cn.nextop.thorin.rcp.support.swt.utility.graphics.Fonts; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import static cn.nextop.thorin.rcp.support.swt.utility.graphics.Colors.getColor; package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.model.theme; /** * * @author Jingqi Xu */ public abstract class XCalendarTheme { private static final String[][] HOUR = { { "00", "01", "02", "03" }, { "04", "05", "06", "07" }, { "08", "09", "10", "11" }, { "12", "13", "14", "15" }, { "16", "17", "18", "19" }, { "20", "21", "22", "23" } }; private static final String[][] MINUTE = { { "00", "05", "10", "15" }, { "20", "25", "30", "35" }, { "40", "45", "50", "55" } }; private static final String[][] SECOND = { { "00", "05", "10", "15" }, { "20", "25", "30", "35" }, { "40", "45", "50", "55" } }; // protected int arc = 8; protected int margin = 5; protected int width = 220; protected Font font = Fonts.getSystemFont(); protected Font bold = Fonts.getFont(XCalendarTheme.class, "bold", () -> Fonts.bold(this.font));
protected Color[] grid = new Color[] { getColor(0xc8, 0xc8, 0xc8), getColor(0x8f, 0xbc, 0xee) };
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/XCalendarEventBus.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/handler/XCalendarEventHandler.java // public interface XCalendarEventHandler { // // /** // * // */ // int getPriority(); // // boolean handle(Context context, Event event); // // /** // * // */ // interface Context { // // XCalendarEventHandler getFocus(); // // void setFocus(XCalendarEventHandler handler); // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/listener/XCalendarEventListener.java // public interface XCalendarEventListener { // // void onEvent(XCalendarEvent event); // }
import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.handler.XCalendarEventHandler; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.listener.XCalendarEventListener; import org.eclipse.swt.widgets.Event;
package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event; /** * * @author Jingqi Xu */ public interface XCalendarEventBus { /** * */ void handle(Event event);
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/handler/XCalendarEventHandler.java // public interface XCalendarEventHandler { // // /** // * // */ // int getPriority(); // // boolean handle(Context context, Event event); // // /** // * // */ // interface Context { // // XCalendarEventHandler getFocus(); // // void setFocus(XCalendarEventHandler handler); // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/listener/XCalendarEventListener.java // public interface XCalendarEventListener { // // void onEvent(XCalendarEvent event); // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/XCalendarEventBus.java import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.handler.XCalendarEventHandler; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.listener.XCalendarEventListener; import org.eclipse.swt.widgets.Event; package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event; /** * * @author Jingqi Xu */ public interface XCalendarEventBus { /** * */ void handle(Event event);
boolean addHandler(XCalendarEventHandler reactor);
nextopcn/xcalendar
src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/XCalendarEventBus.java
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/handler/XCalendarEventHandler.java // public interface XCalendarEventHandler { // // /** // * // */ // int getPriority(); // // boolean handle(Context context, Event event); // // /** // * // */ // interface Context { // // XCalendarEventHandler getFocus(); // // void setFocus(XCalendarEventHandler handler); // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/listener/XCalendarEventListener.java // public interface XCalendarEventListener { // // void onEvent(XCalendarEvent event); // }
import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.handler.XCalendarEventHandler; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.listener.XCalendarEventListener; import org.eclipse.swt.widgets.Event;
package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event; /** * * @author Jingqi Xu */ public interface XCalendarEventBus { /** * */ void handle(Event event); boolean addHandler(XCalendarEventHandler reactor); boolean delHandler(XCalendarEventHandler reactor); /** * */ void publish(XCalendarEvent event);
// Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/handler/XCalendarEventHandler.java // public interface XCalendarEventHandler { // // /** // * // */ // int getPriority(); // // boolean handle(Context context, Event event); // // /** // * // */ // interface Context { // // XCalendarEventHandler getFocus(); // // void setFocus(XCalendarEventHandler handler); // } // } // // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/listener/XCalendarEventListener.java // public interface XCalendarEventListener { // // void onEvent(XCalendarEvent event); // } // Path: src/main/java/cn/nextop/thorin/rcp/support/swt/widget/xcalendar/event/XCalendarEventBus.java import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.handler.XCalendarEventHandler; import cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event.listener.XCalendarEventListener; import org.eclipse.swt.widgets.Event; package cn.nextop.thorin.rcp.support.swt.widget.xcalendar.event; /** * * @author Jingqi Xu */ public interface XCalendarEventBus { /** * */ void handle(Event event); boolean addHandler(XCalendarEventHandler reactor); boolean delHandler(XCalendarEventHandler reactor); /** * */ void publish(XCalendarEvent event);
boolean addListener(XCalendarEventListener listener);
Doctoror/Pure-File-Manager
purefm/src/androidTest/java/com/docd/purefm/test/ArrayUtilsTest.java
// Path: purefm/src/main/java/com/docd/purefm/utils/ArrayUtils.java // public final class ArrayUtils { // // private ArrayUtils() {} // // @SuppressWarnings("unchecked") // public static <INPUT, OUTPUT> void copyArrayAndCast(@NonNull final INPUT[] input, @NonNull final OUTPUT[] output) { // if (input.length != output.length) { // throw new IllegalArgumentException("input and output lengths differ"); // } // for (int i = 0; i < input.length; i++) { // output[i] = (OUTPUT) input[i]; // } // } // }
import android.test.AndroidTestCase; import com.docd.purefm.utils.ArrayUtils;
/* * Copyright 2014 Yaroslav Mytkalyk * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.docd.purefm.test; /** * Tests {@link com.docd.purefm.utils.ArrayUtils} * * @author Doctoror */ public final class ArrayUtilsTest extends AndroidTestCase { @Override protected void runTest() throws Throwable { super.runTest(); testEmpty(); test(); } private void testEmpty() throws Throwable {
// Path: purefm/src/main/java/com/docd/purefm/utils/ArrayUtils.java // public final class ArrayUtils { // // private ArrayUtils() {} // // @SuppressWarnings("unchecked") // public static <INPUT, OUTPUT> void copyArrayAndCast(@NonNull final INPUT[] input, @NonNull final OUTPUT[] output) { // if (input.length != output.length) { // throw new IllegalArgumentException("input and output lengths differ"); // } // for (int i = 0; i < input.length; i++) { // output[i] = (OUTPUT) input[i]; // } // } // } // Path: purefm/src/androidTest/java/com/docd/purefm/test/ArrayUtilsTest.java import android.test.AndroidTestCase; import com.docd.purefm.utils.ArrayUtils; /* * Copyright 2014 Yaroslav Mytkalyk * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.docd.purefm.test; /** * Tests {@link com.docd.purefm.utils.ArrayUtils} * * @author Doctoror */ public final class ArrayUtilsTest extends AndroidTestCase { @Override protected void runTest() throws Throwable { super.runTest(); testEmpty(); test(); } private void testEmpty() throws Throwable {
ArrayUtils.copyArrayAndCast(new CharSequence[0], new String[0]);
Doctoror/Pure-File-Manager
purefm/src/androidTest/java/com/docd/purefm/test/StatFsCompatTest.java
// Path: purefm/src/main/java/com/docd/purefm/utils/StatFsCompat.java // public final class StatFsCompat { // // /** // * StatFs instance // */ // @NonNull // private final StatFs mStatFs; // // /** // * Construct a new StatFs for looking at the stats of the filesystem at // * {@code path}. Upon construction, the stat of the file system will be // * performed, and the values retrieved available from the methods on this // * class. // * // * @param path path in the desired file system to stat. // */ // public StatFsCompat(@NonNull final String path) { // this.mStatFs = new StatFs(path); // } // // /** // * The number of blocks that are free on the file system and available to // * applications. This corresponds to the Unix {@code statvfs.f_bavail} field. // */ // @SuppressLint("NewApi") // @SuppressWarnings("deprecation") // public long getAvailableBlocksLong() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getAvailableBlocksLong(); // } else { // return mStatFs.getAvailableBlocks(); // } // } // // /** // * The total number of blocks on the file system. This corresponds to the // * Unix {@code statvfs.f_blocks} field. // */ // @SuppressLint("NewApi") // @SuppressWarnings("deprecation") // public long getBlockCountLong() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getBlockCountLong(); // } else { // return mStatFs.getBlockCount(); // } // } // // /** // * The size, in bytes, of a block on the file system. This corresponds to // * the Unix {@code statvfs.f_bsize} field. // */ // @SuppressLint("NewApi") // @SuppressWarnings("deprecation") // public long getBlockSizeLong() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getBlockSizeLong(); // } else { // return mStatFs.getBlockSize(); // } // } // // /** // * The total number of blocks that are free on the file system, including // * reserved blocks (that are not available to normal applications). This // * corresponds to the Unix {@code statvfs.f_bfree} field. Most applications // * will want to use {@link #getAvailableBlocksLong()} instead. // */ // @SuppressLint("NewApi") // @SuppressWarnings("deprecation") // public long getFreeBlocksLong() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getFreeBlocksLong(); // } else { // return mStatFs.getFreeBlocks(); // } // } // // /** // * The number of bytes that are free on the file system and available to // * applications. // */ // @SuppressLint("NewApi") // public long getAvailableBytes() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getAvailableBytes(); // } else { // return getAvailableBlocksLong() * getBlockSizeLong(); // } // } // // /** // * The number of bytes that are free on the file system, including reserved // * blocks (that are not available to normal applications). Most applications // * will want to use {@link #getAvailableBytes()} instead. // */ // @SuppressLint("NewApi") // public long getFreeBytes() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getFreeBytes(); // } else { // return getFreeBlocksLong() * getBlockSizeLong(); // } // } // // /** // * The total number of bytes supported by the file system. // */ // public long getTotalBytes() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getTotalBytes(); // } else { // return getBlockCountLong() * getBlockSizeLong(); // } // } // // /** // * Perform a restat of the file system referenced by this object. This is // * the same as re-constructing the object with the same file system path, // * and the new stat values are available upon return. // */ // public void restat(@NonNull final String path) { // mStatFs.restat(path); // } // }
import android.annotation.TargetApi; import android.os.Build; import android.os.Environment; import android.os.StatFs; import android.test.AndroidTestCase; import com.docd.purefm.utils.StatFsCompat; import android.support.annotation.NonNull;
/* * Copyright 2014 Yaroslav Mytkalyk * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.docd.purefm.test; /** * Tests {@link com.docd.purefm.utils.StatFsCompat} * * @author Doctoror */ public final class StatFsCompatTest extends AndroidTestCase { @Override protected void setUp() throws Exception { super.setUp(); final String state = Environment.getExternalStorageState(); if (!state.equals(Environment.MEDIA_MOUNTED) && !state.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { throw new RuntimeException("Make sure the external storage is mounted before running this test"); } } @Override protected void runTest() throws Throwable { super.runTest(); final String path = Environment.getExternalStorageDirectory().getAbsolutePath(); final StatFs statFs = new StatFs(path);
// Path: purefm/src/main/java/com/docd/purefm/utils/StatFsCompat.java // public final class StatFsCompat { // // /** // * StatFs instance // */ // @NonNull // private final StatFs mStatFs; // // /** // * Construct a new StatFs for looking at the stats of the filesystem at // * {@code path}. Upon construction, the stat of the file system will be // * performed, and the values retrieved available from the methods on this // * class. // * // * @param path path in the desired file system to stat. // */ // public StatFsCompat(@NonNull final String path) { // this.mStatFs = new StatFs(path); // } // // /** // * The number of blocks that are free on the file system and available to // * applications. This corresponds to the Unix {@code statvfs.f_bavail} field. // */ // @SuppressLint("NewApi") // @SuppressWarnings("deprecation") // public long getAvailableBlocksLong() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getAvailableBlocksLong(); // } else { // return mStatFs.getAvailableBlocks(); // } // } // // /** // * The total number of blocks on the file system. This corresponds to the // * Unix {@code statvfs.f_blocks} field. // */ // @SuppressLint("NewApi") // @SuppressWarnings("deprecation") // public long getBlockCountLong() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getBlockCountLong(); // } else { // return mStatFs.getBlockCount(); // } // } // // /** // * The size, in bytes, of a block on the file system. This corresponds to // * the Unix {@code statvfs.f_bsize} field. // */ // @SuppressLint("NewApi") // @SuppressWarnings("deprecation") // public long getBlockSizeLong() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getBlockSizeLong(); // } else { // return mStatFs.getBlockSize(); // } // } // // /** // * The total number of blocks that are free on the file system, including // * reserved blocks (that are not available to normal applications). This // * corresponds to the Unix {@code statvfs.f_bfree} field. Most applications // * will want to use {@link #getAvailableBlocksLong()} instead. // */ // @SuppressLint("NewApi") // @SuppressWarnings("deprecation") // public long getFreeBlocksLong() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getFreeBlocksLong(); // } else { // return mStatFs.getFreeBlocks(); // } // } // // /** // * The number of bytes that are free on the file system and available to // * applications. // */ // @SuppressLint("NewApi") // public long getAvailableBytes() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getAvailableBytes(); // } else { // return getAvailableBlocksLong() * getBlockSizeLong(); // } // } // // /** // * The number of bytes that are free on the file system, including reserved // * blocks (that are not available to normal applications). Most applications // * will want to use {@link #getAvailableBytes()} instead. // */ // @SuppressLint("NewApi") // public long getFreeBytes() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getFreeBytes(); // } else { // return getFreeBlocksLong() * getBlockSizeLong(); // } // } // // /** // * The total number of bytes supported by the file system. // */ // public long getTotalBytes() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { // return mStatFs.getTotalBytes(); // } else { // return getBlockCountLong() * getBlockSizeLong(); // } // } // // /** // * Perform a restat of the file system referenced by this object. This is // * the same as re-constructing the object with the same file system path, // * and the new stat values are available upon return. // */ // public void restat(@NonNull final String path) { // mStatFs.restat(path); // } // } // Path: purefm/src/androidTest/java/com/docd/purefm/test/StatFsCompatTest.java import android.annotation.TargetApi; import android.os.Build; import android.os.Environment; import android.os.StatFs; import android.test.AndroidTestCase; import com.docd.purefm.utils.StatFsCompat; import android.support.annotation.NonNull; /* * Copyright 2014 Yaroslav Mytkalyk * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.docd.purefm.test; /** * Tests {@link com.docd.purefm.utils.StatFsCompat} * * @author Doctoror */ public final class StatFsCompatTest extends AndroidTestCase { @Override protected void setUp() throws Exception { super.setUp(); final String state = Environment.getExternalStorageState(); if (!state.equals(Environment.MEDIA_MOUNTED) && !state.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { throw new RuntimeException("Make sure the external storage is mounted before running this test"); } } @Override protected void runTest() throws Throwable { super.runTest(); final String path = Environment.getExternalStorageDirectory().getAbsolutePath(); final StatFs statFs = new StatFs(path);
final StatFsCompat statFsCompat = new StatFsCompat(path);
Doctoror/Pure-File-Manager
purefm/src/androidTest/java/com/docd/purefm/test/PureFMTextUtilsTest.java
// Path: purefm/src/main/java/com/docd/purefm/utils/PFMTextUtils.java // public final class PFMTextUtils { // // private PFMTextUtils() {} // // private static SimpleDateFormat sFormat; // private static final Calendar CALENDAR = Calendar.getInstance( // TimeZone.getDefault(), Locale.getDefault()); // // public static void init(@NonNull final Context context) { // if (DateFormat.is24HourFormat(context)) { // sFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.getDefault()); // } else { // sFormat = new SimpleDateFormat("dd/MM/yyyy KK:mm aa", Locale.getDefault()); // } // } // // @NonNull // public static synchronized String humanReadableDate( // final long date, final boolean isUtc) { // if (isUtc) { // final long offset = -(CALENDAR.get(Calendar.ZONE_OFFSET) + CALENDAR.get(Calendar.DST_OFFSET)); // return sFormat.format(date - offset); // } else { // return sFormat.format(date); // } // } // // public static int stringMonthToInt(@NonNull final String month) { // switch (month) { // case "Jan": // return Calendar.JANUARY; // // case "Feb": // return Calendar.FEBRUARY; // // case "Mar": // return Calendar.MARCH; // // case "Apr": // return Calendar.APRIL; // // case "May": // return Calendar.MAY; // // case "Jun": // return Calendar.JUNE; // // case "Jul": // return Calendar.JULY; // // case "Aug": // return Calendar.AUGUST; // // case "Sep": // return Calendar.SEPTEMBER; // // case "Oct": // return Calendar.OCTOBER; // // case "Nov": // return Calendar.NOVEMBER; // // case "Dec": // return Calendar.DECEMBER; // // default: // return 0; // } // } // // @NonNull // public static SpannableString fileListToDashList(@NonNull final Iterable<GenericFile> files) { // final StringBuilder fileList = new StringBuilder(66); // for (final GenericFile file : files) { // fileList.append(file.getName()); // fileList.append('\n'); // } // // remove last '\n' // if (fileList.length() != 0) { // fileList.deleteCharAt(fileList.length() - 1); // final SpannableString ss = new SpannableString(fileList.toString()); // ss.setSpan(new DashSpan(), 0, ss.length(), 0); // // return ss; // } // return new SpannableString(""); // } // }
import android.test.AndroidTestCase; import com.docd.purefm.utils.PFMTextUtils; import java.util.Calendar;
/* * Copyright 2014 Yaroslav Mytkalyk * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.docd.purefm.test; /** * Tests {@link com.docd.purefm.utils.PFMTextUtils} * * @author Doctoror */ public final class PureFMTextUtilsTest extends AndroidTestCase { @Override protected void runTest() throws Throwable { super.runTest();
// Path: purefm/src/main/java/com/docd/purefm/utils/PFMTextUtils.java // public final class PFMTextUtils { // // private PFMTextUtils() {} // // private static SimpleDateFormat sFormat; // private static final Calendar CALENDAR = Calendar.getInstance( // TimeZone.getDefault(), Locale.getDefault()); // // public static void init(@NonNull final Context context) { // if (DateFormat.is24HourFormat(context)) { // sFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.getDefault()); // } else { // sFormat = new SimpleDateFormat("dd/MM/yyyy KK:mm aa", Locale.getDefault()); // } // } // // @NonNull // public static synchronized String humanReadableDate( // final long date, final boolean isUtc) { // if (isUtc) { // final long offset = -(CALENDAR.get(Calendar.ZONE_OFFSET) + CALENDAR.get(Calendar.DST_OFFSET)); // return sFormat.format(date - offset); // } else { // return sFormat.format(date); // } // } // // public static int stringMonthToInt(@NonNull final String month) { // switch (month) { // case "Jan": // return Calendar.JANUARY; // // case "Feb": // return Calendar.FEBRUARY; // // case "Mar": // return Calendar.MARCH; // // case "Apr": // return Calendar.APRIL; // // case "May": // return Calendar.MAY; // // case "Jun": // return Calendar.JUNE; // // case "Jul": // return Calendar.JULY; // // case "Aug": // return Calendar.AUGUST; // // case "Sep": // return Calendar.SEPTEMBER; // // case "Oct": // return Calendar.OCTOBER; // // case "Nov": // return Calendar.NOVEMBER; // // case "Dec": // return Calendar.DECEMBER; // // default: // return 0; // } // } // // @NonNull // public static SpannableString fileListToDashList(@NonNull final Iterable<GenericFile> files) { // final StringBuilder fileList = new StringBuilder(66); // for (final GenericFile file : files) { // fileList.append(file.getName()); // fileList.append('\n'); // } // // remove last '\n' // if (fileList.length() != 0) { // fileList.deleteCharAt(fileList.length() - 1); // final SpannableString ss = new SpannableString(fileList.toString()); // ss.setSpan(new DashSpan(), 0, ss.length(), 0); // // return ss; // } // return new SpannableString(""); // } // } // Path: purefm/src/androidTest/java/com/docd/purefm/test/PureFMTextUtilsTest.java import android.test.AndroidTestCase; import com.docd.purefm.utils.PFMTextUtils; import java.util.Calendar; /* * Copyright 2014 Yaroslav Mytkalyk * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.docd.purefm.test; /** * Tests {@link com.docd.purefm.utils.PFMTextUtils} * * @author Doctoror */ public final class PureFMTextUtilsTest extends AndroidTestCase { @Override protected void runTest() throws Throwable { super.runTest();
PFMTextUtils.init(getContext());
equadon/intellij-mips
src/com/equadon/intellij/mips/editor/MipsColorSettingsPage.java
// Path: src/com/equadon/intellij/mips/icons/MipsIcons.java // public interface MipsIcons { // Icon FILE = IconLoader.getIcon("/icons/mips-file-16.png"); // Icon LABEL = IconLoader.getIcon("/icons/mips-label-16.png"); // Icon DIRECTIVE = IconLoader.getIcon("/icons/mips-directive-16.png"); // Icon INSTRUCTION = IconLoader.getIcon("/icons/mips-instruction-16.png"); // } // // Path: src/com/equadon/intellij/mips/editor/MipsSyntaxHighlighter.java // public class MipsSyntaxHighlighter extends SyntaxHighlighterBase { // public static final TextAttributesKey ERROR = TextAttributesKey.createTextAttributesKey("MIPS_ERROR", DefaultLanguageHighlighterColors.INVALID_STRING_ESCAPE); // // public static final TextAttributesKey COMMENT = TextAttributesKey.createTextAttributesKey("MIPS_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); // // public static final TextAttributesKey OPERATOR = TextAttributesKey.createTextAttributesKey("MIPS_OPERATOR", DefaultLanguageHighlighterColors.KEYWORD); // public static final TextAttributesKey DIRECTIVE = TextAttributesKey.createTextAttributesKey("MIPS_DIRECTIVE", DefaultLanguageHighlighterColors.STATIC_FIELD); // public static final TextAttributesKey LABEL = TextAttributesKey.createTextAttributesKey("MIPS_LABEL", DefaultLanguageHighlighterColors.IDENTIFIER); // public static final TextAttributesKey MAIN_LABEL = TextAttributesKey.createTextAttributesKey("MIPS_MAIN_LABEL", DefaultLanguageHighlighterColors.STATIC_METHOD); // // public static final TextAttributesKey STRING = TextAttributesKey.createTextAttributesKey("MIPS_STRING", DefaultLanguageHighlighterColors.STRING); // public static final TextAttributesKey NUMBER = TextAttributesKey.createTextAttributesKey("MIPS_NUMBER", DefaultLanguageHighlighterColors.NUMBER); // public static final TextAttributesKey REGISTER = TextAttributesKey.createTextAttributesKey("MIPS_REGISTER", DefaultLanguageHighlighterColors.INSTANCE_FIELD); // // @NotNull // @Override // public Lexer getHighlightingLexer() { // return new MipsLexerAdapter(); // } // // @NotNull // @Override // public TextAttributesKey[] getTokenHighlights(IElementType type) { // if (type == TokenType.BAD_CHARACTER) // return pack(ERROR); // if (MipsTokenTypes.COMMENTS.contains(type)) // return pack(COMMENT); // if (type == MipsElementTypes.OPERATOR) // return pack(OPERATOR); // if (type == MipsElementTypes.DIRECTIVE) // return pack(DIRECTIVE); // if (type == MipsElementTypes.IDENTIFIER) // return pack(LABEL); // if (MipsTokenTypes.STRINGS.contains(type)) // return pack(STRING); // if (MipsTokenTypes.NUMBERS.contains(type)) // return pack(NUMBER); // if (MipsTokenTypes.REGISTERS.contains(type)) // return pack(REGISTER); // // return EMPTY; // } // }
import static com.equadon.intellij.mips.editor.MipsSyntaxHighlighter.*; import com.equadon.intellij.mips.icons.MipsIcons; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.openapi.options.colors.AttributesDescriptor; import com.intellij.openapi.options.colors.ColorDescriptor; import com.intellij.openapi.options.colors.ColorSettingsPage; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Map; import javax.swing.*;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.editor; public class MipsColorSettingsPage implements ColorSettingsPage { private static final AttributesDescriptor[] ATTRIBUTES = new AttributesDescriptor[] { new AttributesDescriptor("Illegal character", ERROR), new AttributesDescriptor("Comment", COMMENT), new AttributesDescriptor("String", STRING), new AttributesDescriptor("Number", NUMBER), new AttributesDescriptor("Register", REGISTER), new AttributesDescriptor("Operator", OPERATOR), new AttributesDescriptor("Directive", DIRECTIVE), new AttributesDescriptor("Label", LABEL), }; private static Map<String, TextAttributesKey> ATTRIBUTES_KEY_MAP = ContainerUtil.newHashMap(); static { ATTRIBUTES_KEY_MAP.put("d", DIRECTIVE); ATTRIBUTES_KEY_MAP.put("l", LABEL); ATTRIBUTES_KEY_MAP.put("o", OPERATOR); } @Nullable @Override public Icon getIcon() {
// Path: src/com/equadon/intellij/mips/icons/MipsIcons.java // public interface MipsIcons { // Icon FILE = IconLoader.getIcon("/icons/mips-file-16.png"); // Icon LABEL = IconLoader.getIcon("/icons/mips-label-16.png"); // Icon DIRECTIVE = IconLoader.getIcon("/icons/mips-directive-16.png"); // Icon INSTRUCTION = IconLoader.getIcon("/icons/mips-instruction-16.png"); // } // // Path: src/com/equadon/intellij/mips/editor/MipsSyntaxHighlighter.java // public class MipsSyntaxHighlighter extends SyntaxHighlighterBase { // public static final TextAttributesKey ERROR = TextAttributesKey.createTextAttributesKey("MIPS_ERROR", DefaultLanguageHighlighterColors.INVALID_STRING_ESCAPE); // // public static final TextAttributesKey COMMENT = TextAttributesKey.createTextAttributesKey("MIPS_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); // // public static final TextAttributesKey OPERATOR = TextAttributesKey.createTextAttributesKey("MIPS_OPERATOR", DefaultLanguageHighlighterColors.KEYWORD); // public static final TextAttributesKey DIRECTIVE = TextAttributesKey.createTextAttributesKey("MIPS_DIRECTIVE", DefaultLanguageHighlighterColors.STATIC_FIELD); // public static final TextAttributesKey LABEL = TextAttributesKey.createTextAttributesKey("MIPS_LABEL", DefaultLanguageHighlighterColors.IDENTIFIER); // public static final TextAttributesKey MAIN_LABEL = TextAttributesKey.createTextAttributesKey("MIPS_MAIN_LABEL", DefaultLanguageHighlighterColors.STATIC_METHOD); // // public static final TextAttributesKey STRING = TextAttributesKey.createTextAttributesKey("MIPS_STRING", DefaultLanguageHighlighterColors.STRING); // public static final TextAttributesKey NUMBER = TextAttributesKey.createTextAttributesKey("MIPS_NUMBER", DefaultLanguageHighlighterColors.NUMBER); // public static final TextAttributesKey REGISTER = TextAttributesKey.createTextAttributesKey("MIPS_REGISTER", DefaultLanguageHighlighterColors.INSTANCE_FIELD); // // @NotNull // @Override // public Lexer getHighlightingLexer() { // return new MipsLexerAdapter(); // } // // @NotNull // @Override // public TextAttributesKey[] getTokenHighlights(IElementType type) { // if (type == TokenType.BAD_CHARACTER) // return pack(ERROR); // if (MipsTokenTypes.COMMENTS.contains(type)) // return pack(COMMENT); // if (type == MipsElementTypes.OPERATOR) // return pack(OPERATOR); // if (type == MipsElementTypes.DIRECTIVE) // return pack(DIRECTIVE); // if (type == MipsElementTypes.IDENTIFIER) // return pack(LABEL); // if (MipsTokenTypes.STRINGS.contains(type)) // return pack(STRING); // if (MipsTokenTypes.NUMBERS.contains(type)) // return pack(NUMBER); // if (MipsTokenTypes.REGISTERS.contains(type)) // return pack(REGISTER); // // return EMPTY; // } // } // Path: src/com/equadon/intellij/mips/editor/MipsColorSettingsPage.java import static com.equadon.intellij.mips.editor.MipsSyntaxHighlighter.*; import com.equadon.intellij.mips.icons.MipsIcons; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.openapi.options.colors.AttributesDescriptor; import com.intellij.openapi.options.colors.ColorDescriptor; import com.intellij.openapi.options.colors.ColorSettingsPage; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Map; import javax.swing.*; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.editor; public class MipsColorSettingsPage implements ColorSettingsPage { private static final AttributesDescriptor[] ATTRIBUTES = new AttributesDescriptor[] { new AttributesDescriptor("Illegal character", ERROR), new AttributesDescriptor("Comment", COMMENT), new AttributesDescriptor("String", STRING), new AttributesDescriptor("Number", NUMBER), new AttributesDescriptor("Register", REGISTER), new AttributesDescriptor("Operator", OPERATOR), new AttributesDescriptor("Directive", DIRECTIVE), new AttributesDescriptor("Label", LABEL), }; private static Map<String, TextAttributesKey> ATTRIBUTES_KEY_MAP = ContainerUtil.newHashMap(); static { ATTRIBUTES_KEY_MAP.put("d", DIRECTIVE); ATTRIBUTES_KEY_MAP.put("l", LABEL); ATTRIBUTES_KEY_MAP.put("o", OPERATOR); } @Nullable @Override public Icon getIcon() {
return MipsIcons.FILE;
equadon/intellij-mips
src/com/equadon/intellij/mips/editor/MipsColorSettingsPage.java
// Path: src/com/equadon/intellij/mips/icons/MipsIcons.java // public interface MipsIcons { // Icon FILE = IconLoader.getIcon("/icons/mips-file-16.png"); // Icon LABEL = IconLoader.getIcon("/icons/mips-label-16.png"); // Icon DIRECTIVE = IconLoader.getIcon("/icons/mips-directive-16.png"); // Icon INSTRUCTION = IconLoader.getIcon("/icons/mips-instruction-16.png"); // } // // Path: src/com/equadon/intellij/mips/editor/MipsSyntaxHighlighter.java // public class MipsSyntaxHighlighter extends SyntaxHighlighterBase { // public static final TextAttributesKey ERROR = TextAttributesKey.createTextAttributesKey("MIPS_ERROR", DefaultLanguageHighlighterColors.INVALID_STRING_ESCAPE); // // public static final TextAttributesKey COMMENT = TextAttributesKey.createTextAttributesKey("MIPS_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); // // public static final TextAttributesKey OPERATOR = TextAttributesKey.createTextAttributesKey("MIPS_OPERATOR", DefaultLanguageHighlighterColors.KEYWORD); // public static final TextAttributesKey DIRECTIVE = TextAttributesKey.createTextAttributesKey("MIPS_DIRECTIVE", DefaultLanguageHighlighterColors.STATIC_FIELD); // public static final TextAttributesKey LABEL = TextAttributesKey.createTextAttributesKey("MIPS_LABEL", DefaultLanguageHighlighterColors.IDENTIFIER); // public static final TextAttributesKey MAIN_LABEL = TextAttributesKey.createTextAttributesKey("MIPS_MAIN_LABEL", DefaultLanguageHighlighterColors.STATIC_METHOD); // // public static final TextAttributesKey STRING = TextAttributesKey.createTextAttributesKey("MIPS_STRING", DefaultLanguageHighlighterColors.STRING); // public static final TextAttributesKey NUMBER = TextAttributesKey.createTextAttributesKey("MIPS_NUMBER", DefaultLanguageHighlighterColors.NUMBER); // public static final TextAttributesKey REGISTER = TextAttributesKey.createTextAttributesKey("MIPS_REGISTER", DefaultLanguageHighlighterColors.INSTANCE_FIELD); // // @NotNull // @Override // public Lexer getHighlightingLexer() { // return new MipsLexerAdapter(); // } // // @NotNull // @Override // public TextAttributesKey[] getTokenHighlights(IElementType type) { // if (type == TokenType.BAD_CHARACTER) // return pack(ERROR); // if (MipsTokenTypes.COMMENTS.contains(type)) // return pack(COMMENT); // if (type == MipsElementTypes.OPERATOR) // return pack(OPERATOR); // if (type == MipsElementTypes.DIRECTIVE) // return pack(DIRECTIVE); // if (type == MipsElementTypes.IDENTIFIER) // return pack(LABEL); // if (MipsTokenTypes.STRINGS.contains(type)) // return pack(STRING); // if (MipsTokenTypes.NUMBERS.contains(type)) // return pack(NUMBER); // if (MipsTokenTypes.REGISTERS.contains(type)) // return pack(REGISTER); // // return EMPTY; // } // }
import static com.equadon.intellij.mips.editor.MipsSyntaxHighlighter.*; import com.equadon.intellij.mips.icons.MipsIcons; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.openapi.options.colors.AttributesDescriptor; import com.intellij.openapi.options.colors.ColorDescriptor; import com.intellij.openapi.options.colors.ColorSettingsPage; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Map; import javax.swing.*;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.editor; public class MipsColorSettingsPage implements ColorSettingsPage { private static final AttributesDescriptor[] ATTRIBUTES = new AttributesDescriptor[] { new AttributesDescriptor("Illegal character", ERROR), new AttributesDescriptor("Comment", COMMENT), new AttributesDescriptor("String", STRING), new AttributesDescriptor("Number", NUMBER), new AttributesDescriptor("Register", REGISTER), new AttributesDescriptor("Operator", OPERATOR), new AttributesDescriptor("Directive", DIRECTIVE), new AttributesDescriptor("Label", LABEL), }; private static Map<String, TextAttributesKey> ATTRIBUTES_KEY_MAP = ContainerUtil.newHashMap(); static { ATTRIBUTES_KEY_MAP.put("d", DIRECTIVE); ATTRIBUTES_KEY_MAP.put("l", LABEL); ATTRIBUTES_KEY_MAP.put("o", OPERATOR); } @Nullable @Override public Icon getIcon() { return MipsIcons.FILE; } @NotNull @Override public SyntaxHighlighter getHighlighter() {
// Path: src/com/equadon/intellij/mips/icons/MipsIcons.java // public interface MipsIcons { // Icon FILE = IconLoader.getIcon("/icons/mips-file-16.png"); // Icon LABEL = IconLoader.getIcon("/icons/mips-label-16.png"); // Icon DIRECTIVE = IconLoader.getIcon("/icons/mips-directive-16.png"); // Icon INSTRUCTION = IconLoader.getIcon("/icons/mips-instruction-16.png"); // } // // Path: src/com/equadon/intellij/mips/editor/MipsSyntaxHighlighter.java // public class MipsSyntaxHighlighter extends SyntaxHighlighterBase { // public static final TextAttributesKey ERROR = TextAttributesKey.createTextAttributesKey("MIPS_ERROR", DefaultLanguageHighlighterColors.INVALID_STRING_ESCAPE); // // public static final TextAttributesKey COMMENT = TextAttributesKey.createTextAttributesKey("MIPS_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); // // public static final TextAttributesKey OPERATOR = TextAttributesKey.createTextAttributesKey("MIPS_OPERATOR", DefaultLanguageHighlighterColors.KEYWORD); // public static final TextAttributesKey DIRECTIVE = TextAttributesKey.createTextAttributesKey("MIPS_DIRECTIVE", DefaultLanguageHighlighterColors.STATIC_FIELD); // public static final TextAttributesKey LABEL = TextAttributesKey.createTextAttributesKey("MIPS_LABEL", DefaultLanguageHighlighterColors.IDENTIFIER); // public static final TextAttributesKey MAIN_LABEL = TextAttributesKey.createTextAttributesKey("MIPS_MAIN_LABEL", DefaultLanguageHighlighterColors.STATIC_METHOD); // // public static final TextAttributesKey STRING = TextAttributesKey.createTextAttributesKey("MIPS_STRING", DefaultLanguageHighlighterColors.STRING); // public static final TextAttributesKey NUMBER = TextAttributesKey.createTextAttributesKey("MIPS_NUMBER", DefaultLanguageHighlighterColors.NUMBER); // public static final TextAttributesKey REGISTER = TextAttributesKey.createTextAttributesKey("MIPS_REGISTER", DefaultLanguageHighlighterColors.INSTANCE_FIELD); // // @NotNull // @Override // public Lexer getHighlightingLexer() { // return new MipsLexerAdapter(); // } // // @NotNull // @Override // public TextAttributesKey[] getTokenHighlights(IElementType type) { // if (type == TokenType.BAD_CHARACTER) // return pack(ERROR); // if (MipsTokenTypes.COMMENTS.contains(type)) // return pack(COMMENT); // if (type == MipsElementTypes.OPERATOR) // return pack(OPERATOR); // if (type == MipsElementTypes.DIRECTIVE) // return pack(DIRECTIVE); // if (type == MipsElementTypes.IDENTIFIER) // return pack(LABEL); // if (MipsTokenTypes.STRINGS.contains(type)) // return pack(STRING); // if (MipsTokenTypes.NUMBERS.contains(type)) // return pack(NUMBER); // if (MipsTokenTypes.REGISTERS.contains(type)) // return pack(REGISTER); // // return EMPTY; // } // } // Path: src/com/equadon/intellij/mips/editor/MipsColorSettingsPage.java import static com.equadon.intellij.mips.editor.MipsSyntaxHighlighter.*; import com.equadon.intellij.mips.icons.MipsIcons; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.openapi.options.colors.AttributesDescriptor; import com.intellij.openapi.options.colors.ColorDescriptor; import com.intellij.openapi.options.colors.ColorSettingsPage; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Map; import javax.swing.*; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.editor; public class MipsColorSettingsPage implements ColorSettingsPage { private static final AttributesDescriptor[] ATTRIBUTES = new AttributesDescriptor[] { new AttributesDescriptor("Illegal character", ERROR), new AttributesDescriptor("Comment", COMMENT), new AttributesDescriptor("String", STRING), new AttributesDescriptor("Number", NUMBER), new AttributesDescriptor("Register", REGISTER), new AttributesDescriptor("Operator", OPERATOR), new AttributesDescriptor("Directive", DIRECTIVE), new AttributesDescriptor("Label", LABEL), }; private static Map<String, TextAttributesKey> ATTRIBUTES_KEY_MAP = ContainerUtil.newHashMap(); static { ATTRIBUTES_KEY_MAP.put("d", DIRECTIVE); ATTRIBUTES_KEY_MAP.put("l", LABEL); ATTRIBUTES_KEY_MAP.put("o", OPERATOR); } @Nullable @Override public Icon getIcon() { return MipsIcons.FILE; } @NotNull @Override public SyntaxHighlighter getHighlighter() {
return new MipsSyntaxHighlighter();
equadon/intellij-mips
src/com/equadon/intellij/mips/formatter/MipsLanguageCodeStyleSettingsProvider.java
// Path: src/com/equadon/intellij/mips/lang/MipsLanguage.java // public class MipsLanguage extends Language { // public static final MipsLanguage INSTANCE = new MipsLanguage(); // // public static final String NAME = "MIPS"; // // private MipsLanguage() { // super(NAME); // // Globals.initialize(false); // Globals.program = new MIPSprogram(); // } // // @NotNull // @Override // public String getDisplayName() { // return NAME; // } // }
import com.equadon.intellij.mips.lang.MipsLanguage; import com.intellij.lang.Language; import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.formatter; public class MipsLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider { private static final String MIPS = "MIPS"; @NotNull @Override public Language getLanguage() {
// Path: src/com/equadon/intellij/mips/lang/MipsLanguage.java // public class MipsLanguage extends Language { // public static final MipsLanguage INSTANCE = new MipsLanguage(); // // public static final String NAME = "MIPS"; // // private MipsLanguage() { // super(NAME); // // Globals.initialize(false); // Globals.program = new MIPSprogram(); // } // // @NotNull // @Override // public String getDisplayName() { // return NAME; // } // } // Path: src/com/equadon/intellij/mips/formatter/MipsLanguageCodeStyleSettingsProvider.java import com.equadon.intellij.mips.lang.MipsLanguage; import com.intellij.lang.Language; import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.formatter; public class MipsLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider { private static final String MIPS = "MIPS"; @NotNull @Override public Language getLanguage() {
return MipsLanguage.INSTANCE;
equadon/intellij-mips
src/com/equadon/intellij/mips/run/controllers/MipsSimulatorController.java
// Path: src/com/equadon/intellij/mips/run/MipsRunConfiguration.java // public class MipsRunConfiguration extends LocatableConfigurationBase implements MipsRunConfigurationParams { // private String mainFile; // private Integer maxSteps; // private String workingDirectory; // private Boolean startMain; // private Boolean extendedInstructions; // // protected MipsRunConfiguration(@NotNull Project project, @NotNull ConfigurationFactory factory) { // super(project, factory, "com.equadon.intellij.mips.runconfig.MipsRunConfiguration"); // } // // @Nullable // @Override // public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException { // boolean isDebugger = executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID); // // if (isDebugger) { // return new MipsDebugConsoleState(this, env, getProject()); // } else { // return new MipsConsoleState(this, env, getProject()); // } // } // // @NotNull // @Override // public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() { // return new MipsRunConfigurationEditor(this); // } // // @Override // public void readExternal(Element element) throws InvalidDataException { // super.readExternal(element); // // mainFile = JDOMExternalizerUtil.readField(element, "MIPS_MAIN_FILE"); // // String steps = JDOMExternalizerUtil.readField(element, "MIPS_MAX_STEPS"); // maxSteps = (steps == null || steps.isEmpty()) ? -1 : Integer.parseInt(steps); // // String useMain = JDOMExternalizerUtil.readField(element, "MIPS_START_MAIN"); // startMain = useMain != null && Boolean.parseBoolean(useMain); // // String extended = JDOMExternalizerUtil.readField(element, "MIPS_EXTENDED_INSTRUCTIONS"); // extendedInstructions = extended != null && Boolean.parseBoolean(extended); // } // // @Override // public void writeExternal(Element element) throws WriteExternalException { // super.writeExternal(element); // // String steps = maxSteps == null ? "-1" : maxSteps.toString(); // // JDOMExternalizerUtil.writeField(element, "MIPS_MAIN_FILE", mainFile); // JDOMExternalizerUtil.writeField(element, "MIPS_MAX_STEPS", steps); // JDOMExternalizerUtil.writeField(element, "MIPS_START_MAIN", String.valueOf(startMain)); // JDOMExternalizerUtil.writeField(element, "MIPS_EXTENDED_INSTRUCTIONS", String.valueOf(extendedInstructions)); // } // // @Override // public void checkConfiguration() throws RuntimeConfigurationException { // } // // public static void copyParams(MipsRunConfigurationParams from, MipsRunConfigurationParams to) { // to.setMainFile(from.getMainFile()); // to.setMaxSteps(from.getMaxSteps()); // to.setWorkingDirectory(from.getWorkingDirectory()); // to.setStartMain(from.getStartMain()); // to.setAllowExtendedInstructions(from.allowExtendedInstructions()); // } // // @Override // public String getMainFile() { // return mainFile; // } // // @Override // public void setMainFile(String filename) { // mainFile = filename; // } // // @Override // public String getWorkingDirectory() { // return workingDirectory; // } // // @Override // public void setWorkingDirectory(String dir) { // workingDirectory = dir; // } // // @Override // public Integer getMaxSteps() { // return maxSteps; // } // // @Override // public void setMaxSteps(Integer steps) { // maxSteps = steps; // } // // @Override // public Boolean getStartMain() { // return startMain; // } // // @Override // public void setStartMain(Boolean checked) { // startMain = checked; // } // // @Override // public Boolean allowExtendedInstructions() { // return extendedInstructions; // } // // @Override // public void setAllowExtendedInstructions(Boolean checked) { // extendedInstructions = checked; // } // }
import com.equadon.intellij.mips.run.MipsRunConfiguration; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.xdebugger.XDebugProcess; import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.breakpoints.XBreakpoint; import java.util.ArrayList; import java.util.List;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.run.controllers; /** * Simulator controllers should implement this interface to handle simulation and debugging. */ public abstract class MipsSimulatorController { protected final boolean debugger;
// Path: src/com/equadon/intellij/mips/run/MipsRunConfiguration.java // public class MipsRunConfiguration extends LocatableConfigurationBase implements MipsRunConfigurationParams { // private String mainFile; // private Integer maxSteps; // private String workingDirectory; // private Boolean startMain; // private Boolean extendedInstructions; // // protected MipsRunConfiguration(@NotNull Project project, @NotNull ConfigurationFactory factory) { // super(project, factory, "com.equadon.intellij.mips.runconfig.MipsRunConfiguration"); // } // // @Nullable // @Override // public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException { // boolean isDebugger = executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID); // // if (isDebugger) { // return new MipsDebugConsoleState(this, env, getProject()); // } else { // return new MipsConsoleState(this, env, getProject()); // } // } // // @NotNull // @Override // public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() { // return new MipsRunConfigurationEditor(this); // } // // @Override // public void readExternal(Element element) throws InvalidDataException { // super.readExternal(element); // // mainFile = JDOMExternalizerUtil.readField(element, "MIPS_MAIN_FILE"); // // String steps = JDOMExternalizerUtil.readField(element, "MIPS_MAX_STEPS"); // maxSteps = (steps == null || steps.isEmpty()) ? -1 : Integer.parseInt(steps); // // String useMain = JDOMExternalizerUtil.readField(element, "MIPS_START_MAIN"); // startMain = useMain != null && Boolean.parseBoolean(useMain); // // String extended = JDOMExternalizerUtil.readField(element, "MIPS_EXTENDED_INSTRUCTIONS"); // extendedInstructions = extended != null && Boolean.parseBoolean(extended); // } // // @Override // public void writeExternal(Element element) throws WriteExternalException { // super.writeExternal(element); // // String steps = maxSteps == null ? "-1" : maxSteps.toString(); // // JDOMExternalizerUtil.writeField(element, "MIPS_MAIN_FILE", mainFile); // JDOMExternalizerUtil.writeField(element, "MIPS_MAX_STEPS", steps); // JDOMExternalizerUtil.writeField(element, "MIPS_START_MAIN", String.valueOf(startMain)); // JDOMExternalizerUtil.writeField(element, "MIPS_EXTENDED_INSTRUCTIONS", String.valueOf(extendedInstructions)); // } // // @Override // public void checkConfiguration() throws RuntimeConfigurationException { // } // // public static void copyParams(MipsRunConfigurationParams from, MipsRunConfigurationParams to) { // to.setMainFile(from.getMainFile()); // to.setMaxSteps(from.getMaxSteps()); // to.setWorkingDirectory(from.getWorkingDirectory()); // to.setStartMain(from.getStartMain()); // to.setAllowExtendedInstructions(from.allowExtendedInstructions()); // } // // @Override // public String getMainFile() { // return mainFile; // } // // @Override // public void setMainFile(String filename) { // mainFile = filename; // } // // @Override // public String getWorkingDirectory() { // return workingDirectory; // } // // @Override // public void setWorkingDirectory(String dir) { // workingDirectory = dir; // } // // @Override // public Integer getMaxSteps() { // return maxSteps; // } // // @Override // public void setMaxSteps(Integer steps) { // maxSteps = steps; // } // // @Override // public Boolean getStartMain() { // return startMain; // } // // @Override // public void setStartMain(Boolean checked) { // startMain = checked; // } // // @Override // public Boolean allowExtendedInstructions() { // return extendedInstructions; // } // // @Override // public void setAllowExtendedInstructions(Boolean checked) { // extendedInstructions = checked; // } // } // Path: src/com/equadon/intellij/mips/run/controllers/MipsSimulatorController.java import com.equadon.intellij.mips.run.MipsRunConfiguration; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.xdebugger.XDebugProcess; import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.breakpoints.XBreakpoint; import java.util.ArrayList; import java.util.List; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.run.controllers; /** * Simulator controllers should implement this interface to handle simulation and debugging. */ public abstract class MipsSimulatorController { protected final boolean debugger;
protected final MipsRunConfiguration cfg;
equadon/intellij-mips
src/com/equadon/intellij/mips/run/debugger/MipsExecutionStack.java
// Path: src/com/equadon/intellij/mips/run/controllers/MipsSimulatorController.java // public abstract class MipsSimulatorController { // protected final boolean debugger; // protected final MipsRunConfiguration cfg; // protected final ConsoleView console; // protected final ProcessHandler processHandler; // protected final XDebugProcess debugProcess; // protected final XDebugSession debugSession; // // protected MipsConsoleInputStream inputStream; // // protected final List<XBreakpoint> breakpoints; // // public MipsSimulatorController(MipsRunConfiguration cfg, ConsoleView console, ProcessHandler processHandler) { // this(false, cfg, console, processHandler, null, null); // } // // public MipsSimulatorController(MipsRunConfiguration cfg, ConsoleView console, XDebugProcess process, XDebugSession session) { // this(true, cfg, console, process.getProcessHandler(), process, session); // } // // public MipsSimulatorController(boolean debugger, // MipsRunConfiguration cfg, // ConsoleView console, // ProcessHandler processHandler, // XDebugProcess debugProcess, // XDebugSession debugSession) { // this.debugger = debugger; // this.cfg = cfg; // this.console = console; // this.processHandler = processHandler; // this.debugProcess = debugProcess; // this.debugSession = debugSession; // // inputStream = new MipsConsoleInputStream(cfg.getProject()); // // breakpoints = new ArrayList<>(); // // // Intercept System.out and System.in to handle output and input. // System.setOut(new MipsConsoleOutputStream(this, inputStream)); // System.setIn(inputStream); // } // // public boolean isDebugger() { // return debugger; // } // // /** // * Check if simulator has paused (at a breakpoint) // * @return true if paused // */ // public abstract boolean isPaused(); // // /** // * Check if simulator is finished (i.e. no more instructions to execute) // * @return true if finished // */ // public abstract boolean isFinished(); // // /** // * Resume simulation. // */ // public abstract void resume(); // // /** // * Pause simulation. // */ // public abstract void pause(); // // /** // * Stop simulation. // */ // public void stop() { // processHandler.destroyProcess(); // } // // /** // * Step one instruction. // */ // public abstract void step(); // // /** // * Add new breakpoint. // * @param breakpoint breakpoint to add // */ // public void addBreakpoint(XBreakpoint breakpoint) { // breakpoints.add(breakpoint); // } // // /** // * Remove breakpoint. // * @param breakpoint breakpoint to remove // */ // public void removeBreakpoint(XBreakpoint breakpoint) { // breakpoints.remove(breakpoint); // } // // public void println(String message) { // print(message + "\n"); // } // // public void print(String message) { // print(message, ConsoleViewContentType.NORMAL_OUTPUT); // } // // public void printlnSystem(String message) { // printSystem(message + "\n"); // } // // public void printSystem(String message) { // print(message, ConsoleViewContentType.SYSTEM_OUTPUT); // } // // public void printlnError(String message) { // printError(message + "\n"); // } // // public void printError(String message) { // print(message, ConsoleViewContentType.ERROR_OUTPUT); // } // // public void print(String message, ConsoleViewContentType type) { // console.print(message, type); // } // }
import com.equadon.intellij.mips.run.controllers.MipsSimulatorController; import com.intellij.openapi.project.Project; import com.intellij.xdebugger.frame.XExecutionStack; import com.intellij.xdebugger.frame.XStackFrame; import org.jetbrains.annotations.Nullable;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.run.debugger; public class MipsExecutionStack extends XExecutionStack { private final Project project;
// Path: src/com/equadon/intellij/mips/run/controllers/MipsSimulatorController.java // public abstract class MipsSimulatorController { // protected final boolean debugger; // protected final MipsRunConfiguration cfg; // protected final ConsoleView console; // protected final ProcessHandler processHandler; // protected final XDebugProcess debugProcess; // protected final XDebugSession debugSession; // // protected MipsConsoleInputStream inputStream; // // protected final List<XBreakpoint> breakpoints; // // public MipsSimulatorController(MipsRunConfiguration cfg, ConsoleView console, ProcessHandler processHandler) { // this(false, cfg, console, processHandler, null, null); // } // // public MipsSimulatorController(MipsRunConfiguration cfg, ConsoleView console, XDebugProcess process, XDebugSession session) { // this(true, cfg, console, process.getProcessHandler(), process, session); // } // // public MipsSimulatorController(boolean debugger, // MipsRunConfiguration cfg, // ConsoleView console, // ProcessHandler processHandler, // XDebugProcess debugProcess, // XDebugSession debugSession) { // this.debugger = debugger; // this.cfg = cfg; // this.console = console; // this.processHandler = processHandler; // this.debugProcess = debugProcess; // this.debugSession = debugSession; // // inputStream = new MipsConsoleInputStream(cfg.getProject()); // // breakpoints = new ArrayList<>(); // // // Intercept System.out and System.in to handle output and input. // System.setOut(new MipsConsoleOutputStream(this, inputStream)); // System.setIn(inputStream); // } // // public boolean isDebugger() { // return debugger; // } // // /** // * Check if simulator has paused (at a breakpoint) // * @return true if paused // */ // public abstract boolean isPaused(); // // /** // * Check if simulator is finished (i.e. no more instructions to execute) // * @return true if finished // */ // public abstract boolean isFinished(); // // /** // * Resume simulation. // */ // public abstract void resume(); // // /** // * Pause simulation. // */ // public abstract void pause(); // // /** // * Stop simulation. // */ // public void stop() { // processHandler.destroyProcess(); // } // // /** // * Step one instruction. // */ // public abstract void step(); // // /** // * Add new breakpoint. // * @param breakpoint breakpoint to add // */ // public void addBreakpoint(XBreakpoint breakpoint) { // breakpoints.add(breakpoint); // } // // /** // * Remove breakpoint. // * @param breakpoint breakpoint to remove // */ // public void removeBreakpoint(XBreakpoint breakpoint) { // breakpoints.remove(breakpoint); // } // // public void println(String message) { // print(message + "\n"); // } // // public void print(String message) { // print(message, ConsoleViewContentType.NORMAL_OUTPUT); // } // // public void printlnSystem(String message) { // printSystem(message + "\n"); // } // // public void printSystem(String message) { // print(message, ConsoleViewContentType.SYSTEM_OUTPUT); // } // // public void printlnError(String message) { // printError(message + "\n"); // } // // public void printError(String message) { // print(message, ConsoleViewContentType.ERROR_OUTPUT); // } // // public void print(String message, ConsoleViewContentType type) { // console.print(message, type); // } // } // Path: src/com/equadon/intellij/mips/run/debugger/MipsExecutionStack.java import com.equadon.intellij.mips.run.controllers.MipsSimulatorController; import com.intellij.openapi.project.Project; import com.intellij.xdebugger.frame.XExecutionStack; import com.intellij.xdebugger.frame.XStackFrame; import org.jetbrains.annotations.Nullable; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.run.debugger; public class MipsExecutionStack extends XExecutionStack { private final Project project;
private final MipsSimulatorController controller;
equadon/intellij-mips
src/com/equadon/intellij/mips/run/MipsRunConfigurationType.java
// Path: src/com/equadon/intellij/mips/icons/MipsIcons.java // public interface MipsIcons { // Icon FILE = IconLoader.getIcon("/icons/mips-file-16.png"); // Icon LABEL = IconLoader.getIcon("/icons/mips-label-16.png"); // Icon DIRECTIVE = IconLoader.getIcon("/icons/mips-directive-16.png"); // Icon INSTRUCTION = IconLoader.getIcon("/icons/mips-instruction-16.png"); // }
import com.equadon.intellij.mips.icons.MipsIcons; import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationTypeBase; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.run; public class MipsRunConfigurationType extends ConfigurationTypeBase { private MipsRunConfigurationType() {
// Path: src/com/equadon/intellij/mips/icons/MipsIcons.java // public interface MipsIcons { // Icon FILE = IconLoader.getIcon("/icons/mips-file-16.png"); // Icon LABEL = IconLoader.getIcon("/icons/mips-label-16.png"); // Icon DIRECTIVE = IconLoader.getIcon("/icons/mips-directive-16.png"); // Icon INSTRUCTION = IconLoader.getIcon("/icons/mips-instruction-16.png"); // } // Path: src/com/equadon/intellij/mips/run/MipsRunConfigurationType.java import com.equadon.intellij.mips.icons.MipsIcons; import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationTypeBase; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.run; public class MipsRunConfigurationType extends ConfigurationTypeBase { private MipsRunConfigurationType() {
super("MipsRunConfiguration", "MIPS Application", "MIPS application run configuration", MipsIcons.FILE);
equadon/intellij-mips
src/com/equadon/intellij/mips/structure/MipsStructureViewElement.java
// Path: src/com/equadon/intellij/mips/lang/psi/MipsFile.java // public interface MipsFile extends PsiFile { // Collection<MipsLabelDefinition> getLabelDefinitions(); // }
import javax.swing.*; import com.equadon.intellij.mips.lang.psi.MipsFile; import com.equadon.intellij.mips.lang.psi.MipsLabelDefinition; import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.ide.util.treeView.smartTree.TreeElement; import com.intellij.navigation.ItemPresentation; import com.intellij.navigation.NavigationItem; import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.structure; public class MipsStructureViewElement implements StructureViewTreeElement, ItemPresentation { private final PsiElement element; public MipsStructureViewElement(PsiElement element) { this.element = element; } @Override public Object getValue() { return element; } @NotNull @Override public ItemPresentation getPresentation() { return this; } @NotNull @Override public TreeElement[] getChildren() {
// Path: src/com/equadon/intellij/mips/lang/psi/MipsFile.java // public interface MipsFile extends PsiFile { // Collection<MipsLabelDefinition> getLabelDefinitions(); // } // Path: src/com/equadon/intellij/mips/structure/MipsStructureViewElement.java import javax.swing.*; import com.equadon.intellij.mips.lang.psi.MipsFile; import com.equadon.intellij.mips.lang.psi.MipsLabelDefinition; import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.ide.util.treeView.smartTree.TreeElement; import com.intellij.navigation.ItemPresentation; import com.intellij.navigation.NavigationItem; import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.structure; public class MipsStructureViewElement implements StructureViewTreeElement, ItemPresentation { private final PsiElement element; public MipsStructureViewElement(PsiElement element) { this.element = element; } @Override public Object getValue() { return element; } @NotNull @Override public ItemPresentation getPresentation() { return this; } @NotNull @Override public TreeElement[] getChildren() {
if (element instanceof MipsFile) {
equadon/intellij-mips
src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB);
import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.parser; public class MipsParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) {
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB); // Path: src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.parser; public class MipsParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) {
return new MipsLexerAdapter();
equadon/intellij-mips
src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB);
import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.parser; public class MipsParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) { return new MipsLexerAdapter(); } @Override public PsiParser createParser(Project project) { return new _MipsParser(); } @Override public IFileElementType getFileNodeType() {
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB); // Path: src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.parser; public class MipsParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) { return new MipsLexerAdapter(); } @Override public PsiParser createParser(Project project) { return new _MipsParser(); } @Override public IFileElementType getFileNodeType() {
return MipsFileElementType.INSTANCE;
equadon/intellij-mips
src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB);
import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.parser; public class MipsParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) { return new MipsLexerAdapter(); } @Override public PsiParser createParser(Project project) { return new _MipsParser(); } @Override public IFileElementType getFileNodeType() { return MipsFileElementType.INSTANCE; } @NotNull @Override public TokenSet getWhitespaceTokens() {
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB); // Path: src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.parser; public class MipsParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) { return new MipsLexerAdapter(); } @Override public PsiParser createParser(Project project) { return new _MipsParser(); } @Override public IFileElementType getFileNodeType() { return MipsFileElementType.INSTANCE; } @NotNull @Override public TokenSet getWhitespaceTokens() {
return WHITE_SPACES;
equadon/intellij-mips
src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB);
import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.parser; public class MipsParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) { return new MipsLexerAdapter(); } @Override public PsiParser createParser(Project project) { return new _MipsParser(); } @Override public IFileElementType getFileNodeType() { return MipsFileElementType.INSTANCE; } @NotNull @Override public TokenSet getWhitespaceTokens() { return WHITE_SPACES; } @NotNull @Override public TokenSet getCommentTokens() {
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB); // Path: src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.parser; public class MipsParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) { return new MipsLexerAdapter(); } @Override public PsiParser createParser(Project project) { return new _MipsParser(); } @Override public IFileElementType getFileNodeType() { return MipsFileElementType.INSTANCE; } @NotNull @Override public TokenSet getWhitespaceTokens() { return WHITE_SPACES; } @NotNull @Override public TokenSet getCommentTokens() {
return COMMENTS;
equadon/intellij-mips
src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB);
import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.parser; public class MipsParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) { return new MipsLexerAdapter(); } @Override public PsiParser createParser(Project project) { return new _MipsParser(); } @Override public IFileElementType getFileNodeType() { return MipsFileElementType.INSTANCE; } @NotNull @Override public TokenSet getWhitespaceTokens() { return WHITE_SPACES; } @NotNull @Override public TokenSet getCommentTokens() { return COMMENTS; } @NotNull @Override public TokenSet getStringLiteralElements() {
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB); // Path: src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.parser; public class MipsParserDefinition implements ParserDefinition { @NotNull @Override public Lexer createLexer(Project project) { return new MipsLexerAdapter(); } @Override public PsiParser createParser(Project project) { return new _MipsParser(); } @Override public IFileElementType getFileNodeType() { return MipsFileElementType.INSTANCE; } @NotNull @Override public TokenSet getWhitespaceTokens() { return WHITE_SPACES; } @NotNull @Override public TokenSet getCommentTokens() { return COMMENTS; } @NotNull @Override public TokenSet getStringLiteralElements() {
return STRINGS;
equadon/intellij-mips
src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB);
import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet;
public IFileElementType getFileNodeType() { return MipsFileElementType.INSTANCE; } @NotNull @Override public TokenSet getWhitespaceTokens() { return WHITE_SPACES; } @NotNull @Override public TokenSet getCommentTokens() { return COMMENTS; } @NotNull @Override public TokenSet getStringLiteralElements() { return STRINGS; } @NotNull @Override public PsiElement createElement(ASTNode node) { return MipsElementTypes.Factory.createElement(node); } @Override public PsiFile createFile(FileViewProvider fileViewProvider) {
// Path: src/com/equadon/intellij/mips/lang/lexer/MipsLexerAdapter.java // public class MipsLexerAdapter extends LookAheadLexer { // public MipsLexerAdapter() { // super(new MergingLexerAdapter(new FlexAdapter(new __MipsLexer()), MipsTokenTypes.COMMENTS)); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/impl/MipsFileImpl.java // public class MipsFileImpl extends PsiFileBase implements MipsFile { // public MipsFileImpl(@NotNull FileViewProvider viewProvider) { // super(viewProvider, MipsLanguage.INSTANCE); // } // // @NotNull // @Override // public FileType getFileType() { // return getViewProvider().getFileType(); // } // // @Override // public Collection<MipsLabelDefinition> getLabelDefinitions() { // return PsiTreeUtil.findChildrenOfType(this, MipsLabelDefinition.class); // } // } // // Path: src/com/equadon/intellij/mips/stubs/types/MipsFileElementType.java // public class MipsFileElementType extends IStubFileElementType<MipsFileStub> { // public static final IStubFileElementType INSTANCE = new MipsFileElementType(); // private MipsFileElementType() { // super("MIPS_FILE", MipsLanguage.INSTANCE); // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet COMMENTS = TokenSet.create(COMMENT); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet STRINGS = TokenSet.create(LQUOTE, QUOTED_STRING, RQUOTE); // // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenTypes.java // public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE, TAB); // Path: src/com/equadon/intellij/mips/lang/parser/MipsParserDefinition.java import org.jetbrains.annotations.NotNull; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.COMMENTS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.STRINGS; import static com.equadon.intellij.mips.lang.psi.MipsTokenTypes.WHITE_SPACES; import com.equadon.intellij.mips.lang.lexer.MipsLexerAdapter; import com.equadon.intellij.mips.lang.psi.MipsElementTypes; import com.equadon.intellij.mips.lang.psi.impl.MipsFileImpl; import com.equadon.intellij.mips.stubs.types.MipsFileElementType; import com.intellij.lang.ASTNode; import com.intellij.lang.ParserDefinition; import com.intellij.lang.PsiParser; import com.intellij.lexer.Lexer; import com.intellij.openapi.project.Project; import com.intellij.psi.FileViewProvider; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet; public IFileElementType getFileNodeType() { return MipsFileElementType.INSTANCE; } @NotNull @Override public TokenSet getWhitespaceTokens() { return WHITE_SPACES; } @NotNull @Override public TokenSet getCommentTokens() { return COMMENTS; } @NotNull @Override public TokenSet getStringLiteralElements() { return STRINGS; } @NotNull @Override public PsiElement createElement(ASTNode node) { return MipsElementTypes.Factory.createElement(node); } @Override public PsiFile createFile(FileViewProvider fileViewProvider) {
return new MipsFileImpl(fileViewProvider);
equadon/intellij-mips
src/com/equadon/intellij/mips/run/debugger/MipsSuspendContext.java
// Path: src/com/equadon/intellij/mips/run/controllers/MipsSimulatorController.java // public abstract class MipsSimulatorController { // protected final boolean debugger; // protected final MipsRunConfiguration cfg; // protected final ConsoleView console; // protected final ProcessHandler processHandler; // protected final XDebugProcess debugProcess; // protected final XDebugSession debugSession; // // protected MipsConsoleInputStream inputStream; // // protected final List<XBreakpoint> breakpoints; // // public MipsSimulatorController(MipsRunConfiguration cfg, ConsoleView console, ProcessHandler processHandler) { // this(false, cfg, console, processHandler, null, null); // } // // public MipsSimulatorController(MipsRunConfiguration cfg, ConsoleView console, XDebugProcess process, XDebugSession session) { // this(true, cfg, console, process.getProcessHandler(), process, session); // } // // public MipsSimulatorController(boolean debugger, // MipsRunConfiguration cfg, // ConsoleView console, // ProcessHandler processHandler, // XDebugProcess debugProcess, // XDebugSession debugSession) { // this.debugger = debugger; // this.cfg = cfg; // this.console = console; // this.processHandler = processHandler; // this.debugProcess = debugProcess; // this.debugSession = debugSession; // // inputStream = new MipsConsoleInputStream(cfg.getProject()); // // breakpoints = new ArrayList<>(); // // // Intercept System.out and System.in to handle output and input. // System.setOut(new MipsConsoleOutputStream(this, inputStream)); // System.setIn(inputStream); // } // // public boolean isDebugger() { // return debugger; // } // // /** // * Check if simulator has paused (at a breakpoint) // * @return true if paused // */ // public abstract boolean isPaused(); // // /** // * Check if simulator is finished (i.e. no more instructions to execute) // * @return true if finished // */ // public abstract boolean isFinished(); // // /** // * Resume simulation. // */ // public abstract void resume(); // // /** // * Pause simulation. // */ // public abstract void pause(); // // /** // * Stop simulation. // */ // public void stop() { // processHandler.destroyProcess(); // } // // /** // * Step one instruction. // */ // public abstract void step(); // // /** // * Add new breakpoint. // * @param breakpoint breakpoint to add // */ // public void addBreakpoint(XBreakpoint breakpoint) { // breakpoints.add(breakpoint); // } // // /** // * Remove breakpoint. // * @param breakpoint breakpoint to remove // */ // public void removeBreakpoint(XBreakpoint breakpoint) { // breakpoints.remove(breakpoint); // } // // public void println(String message) { // print(message + "\n"); // } // // public void print(String message) { // print(message, ConsoleViewContentType.NORMAL_OUTPUT); // } // // public void printlnSystem(String message) { // printSystem(message + "\n"); // } // // public void printSystem(String message) { // print(message, ConsoleViewContentType.SYSTEM_OUTPUT); // } // // public void printlnError(String message) { // printError(message + "\n"); // } // // public void printError(String message) { // print(message, ConsoleViewContentType.ERROR_OUTPUT); // } // // public void print(String message, ConsoleViewContentType type) { // console.print(message, type); // } // }
import com.equadon.intellij.mips.run.controllers.MipsSimulatorController; import com.intellij.openapi.project.Project; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.frame.XExecutionStack; import com.intellij.xdebugger.frame.XSuspendContext; import org.jetbrains.annotations.Nullable;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.run.debugger; public class MipsSuspendContext extends XSuspendContext { private final Project project;
// Path: src/com/equadon/intellij/mips/run/controllers/MipsSimulatorController.java // public abstract class MipsSimulatorController { // protected final boolean debugger; // protected final MipsRunConfiguration cfg; // protected final ConsoleView console; // protected final ProcessHandler processHandler; // protected final XDebugProcess debugProcess; // protected final XDebugSession debugSession; // // protected MipsConsoleInputStream inputStream; // // protected final List<XBreakpoint> breakpoints; // // public MipsSimulatorController(MipsRunConfiguration cfg, ConsoleView console, ProcessHandler processHandler) { // this(false, cfg, console, processHandler, null, null); // } // // public MipsSimulatorController(MipsRunConfiguration cfg, ConsoleView console, XDebugProcess process, XDebugSession session) { // this(true, cfg, console, process.getProcessHandler(), process, session); // } // // public MipsSimulatorController(boolean debugger, // MipsRunConfiguration cfg, // ConsoleView console, // ProcessHandler processHandler, // XDebugProcess debugProcess, // XDebugSession debugSession) { // this.debugger = debugger; // this.cfg = cfg; // this.console = console; // this.processHandler = processHandler; // this.debugProcess = debugProcess; // this.debugSession = debugSession; // // inputStream = new MipsConsoleInputStream(cfg.getProject()); // // breakpoints = new ArrayList<>(); // // // Intercept System.out and System.in to handle output and input. // System.setOut(new MipsConsoleOutputStream(this, inputStream)); // System.setIn(inputStream); // } // // public boolean isDebugger() { // return debugger; // } // // /** // * Check if simulator has paused (at a breakpoint) // * @return true if paused // */ // public abstract boolean isPaused(); // // /** // * Check if simulator is finished (i.e. no more instructions to execute) // * @return true if finished // */ // public abstract boolean isFinished(); // // /** // * Resume simulation. // */ // public abstract void resume(); // // /** // * Pause simulation. // */ // public abstract void pause(); // // /** // * Stop simulation. // */ // public void stop() { // processHandler.destroyProcess(); // } // // /** // * Step one instruction. // */ // public abstract void step(); // // /** // * Add new breakpoint. // * @param breakpoint breakpoint to add // */ // public void addBreakpoint(XBreakpoint breakpoint) { // breakpoints.add(breakpoint); // } // // /** // * Remove breakpoint. // * @param breakpoint breakpoint to remove // */ // public void removeBreakpoint(XBreakpoint breakpoint) { // breakpoints.remove(breakpoint); // } // // public void println(String message) { // print(message + "\n"); // } // // public void print(String message) { // print(message, ConsoleViewContentType.NORMAL_OUTPUT); // } // // public void printlnSystem(String message) { // printSystem(message + "\n"); // } // // public void printSystem(String message) { // print(message, ConsoleViewContentType.SYSTEM_OUTPUT); // } // // public void printlnError(String message) { // printError(message + "\n"); // } // // public void printError(String message) { // print(message, ConsoleViewContentType.ERROR_OUTPUT); // } // // public void print(String message, ConsoleViewContentType type) { // console.print(message, type); // } // } // Path: src/com/equadon/intellij/mips/run/debugger/MipsSuspendContext.java import com.equadon.intellij.mips.run.controllers.MipsSimulatorController; import com.intellij.openapi.project.Project; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.frame.XExecutionStack; import com.intellij.xdebugger.frame.XSuspendContext; import org.jetbrains.annotations.Nullable; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.run.debugger; public class MipsSuspendContext extends XSuspendContext { private final Project project;
private final MipsSimulatorController controller;
equadon/intellij-mips
src/com/equadon/intellij/mips/spellchecker/MipsSpellCheckingStrategy.java
// Path: src/com/equadon/intellij/mips/lang/MipsLanguage.java // public class MipsLanguage extends Language { // public static final MipsLanguage INSTANCE = new MipsLanguage(); // // public static final String NAME = "MIPS"; // // private MipsLanguage() { // super(NAME); // // Globals.initialize(false); // Globals.program = new MIPSprogram(); // } // // @NotNull // @Override // public String getDisplayName() { // return NAME; // } // }
import com.equadon.intellij.mips.lang.MipsLanguage; import com.intellij.psi.PsiElement; import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy; import org.jetbrains.annotations.NotNull;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.spellchecker; public class MipsSpellCheckingStrategy extends SpellcheckingStrategy { @Override public boolean isMyContext(@NotNull PsiElement element) {
// Path: src/com/equadon/intellij/mips/lang/MipsLanguage.java // public class MipsLanguage extends Language { // public static final MipsLanguage INSTANCE = new MipsLanguage(); // // public static final String NAME = "MIPS"; // // private MipsLanguage() { // super(NAME); // // Globals.initialize(false); // Globals.program = new MIPSprogram(); // } // // @NotNull // @Override // public String getDisplayName() { // return NAME; // } // } // Path: src/com/equadon/intellij/mips/spellchecker/MipsSpellCheckingStrategy.java import com.equadon.intellij.mips.lang.MipsLanguage; import com.intellij.psi.PsiElement; import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy; import org.jetbrains.annotations.NotNull; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.spellchecker; public class MipsSpellCheckingStrategy extends SpellcheckingStrategy { @Override public boolean isMyContext(@NotNull PsiElement element) {
return MipsLanguage.INSTANCE.is(element.getLanguage());
equadon/intellij-mips
src/com/equadon/intellij/mips/template/MipsContextType.java
// Path: src/com/equadon/intellij/mips/lang/MipsLanguage.java // public class MipsLanguage extends Language { // public static final MipsLanguage INSTANCE = new MipsLanguage(); // // public static final String NAME = "MIPS"; // // private MipsLanguage() { // super(NAME); // // Globals.initialize(false); // Globals.program = new MIPSprogram(); // } // // @NotNull // @Override // public String getDisplayName() { // return NAME; // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsFile.java // public interface MipsFile extends PsiFile { // Collection<MipsLabelDefinition> getLabelDefinitions(); // }
import com.equadon.intellij.mips.lang.MipsLanguage; import com.equadon.intellij.mips.lang.psi.MipsFile; import com.intellij.codeInsight.template.EverywhereContextType; import com.intellij.codeInsight.template.TemplateContextType; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.util.PsiUtilCore; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.template; public abstract class MipsContextType extends TemplateContextType { protected MipsContextType(@NotNull String id, @NotNull String presentableName, @Nullable Class<? extends TemplateContextType> baseContextType) { super(id, presentableName, baseContextType); } @Override public boolean isInContext(@NotNull PsiFile file, int offset) {
// Path: src/com/equadon/intellij/mips/lang/MipsLanguage.java // public class MipsLanguage extends Language { // public static final MipsLanguage INSTANCE = new MipsLanguage(); // // public static final String NAME = "MIPS"; // // private MipsLanguage() { // super(NAME); // // Globals.initialize(false); // Globals.program = new MIPSprogram(); // } // // @NotNull // @Override // public String getDisplayName() { // return NAME; // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsFile.java // public interface MipsFile extends PsiFile { // Collection<MipsLabelDefinition> getLabelDefinitions(); // } // Path: src/com/equadon/intellij/mips/template/MipsContextType.java import com.equadon.intellij.mips.lang.MipsLanguage; import com.equadon.intellij.mips.lang.psi.MipsFile; import com.intellij.codeInsight.template.EverywhereContextType; import com.intellij.codeInsight.template.TemplateContextType; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.util.PsiUtilCore; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.template; public abstract class MipsContextType extends TemplateContextType { protected MipsContextType(@NotNull String id, @NotNull String presentableName, @Nullable Class<? extends TemplateContextType> baseContextType) { super(id, presentableName, baseContextType); } @Override public boolean isInContext(@NotNull PsiFile file, int offset) {
if (!PsiUtilCore.getLanguageAtOffset(file, offset).isKindOf(MipsLanguage.INSTANCE)) return false;
equadon/intellij-mips
src/com/equadon/intellij/mips/template/MipsContextType.java
// Path: src/com/equadon/intellij/mips/lang/MipsLanguage.java // public class MipsLanguage extends Language { // public static final MipsLanguage INSTANCE = new MipsLanguage(); // // public static final String NAME = "MIPS"; // // private MipsLanguage() { // super(NAME); // // Globals.initialize(false); // Globals.program = new MIPSprogram(); // } // // @NotNull // @Override // public String getDisplayName() { // return NAME; // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsFile.java // public interface MipsFile extends PsiFile { // Collection<MipsLabelDefinition> getLabelDefinitions(); // }
import com.equadon.intellij.mips.lang.MipsLanguage; import com.equadon.intellij.mips.lang.psi.MipsFile; import com.intellij.codeInsight.template.EverywhereContextType; import com.intellij.codeInsight.template.TemplateContextType; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.util.PsiUtilCore; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.template; public abstract class MipsContextType extends TemplateContextType { protected MipsContextType(@NotNull String id, @NotNull String presentableName, @Nullable Class<? extends TemplateContextType> baseContextType) { super(id, presentableName, baseContextType); } @Override public boolean isInContext(@NotNull PsiFile file, int offset) { if (!PsiUtilCore.getLanguageAtOffset(file, offset).isKindOf(MipsLanguage.INSTANCE)) return false; PsiElement element = file.findElementAt(offset); if (element instanceof PsiWhiteSpace) { return false; } return element != null && isInContext(element); } protected abstract boolean isInContext(PsiElement element); protected static class Generic extends MipsContextType { protected Generic() { super("MIPS_CODE", "MIPS", EverywhereContextType.class); } @Override protected boolean isInContext(PsiElement element) { return true; } } protected static class Declaration extends MipsContextType { protected Declaration() { super("MIPS_DECLARATION", "MIPS", Generic.class); } @Override protected boolean isInContext(PsiElement element) {
// Path: src/com/equadon/intellij/mips/lang/MipsLanguage.java // public class MipsLanguage extends Language { // public static final MipsLanguage INSTANCE = new MipsLanguage(); // // public static final String NAME = "MIPS"; // // private MipsLanguage() { // super(NAME); // // Globals.initialize(false); // Globals.program = new MIPSprogram(); // } // // @NotNull // @Override // public String getDisplayName() { // return NAME; // } // } // // Path: src/com/equadon/intellij/mips/lang/psi/MipsFile.java // public interface MipsFile extends PsiFile { // Collection<MipsLabelDefinition> getLabelDefinitions(); // } // Path: src/com/equadon/intellij/mips/template/MipsContextType.java import com.equadon.intellij.mips.lang.MipsLanguage; import com.equadon.intellij.mips.lang.psi.MipsFile; import com.intellij.codeInsight.template.EverywhereContextType; import com.intellij.codeInsight.template.TemplateContextType; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.util.PsiUtilCore; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.template; public abstract class MipsContextType extends TemplateContextType { protected MipsContextType(@NotNull String id, @NotNull String presentableName, @Nullable Class<? extends TemplateContextType> baseContextType) { super(id, presentableName, baseContextType); } @Override public boolean isInContext(@NotNull PsiFile file, int offset) { if (!PsiUtilCore.getLanguageAtOffset(file, offset).isKindOf(MipsLanguage.INSTANCE)) return false; PsiElement element = file.findElementAt(offset); if (element instanceof PsiWhiteSpace) { return false; } return element != null && isInContext(element); } protected abstract boolean isInContext(PsiElement element); protected static class Generic extends MipsContextType { protected Generic() { super("MIPS_CODE", "MIPS", EverywhereContextType.class); } @Override protected boolean isInContext(PsiElement element) { return true; } } protected static class Declaration extends MipsContextType { protected Declaration() { super("MIPS_DECLARATION", "MIPS", Generic.class); } @Override protected boolean isInContext(PsiElement element) {
return element != null && element.getParent() instanceof MipsFile;
equadon/intellij-mips
src/com/equadon/intellij/mips/lang/psi/MipsTokenType.java
// Path: src/com/equadon/intellij/mips/lang/MipsLanguage.java // public class MipsLanguage extends Language { // public static final MipsLanguage INSTANCE = new MipsLanguage(); // // public static final String NAME = "MIPS"; // // private MipsLanguage() { // super(NAME); // // Globals.initialize(false); // Globals.program = new MIPSprogram(); // } // // @NotNull // @Override // public String getDisplayName() { // return NAME; // } // }
import com.equadon.intellij.mips.lang.MipsLanguage; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull;
/* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.psi; public class MipsTokenType extends IElementType { public MipsTokenType(@NotNull String debug) {
// Path: src/com/equadon/intellij/mips/lang/MipsLanguage.java // public class MipsLanguage extends Language { // public static final MipsLanguage INSTANCE = new MipsLanguage(); // // public static final String NAME = "MIPS"; // // private MipsLanguage() { // super(NAME); // // Globals.initialize(false); // Globals.program = new MIPSprogram(); // } // // @NotNull // @Override // public String getDisplayName() { // return NAME; // } // } // Path: src/com/equadon/intellij/mips/lang/psi/MipsTokenType.java import com.equadon.intellij.mips.lang.MipsLanguage; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; /* * Copyright 2017 Niklas Persson * * 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. * See the License for the specific language governing permissions and * limitations under the License. */ package com.equadon.intellij.mips.lang.psi; public class MipsTokenType extends IElementType { public MipsTokenType(@NotNull String debug) {
super(debug, MipsLanguage.INSTANCE);