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
bmoyer/osrsclient
src/rsreflection/GameSession.java
// Path: src/rsclient/coregui/RSClient.java // public class RSClient { // // public static Reflector reflector = null; // // public static void main(String[] args) throws IrcException, IOException { // // Toolkit.getDefaultToolkit().setDynamicLayout(true); // System.setProperty("sun.awt.noerasebackground", "true"); // JFrame.setDefaultLookAndFeelDecorated(true); // JDialog.setDefaultLookAndFeelDecorated(true); // // try { // UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel"); // // } catch (Exception e) { // e.printStackTrace(); // } // // initUI(); // } // // public static void initUI() { // JFrame mainwnd = new JFrame("Luna - Open source OSRS Client"); // Image icon = Toolkit.getDefaultToolkit().getImage("resources/lunaicon.png"); // mainwnd.setIconImage(icon); // // // MainToolBar toolbar = new MainToolBar(); // // mainwnd.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // // JPanel mainpanel = new JPanel(new MigLayout("fill, insets 5")); // mainpanel.setBackground(Color.black); // mainpanel.add(toolbar, "dock north, growx, gap 0"); // toolbar.setVisible(true); // // mainwnd.getContentPane().add(mainpanel); // JPanel gamepanel = new JPanel(new MigLayout(" gap 0, ins 0 ")); // gamepanel.setBackground(Color.gray); // // boolean debug = false; // // gamepanel.setVisible(true); // mainpanel.add(gamepanel, "height 503:503,width 765:765, cell 0 0, growx, growy"); //height 503:503:503,width 765:765:765, // gamepanel.setVisible(true); // // JPanel sidepanel = new JPanel(new MigLayout("ins 0")); // JPanel bottompanel = new JPanel(new MigLayout("ins 0")); // sidepanel.setBackground(Color.black); // bottompanel.setBackground(Color.black); // // sidepanel.add(new SidePane(), "width 250:250, height 503, cell 0 0, spany, push, growy"); // bottompanel.add(new BottomPane(), "height 200:200, width 765, cell 0 0,spanx, push, growx "); // mainpanel.add(sidepanel, "width 250, height 503, cell 1 0,growy, spany, dock east "); // mainpanel.add(bottompanel, "height 200, width 765,cell 0 1, growx, dock south"); // // // mainwnd.setVisible(true); // // mainwnd.pack(); // // if (debug) { // gamepanel.add(new JPanel(), "width 765, height 503, cell 0 0"); // // //GameSession game = new GameSession(); // //reflector.setHooks(HookImporter.readJSON("/home/ben/hooks.json")); // //IRCSession mainsesh = new IRCSession(); // //mainsesh.connect("irc.swiftirc.net"); // //mainsesh.joinChannel("#night"); // // // } // if (!debug) { // try { // LoadingPanel l = new LoadingPanel(); // gamepanel.add(l, "width 765:765, height 503:503, cell 0 0, growx, growy, push"); // final Loader loader = new Loader(Game.OSRS, gamepanel); // gamepanel.add(loader.applet, "width 765:765, height 503:503, dock center, growx, growy, push"); // gamepanel.remove(l); // reflector = loader.loader; // // } catch (IllegalArgumentException ex) { // Logger.getLogger(RSClient.class.getName()).log(Level.SEVERE, null, ex); // // } // // } // // } // }
import rsclient.coregui.RSClient;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsreflection; /** * * @author ben */ public class GameSession { public GameSession(){ } public String getSelectedItem(){
// Path: src/rsclient/coregui/RSClient.java // public class RSClient { // // public static Reflector reflector = null; // // public static void main(String[] args) throws IrcException, IOException { // // Toolkit.getDefaultToolkit().setDynamicLayout(true); // System.setProperty("sun.awt.noerasebackground", "true"); // JFrame.setDefaultLookAndFeelDecorated(true); // JDialog.setDefaultLookAndFeelDecorated(true); // // try { // UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel"); // // } catch (Exception e) { // e.printStackTrace(); // } // // initUI(); // } // // public static void initUI() { // JFrame mainwnd = new JFrame("Luna - Open source OSRS Client"); // Image icon = Toolkit.getDefaultToolkit().getImage("resources/lunaicon.png"); // mainwnd.setIconImage(icon); // // // MainToolBar toolbar = new MainToolBar(); // // mainwnd.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // // JPanel mainpanel = new JPanel(new MigLayout("fill, insets 5")); // mainpanel.setBackground(Color.black); // mainpanel.add(toolbar, "dock north, growx, gap 0"); // toolbar.setVisible(true); // // mainwnd.getContentPane().add(mainpanel); // JPanel gamepanel = new JPanel(new MigLayout(" gap 0, ins 0 ")); // gamepanel.setBackground(Color.gray); // // boolean debug = false; // // gamepanel.setVisible(true); // mainpanel.add(gamepanel, "height 503:503,width 765:765, cell 0 0, growx, growy"); //height 503:503:503,width 765:765:765, // gamepanel.setVisible(true); // // JPanel sidepanel = new JPanel(new MigLayout("ins 0")); // JPanel bottompanel = new JPanel(new MigLayout("ins 0")); // sidepanel.setBackground(Color.black); // bottompanel.setBackground(Color.black); // // sidepanel.add(new SidePane(), "width 250:250, height 503, cell 0 0, spany, push, growy"); // bottompanel.add(new BottomPane(), "height 200:200, width 765, cell 0 0,spanx, push, growx "); // mainpanel.add(sidepanel, "width 250, height 503, cell 1 0,growy, spany, dock east "); // mainpanel.add(bottompanel, "height 200, width 765,cell 0 1, growx, dock south"); // // // mainwnd.setVisible(true); // // mainwnd.pack(); // // if (debug) { // gamepanel.add(new JPanel(), "width 765, height 503, cell 0 0"); // // //GameSession game = new GameSession(); // //reflector.setHooks(HookImporter.readJSON("/home/ben/hooks.json")); // //IRCSession mainsesh = new IRCSession(); // //mainsesh.connect("irc.swiftirc.net"); // //mainsesh.joinChannel("#night"); // // // } // if (!debug) { // try { // LoadingPanel l = new LoadingPanel(); // gamepanel.add(l, "width 765:765, height 503:503, cell 0 0, growx, growy, push"); // final Loader loader = new Loader(Game.OSRS, gamepanel); // gamepanel.add(loader.applet, "width 765:765, height 503:503, dock center, growx, growy, push"); // gamepanel.remove(l); // reflector = loader.loader; // // } catch (IllegalArgumentException ex) { // Logger.getLogger(RSClient.class.getName()).log(Level.SEVERE, null, ex); // // } // // } // // } // } // Path: src/rsreflection/GameSession.java import rsclient.coregui.RSClient; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsreflection; /** * * @author ben */ public class GameSession { public GameSession(){ } public String getSelectedItem(){
return (String)RSClient.reflector.getFieldValueByDetails("client", "it");
bmoyer/osrsclient
src/rsclient/chat/ChatConfigPanel.java
// Path: src/logic/Parse.java // public class Parse { // // public static ArrayList<String> parseIrcChannels(String string){ // string = string.replace(" ", ""); // ArrayList<String> chanList = new ArrayList(Arrays.asList(string.split(","))); // // return chanList; // } // // }
import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import logic.Parse; import net.miginfocom.swing.MigLayout; import org.pircbotx.exception.IrcException;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsclient.chat; /** * * @author ben */ public class ChatConfigPanel extends JPanel { private JTextField nickField, chanField; private JButton connectButton; private JLabel nickLabel, chanLabel; private ActionListener fireConnect; private final IrcPanel mainIrcPanel; public ChatConfigPanel(IrcPanel ircPanel) { mainIrcPanel = ircPanel; this.setLayout(new MigLayout("ins 10")); setup(); setupListeners(); connectButton.addActionListener(fireConnect); } private void setup() { //setBackground(Color.black); nickField = new JTextField(); chanField = new JTextField(); nickLabel = new JLabel("Nick:"); chanLabel = new JLabel("Channels:"); connectButton = new JButton("Connect"); add(nickLabel, "cell 0 0"); add(chanLabel, "cell 0 1"); add(nickField, "cell 1 0, width 10%, "); add(chanField, "cell 1 1, width 10%,"); add(connectButton, "cell 0 2"); } private void setupListeners() { fireConnect = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) {
// Path: src/logic/Parse.java // public class Parse { // // public static ArrayList<String> parseIrcChannels(String string){ // string = string.replace(" ", ""); // ArrayList<String> chanList = new ArrayList(Arrays.asList(string.split(","))); // // return chanList; // } // // } // Path: src/rsclient/chat/ChatConfigPanel.java import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import logic.Parse; import net.miginfocom.swing.MigLayout; import org.pircbotx.exception.IrcException; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsclient.chat; /** * * @author ben */ public class ChatConfigPanel extends JPanel { private JTextField nickField, chanField; private JButton connectButton; private JLabel nickLabel, chanLabel; private ActionListener fireConnect; private final IrcPanel mainIrcPanel; public ChatConfigPanel(IrcPanel ircPanel) { mainIrcPanel = ircPanel; this.setLayout(new MigLayout("ins 10")); setup(); setupListeners(); connectButton.addActionListener(fireConnect); } private void setup() { //setBackground(Color.black); nickField = new JTextField(); chanField = new JTextField(); nickLabel = new JLabel("Nick:"); chanLabel = new JLabel("Channels:"); connectButton = new JButton("Connect"); add(nickLabel, "cell 0 0"); add(chanLabel, "cell 0 1"); add(nickField, "cell 1 0, width 10%, "); add(chanField, "cell 1 1, width 10%,"); add(connectButton, "cell 0 2"); } private void setupListeners() { fireConnect = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) {
ArrayList<String> joinChannels = Parse.parseIrcChannels(chanField.getText());
bmoyer/osrsclient
src/rsclient/market/ItemDetailPanel.java
// Path: src/logic/ZybezOffer.java // public class ZybezOffer { // // private final String itemName, rsn, notes,quantity, price, id, selling; // // public ZybezOffer(String i, String s,String q, String p, String iN, String r, String n) { // id = i; // quantity = q; // price = p; // itemName = iN; // notes = n; // rsn = r; // selling = s; // // } // // public String isSellingOffer(){ // return selling; // } // // public String getRSN(){ // return rsn; // } // // public String getID() { // return id; // } // // public String getQuantity() { // return quantity; // } // // public String getPrice() { // return price; // } // // public String getItemName() { // return itemName; // } // // public String getNotes() { // return notes; // } // // }
import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JToggleButton; import javax.swing.border.EtchedBorder; import logic.ZybezOffer; import net.miginfocom.swing.MigLayout;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsclient.market; /** * * @author ben */ public class ItemDetailPanel extends JPanel { private JToggleButton wtbButton, wtsButton; private JScrollPane listScroller; private JLabel itemSelectedLabel; private JTable offerTable; private OfferModel offerModel;
// Path: src/logic/ZybezOffer.java // public class ZybezOffer { // // private final String itemName, rsn, notes,quantity, price, id, selling; // // public ZybezOffer(String i, String s,String q, String p, String iN, String r, String n) { // id = i; // quantity = q; // price = p; // itemName = iN; // notes = n; // rsn = r; // selling = s; // // } // // public String isSellingOffer(){ // return selling; // } // // public String getRSN(){ // return rsn; // } // // public String getID() { // return id; // } // // public String getQuantity() { // return quantity; // } // // public String getPrice() { // return price; // } // // public String getItemName() { // return itemName; // } // // public String getNotes() { // return notes; // } // // } // Path: src/rsclient/market/ItemDetailPanel.java import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JToggleButton; import javax.swing.border.EtchedBorder; import logic.ZybezOffer; import net.miginfocom.swing.MigLayout; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsclient.market; /** * * @author ben */ public class ItemDetailPanel extends JPanel { private JToggleButton wtbButton, wtsButton; private JScrollPane listScroller; private JLabel itemSelectedLabel; private JTable offerTable; private OfferModel offerModel;
private ArrayList<ZybezOffer> currentOffers;
bmoyer/osrsclient
src/rsclient/market/ItemResultPanel.java
// Path: src/logic/ZybezItemListing.java // public class ZybezItemListing { // // private String itemName, imageURL, averagePrice, itemID; // private ArrayList<ZybezOffer> offerList = new ArrayList(); // private int numOffers; // private final String apiURL = "http://forums.zybez.net/runescape-2007-prices/api/item/"; // private String listingJsonString; // // public ZybezItemListing(String id) { // // itemID = id; // setItemData(); // setItemOffers(); // } // // private void setItemData() { // // try { // listingJsonString = getJsonString(); // JSONObject o = (JSONObject) JSONValue.parse(listingJsonString); // // itemName = o.get("name").toString(); // imageURL = o.get("image").toString(); // averagePrice = o.get("average").toString(); // // // } catch (IOException ex) { // Logger.getLogger(ZybezItemListing.class.getName()).log(Level.SEVERE, null, ex); // } // // } // // private void setItemOffers(){ // // JSONObject o = (JSONObject) JSONValue.parse(listingJsonString); // String offerString = o.get("offers").toString(); // JSONArray array = (JSONArray) JSONValue.parse(offerString); // // numOffers = array.size(); // for(int i = 0; i < numOffers; i ++){ // JSONObject o2 = (JSONObject) JSONValue.parse(array.get(i).toString()); // // ZybezOffer z = new ZybezOffer(itemID, o2.get("selling").toString(), // o2.get("quantity").toString(), o2.get("price").toString(), itemName, o2.get("rs_name").toString(), o2.get("notes").toString()); // // offerList.add(z); // } // // // } // // //returns Json string for offers for this item // private String getJsonString() throws MalformedURLException, IOException { // URL url = new URL(apiURL + itemID); // URLConnection urlConnection = url.openConnection(); // urlConnection.addRequestProperty("User-Agent", "Mozilla/5.0"); // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); // //Put JSON data into String message // String message = org.apache.commons.io.IOUtils.toString(in); // return message; // } // // public String getItemID() { // return itemID; // } // // public String getItemName() { // return itemName; // } // // public String getImageURL() { // return imageURL; // } // // public String getAveragePrice() { // return averagePrice; // } // // public ArrayList<ZybezOffer> getOfferList() { // return offerList; // } // // } // // Path: src/logic/ZybezOffer.java // public class ZybezOffer { // // private final String itemName, rsn, notes,quantity, price, id, selling; // // public ZybezOffer(String i, String s,String q, String p, String iN, String r, String n) { // id = i; // quantity = q; // price = p; // itemName = iN; // notes = n; // rsn = r; // selling = s; // // } // // public String isSellingOffer(){ // return selling; // } // // public String getRSN(){ // return rsn; // } // // public String getID() { // return id; // } // // public String getQuantity() { // return quantity; // } // // public String getPrice() { // return price; // } // // public String getItemName() { // return itemName; // } // // public String getNotes() { // return notes; // } // // }
import java.awt.Color; import java.awt.Dimension; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.text.NumberFormat; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.EtchedBorder; import logic.ZybezItemListing; import logic.ZybezOffer; import net.miginfocom.swing.MigLayout; import org.pushingpixels.trident.Timeline;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsclient.market; /** * * @author ben */ public class ItemResultPanel extends JPanel implements MouseListener { private JLabel itemNameLabel, itemPriceLabel, itemPictureLabel; private ItemListingRolloverListener rolloverListener;
// Path: src/logic/ZybezItemListing.java // public class ZybezItemListing { // // private String itemName, imageURL, averagePrice, itemID; // private ArrayList<ZybezOffer> offerList = new ArrayList(); // private int numOffers; // private final String apiURL = "http://forums.zybez.net/runescape-2007-prices/api/item/"; // private String listingJsonString; // // public ZybezItemListing(String id) { // // itemID = id; // setItemData(); // setItemOffers(); // } // // private void setItemData() { // // try { // listingJsonString = getJsonString(); // JSONObject o = (JSONObject) JSONValue.parse(listingJsonString); // // itemName = o.get("name").toString(); // imageURL = o.get("image").toString(); // averagePrice = o.get("average").toString(); // // // } catch (IOException ex) { // Logger.getLogger(ZybezItemListing.class.getName()).log(Level.SEVERE, null, ex); // } // // } // // private void setItemOffers(){ // // JSONObject o = (JSONObject) JSONValue.parse(listingJsonString); // String offerString = o.get("offers").toString(); // JSONArray array = (JSONArray) JSONValue.parse(offerString); // // numOffers = array.size(); // for(int i = 0; i < numOffers; i ++){ // JSONObject o2 = (JSONObject) JSONValue.parse(array.get(i).toString()); // // ZybezOffer z = new ZybezOffer(itemID, o2.get("selling").toString(), // o2.get("quantity").toString(), o2.get("price").toString(), itemName, o2.get("rs_name").toString(), o2.get("notes").toString()); // // offerList.add(z); // } // // // } // // //returns Json string for offers for this item // private String getJsonString() throws MalformedURLException, IOException { // URL url = new URL(apiURL + itemID); // URLConnection urlConnection = url.openConnection(); // urlConnection.addRequestProperty("User-Agent", "Mozilla/5.0"); // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); // //Put JSON data into String message // String message = org.apache.commons.io.IOUtils.toString(in); // return message; // } // // public String getItemID() { // return itemID; // } // // public String getItemName() { // return itemName; // } // // public String getImageURL() { // return imageURL; // } // // public String getAveragePrice() { // return averagePrice; // } // // public ArrayList<ZybezOffer> getOfferList() { // return offerList; // } // // } // // Path: src/logic/ZybezOffer.java // public class ZybezOffer { // // private final String itemName, rsn, notes,quantity, price, id, selling; // // public ZybezOffer(String i, String s,String q, String p, String iN, String r, String n) { // id = i; // quantity = q; // price = p; // itemName = iN; // notes = n; // rsn = r; // selling = s; // // } // // public String isSellingOffer(){ // return selling; // } // // public String getRSN(){ // return rsn; // } // // public String getID() { // return id; // } // // public String getQuantity() { // return quantity; // } // // public String getPrice() { // return price; // } // // public String getItemName() { // return itemName; // } // // public String getNotes() { // return notes; // } // // } // Path: src/rsclient/market/ItemResultPanel.java import java.awt.Color; import java.awt.Dimension; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.text.NumberFormat; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.EtchedBorder; import logic.ZybezItemListing; import logic.ZybezOffer; import net.miginfocom.swing.MigLayout; import org.pushingpixels.trident.Timeline; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsclient.market; /** * * @author ben */ public class ItemResultPanel extends JPanel implements MouseListener { private JLabel itemNameLabel, itemPriceLabel, itemPictureLabel; private ItemListingRolloverListener rolloverListener;
private ArrayList<ZybezOffer> offerList = new ArrayList();
bmoyer/osrsclient
src/rsclient/market/ItemResultPanel.java
// Path: src/logic/ZybezItemListing.java // public class ZybezItemListing { // // private String itemName, imageURL, averagePrice, itemID; // private ArrayList<ZybezOffer> offerList = new ArrayList(); // private int numOffers; // private final String apiURL = "http://forums.zybez.net/runescape-2007-prices/api/item/"; // private String listingJsonString; // // public ZybezItemListing(String id) { // // itemID = id; // setItemData(); // setItemOffers(); // } // // private void setItemData() { // // try { // listingJsonString = getJsonString(); // JSONObject o = (JSONObject) JSONValue.parse(listingJsonString); // // itemName = o.get("name").toString(); // imageURL = o.get("image").toString(); // averagePrice = o.get("average").toString(); // // // } catch (IOException ex) { // Logger.getLogger(ZybezItemListing.class.getName()).log(Level.SEVERE, null, ex); // } // // } // // private void setItemOffers(){ // // JSONObject o = (JSONObject) JSONValue.parse(listingJsonString); // String offerString = o.get("offers").toString(); // JSONArray array = (JSONArray) JSONValue.parse(offerString); // // numOffers = array.size(); // for(int i = 0; i < numOffers; i ++){ // JSONObject o2 = (JSONObject) JSONValue.parse(array.get(i).toString()); // // ZybezOffer z = new ZybezOffer(itemID, o2.get("selling").toString(), // o2.get("quantity").toString(), o2.get("price").toString(), itemName, o2.get("rs_name").toString(), o2.get("notes").toString()); // // offerList.add(z); // } // // // } // // //returns Json string for offers for this item // private String getJsonString() throws MalformedURLException, IOException { // URL url = new URL(apiURL + itemID); // URLConnection urlConnection = url.openConnection(); // urlConnection.addRequestProperty("User-Agent", "Mozilla/5.0"); // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); // //Put JSON data into String message // String message = org.apache.commons.io.IOUtils.toString(in); // return message; // } // // public String getItemID() { // return itemID; // } // // public String getItemName() { // return itemName; // } // // public String getImageURL() { // return imageURL; // } // // public String getAveragePrice() { // return averagePrice; // } // // public ArrayList<ZybezOffer> getOfferList() { // return offerList; // } // // } // // Path: src/logic/ZybezOffer.java // public class ZybezOffer { // // private final String itemName, rsn, notes,quantity, price, id, selling; // // public ZybezOffer(String i, String s,String q, String p, String iN, String r, String n) { // id = i; // quantity = q; // price = p; // itemName = iN; // notes = n; // rsn = r; // selling = s; // // } // // public String isSellingOffer(){ // return selling; // } // // public String getRSN(){ // return rsn; // } // // public String getID() { // return id; // } // // public String getQuantity() { // return quantity; // } // // public String getPrice() { // return price; // } // // public String getItemName() { // return itemName; // } // // public String getNotes() { // return notes; // } // // }
import java.awt.Color; import java.awt.Dimension; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.text.NumberFormat; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.EtchedBorder; import logic.ZybezItemListing; import logic.ZybezOffer; import net.miginfocom.swing.MigLayout; import org.pushingpixels.trident.Timeline;
setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); itemNameLabel = new JLabel("--"); //this prevents several item names from stretching too large itemNameLabel.setMaximumSize(new Dimension(160, 50)); itemPriceLabel = new JLabel("--"); itemPictureLabel = new JLabel(emptyItem); itemPictureLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); itemNameLabel.setForeground(Color.white); itemPriceLabel.setForeground(Color.white); addMouseListener(this); add(itemPictureLabel, "cell 0 0, width 20, height 20, dock west,"); add(itemNameLabel, "cell 1 0"); add(itemPriceLabel, "cell 1 1"); } public void clearContents() { itemNameLabel.setText("--"); itemPriceLabel.setText("--"); itemPictureLabel.setIcon(emptyItem); offerList.clear(); }
// Path: src/logic/ZybezItemListing.java // public class ZybezItemListing { // // private String itemName, imageURL, averagePrice, itemID; // private ArrayList<ZybezOffer> offerList = new ArrayList(); // private int numOffers; // private final String apiURL = "http://forums.zybez.net/runescape-2007-prices/api/item/"; // private String listingJsonString; // // public ZybezItemListing(String id) { // // itemID = id; // setItemData(); // setItemOffers(); // } // // private void setItemData() { // // try { // listingJsonString = getJsonString(); // JSONObject o = (JSONObject) JSONValue.parse(listingJsonString); // // itemName = o.get("name").toString(); // imageURL = o.get("image").toString(); // averagePrice = o.get("average").toString(); // // // } catch (IOException ex) { // Logger.getLogger(ZybezItemListing.class.getName()).log(Level.SEVERE, null, ex); // } // // } // // private void setItemOffers(){ // // JSONObject o = (JSONObject) JSONValue.parse(listingJsonString); // String offerString = o.get("offers").toString(); // JSONArray array = (JSONArray) JSONValue.parse(offerString); // // numOffers = array.size(); // for(int i = 0; i < numOffers; i ++){ // JSONObject o2 = (JSONObject) JSONValue.parse(array.get(i).toString()); // // ZybezOffer z = new ZybezOffer(itemID, o2.get("selling").toString(), // o2.get("quantity").toString(), o2.get("price").toString(), itemName, o2.get("rs_name").toString(), o2.get("notes").toString()); // // offerList.add(z); // } // // // } // // //returns Json string for offers for this item // private String getJsonString() throws MalformedURLException, IOException { // URL url = new URL(apiURL + itemID); // URLConnection urlConnection = url.openConnection(); // urlConnection.addRequestProperty("User-Agent", "Mozilla/5.0"); // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); // //Put JSON data into String message // String message = org.apache.commons.io.IOUtils.toString(in); // return message; // } // // public String getItemID() { // return itemID; // } // // public String getItemName() { // return itemName; // } // // public String getImageURL() { // return imageURL; // } // // public String getAveragePrice() { // return averagePrice; // } // // public ArrayList<ZybezOffer> getOfferList() { // return offerList; // } // // } // // Path: src/logic/ZybezOffer.java // public class ZybezOffer { // // private final String itemName, rsn, notes,quantity, price, id, selling; // // public ZybezOffer(String i, String s,String q, String p, String iN, String r, String n) { // id = i; // quantity = q; // price = p; // itemName = iN; // notes = n; // rsn = r; // selling = s; // // } // // public String isSellingOffer(){ // return selling; // } // // public String getRSN(){ // return rsn; // } // // public String getID() { // return id; // } // // public String getQuantity() { // return quantity; // } // // public String getPrice() { // return price; // } // // public String getItemName() { // return itemName; // } // // public String getNotes() { // return notes; // } // // } // Path: src/rsclient/market/ItemResultPanel.java import java.awt.Color; import java.awt.Dimension; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.text.NumberFormat; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.EtchedBorder; import logic.ZybezItemListing; import logic.ZybezOffer; import net.miginfocom.swing.MigLayout; import org.pushingpixels.trident.Timeline; setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); itemNameLabel = new JLabel("--"); //this prevents several item names from stretching too large itemNameLabel.setMaximumSize(new Dimension(160, 50)); itemPriceLabel = new JLabel("--"); itemPictureLabel = new JLabel(emptyItem); itemPictureLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); itemNameLabel.setForeground(Color.white); itemPriceLabel.setForeground(Color.white); addMouseListener(this); add(itemPictureLabel, "cell 0 0, width 20, height 20, dock west,"); add(itemNameLabel, "cell 1 0"); add(itemPriceLabel, "cell 1 1"); } public void clearContents() { itemNameLabel.setText("--"); itemPriceLabel.setText("--"); itemPictureLabel.setIcon(emptyItem); offerList.clear(); }
private ImageIcon getItemPicture(ZybezItemListing z) throws IOException {
bmoyer/osrsclient
src/rsclient/chat/IrcPanel.java
// Path: src/logic/IrcManager.java // public class IrcManager { // // NetworkSession networkSession; // ChatMainPane mainIrcPanel; // // public IrcManager() { // //called from gui // //mainIrcPanel = ircPanel; // } // // public void addConnection(String nick, ArrayList<String> chanNames) { // networkSession = new NetworkSession(nick, chanNames, this); // } // // public void startConnections() throws IOException, IrcException { // networkSession.startSession(); // } // // public void messageReceived(String channel, String message, String user) { // mainIrcPanel.addMessageToPanel(user, channel, message); // } // // public void onUserInput(String str) { // String lexed[] = str.split("\\s+"); // if (lexed.length == 2 && lexed[0].equals("/join")) { // if (mainIrcPanel.getMessagePanels().containsKey(lexed[1])) { // mainIrcPanel.clearInputField(); // mainIrcPanel.switchChanPanels(lexed[1]); // } else { // mainIrcPanel.clearInputField(); // joinChannel(lexed[1]); // } // } else { // mainIrcPanel.clearInputField(); // networkSession.sendMessage(mainIrcPanel.getCurrentChannel(), str); // } // // } // // public void onJoinEvent(Object[] users) { // for (Object o : users) { // System.out.println(); // } // } // // public void setIrcPanel(ChatMainPane ircPanel) { // mainIrcPanel = ircPanel; // } // // public void joinChannel(final String chanName) { // // mainIrcPanel.addChanPanel(chanName); // mainIrcPanel.switchChanPanels(chanName); // networkSession.joinChannel(chanName); // // } // }
import java.io.IOException; import java.util.ArrayList; import javax.swing.JPanel; import logic.IrcManager; import net.miginfocom.swing.MigLayout; import org.pircbotx.exception.IrcException;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsclient.chat; /** * * @author ben */ public class IrcPanel extends JPanel { ChatConfigPanel chatConfigPanel; ChatMainPane chatMainPanel;
// Path: src/logic/IrcManager.java // public class IrcManager { // // NetworkSession networkSession; // ChatMainPane mainIrcPanel; // // public IrcManager() { // //called from gui // //mainIrcPanel = ircPanel; // } // // public void addConnection(String nick, ArrayList<String> chanNames) { // networkSession = new NetworkSession(nick, chanNames, this); // } // // public void startConnections() throws IOException, IrcException { // networkSession.startSession(); // } // // public void messageReceived(String channel, String message, String user) { // mainIrcPanel.addMessageToPanel(user, channel, message); // } // // public void onUserInput(String str) { // String lexed[] = str.split("\\s+"); // if (lexed.length == 2 && lexed[0].equals("/join")) { // if (mainIrcPanel.getMessagePanels().containsKey(lexed[1])) { // mainIrcPanel.clearInputField(); // mainIrcPanel.switchChanPanels(lexed[1]); // } else { // mainIrcPanel.clearInputField(); // joinChannel(lexed[1]); // } // } else { // mainIrcPanel.clearInputField(); // networkSession.sendMessage(mainIrcPanel.getCurrentChannel(), str); // } // // } // // public void onJoinEvent(Object[] users) { // for (Object o : users) { // System.out.println(); // } // } // // public void setIrcPanel(ChatMainPane ircPanel) { // mainIrcPanel = ircPanel; // } // // public void joinChannel(final String chanName) { // // mainIrcPanel.addChanPanel(chanName); // mainIrcPanel.switchChanPanels(chanName); // networkSession.joinChannel(chanName); // // } // } // Path: src/rsclient/chat/IrcPanel.java import java.io.IOException; import java.util.ArrayList; import javax.swing.JPanel; import logic.IrcManager; import net.miginfocom.swing.MigLayout; import org.pircbotx.exception.IrcException; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsclient.chat; /** * * @author ben */ public class IrcPanel extends JPanel { ChatConfigPanel chatConfigPanel; ChatMainPane chatMainPanel;
IrcManager ircManager;
bmoyer/osrsclient
src/rsclient/market/MarketPanel.java
// Path: src/logic/ZybezQuery.java // public class ZybezQuery { // // private final String itemRequested; // private final String apiURL = "http://forums.zybez.net/runescape-2007-prices/api/"; // private final ArrayList<String> itemIDList; // private ArrayList<ZybezItemListing> itemList; // // public ZybezQuery(String s) { // itemRequested = s; // itemIDList = getItemIDList(); // createItemListings(); // // } // // public ArrayList<ZybezItemListing> getItemListings() { // // ArrayList<ZybezItemListing> listings = new ArrayList(); // // for (String itemID : itemIDList) { // listings.add(new ZybezItemListing(itemID)); // } // // return listings; // } // // public void createItemListings() { // // itemList = new ArrayList(); // // for (String itemID : itemIDList) { // itemList.add(new ZybezItemListing(itemID)); // } // } // // public ArrayList<String> getItemIDList() { // // ArrayList<String> itemIDs = new ArrayList(); // // try { // String s = getJsonString(); // JSONArray array = (JSONArray) JSONValue.parse(s); // int numItems = array.size(); // // for (int i = 0; i < numItems; i++) { // JSONObject o = ((JSONObject) array.get(i)); // itemIDs.add(o.get("id").toString()); // // } // // } catch (IOException ex) { // Logger.getLogger(ZybezQuery.class.getName()).log(Level.SEVERE, null, ex); // } // return itemIDs; // } // // private String getJsonString() throws MalformedURLException, IOException { // URL url = new URL(apiURL + itemRequested); // URLConnection urlConnection = url.openConnection(); // urlConnection.addRequestProperty("User-Agent", "Mozilla/5.0"); // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); // // //Put JSON data into String message // String message = org.apache.commons.io.IOUtils.toString(in); // return message; // } // // }
import java.awt.Color; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.Border; import javax.swing.border.EtchedBorder; import logic.ZybezQuery; import net.miginfocom.swing.MigLayout; import org.pushingpixels.trident.Timeline;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsclient.market; /** * * @author ben */ public class MarketPanel extends JPanel implements ItemListingRolloverListener { JTextField itemInputField; ItemListPanel itemDisplayPanel; ItemDetailPanel itemDetailPanel; JLabel itemLabel; JButton searchButton;
// Path: src/logic/ZybezQuery.java // public class ZybezQuery { // // private final String itemRequested; // private final String apiURL = "http://forums.zybez.net/runescape-2007-prices/api/"; // private final ArrayList<String> itemIDList; // private ArrayList<ZybezItemListing> itemList; // // public ZybezQuery(String s) { // itemRequested = s; // itemIDList = getItemIDList(); // createItemListings(); // // } // // public ArrayList<ZybezItemListing> getItemListings() { // // ArrayList<ZybezItemListing> listings = new ArrayList(); // // for (String itemID : itemIDList) { // listings.add(new ZybezItemListing(itemID)); // } // // return listings; // } // // public void createItemListings() { // // itemList = new ArrayList(); // // for (String itemID : itemIDList) { // itemList.add(new ZybezItemListing(itemID)); // } // } // // public ArrayList<String> getItemIDList() { // // ArrayList<String> itemIDs = new ArrayList(); // // try { // String s = getJsonString(); // JSONArray array = (JSONArray) JSONValue.parse(s); // int numItems = array.size(); // // for (int i = 0; i < numItems; i++) { // JSONObject o = ((JSONObject) array.get(i)); // itemIDs.add(o.get("id").toString()); // // } // // } catch (IOException ex) { // Logger.getLogger(ZybezQuery.class.getName()).log(Level.SEVERE, null, ex); // } // return itemIDs; // } // // private String getJsonString() throws MalformedURLException, IOException { // URL url = new URL(apiURL + itemRequested); // URLConnection urlConnection = url.openConnection(); // urlConnection.addRequestProperty("User-Agent", "Mozilla/5.0"); // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); // // //Put JSON data into String message // String message = org.apache.commons.io.IOUtils.toString(in); // return message; // } // // } // Path: src/rsclient/market/MarketPanel.java import java.awt.Color; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.Border; import javax.swing.border.EtchedBorder; import logic.ZybezQuery; import net.miginfocom.swing.MigLayout; import org.pushingpixels.trident.Timeline; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package rsclient.market; /** * * @author ben */ public class MarketPanel extends JPanel implements ItemListingRolloverListener { JTextField itemInputField; ItemListPanel itemDisplayPanel; ItemDetailPanel itemDetailPanel; JLabel itemLabel; JButton searchButton;
ZybezQuery query;
Countly/countly-sdk-unity
Services/app/src/main/java/ly/count/unity/push_fcm/NotificationBroadcastReceiver.java
// Path: Services/app/src/main/java/ly/count/unity/push_fcm/CountlyPushPlugin.java // public static final String EXTRA_ACTION_INDEX = "ly.count.android.sdk.CountlyPush.Action"; // // Path: Services/app/src/main/java/ly/count/unity/push_fcm/CountlyPushPlugin.java // public static final String EXTRA_MESSAGE = "ly.count.android.sdk.CountlyPush.message";
import android.app.NotificationManager; import android.net.Uri; import android.util.Log; import android.os.Bundle; import android.content.Intent; import android.content.Context; import com.unity3d.player.UnityPlayer; import com.unity3d.player.UnityPlayerActivity; import android.content.BroadcastReceiver; import org.json.JSONException; import org.json.JSONObject; import java.util.Map; import static ly.count.unity.push_fcm.CountlyPushPlugin.EXTRA_ACTION_INDEX; import static ly.count.unity.push_fcm.CountlyPushPlugin.EXTRA_MESSAGE;
package ly.count.unity.push_fcm; public class NotificationBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { CountlyPushPlugin.log("NotificationBroadcastReceiver::onReceive", CountlyPushPlugin.LogLevel.DEBUG); Bundle bundle = intent.getExtras(); if (bundle == null) { CountlyPushPlugin.log("bundle is null", CountlyPushPlugin.LogLevel.DEBUG); return; }
// Path: Services/app/src/main/java/ly/count/unity/push_fcm/CountlyPushPlugin.java // public static final String EXTRA_ACTION_INDEX = "ly.count.android.sdk.CountlyPush.Action"; // // Path: Services/app/src/main/java/ly/count/unity/push_fcm/CountlyPushPlugin.java // public static final String EXTRA_MESSAGE = "ly.count.android.sdk.CountlyPush.message"; // Path: Services/app/src/main/java/ly/count/unity/push_fcm/NotificationBroadcastReceiver.java import android.app.NotificationManager; import android.net.Uri; import android.util.Log; import android.os.Bundle; import android.content.Intent; import android.content.Context; import com.unity3d.player.UnityPlayer; import com.unity3d.player.UnityPlayerActivity; import android.content.BroadcastReceiver; import org.json.JSONException; import org.json.JSONObject; import java.util.Map; import static ly.count.unity.push_fcm.CountlyPushPlugin.EXTRA_ACTION_INDEX; import static ly.count.unity.push_fcm.CountlyPushPlugin.EXTRA_MESSAGE; package ly.count.unity.push_fcm; public class NotificationBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { CountlyPushPlugin.log("NotificationBroadcastReceiver::onReceive", CountlyPushPlugin.LogLevel.DEBUG); Bundle bundle = intent.getExtras(); if (bundle == null) { CountlyPushPlugin.log("bundle is null", CountlyPushPlugin.LogLevel.DEBUG); return; }
int index = bundle.getInt(CountlyPushPlugin.EXTRA_ACTION_INDEX, 0);
Countly/countly-sdk-unity
Services/app/src/main/java/ly/count/unity/push_fcm/NotificationBroadcastReceiver.java
// Path: Services/app/src/main/java/ly/count/unity/push_fcm/CountlyPushPlugin.java // public static final String EXTRA_ACTION_INDEX = "ly.count.android.sdk.CountlyPush.Action"; // // Path: Services/app/src/main/java/ly/count/unity/push_fcm/CountlyPushPlugin.java // public static final String EXTRA_MESSAGE = "ly.count.android.sdk.CountlyPush.message";
import android.app.NotificationManager; import android.net.Uri; import android.util.Log; import android.os.Bundle; import android.content.Intent; import android.content.Context; import com.unity3d.player.UnityPlayer; import com.unity3d.player.UnityPlayerActivity; import android.content.BroadcastReceiver; import org.json.JSONException; import org.json.JSONObject; import java.util.Map; import static ly.count.unity.push_fcm.CountlyPushPlugin.EXTRA_ACTION_INDEX; import static ly.count.unity.push_fcm.CountlyPushPlugin.EXTRA_MESSAGE;
package ly.count.unity.push_fcm; public class NotificationBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { CountlyPushPlugin.log("NotificationBroadcastReceiver::onReceive", CountlyPushPlugin.LogLevel.DEBUG); Bundle bundle = intent.getExtras(); if (bundle == null) { CountlyPushPlugin.log("bundle is null", CountlyPushPlugin.LogLevel.DEBUG); return; } int index = bundle.getInt(CountlyPushPlugin.EXTRA_ACTION_INDEX, 0);
// Path: Services/app/src/main/java/ly/count/unity/push_fcm/CountlyPushPlugin.java // public static final String EXTRA_ACTION_INDEX = "ly.count.android.sdk.CountlyPush.Action"; // // Path: Services/app/src/main/java/ly/count/unity/push_fcm/CountlyPushPlugin.java // public static final String EXTRA_MESSAGE = "ly.count.android.sdk.CountlyPush.message"; // Path: Services/app/src/main/java/ly/count/unity/push_fcm/NotificationBroadcastReceiver.java import android.app.NotificationManager; import android.net.Uri; import android.util.Log; import android.os.Bundle; import android.content.Intent; import android.content.Context; import com.unity3d.player.UnityPlayer; import com.unity3d.player.UnityPlayerActivity; import android.content.BroadcastReceiver; import org.json.JSONException; import org.json.JSONObject; import java.util.Map; import static ly.count.unity.push_fcm.CountlyPushPlugin.EXTRA_ACTION_INDEX; import static ly.count.unity.push_fcm.CountlyPushPlugin.EXTRA_MESSAGE; package ly.count.unity.push_fcm; public class NotificationBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { CountlyPushPlugin.log("NotificationBroadcastReceiver::onReceive", CountlyPushPlugin.LogLevel.DEBUG); Bundle bundle = intent.getExtras(); if (bundle == null) { CountlyPushPlugin.log("bundle is null", CountlyPushPlugin.LogLevel.DEBUG); return; } int index = bundle.getInt(CountlyPushPlugin.EXTRA_ACTION_INDEX, 0);
CountlyPushPlugin.Message message = bundle.getParcelable(EXTRA_MESSAGE);
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/Fixture.java
// Path: src/main/java/com/github/agiledon/sisyphus/composer/Composer.java // public interface Composer { // <T> T to(Class<T> tClass); // MultiSectionsComposer withTemplate(String templateFileName); // void setResourceName(String resourceName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/composer/UnknownComposer.java // public class UnknownComposer extends AbstractComposer { // private final Logger logger = LoggerFactory.getLogger(UnknownComposer.class); // @Override // protected <T> T deserialize(Class<T> tClass, String resource) { // logger.info("Unknown file type, can't compose the java object and return null"); // return null; // } // }
import com.google.common.base.CaseFormat; import com.google.common.base.Joiner; import com.google.common.io.Files; import com.github.agiledon.sisyphus.composer.Composer; import com.github.agiledon.sisyphus.composer.UnknownComposer; import java.util.Map; import static com.google.common.base.CaseFormat.UPPER_CAMEL; import static com.google.common.collect.Maps.newHashMap;
package com.github.agiledon.sisyphus; public final class Fixture { private Fixture() {}
// Path: src/main/java/com/github/agiledon/sisyphus/composer/Composer.java // public interface Composer { // <T> T to(Class<T> tClass); // MultiSectionsComposer withTemplate(String templateFileName); // void setResourceName(String resourceName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/composer/UnknownComposer.java // public class UnknownComposer extends AbstractComposer { // private final Logger logger = LoggerFactory.getLogger(UnknownComposer.class); // @Override // protected <T> T deserialize(Class<T> tClass, String resource) { // logger.info("Unknown file type, can't compose the java object and return null"); // return null; // } // } // Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java import com.google.common.base.CaseFormat; import com.google.common.base.Joiner; import com.google.common.io.Files; import com.github.agiledon.sisyphus.composer.Composer; import com.github.agiledon.sisyphus.composer.UnknownComposer; import java.util.Map; import static com.google.common.base.CaseFormat.UPPER_CAMEL; import static com.google.common.collect.Maps.newHashMap; package com.github.agiledon.sisyphus; public final class Fixture { private Fixture() {}
private static Map<String, Composer> composers = newHashMap();
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/Fixture.java
// Path: src/main/java/com/github/agiledon/sisyphus/composer/Composer.java // public interface Composer { // <T> T to(Class<T> tClass); // MultiSectionsComposer withTemplate(String templateFileName); // void setResourceName(String resourceName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/composer/UnknownComposer.java // public class UnknownComposer extends AbstractComposer { // private final Logger logger = LoggerFactory.getLogger(UnknownComposer.class); // @Override // protected <T> T deserialize(Class<T> tClass, String resource) { // logger.info("Unknown file type, can't compose the java object and return null"); // return null; // } // }
import com.google.common.base.CaseFormat; import com.google.common.base.Joiner; import com.google.common.io.Files; import com.github.agiledon.sisyphus.composer.Composer; import com.github.agiledon.sisyphus.composer.UnknownComposer; import java.util.Map; import static com.google.common.base.CaseFormat.UPPER_CAMEL; import static com.google.common.collect.Maps.newHashMap;
package com.github.agiledon.sisyphus; public final class Fixture { private Fixture() {} private static Map<String, Composer> composers = newHashMap(); public static Composer from(String resourceName) { String fileExtension = Files.getFileExtension(resourceName); Composer composer = composers.get(fileExtension); if (composer == null) { composer = createComposer(fileExtension); composers.put(fileExtension, composer); } composer.setResourceName(resourceName); return composer; } @SuppressWarnings("unchecked") private static Composer createComposer(String fileExtension) { try { Class<Composer> aClass = (Class<Composer>) Class.forName(getClassFullName(fileExtension)); return aClass.newInstance(); } catch (ClassNotFoundException e) {
// Path: src/main/java/com/github/agiledon/sisyphus/composer/Composer.java // public interface Composer { // <T> T to(Class<T> tClass); // MultiSectionsComposer withTemplate(String templateFileName); // void setResourceName(String resourceName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/composer/UnknownComposer.java // public class UnknownComposer extends AbstractComposer { // private final Logger logger = LoggerFactory.getLogger(UnknownComposer.class); // @Override // protected <T> T deserialize(Class<T> tClass, String resource) { // logger.info("Unknown file type, can't compose the java object and return null"); // return null; // } // } // Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java import com.google.common.base.CaseFormat; import com.google.common.base.Joiner; import com.google.common.io.Files; import com.github.agiledon.sisyphus.composer.Composer; import com.github.agiledon.sisyphus.composer.UnknownComposer; import java.util.Map; import static com.google.common.base.CaseFormat.UPPER_CAMEL; import static com.google.common.collect.Maps.newHashMap; package com.github.agiledon.sisyphus; public final class Fixture { private Fixture() {} private static Map<String, Composer> composers = newHashMap(); public static Composer from(String resourceName) { String fileExtension = Files.getFileExtension(resourceName); Composer composer = composers.get(fileExtension); if (composer == null) { composer = createComposer(fileExtension); composers.put(fileExtension, composer); } composer.setResourceName(resourceName); return composer; } @SuppressWarnings("unchecked") private static Composer createComposer(String fileExtension) { try { Class<Composer> aClass = (Class<Composer>) Class.forName(getClassFullName(fileExtension)); return aClass.newInstance(); } catch (ClassNotFoundException e) {
return new UnknownComposer();
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/util/StringTemplate.java
// Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceLoader.java // public static String loadResource(String resourceName) { // List<String> resource = loadResourceAsLines(resourceName); // return Joiner.on("\n").join(resource); // }
import com.google.common.base.Function; import com.google.common.base.Splitter; import com.google.common.collect.Lists; import org.stringtemplate.v4.ST; import java.util.List; import static com.github.agiledon.sisyphus.util.ResourceLoader.loadResource; import static com.google.common.collect.Iterables.getFirst; import static com.google.common.collect.Iterables.getLast;
package com.github.agiledon.sisyphus.util; public class StringTemplate { private static final char VARIABLE_INDICATOR = '$'; private String templateFileName; public StringTemplate(String templateFileName) { this.templateFileName = templateFileName; } public String evaluate(List<String> variableContent) {
// Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceLoader.java // public static String loadResource(String resourceName) { // List<String> resource = loadResourceAsLines(resourceName); // return Joiner.on("\n").join(resource); // } // Path: src/main/java/com/github/agiledon/sisyphus/util/StringTemplate.java import com.google.common.base.Function; import com.google.common.base.Splitter; import com.google.common.collect.Lists; import org.stringtemplate.v4.ST; import java.util.List; import static com.github.agiledon.sisyphus.util.ResourceLoader.loadResource; import static com.google.common.collect.Iterables.getFirst; import static com.google.common.collect.Iterables.getLast; package com.github.agiledon.sisyphus.util; public class StringTemplate { private static final char VARIABLE_INDICATOR = '$'; private String templateFileName; public StringTemplate(String templateFileName) { this.templateFileName = templateFileName; } public String evaluate(List<String> variableContent) {
String template = loadResource(templateFileName);
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/composer/MultiSectionsComposer.java
// Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceLoader.java // public static List<List<String>> loadResources(String resourceName) { // return ListUtil.partition(loadResourceAsLines(resourceName), new Predicates<String>() { // @Override // public boolean apply(String element) { // return element.trim().startsWith(SECTION_INDICATOR); // } // }); // }
import java.util.List; import static com.github.agiledon.sisyphus.util.ResourceLoader.loadResources; import static com.google.common.collect.Lists.newArrayList;
package com.github.agiledon.sisyphus.composer; public class MultiSectionsComposer extends ComposerDecorator { public MultiSectionsComposer(AbstractComposer composer) { super(composer); } @Override public <T> T to(Class<T> tClass) { return decoratedComposer.to(tClass); } public <T> List<T> toList(Class<T> tClass) { List<T> results = newArrayList();
// Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceLoader.java // public static List<List<String>> loadResources(String resourceName) { // return ListUtil.partition(loadResourceAsLines(resourceName), new Predicates<String>() { // @Override // public boolean apply(String element) { // return element.trim().startsWith(SECTION_INDICATOR); // } // }); // } // Path: src/main/java/com/github/agiledon/sisyphus/composer/MultiSectionsComposer.java import java.util.List; import static com.github.agiledon.sisyphus.util.ResourceLoader.loadResources; import static com.google.common.collect.Lists.newArrayList; package com.github.agiledon.sisyphus.composer; public class MultiSectionsComposer extends ComposerDecorator { public MultiSectionsComposer(AbstractComposer composer) { super(composer); } @Override public <T> T to(Class<T> tClass) { return decoratedComposer.to(tClass); } public <T> List<T> toList(Class<T> tClass) { List<T> results = newArrayList();
for (List<String> resource : loadResources(resourceName)) {
agiledon/sisyphus
src/test/java/com/github/agiledon/sisyphus/assist/printer/JsonPrinterTest.java
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // }
import com.github.agiledon.sisyphus.domain.json.User; import org.junit.Ignore; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat;
package com.github.agiledon.sisyphus.assist.printer; public class JsonPrinterTest extends UserDataFixture { @Test @Ignore public void should_serialize_specific_object_to_string_with_json_format() { JsonPrinter printer = new JsonPrinter();
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // Path: src/test/java/com/github/agiledon/sisyphus/assist/printer/JsonPrinterTest.java import com.github.agiledon.sisyphus.domain.json.User; import org.junit.Ignore; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; package com.github.agiledon.sisyphus.assist.printer; public class JsonPrinterTest extends UserDataFixture { @Test @Ignore public void should_serialize_specific_object_to_string_with_json_format() { JsonPrinter printer = new JsonPrinter();
User user = createUser();
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/junit/DataProvider.java
// Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java // public final class Fixture { // private Fixture() {} // // private static Map<String, Composer> composers = newHashMap(); // // public static Composer from(String resourceName) { // String fileExtension = Files.getFileExtension(resourceName); // Composer composer = composers.get(fileExtension); // if (composer == null) { // composer = createComposer(fileExtension); // composers.put(fileExtension, composer); // } // composer.setResourceName(resourceName); // return composer; // } // // @SuppressWarnings("unchecked") // private static Composer createComposer(String fileExtension) { // try { // Class<Composer> aClass = (Class<Composer>) Class.forName(getClassFullName(fileExtension)); // return aClass.newInstance(); // } catch (ClassNotFoundException e) { // return new UnknownComposer(); // } catch (InstantiationException e) { // return new UnknownComposer(); // } catch (IllegalAccessException e) { // return new UnknownComposer(); // } catch (Exception e) { // return new UnknownComposer(); // } // } // // private static String getClassFullName(String fileExtension) { // String fullNamePrefix = "com.github.agiledon.sisyphus.composer."; // String classNameSuffix = "Composer"; // String classNamePrefix = CaseFormat.LOWER_HYPHEN.to(UPPER_CAMEL, fileExtension); // return Joiner.on("").join(fullNamePrefix, classNamePrefix, classNameSuffix); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/exception/NotSupportedException.java // public class NotSupportedException extends RuntimeException { // public NotSupportedException(String message) { // super(message); // } // }
import com.github.agiledon.sisyphus.Fixture; import com.github.agiledon.sisyphus.exception.NotSupportedException;import com.google.common.base.Strings; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.util.List;
package com.github.agiledon.sisyphus.junit; public class DataProvider implements TestRule { private String resourceName; private Class<?> targetClass; private String templateName; @Override public Statement apply(final Statement statement, final Description description) { return new Statement() { @Override public void evaluate() throws Throwable { DataResource dataResource = description.getAnnotation(DataResource.class); resourceName = dataResource.resourceName(); templateName = dataResource.templateName(); targetClass = dataResource.targetClass(); statement.evaluate(); } }; } @SuppressWarnings("unchecked") public <T> T provideData() { if (Strings.isNullOrEmpty(templateName)) {
// Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java // public final class Fixture { // private Fixture() {} // // private static Map<String, Composer> composers = newHashMap(); // // public static Composer from(String resourceName) { // String fileExtension = Files.getFileExtension(resourceName); // Composer composer = composers.get(fileExtension); // if (composer == null) { // composer = createComposer(fileExtension); // composers.put(fileExtension, composer); // } // composer.setResourceName(resourceName); // return composer; // } // // @SuppressWarnings("unchecked") // private static Composer createComposer(String fileExtension) { // try { // Class<Composer> aClass = (Class<Composer>) Class.forName(getClassFullName(fileExtension)); // return aClass.newInstance(); // } catch (ClassNotFoundException e) { // return new UnknownComposer(); // } catch (InstantiationException e) { // return new UnknownComposer(); // } catch (IllegalAccessException e) { // return new UnknownComposer(); // } catch (Exception e) { // return new UnknownComposer(); // } // } // // private static String getClassFullName(String fileExtension) { // String fullNamePrefix = "com.github.agiledon.sisyphus.composer."; // String classNameSuffix = "Composer"; // String classNamePrefix = CaseFormat.LOWER_HYPHEN.to(UPPER_CAMEL, fileExtension); // return Joiner.on("").join(fullNamePrefix, classNamePrefix, classNameSuffix); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/exception/NotSupportedException.java // public class NotSupportedException extends RuntimeException { // public NotSupportedException(String message) { // super(message); // } // } // Path: src/main/java/com/github/agiledon/sisyphus/junit/DataProvider.java import com.github.agiledon.sisyphus.Fixture; import com.github.agiledon.sisyphus.exception.NotSupportedException;import com.google.common.base.Strings; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.util.List; package com.github.agiledon.sisyphus.junit; public class DataProvider implements TestRule { private String resourceName; private Class<?> targetClass; private String templateName; @Override public Statement apply(final Statement statement, final Description description) { return new Statement() { @Override public void evaluate() throws Throwable { DataResource dataResource = description.getAnnotation(DataResource.class); resourceName = dataResource.resourceName(); templateName = dataResource.templateName(); targetClass = dataResource.targetClass(); statement.evaluate(); } }; } @SuppressWarnings("unchecked") public <T> T provideData() { if (Strings.isNullOrEmpty(templateName)) {
return (T) Fixture.from(resourceName)
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/junit/DataProvider.java
// Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java // public final class Fixture { // private Fixture() {} // // private static Map<String, Composer> composers = newHashMap(); // // public static Composer from(String resourceName) { // String fileExtension = Files.getFileExtension(resourceName); // Composer composer = composers.get(fileExtension); // if (composer == null) { // composer = createComposer(fileExtension); // composers.put(fileExtension, composer); // } // composer.setResourceName(resourceName); // return composer; // } // // @SuppressWarnings("unchecked") // private static Composer createComposer(String fileExtension) { // try { // Class<Composer> aClass = (Class<Composer>) Class.forName(getClassFullName(fileExtension)); // return aClass.newInstance(); // } catch (ClassNotFoundException e) { // return new UnknownComposer(); // } catch (InstantiationException e) { // return new UnknownComposer(); // } catch (IllegalAccessException e) { // return new UnknownComposer(); // } catch (Exception e) { // return new UnknownComposer(); // } // } // // private static String getClassFullName(String fileExtension) { // String fullNamePrefix = "com.github.agiledon.sisyphus.composer."; // String classNameSuffix = "Composer"; // String classNamePrefix = CaseFormat.LOWER_HYPHEN.to(UPPER_CAMEL, fileExtension); // return Joiner.on("").join(fullNamePrefix, classNamePrefix, classNameSuffix); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/exception/NotSupportedException.java // public class NotSupportedException extends RuntimeException { // public NotSupportedException(String message) { // super(message); // } // }
import com.github.agiledon.sisyphus.Fixture; import com.github.agiledon.sisyphus.exception.NotSupportedException;import com.google.common.base.Strings; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.util.List;
@Override public Statement apply(final Statement statement, final Description description) { return new Statement() { @Override public void evaluate() throws Throwable { DataResource dataResource = description.getAnnotation(DataResource.class); resourceName = dataResource.resourceName(); templateName = dataResource.templateName(); targetClass = dataResource.targetClass(); statement.evaluate(); } }; } @SuppressWarnings("unchecked") public <T> T provideData() { if (Strings.isNullOrEmpty(templateName)) { return (T) Fixture.from(resourceName) .to(targetClass); } else { return (T) Fixture.from(resourceName) .withTemplate(templateName) .to(targetClass); } } @SuppressWarnings("unchecked") public <T> List<T> provideDataList() { if (Strings.isNullOrEmpty(templateName)) {
// Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java // public final class Fixture { // private Fixture() {} // // private static Map<String, Composer> composers = newHashMap(); // // public static Composer from(String resourceName) { // String fileExtension = Files.getFileExtension(resourceName); // Composer composer = composers.get(fileExtension); // if (composer == null) { // composer = createComposer(fileExtension); // composers.put(fileExtension, composer); // } // composer.setResourceName(resourceName); // return composer; // } // // @SuppressWarnings("unchecked") // private static Composer createComposer(String fileExtension) { // try { // Class<Composer> aClass = (Class<Composer>) Class.forName(getClassFullName(fileExtension)); // return aClass.newInstance(); // } catch (ClassNotFoundException e) { // return new UnknownComposer(); // } catch (InstantiationException e) { // return new UnknownComposer(); // } catch (IllegalAccessException e) { // return new UnknownComposer(); // } catch (Exception e) { // return new UnknownComposer(); // } // } // // private static String getClassFullName(String fileExtension) { // String fullNamePrefix = "com.github.agiledon.sisyphus.composer."; // String classNameSuffix = "Composer"; // String classNamePrefix = CaseFormat.LOWER_HYPHEN.to(UPPER_CAMEL, fileExtension); // return Joiner.on("").join(fullNamePrefix, classNamePrefix, classNameSuffix); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/exception/NotSupportedException.java // public class NotSupportedException extends RuntimeException { // public NotSupportedException(String message) { // super(message); // } // } // Path: src/main/java/com/github/agiledon/sisyphus/junit/DataProvider.java import com.github.agiledon.sisyphus.Fixture; import com.github.agiledon.sisyphus.exception.NotSupportedException;import com.google.common.base.Strings; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; import java.util.List; @Override public Statement apply(final Statement statement, final Description description) { return new Statement() { @Override public void evaluate() throws Throwable { DataResource dataResource = description.getAnnotation(DataResource.class); resourceName = dataResource.resourceName(); templateName = dataResource.templateName(); targetClass = dataResource.targetClass(); statement.evaluate(); } }; } @SuppressWarnings("unchecked") public <T> T provideData() { if (Strings.isNullOrEmpty(templateName)) { return (T) Fixture.from(resourceName) .to(targetClass); } else { return (T) Fixture.from(resourceName) .withTemplate(templateName) .to(targetClass); } } @SuppressWarnings("unchecked") public <T> List<T> provideDataList() { if (Strings.isNullOrEmpty(templateName)) {
throw new NotSupportedException("Must provide template file name");
agiledon/sisyphus
src/test/java/com/github/agiledon/sisyphus/assist/printer/YamlPrinterTest.java
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // }
import com.github.agiledon.sisyphus.domain.json.User; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat;
package com.github.agiledon.sisyphus.assist.printer; public class YamlPrinterTest extends UserDataFixture { @Test public void should_serialize_specific_object_to_string_with_yaml_format() { YamlPrinter printer = new YamlPrinter();
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // Path: src/test/java/com/github/agiledon/sisyphus/assist/printer/YamlPrinterTest.java import com.github.agiledon.sisyphus.domain.json.User; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; package com.github.agiledon.sisyphus.assist.printer; public class YamlPrinterTest extends UserDataFixture { @Test public void should_serialize_specific_object_to_string_with_yaml_format() { YamlPrinter printer = new YamlPrinter();
User user = createUser();
agiledon/sisyphus
src/test/java/com/github/agiledon/sisyphus/YamlFixtureTest.java
// Path: src/test/java/com/github/agiledon/sisyphus/domain/yaml/Invoice.java // public class Invoice { // public Integer invoice; // invoice // public String date; // date // public Person billTo;// bill-to // public Person shipTo;// ship-to // public Product[] products; // public Float tax; // public Float total; // public String comments; // // }
import com.github.agiledon.sisyphus.domain.yaml.Invoice; import com.google.common.base.Objects; import org.junit.Test; import java.util.List; import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertThat;
package com.github.agiledon.sisyphus; public class YamlFixtureTest { @Test public void should_compose_invoice_data_with_yaml_format() {
// Path: src/test/java/com/github/agiledon/sisyphus/domain/yaml/Invoice.java // public class Invoice { // public Integer invoice; // invoice // public String date; // date // public Person billTo;// bill-to // public Person shipTo;// ship-to // public Product[] products; // public Float tax; // public Float total; // public String comments; // // } // Path: src/test/java/com/github/agiledon/sisyphus/YamlFixtureTest.java import com.github.agiledon.sisyphus.domain.yaml.Invoice; import com.google.common.base.Objects; import org.junit.Test; import java.util.List; import java.util.Map; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertThat; package com.github.agiledon.sisyphus; public class YamlFixtureTest { @Test public void should_compose_invoice_data_with_yaml_format() {
Invoice invoice = Fixture.from("invoice.yaml").to(Invoice.class);
agiledon/sisyphus
src/test/java/com/github/agiledon/sisyphus/JsonFixtureTest.java
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/StandardVariable.java // public class StandardVariable { // public String result; // public String id; // // public StandardVariable(String result, // String id) { // this.result = result; // this.id = id; // } // } // // Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // // Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java // public static Composer from(String resourceName) { // String fileExtension = Files.getFileExtension(resourceName); // Composer composer = composers.get(fileExtension); // if (composer == null) { // composer = createComposer(fileExtension); // composers.put(fileExtension, composer); // } // composer.setResourceName(resourceName); // return composer; // }
import com.github.agiledon.sisyphus.domain.json.StandardVariable; import com.github.agiledon.sisyphus.domain.json.User; import com.google.common.base.Objects; import org.junit.Test; import java.util.List; import static com.github.agiledon.sisyphus.Fixture.from; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat;
package com.github.agiledon.sisyphus; public class JsonFixtureTest { @Test public void should_compose_User_data_with_json_format() {
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/StandardVariable.java // public class StandardVariable { // public String result; // public String id; // // public StandardVariable(String result, // String id) { // this.result = result; // this.id = id; // } // } // // Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // // Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java // public static Composer from(String resourceName) { // String fileExtension = Files.getFileExtension(resourceName); // Composer composer = composers.get(fileExtension); // if (composer == null) { // composer = createComposer(fileExtension); // composers.put(fileExtension, composer); // } // composer.setResourceName(resourceName); // return composer; // } // Path: src/test/java/com/github/agiledon/sisyphus/JsonFixtureTest.java import com.github.agiledon.sisyphus.domain.json.StandardVariable; import com.github.agiledon.sisyphus.domain.json.User; import com.google.common.base.Objects; import org.junit.Test; import java.util.List; import static com.github.agiledon.sisyphus.Fixture.from; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; package com.github.agiledon.sisyphus; public class JsonFixtureTest { @Test public void should_compose_User_data_with_json_format() {
User user = Fixture.from("user.json").to(User.class);
agiledon/sisyphus
src/test/java/com/github/agiledon/sisyphus/JsonFixtureTest.java
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/StandardVariable.java // public class StandardVariable { // public String result; // public String id; // // public StandardVariable(String result, // String id) { // this.result = result; // this.id = id; // } // } // // Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // // Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java // public static Composer from(String resourceName) { // String fileExtension = Files.getFileExtension(resourceName); // Composer composer = composers.get(fileExtension); // if (composer == null) { // composer = createComposer(fileExtension); // composers.put(fileExtension, composer); // } // composer.setResourceName(resourceName); // return composer; // }
import com.github.agiledon.sisyphus.domain.json.StandardVariable; import com.github.agiledon.sisyphus.domain.json.User; import com.google.common.base.Objects; import org.junit.Test; import java.util.List; import static com.github.agiledon.sisyphus.Fixture.from; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat;
package com.github.agiledon.sisyphus; public class JsonFixtureTest { @Test public void should_compose_User_data_with_json_format() {
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/StandardVariable.java // public class StandardVariable { // public String result; // public String id; // // public StandardVariable(String result, // String id) { // this.result = result; // this.id = id; // } // } // // Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // // Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java // public static Composer from(String resourceName) { // String fileExtension = Files.getFileExtension(resourceName); // Composer composer = composers.get(fileExtension); // if (composer == null) { // composer = createComposer(fileExtension); // composers.put(fileExtension, composer); // } // composer.setResourceName(resourceName); // return composer; // } // Path: src/test/java/com/github/agiledon/sisyphus/JsonFixtureTest.java import com.github.agiledon.sisyphus.domain.json.StandardVariable; import com.github.agiledon.sisyphus.domain.json.User; import com.google.common.base.Objects; import org.junit.Test; import java.util.List; import static com.github.agiledon.sisyphus.Fixture.from; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; package com.github.agiledon.sisyphus; public class JsonFixtureTest { @Test public void should_compose_User_data_with_json_format() {
User user = Fixture.from("user.json").to(User.class);
agiledon/sisyphus
src/test/java/com/github/agiledon/sisyphus/JsonFixtureTest.java
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/StandardVariable.java // public class StandardVariable { // public String result; // public String id; // // public StandardVariable(String result, // String id) { // this.result = result; // this.id = id; // } // } // // Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // // Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java // public static Composer from(String resourceName) { // String fileExtension = Files.getFileExtension(resourceName); // Composer composer = composers.get(fileExtension); // if (composer == null) { // composer = createComposer(fileExtension); // composers.put(fileExtension, composer); // } // composer.setResourceName(resourceName); // return composer; // }
import com.github.agiledon.sisyphus.domain.json.StandardVariable; import com.github.agiledon.sisyphus.domain.json.User; import com.google.common.base.Objects; import org.junit.Test; import java.util.List; import static com.github.agiledon.sisyphus.Fixture.from; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat;
package com.github.agiledon.sisyphus; public class JsonFixtureTest { @Test public void should_compose_User_data_with_json_format() { User user = Fixture.from("user.json").to(User.class); assertThat(user, not(nullValue())); assertUserName(user, "Joe", "Sixpack"); assertThat(user.getGender(), is(User.Gender.MALE)); assertThat(user.isVerified(), is(false)); } @Test public void should_compose_User_data_with_gson_format() { User user = Fixture.from("user.gson").to(User.class); assertThat(user, not(nullValue())); //gson can't support the case which fieldname is not match get method //gson can't convert "Rm9vYmFyIQ==" to byte[] assertThat(user.getName(), is(nullValue())); } @Test public void should_compose_User_data_from_cache_with_json_format() { User user = Fixture.from("user.json").to(User.class); assertThat(user, not(nullValue())); User cachedUser = Fixture.from("user.json").to(User.class); assertThat(cachedUser, not(nullValue())); assertThat(Objects.equal(user, cachedUser), is(true)); } @Test public void should_compose_StandardVariables_data_with_json_format() {
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/StandardVariable.java // public class StandardVariable { // public String result; // public String id; // // public StandardVariable(String result, // String id) { // this.result = result; // this.id = id; // } // } // // Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // // Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java // public static Composer from(String resourceName) { // String fileExtension = Files.getFileExtension(resourceName); // Composer composer = composers.get(fileExtension); // if (composer == null) { // composer = createComposer(fileExtension); // composers.put(fileExtension, composer); // } // composer.setResourceName(resourceName); // return composer; // } // Path: src/test/java/com/github/agiledon/sisyphus/JsonFixtureTest.java import com.github.agiledon.sisyphus.domain.json.StandardVariable; import com.github.agiledon.sisyphus.domain.json.User; import com.google.common.base.Objects; import org.junit.Test; import java.util.List; import static com.github.agiledon.sisyphus.Fixture.from; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; package com.github.agiledon.sisyphus; public class JsonFixtureTest { @Test public void should_compose_User_data_with_json_format() { User user = Fixture.from("user.json").to(User.class); assertThat(user, not(nullValue())); assertUserName(user, "Joe", "Sixpack"); assertThat(user.getGender(), is(User.Gender.MALE)); assertThat(user.isVerified(), is(false)); } @Test public void should_compose_User_data_with_gson_format() { User user = Fixture.from("user.gson").to(User.class); assertThat(user, not(nullValue())); //gson can't support the case which fieldname is not match get method //gson can't convert "Rm9vYmFyIQ==" to byte[] assertThat(user.getName(), is(nullValue())); } @Test public void should_compose_User_data_from_cache_with_json_format() { User user = Fixture.from("user.json").to(User.class); assertThat(user, not(nullValue())); User cachedUser = Fixture.from("user.json").to(User.class); assertThat(cachedUser, not(nullValue())); assertThat(Objects.equal(user, cachedUser), is(true)); } @Test public void should_compose_StandardVariables_data_with_json_format() {
StandardVariable[] standardVariables = Fixture.from("standardVariable.json").to(StandardVariable[].class);
agiledon/sisyphus
src/test/java/com/github/agiledon/sisyphus/assist/printer/GsonPrinterTest.java
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // }
import com.github.agiledon.sisyphus.domain.json.User; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat;
package com.github.agiledon.sisyphus.assist.printer; public class GsonPrinterTest extends UserDataFixture { @Test public void should_serialize_specific_object_to_string_with_json_format() { GsonPrinter printer = new GsonPrinter();
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // Path: src/test/java/com/github/agiledon/sisyphus/assist/printer/GsonPrinterTest.java import com.github.agiledon.sisyphus.domain.json.User; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; package com.github.agiledon.sisyphus.assist.printer; public class GsonPrinterTest extends UserDataFixture { @Test public void should_serialize_specific_object_to_string_with_json_format() { GsonPrinter printer = new GsonPrinter();
User user = createUser();
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/composer/AbstractComposer.java
// Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceLoader.java // public static List<String> loadResourceAsLines(String resourceName) { // try { // File file = new File(getAbsolutePath(compensatePath(resourceName))); // List<String> strings = Files.readLines(file, Charsets.UTF_8); // return filterInvalidLines(strings); // } catch (IOException e) { // return logAndReturnEmptyList(resourceName); // } catch (Exception e) { // return logAndReturnEmptyList(resourceName); // } // }
import com.google.common.base.Joiner; import java.util.List; import java.util.Map; import static com.github.agiledon.sisyphus.util.ResourceLoader.loadResourceAsLines; import static com.google.common.collect.Maps.newHashMap;
package com.github.agiledon.sisyphus.composer; public abstract class AbstractComposer implements Composer { protected String resourceName; private Map<String, Object> results = newHashMap(); public void setResourceName(String resourceName) { this.resourceName = resourceName; } @SuppressWarnings("unchecked") public <T> T to(Class<T> tClass) { T result = (T)results.get(resourceName); if (result == null) {
// Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceLoader.java // public static List<String> loadResourceAsLines(String resourceName) { // try { // File file = new File(getAbsolutePath(compensatePath(resourceName))); // List<String> strings = Files.readLines(file, Charsets.UTF_8); // return filterInvalidLines(strings); // } catch (IOException e) { // return logAndReturnEmptyList(resourceName); // } catch (Exception e) { // return logAndReturnEmptyList(resourceName); // } // } // Path: src/main/java/com/github/agiledon/sisyphus/composer/AbstractComposer.java import com.google.common.base.Joiner; import java.util.List; import java.util.Map; import static com.github.agiledon.sisyphus.util.ResourceLoader.loadResourceAsLines; import static com.google.common.collect.Maps.newHashMap; package com.github.agiledon.sisyphus.composer; public abstract class AbstractComposer implements Composer { protected String resourceName; private Map<String, Object> results = newHashMap(); public void setResourceName(String resourceName) { this.resourceName = resourceName; } @SuppressWarnings("unchecked") public <T> T to(Class<T> tClass) { T result = (T)results.get(resourceName); if (result == null) {
String resource = evaluate(loadResourceAsLines(resourceName));
agiledon/sisyphus
src/test/java/com/github/agiledon/sisyphus/junit/DataProviderTest.java
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // // Path: src/main/java/com/github/agiledon/sisyphus/exception/NotSupportedException.java // public class NotSupportedException extends RuntimeException { // public NotSupportedException(String message) { // super(message); // } // }
import com.github.agiledon.sisyphus.domain.json.User; import com.github.agiledon.sisyphus.exception.NotSupportedException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.List; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNot.not;
package com.github.agiledon.sisyphus.junit; public class DataProviderTest { @Rule public DataProvider dataProvider = new DataProvider(); @Rule public ExpectedException expectedException = ExpectedException.none(); @Test
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // // Path: src/main/java/com/github/agiledon/sisyphus/exception/NotSupportedException.java // public class NotSupportedException extends RuntimeException { // public NotSupportedException(String message) { // super(message); // } // } // Path: src/test/java/com/github/agiledon/sisyphus/junit/DataProviderTest.java import com.github.agiledon.sisyphus.domain.json.User; import com.github.agiledon.sisyphus.exception.NotSupportedException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.List; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNot.not; package com.github.agiledon.sisyphus.junit; public class DataProviderTest { @Rule public DataProvider dataProvider = new DataProvider(); @Rule public ExpectedException expectedException = ExpectedException.none(); @Test
@DataResource(resourceName = "user.json", targetClass = User.class)
agiledon/sisyphus
src/test/java/com/github/agiledon/sisyphus/junit/DataProviderTest.java
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // // Path: src/main/java/com/github/agiledon/sisyphus/exception/NotSupportedException.java // public class NotSupportedException extends RuntimeException { // public NotSupportedException(String message) { // super(message); // } // }
import com.github.agiledon.sisyphus.domain.json.User; import com.github.agiledon.sisyphus.exception.NotSupportedException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.List; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNot.not;
} @Test @DataResource(resourceName = "userWithTemplate.json", templateName = "template/user.template", targetClass = User.class) public void should_compose_user_data_by_parsing_template_file() { User user = dataProvider.provideData(); assertThat(user, not(nullValue())); assertThat(user.getName().getFirst(), is("Joe")); assertThat(user.getName().getLast(), is("Sixpack")); } @Test @DataResource(resourceName = "userWithMultiSections.json", templateName = "template/user.template", targetClass = User.class) public void should_compose_user_data_list_by_parsing_template_file() { List<User> users = dataProvider.provideDataList(); assertThat(users, not(nullValue())); assertThat(users.get(0).getName().getFirst(), is("Joe")); assertThat(users.get(0).getName().getLast(), is("Sixpack")); assertThat(users.get(2).getName().getFirst(), is("Yi")); assertThat(users.get(2).getName().getLast(), is("Zhang")); } @Test @DataResource(resourceName = "userWithMultiSections.json", targetClass = User.class) public void should_throw_NotSupportException_if_missing_template_file_when_parse_to_list() {
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java // public class User { // public enum Gender { MALE, FEMALE }; // // public static class Name { // private String _first, _last; // // public String getFirst() { return _first; } // public String getLast() { return _last; } // // public void setFirst(String s) { _first = s; } // public void setLast(String s) { _last = s; } // } // // private Gender _gender; // private Name _name; // private boolean _isVerified; // private byte[] _userImage; // // public Name getName() { return _name; } // public boolean isVerified() { return _isVerified; } // public Gender getGender() { return _gender; } // public byte[] getUserImage() { return _userImage; } // // public void setName(Name n) { _name = n; } // public void setVerified(boolean b) { _isVerified = b; } // public void setGender(Gender g) { _gender = g; } // public void setUserImage(byte[] b) { _userImage = b; } // } // // Path: src/main/java/com/github/agiledon/sisyphus/exception/NotSupportedException.java // public class NotSupportedException extends RuntimeException { // public NotSupportedException(String message) { // super(message); // } // } // Path: src/test/java/com/github/agiledon/sisyphus/junit/DataProviderTest.java import com.github.agiledon.sisyphus.domain.json.User; import com.github.agiledon.sisyphus.exception.NotSupportedException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import java.util.List; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNot.not; } @Test @DataResource(resourceName = "userWithTemplate.json", templateName = "template/user.template", targetClass = User.class) public void should_compose_user_data_by_parsing_template_file() { User user = dataProvider.provideData(); assertThat(user, not(nullValue())); assertThat(user.getName().getFirst(), is("Joe")); assertThat(user.getName().getLast(), is("Sixpack")); } @Test @DataResource(resourceName = "userWithMultiSections.json", templateName = "template/user.template", targetClass = User.class) public void should_compose_user_data_list_by_parsing_template_file() { List<User> users = dataProvider.provideDataList(); assertThat(users, not(nullValue())); assertThat(users.get(0).getName().getFirst(), is("Joe")); assertThat(users.get(0).getName().getLast(), is("Sixpack")); assertThat(users.get(2).getName().getFirst(), is("Yi")); assertThat(users.get(2).getName().getLast(), is("Zhang")); } @Test @DataResource(resourceName = "userWithMultiSections.json", targetClass = User.class) public void should_throw_NotSupportException_if_missing_template_file_when_parse_to_list() {
expectedException.expect(NotSupportedException.class);
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/util/ResourceLoader.java
// Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceFilePath.java // public static String compensatePath(String resourceName) { // if (resourceName.startsWith("/")) { // return resourceName; // } // return "/" + resourceName; // } // // Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceFilePath.java // public static String getAbsolutePath(String resourceName) { // return ResourceFilePath.class.getResource(compensatePath(resourceName)).getPath(); // }
import com.google.common.base.Charsets; import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.base.Strings; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.io.Files; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.util.List; import static com.github.agiledon.sisyphus.util.ResourceFilePath.compensatePath; import static com.github.agiledon.sisyphus.util.ResourceFilePath.getAbsolutePath; import static com.google.common.collect.Lists.newArrayList;
package com.github.agiledon.sisyphus.util; public final class ResourceLoader { private ResourceLoader() {} private static Logger logger = LoggerFactory.getLogger(ResourceLoader.class); private static final String COMMENT_INDICATOR = "#"; private static final String SECTION_INDICATOR = "///"; public static String loadResource(String resourceName) { List<String> resource = loadResourceAsLines(resourceName); return Joiner.on("\n").join(resource); } public static List<String> loadResourceAsLines(String resourceName) { try {
// Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceFilePath.java // public static String compensatePath(String resourceName) { // if (resourceName.startsWith("/")) { // return resourceName; // } // return "/" + resourceName; // } // // Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceFilePath.java // public static String getAbsolutePath(String resourceName) { // return ResourceFilePath.class.getResource(compensatePath(resourceName)).getPath(); // } // Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceLoader.java import com.google.common.base.Charsets; import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.base.Strings; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.io.Files; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.util.List; import static com.github.agiledon.sisyphus.util.ResourceFilePath.compensatePath; import static com.github.agiledon.sisyphus.util.ResourceFilePath.getAbsolutePath; import static com.google.common.collect.Lists.newArrayList; package com.github.agiledon.sisyphus.util; public final class ResourceLoader { private ResourceLoader() {} private static Logger logger = LoggerFactory.getLogger(ResourceLoader.class); private static final String COMMENT_INDICATOR = "#"; private static final String SECTION_INDICATOR = "///"; public static String loadResource(String resourceName) { List<String> resource = loadResourceAsLines(resourceName); return Joiner.on("\n").join(resource); } public static List<String> loadResourceAsLines(String resourceName) { try {
File file = new File(getAbsolutePath(compensatePath(resourceName)));
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/util/ResourceLoader.java
// Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceFilePath.java // public static String compensatePath(String resourceName) { // if (resourceName.startsWith("/")) { // return resourceName; // } // return "/" + resourceName; // } // // Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceFilePath.java // public static String getAbsolutePath(String resourceName) { // return ResourceFilePath.class.getResource(compensatePath(resourceName)).getPath(); // }
import com.google.common.base.Charsets; import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.base.Strings; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.io.Files; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.util.List; import static com.github.agiledon.sisyphus.util.ResourceFilePath.compensatePath; import static com.github.agiledon.sisyphus.util.ResourceFilePath.getAbsolutePath; import static com.google.common.collect.Lists.newArrayList;
package com.github.agiledon.sisyphus.util; public final class ResourceLoader { private ResourceLoader() {} private static Logger logger = LoggerFactory.getLogger(ResourceLoader.class); private static final String COMMENT_INDICATOR = "#"; private static final String SECTION_INDICATOR = "///"; public static String loadResource(String resourceName) { List<String> resource = loadResourceAsLines(resourceName); return Joiner.on("\n").join(resource); } public static List<String> loadResourceAsLines(String resourceName) { try {
// Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceFilePath.java // public static String compensatePath(String resourceName) { // if (resourceName.startsWith("/")) { // return resourceName; // } // return "/" + resourceName; // } // // Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceFilePath.java // public static String getAbsolutePath(String resourceName) { // return ResourceFilePath.class.getResource(compensatePath(resourceName)).getPath(); // } // Path: src/main/java/com/github/agiledon/sisyphus/util/ResourceLoader.java import com.google.common.base.Charsets; import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.base.Strings; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.io.Files; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.util.List; import static com.github.agiledon.sisyphus.util.ResourceFilePath.compensatePath; import static com.github.agiledon.sisyphus.util.ResourceFilePath.getAbsolutePath; import static com.google.common.collect.Lists.newArrayList; package com.github.agiledon.sisyphus.util; public final class ResourceLoader { private ResourceLoader() {} private static Logger logger = LoggerFactory.getLogger(ResourceLoader.class); private static final String COMMENT_INDICATOR = "#"; private static final String SECTION_INDICATOR = "///"; public static String loadResource(String resourceName) { List<String> resource = loadResourceAsLines(resourceName); return Joiner.on("\n").join(resource); } public static List<String> loadResourceAsLines(String resourceName) { try {
File file = new File(getAbsolutePath(compensatePath(resourceName)));
agiledon/sisyphus
src/test/java/com/github/agiledon/sisyphus/assist/FixtureAssistTest.java
// Path: src/main/java/com/github/agiledon/sisyphus/assist/FixtureAssist.java // public final class FixtureAssist { // private FixtureAssist() {} // // public static final Printer json() { // return new JsonPrinter(); // } // // public static final Printer gson() { // return new GsonPrinter(); // } // // public static final Printer yaml() { // return new YamlPrinter(); // } // }
import com.github.agiledon.sisyphus.assist.printer.*; import org.junit.Before; import org.junit.Test; import java.io.File; import static com.github.agiledon.sisyphus.assist.FixtureAssist.*; import static com.google.common.io.Files.getNameWithoutExtension; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat;
package com.github.agiledon.sisyphus.assist; public class FixtureAssistTest extends UserDataFixture { private String yamlFileName = "outputUser.yaml"; private String gsonFileName = "outputUser.gson"; private String jsonFileName = "outputUser.json"; @Before public void setUp() throws Exception { clearFiles(yamlFileName, gsonFileName, jsonFileName); } private void clearFiles(String... datafiles) { for (String datafile : datafiles) { File file = new File(datafile); if (file.exists()) { file.delete(); } } } @Test public void should_get_JsonPrinter_and_pass_object_to_it() { Printer printer = json(); assertThat(printer, instanceOf(JsonPrinter.class)); } @Test public void should_get_GsonPrinter_and_pass_object_to_it() {
// Path: src/main/java/com/github/agiledon/sisyphus/assist/FixtureAssist.java // public final class FixtureAssist { // private FixtureAssist() {} // // public static final Printer json() { // return new JsonPrinter(); // } // // public static final Printer gson() { // return new GsonPrinter(); // } // // public static final Printer yaml() { // return new YamlPrinter(); // } // } // Path: src/test/java/com/github/agiledon/sisyphus/assist/FixtureAssistTest.java import com.github.agiledon.sisyphus.assist.printer.*; import org.junit.Before; import org.junit.Test; import java.io.File; import static com.github.agiledon.sisyphus.assist.FixtureAssist.*; import static com.google.common.io.Files.getNameWithoutExtension; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; package com.github.agiledon.sisyphus.assist; public class FixtureAssistTest extends UserDataFixture { private String yamlFileName = "outputUser.yaml"; private String gsonFileName = "outputUser.gson"; private String jsonFileName = "outputUser.json"; @Before public void setUp() throws Exception { clearFiles(yamlFileName, gsonFileName, jsonFileName); } private void clearFiles(String... datafiles) { for (String datafile : datafiles) { File file = new File(datafile); if (file.exists()) { file.delete(); } } } @Test public void should_get_JsonPrinter_and_pass_object_to_it() { Printer printer = json(); assertThat(printer, instanceOf(JsonPrinter.class)); } @Test public void should_get_GsonPrinter_and_pass_object_to_it() {
Printer printer = FixtureAssist.gson();
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/assist/FixtureAssist.java
// Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/GsonPrinter.java // public class GsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "gson"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Gson gson = new Gson(); // return gson.toJson(sourceObject); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/JsonPrinter.java // public class JsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "json"; // } // // @Override // protected <T> String serialize(T sourceObject) { // ObjectMapper mapper = new ObjectMapper(); // try { // return mapper.writeValueAsString(sourceObject); // } catch (IOException e) { // logger.error(e.getMessage()); // return ""; // } // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/Printer.java // public interface Printer { // <T> void print(T sourceObject, String fileName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/YamlPrinter.java // public class YamlPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "yaml"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Yaml yaml = new Yaml(); // return yaml.dump(sourceObject); // } // }
import com.github.agiledon.sisyphus.assist.printer.GsonPrinter; import com.github.agiledon.sisyphus.assist.printer.JsonPrinter; import com.github.agiledon.sisyphus.assist.printer.Printer; import com.github.agiledon.sisyphus.assist.printer.YamlPrinter;
package com.github.agiledon.sisyphus.assist; public final class FixtureAssist { private FixtureAssist() {}
// Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/GsonPrinter.java // public class GsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "gson"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Gson gson = new Gson(); // return gson.toJson(sourceObject); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/JsonPrinter.java // public class JsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "json"; // } // // @Override // protected <T> String serialize(T sourceObject) { // ObjectMapper mapper = new ObjectMapper(); // try { // return mapper.writeValueAsString(sourceObject); // } catch (IOException e) { // logger.error(e.getMessage()); // return ""; // } // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/Printer.java // public interface Printer { // <T> void print(T sourceObject, String fileName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/YamlPrinter.java // public class YamlPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "yaml"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Yaml yaml = new Yaml(); // return yaml.dump(sourceObject); // } // } // Path: src/main/java/com/github/agiledon/sisyphus/assist/FixtureAssist.java import com.github.agiledon.sisyphus.assist.printer.GsonPrinter; import com.github.agiledon.sisyphus.assist.printer.JsonPrinter; import com.github.agiledon.sisyphus.assist.printer.Printer; import com.github.agiledon.sisyphus.assist.printer.YamlPrinter; package com.github.agiledon.sisyphus.assist; public final class FixtureAssist { private FixtureAssist() {}
public static final Printer json() {
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/assist/FixtureAssist.java
// Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/GsonPrinter.java // public class GsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "gson"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Gson gson = new Gson(); // return gson.toJson(sourceObject); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/JsonPrinter.java // public class JsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "json"; // } // // @Override // protected <T> String serialize(T sourceObject) { // ObjectMapper mapper = new ObjectMapper(); // try { // return mapper.writeValueAsString(sourceObject); // } catch (IOException e) { // logger.error(e.getMessage()); // return ""; // } // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/Printer.java // public interface Printer { // <T> void print(T sourceObject, String fileName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/YamlPrinter.java // public class YamlPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "yaml"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Yaml yaml = new Yaml(); // return yaml.dump(sourceObject); // } // }
import com.github.agiledon.sisyphus.assist.printer.GsonPrinter; import com.github.agiledon.sisyphus.assist.printer.JsonPrinter; import com.github.agiledon.sisyphus.assist.printer.Printer; import com.github.agiledon.sisyphus.assist.printer.YamlPrinter;
package com.github.agiledon.sisyphus.assist; public final class FixtureAssist { private FixtureAssist() {} public static final Printer json() {
// Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/GsonPrinter.java // public class GsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "gson"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Gson gson = new Gson(); // return gson.toJson(sourceObject); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/JsonPrinter.java // public class JsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "json"; // } // // @Override // protected <T> String serialize(T sourceObject) { // ObjectMapper mapper = new ObjectMapper(); // try { // return mapper.writeValueAsString(sourceObject); // } catch (IOException e) { // logger.error(e.getMessage()); // return ""; // } // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/Printer.java // public interface Printer { // <T> void print(T sourceObject, String fileName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/YamlPrinter.java // public class YamlPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "yaml"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Yaml yaml = new Yaml(); // return yaml.dump(sourceObject); // } // } // Path: src/main/java/com/github/agiledon/sisyphus/assist/FixtureAssist.java import com.github.agiledon.sisyphus.assist.printer.GsonPrinter; import com.github.agiledon.sisyphus.assist.printer.JsonPrinter; import com.github.agiledon.sisyphus.assist.printer.Printer; import com.github.agiledon.sisyphus.assist.printer.YamlPrinter; package com.github.agiledon.sisyphus.assist; public final class FixtureAssist { private FixtureAssist() {} public static final Printer json() {
return new JsonPrinter();
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/assist/FixtureAssist.java
// Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/GsonPrinter.java // public class GsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "gson"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Gson gson = new Gson(); // return gson.toJson(sourceObject); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/JsonPrinter.java // public class JsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "json"; // } // // @Override // protected <T> String serialize(T sourceObject) { // ObjectMapper mapper = new ObjectMapper(); // try { // return mapper.writeValueAsString(sourceObject); // } catch (IOException e) { // logger.error(e.getMessage()); // return ""; // } // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/Printer.java // public interface Printer { // <T> void print(T sourceObject, String fileName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/YamlPrinter.java // public class YamlPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "yaml"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Yaml yaml = new Yaml(); // return yaml.dump(sourceObject); // } // }
import com.github.agiledon.sisyphus.assist.printer.GsonPrinter; import com.github.agiledon.sisyphus.assist.printer.JsonPrinter; import com.github.agiledon.sisyphus.assist.printer.Printer; import com.github.agiledon.sisyphus.assist.printer.YamlPrinter;
package com.github.agiledon.sisyphus.assist; public final class FixtureAssist { private FixtureAssist() {} public static final Printer json() { return new JsonPrinter(); } public static final Printer gson() {
// Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/GsonPrinter.java // public class GsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "gson"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Gson gson = new Gson(); // return gson.toJson(sourceObject); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/JsonPrinter.java // public class JsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "json"; // } // // @Override // protected <T> String serialize(T sourceObject) { // ObjectMapper mapper = new ObjectMapper(); // try { // return mapper.writeValueAsString(sourceObject); // } catch (IOException e) { // logger.error(e.getMessage()); // return ""; // } // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/Printer.java // public interface Printer { // <T> void print(T sourceObject, String fileName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/YamlPrinter.java // public class YamlPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "yaml"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Yaml yaml = new Yaml(); // return yaml.dump(sourceObject); // } // } // Path: src/main/java/com/github/agiledon/sisyphus/assist/FixtureAssist.java import com.github.agiledon.sisyphus.assist.printer.GsonPrinter; import com.github.agiledon.sisyphus.assist.printer.JsonPrinter; import com.github.agiledon.sisyphus.assist.printer.Printer; import com.github.agiledon.sisyphus.assist.printer.YamlPrinter; package com.github.agiledon.sisyphus.assist; public final class FixtureAssist { private FixtureAssist() {} public static final Printer json() { return new JsonPrinter(); } public static final Printer gson() {
return new GsonPrinter();
agiledon/sisyphus
src/main/java/com/github/agiledon/sisyphus/assist/FixtureAssist.java
// Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/GsonPrinter.java // public class GsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "gson"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Gson gson = new Gson(); // return gson.toJson(sourceObject); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/JsonPrinter.java // public class JsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "json"; // } // // @Override // protected <T> String serialize(T sourceObject) { // ObjectMapper mapper = new ObjectMapper(); // try { // return mapper.writeValueAsString(sourceObject); // } catch (IOException e) { // logger.error(e.getMessage()); // return ""; // } // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/Printer.java // public interface Printer { // <T> void print(T sourceObject, String fileName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/YamlPrinter.java // public class YamlPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "yaml"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Yaml yaml = new Yaml(); // return yaml.dump(sourceObject); // } // }
import com.github.agiledon.sisyphus.assist.printer.GsonPrinter; import com.github.agiledon.sisyphus.assist.printer.JsonPrinter; import com.github.agiledon.sisyphus.assist.printer.Printer; import com.github.agiledon.sisyphus.assist.printer.YamlPrinter;
package com.github.agiledon.sisyphus.assist; public final class FixtureAssist { private FixtureAssist() {} public static final Printer json() { return new JsonPrinter(); } public static final Printer gson() { return new GsonPrinter(); } public static final Printer yaml() {
// Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/GsonPrinter.java // public class GsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "gson"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Gson gson = new Gson(); // return gson.toJson(sourceObject); // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/JsonPrinter.java // public class JsonPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "json"; // } // // @Override // protected <T> String serialize(T sourceObject) { // ObjectMapper mapper = new ObjectMapper(); // try { // return mapper.writeValueAsString(sourceObject); // } catch (IOException e) { // logger.error(e.getMessage()); // return ""; // } // } // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/Printer.java // public interface Printer { // <T> void print(T sourceObject, String fileName); // } // // Path: src/main/java/com/github/agiledon/sisyphus/assist/printer/YamlPrinter.java // public class YamlPrinter extends AbstractPrinter { // @Override // protected String getExtension() { // return "yaml"; // } // // @Override // protected <T> String serialize(T sourceObject) { // Yaml yaml = new Yaml(); // return yaml.dump(sourceObject); // } // } // Path: src/main/java/com/github/agiledon/sisyphus/assist/FixtureAssist.java import com.github.agiledon.sisyphus.assist.printer.GsonPrinter; import com.github.agiledon.sisyphus.assist.printer.JsonPrinter; import com.github.agiledon.sisyphus.assist.printer.Printer; import com.github.agiledon.sisyphus.assist.printer.YamlPrinter; package com.github.agiledon.sisyphus.assist; public final class FixtureAssist { private FixtureAssist() {} public static final Printer json() { return new JsonPrinter(); } public static final Printer gson() { return new GsonPrinter(); } public static final Printer yaml() {
return new YamlPrinter();
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/ChannelItemDetails.java
// Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelInternal.java // public interface IChannelInternal extends IChannel { // // IChannelService getChannelService(); // // void init(String channelId, IChannelService channelService, // String channelDescription); // // void init(); // // void fini(); // // boolean channelSecurity(HttpServletRequest request, // HttpServletResponse response) throws IOException; // // void channelHttp(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException; // // Properties getChannelConfigProperties(String propertiesFilePrefix); // // IProject getChannelProject(); // // long getChannelNodeId(); // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/IChannelItemDetails.java // public interface IChannelItemDetails extends ISketch { // // String getItemLabel(); // // String getItemKind(); // // long getTimestamp(); // // long getOrdinal(); // // JsonObject getJson(); // // String getUrlPath(); // // String[] getDataLines(); // }
import net.locosoft.fold.sketch.IChannelItemDetails; import com.eclipsesource.json.JsonObject; import net.locosoft.fold.channel.IChannelInternal;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public abstract class ChannelItemDetails implements IChannelItemDetails { private ChannelItemNode _channelItemNode; private long _ordinal; private JsonObject _jsonObject;
// Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelInternal.java // public interface IChannelInternal extends IChannel { // // IChannelService getChannelService(); // // void init(String channelId, IChannelService channelService, // String channelDescription); // // void init(); // // void fini(); // // boolean channelSecurity(HttpServletRequest request, // HttpServletResponse response) throws IOException; // // void channelHttp(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException; // // Properties getChannelConfigProperties(String propertiesFilePrefix); // // IProject getChannelProject(); // // long getChannelNodeId(); // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/IChannelItemDetails.java // public interface IChannelItemDetails extends ISketch { // // String getItemLabel(); // // String getItemKind(); // // long getTimestamp(); // // long getOrdinal(); // // JsonObject getJson(); // // String getUrlPath(); // // String[] getDataLines(); // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/ChannelItemDetails.java import net.locosoft.fold.sketch.IChannelItemDetails; import com.eclipsesource.json.JsonObject; import net.locosoft.fold.channel.IChannelInternal; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public abstract class ChannelItemDetails implements IChannelItemDetails { private ChannelItemNode _channelItemNode; private long _ordinal; private JsonObject _jsonObject;
public ChannelItemDetails(IChannelInternal channel, String itemLabel) {
cjdaly/fold
net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/internal/Neo4jService.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // }
import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.WriterConfig;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.neo4j.internal; public class Neo4jService implements INeo4jService { private BundleContext _bundleContext; private Neo4jController _neo4jController; private ServiceRegistration<INeo4jService> _serviceRegistration; public Neo4jService(BundleContext bundleContext) { _bundleContext = bundleContext; _neo4jController = new Neo4jController(); } public void start() { _serviceRegistration = _bundleContext.registerService( INeo4jService.class, this, null); _neo4jController.start(); } public void stop() { _serviceRegistration.unregister(); _neo4jController.stop(); } public boolean isNeo4jReady() { return _neo4jController.isNeo4jReady(); } public int getNeo4jPID() { return _neo4jController.getNeo4jPID(); }
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/internal/Neo4jService.java import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.WriterConfig; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.neo4j.internal; public class Neo4jService implements INeo4jService { private BundleContext _bundleContext; private Neo4jController _neo4jController; private ServiceRegistration<INeo4jService> _serviceRegistration; public Neo4jService(BundleContext bundleContext) { _bundleContext = bundleContext; _neo4jController = new Neo4jController(); } public void start() { _serviceRegistration = _bundleContext.registerService( INeo4jService.class, this, null); _neo4jController.start(); } public void stop() { _serviceRegistration.unregister(); _neo4jController.stop(); } public boolean isNeo4jReady() { return _neo4jController.isNeo4jReady(); } public int getNeo4jPID() { return _neo4jController.getNeo4jPID(); }
public ICypher constructCypher() {
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/PropertyAccessNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class PropertyAccessNode extends AbstractNodeSketch { public PropertyAccessNode(long nodeId) { _nodeId = nodeId; } // getters public JsonValue getValue(String propertyName) {
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/PropertyAccessNode.java import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class PropertyAccessNode extends AbstractNodeSketch { public PropertyAccessNode(long nodeId) { _nodeId = nodeId; } // getters public JsonValue getValue(String propertyName) {
INeo4jService neo4jService = getNeo4jService();
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/PropertyAccessNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class PropertyAccessNode extends AbstractNodeSketch { public PropertyAccessNode(long nodeId) { _nodeId = nodeId; } // getters public JsonValue getValue(String propertyName) { INeo4jService neo4jService = getNeo4jService(); String cypherText = "MATCH node" // + " WHERE id(node)={nodeId}" + " RETURN node.`" + propertyName + "`";
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/PropertyAccessNode.java import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class PropertyAccessNode extends AbstractNodeSketch { public PropertyAccessNode(long nodeId) { _nodeId = nodeId; } // getters public JsonValue getValue(String propertyName) { INeo4jService neo4jService = getNeo4jService(); String cypherText = "MATCH node" // + " WHERE id(node)={nodeId}" + " RETURN node.`" + propertyName + "`";
ICypher cypher = neo4jService.constructCypher(cypherText);
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/OrdinalNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch;
} protected String getOrdinalLabel() { return _ordinalLabel; } protected String getCounterPropertyName() { return PREFIX_ORDINAL_COUNTER + getOrdinalLabel(); } protected String getIndexPropertyName() { return PREFIX_ORDINAL_INDEX + getOrdinalLabel(); } public long getLatestOrdinal() { return _ordinalCounter.getCounter(getCounterPropertyName()); } public long getOrdinalIndex(long ordinalNodeId) { PropertyAccessNode props = new PropertyAccessNode(ordinalNodeId); return props.getLongValue(getIndexPropertyName()); } public long getOrdinalIndex(JsonObject jsonNode) { return jsonNode.getLong(getIndexPropertyName(), -1); } public long nextOrdinalNodeId() { long ordinalIndex = _ordinalCounter .incrementCounter(getCounterPropertyName());
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/OrdinalNode.java import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; } protected String getOrdinalLabel() { return _ordinalLabel; } protected String getCounterPropertyName() { return PREFIX_ORDINAL_COUNTER + getOrdinalLabel(); } protected String getIndexPropertyName() { return PREFIX_ORDINAL_INDEX + getOrdinalLabel(); } public long getLatestOrdinal() { return _ordinalCounter.getCounter(getCounterPropertyName()); } public long getOrdinalIndex(long ordinalNodeId) { PropertyAccessNode props = new PropertyAccessNode(ordinalNodeId); return props.getLongValue(getIndexPropertyName()); } public long getOrdinalIndex(JsonObject jsonNode) { return jsonNode.getLong(getIndexPropertyName(), -1); } public long nextOrdinalNodeId() { long ordinalIndex = _ordinalCounter .incrementCounter(getCounterPropertyName());
INeo4jService neo4jService = getNeo4jService();
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/OrdinalNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch;
protected String getCounterPropertyName() { return PREFIX_ORDINAL_COUNTER + getOrdinalLabel(); } protected String getIndexPropertyName() { return PREFIX_ORDINAL_INDEX + getOrdinalLabel(); } public long getLatestOrdinal() { return _ordinalCounter.getCounter(getCounterPropertyName()); } public long getOrdinalIndex(long ordinalNodeId) { PropertyAccessNode props = new PropertyAccessNode(ordinalNodeId); return props.getLongValue(getIndexPropertyName()); } public long getOrdinalIndex(JsonObject jsonNode) { return jsonNode.getLong(getIndexPropertyName(), -1); } public long nextOrdinalNodeId() { long ordinalIndex = _ordinalCounter .incrementCounter(getCounterPropertyName()); INeo4jService neo4jService = getNeo4jService(); if (ordinalIndex == 1) { String constraintCypherText = "CREATE CONSTRAINT ON (ordinal:" + getOrdinalLabel() + ") ASSERT ordinal.`" + getIndexPropertyName() + "` IS UNIQUE";
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/OrdinalNode.java import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; protected String getCounterPropertyName() { return PREFIX_ORDINAL_COUNTER + getOrdinalLabel(); } protected String getIndexPropertyName() { return PREFIX_ORDINAL_INDEX + getOrdinalLabel(); } public long getLatestOrdinal() { return _ordinalCounter.getCounter(getCounterPropertyName()); } public long getOrdinalIndex(long ordinalNodeId) { PropertyAccessNode props = new PropertyAccessNode(ordinalNodeId); return props.getLongValue(getIndexPropertyName()); } public long getOrdinalIndex(JsonObject jsonNode) { return jsonNode.getLong(getIndexPropertyName(), -1); } public long nextOrdinalNodeId() { long ordinalIndex = _ordinalCounter .incrementCounter(getCounterPropertyName()); INeo4jService neo4jService = getNeo4jService(); if (ordinalIndex == 1) { String constraintCypherText = "CREATE CONSTRAINT ON (ordinal:" + getOrdinalLabel() + ") ASSERT ordinal.`" + getIndexPropertyName() + "` IS UNIQUE";
ICypher constraintCypher = neo4jService
cjdaly/fold
net.locosoft.fold.channel.vitals/src/net/locosoft/fold/channel/vitals/Vital.java
// Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/MultiPropertyAccessNode.java // public class MultiPropertyAccessNode extends AbstractNodeSketch { // // private String _propertyNamePrefix; // // private ICypher _cypher; // private StringBuilder _cypherStatement; // private boolean _firstProperty; // // public MultiPropertyAccessNode(long nodeId) { // this(nodeId, ""); // } // // public MultiPropertyAccessNode(long nodeId, String propertyNamePrefix) { // _nodeId = nodeId; // _propertyNamePrefix = propertyNamePrefix == null ? "" // : propertyNamePrefix; // reset(); // } // // public void reset() { // INeo4jService neo4jService = getNeo4jService(); // _cypher = neo4jService.constructCypher("...placeholder..."); // _cypherStatement = new StringBuilder( // "MATCH node WHERE id(node)={nodeId} SET "); // _firstProperty = true; // } // // public JsonObject getProperties() { // INeo4jService neo4jService = getNeo4jService(); // String cypherText = "MATCH node" // // + " WHERE id(node)={nodeId}" // // + " RETURN node"; // // ICypher cypher = neo4jService.constructCypher(cypherText); // cypher.addParameter("nodeId", getNodeId()); // neo4jService.invokeCypher(cypher); // JsonValue jsonValue = cypher.getResultDataRow(0); // if ((jsonValue == null) || (!jsonValue.isObject())) // return null; // else // return jsonValue.asObject(); // } // // private void addCypherSet(String name) { // if (_firstProperty) // _firstProperty = false; // else // _cypherStatement.append(","); // // _cypherStatement.append("node.`" + _propertyNamePrefix + name + "`={" // + name + "}"); // } // // public void addProperty(String name, JsonValue value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, int value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, long value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, float value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, double value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, boolean value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, String value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void setProperties() { // INeo4jService neo4jService = getNeo4jService(); // _cypher.addParameter("nodeId", getNodeId()); // _cypher.setStatementText(_cypherStatement.toString()); // neo4jService.invokeCypher(_cypher); // } // }
import net.locosoft.fold.sketch.pad.neo4j.MultiPropertyAccessNode; import org.eclipse.core.runtime.IConfigurationElement;
Id = id; Datatype = datatype; Units = units; Name = name; Description = description; Internal = internal; } Vital(IConfigurationElement vitalElement) { Id = vitalElement.getAttribute("id"); Datatype = vitalElement.getAttribute("datatype"); Units = vitalElement.getAttribute("units"); Name = vitalElement.getAttribute("name"); Description = vitalElement.getAttribute("description"); Internal = false; } // void clear() { _intValue = 0; _longValue = 0; _floatValue = 0; _doubleValue = 0; _booleanValue = false; _stringValue = null; } //
// Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/MultiPropertyAccessNode.java // public class MultiPropertyAccessNode extends AbstractNodeSketch { // // private String _propertyNamePrefix; // // private ICypher _cypher; // private StringBuilder _cypherStatement; // private boolean _firstProperty; // // public MultiPropertyAccessNode(long nodeId) { // this(nodeId, ""); // } // // public MultiPropertyAccessNode(long nodeId, String propertyNamePrefix) { // _nodeId = nodeId; // _propertyNamePrefix = propertyNamePrefix == null ? "" // : propertyNamePrefix; // reset(); // } // // public void reset() { // INeo4jService neo4jService = getNeo4jService(); // _cypher = neo4jService.constructCypher("...placeholder..."); // _cypherStatement = new StringBuilder( // "MATCH node WHERE id(node)={nodeId} SET "); // _firstProperty = true; // } // // public JsonObject getProperties() { // INeo4jService neo4jService = getNeo4jService(); // String cypherText = "MATCH node" // // + " WHERE id(node)={nodeId}" // // + " RETURN node"; // // ICypher cypher = neo4jService.constructCypher(cypherText); // cypher.addParameter("nodeId", getNodeId()); // neo4jService.invokeCypher(cypher); // JsonValue jsonValue = cypher.getResultDataRow(0); // if ((jsonValue == null) || (!jsonValue.isObject())) // return null; // else // return jsonValue.asObject(); // } // // private void addCypherSet(String name) { // if (_firstProperty) // _firstProperty = false; // else // _cypherStatement.append(","); // // _cypherStatement.append("node.`" + _propertyNamePrefix + name + "`={" // + name + "}"); // } // // public void addProperty(String name, JsonValue value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, int value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, long value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, float value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, double value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, boolean value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void addProperty(String name, String value) { // addCypherSet(name); // _cypher.addParameter(name, value); // } // // public void setProperties() { // INeo4jService neo4jService = getNeo4jService(); // _cypher.addParameter("nodeId", getNodeId()); // _cypher.setStatementText(_cypherStatement.toString()); // neo4jService.invokeCypher(_cypher); // } // } // Path: net.locosoft.fold.channel.vitals/src/net/locosoft/fold/channel/vitals/Vital.java import net.locosoft.fold.sketch.pad.neo4j.MultiPropertyAccessNode; import org.eclipse.core.runtime.IConfigurationElement; Id = id; Datatype = datatype; Units = units; Name = name; Description = description; Internal = internal; } Vital(IConfigurationElement vitalElement) { Id = vitalElement.getAttribute("id"); Datatype = vitalElement.getAttribute("datatype"); Units = vitalElement.getAttribute("units"); Name = vitalElement.getAttribute("name"); Description = vitalElement.getAttribute("description"); Internal = false; } // void clear() { _intValue = 0; _longValue = 0; _floatValue = 0; _doubleValue = 0; _booleanValue = false; _stringValue = null; } //
void addTo(MultiPropertyAccessNode sketch) {
cjdaly/fold
net.locosoft.fold.server/src/net/locosoft/fold/server/internal/FoldServletHttpContext.java
// Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/ChannelUtil.java // public class ChannelUtil { // // public static IChannelService getChannelService() { // return FoldUtil.getService(IChannelService.class); // } // } // // Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelService.java // public interface IChannelService { // // IChannel[] getAllChannels(); // // IChannel getChannel(String channelId); // // <T extends IChannel> T getChannel(Class<T> channelInterface); // // String getChannelData(String channelId, String key, String... params); // // IChannelItemDetails getChannelItemDetails(String channelId, // String channelItemLabel, long channelItemOrdinal); // // boolean channelSecurity(HttpServletRequest request, // HttpServletResponse response) throws IOException; // // void channelHttp(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException; // // }
import java.io.IOException; import java.net.URL; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.locosoft.fold.channel.ChannelUtil; import net.locosoft.fold.channel.IChannelService; import org.osgi.service.http.HttpContext;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.server.internal; public class FoldServletHttpContext implements HttpContext { private IChannelService _channelService; public FoldServletHttpContext() {
// Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/ChannelUtil.java // public class ChannelUtil { // // public static IChannelService getChannelService() { // return FoldUtil.getService(IChannelService.class); // } // } // // Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelService.java // public interface IChannelService { // // IChannel[] getAllChannels(); // // IChannel getChannel(String channelId); // // <T extends IChannel> T getChannel(Class<T> channelInterface); // // String getChannelData(String channelId, String key, String... params); // // IChannelItemDetails getChannelItemDetails(String channelId, // String channelItemLabel, long channelItemOrdinal); // // boolean channelSecurity(HttpServletRequest request, // HttpServletResponse response) throws IOException; // // void channelHttp(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException; // // } // Path: net.locosoft.fold.server/src/net/locosoft/fold/server/internal/FoldServletHttpContext.java import java.io.IOException; import java.net.URL; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.locosoft.fold.channel.ChannelUtil; import net.locosoft.fold.channel.IChannelService; import org.osgi.service.http.HttpContext; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.server.internal; public class FoldServletHttpContext implements HttpContext { private IChannelService _channelService; public FoldServletHttpContext() {
_channelService = ChannelUtil.getChannelService();
cjdaly/fold
net.locosoft.fold.server/src/net/locosoft/fold/server/internal/FoldServlet.java
// Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/ChannelUtil.java // public class ChannelUtil { // // public static IChannelService getChannelService() { // return FoldUtil.getService(IChannelService.class); // } // } // // Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelService.java // public interface IChannelService { // // IChannel[] getAllChannels(); // // IChannel getChannel(String channelId); // // <T extends IChannel> T getChannel(Class<T> channelInterface); // // String getChannelData(String channelId, String key, String... params); // // IChannelItemDetails getChannelItemDetails(String channelId, // String channelItemLabel, long channelItemOrdinal); // // boolean channelSecurity(HttpServletRequest request, // HttpServletResponse response) throws IOException; // // void channelHttp(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException; // // }
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.locosoft.fold.channel.ChannelUtil; import net.locosoft.fold.channel.IChannelService;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.server.internal; @SuppressWarnings("serial") public class FoldServlet extends HttpServlet {
// Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/ChannelUtil.java // public class ChannelUtil { // // public static IChannelService getChannelService() { // return FoldUtil.getService(IChannelService.class); // } // } // // Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelService.java // public interface IChannelService { // // IChannel[] getAllChannels(); // // IChannel getChannel(String channelId); // // <T extends IChannel> T getChannel(Class<T> channelInterface); // // String getChannelData(String channelId, String key, String... params); // // IChannelItemDetails getChannelItemDetails(String channelId, // String channelItemLabel, long channelItemOrdinal); // // boolean channelSecurity(HttpServletRequest request, // HttpServletResponse response) throws IOException; // // void channelHttp(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException; // // } // Path: net.locosoft.fold.server/src/net/locosoft/fold/server/internal/FoldServlet.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.locosoft.fold.channel.ChannelUtil; import net.locosoft.fold.channel.IChannelService; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.server.internal; @SuppressWarnings("serial") public class FoldServlet extends HttpServlet {
private IChannelService _channelService;
cjdaly/fold
net.locosoft.fold.server/src/net/locosoft/fold/server/internal/FoldServlet.java
// Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/ChannelUtil.java // public class ChannelUtil { // // public static IChannelService getChannelService() { // return FoldUtil.getService(IChannelService.class); // } // } // // Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelService.java // public interface IChannelService { // // IChannel[] getAllChannels(); // // IChannel getChannel(String channelId); // // <T extends IChannel> T getChannel(Class<T> channelInterface); // // String getChannelData(String channelId, String key, String... params); // // IChannelItemDetails getChannelItemDetails(String channelId, // String channelItemLabel, long channelItemOrdinal); // // boolean channelSecurity(HttpServletRequest request, // HttpServletResponse response) throws IOException; // // void channelHttp(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException; // // }
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.locosoft.fold.channel.ChannelUtil; import net.locosoft.fold.channel.IChannelService;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.server.internal; @SuppressWarnings("serial") public class FoldServlet extends HttpServlet { private IChannelService _channelService; public String getServletInfo() { return "fold"; } public void init() throws ServletException {
// Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/ChannelUtil.java // public class ChannelUtil { // // public static IChannelService getChannelService() { // return FoldUtil.getService(IChannelService.class); // } // } // // Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelService.java // public interface IChannelService { // // IChannel[] getAllChannels(); // // IChannel getChannel(String channelId); // // <T extends IChannel> T getChannel(Class<T> channelInterface); // // String getChannelData(String channelId, String key, String... params); // // IChannelItemDetails getChannelItemDetails(String channelId, // String channelItemLabel, long channelItemOrdinal); // // boolean channelSecurity(HttpServletRequest request, // HttpServletResponse response) throws IOException; // // void channelHttp(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException; // // } // Path: net.locosoft.fold.server/src/net/locosoft/fold/server/internal/FoldServlet.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.locosoft.fold.channel.ChannelUtil; import net.locosoft.fold.channel.IChannelService; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.server.internal; @SuppressWarnings("serial") public class FoldServlet extends HttpServlet { private IChannelService _channelService; public String getServletInfo() { return "fold"; } public void init() throws ServletException {
_channelService = ChannelUtil.getChannelService();
cjdaly/fold
net.locosoft.fold.channel.times/src/net/locosoft/fold/channel/times/internal/GetTimesNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import java.util.Calendar; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import org.eclipse.core.runtime.IPath;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.channel.times.internal; public class GetTimesNode extends AbstractNodeSketch { public GetTimesNode(long nodeId) { _nodeId = nodeId; } private static final String CYPHER_CREATE_MINUTE = "MATCH epochNode" // + " WHERE id(epochNode)={epochNodeId}" // + " CREATE UNIQUE (epochNode)-[:fold_Hierarchy]->" + "(yearNode { fold_Hierarchy_segment:{year} })-[:fold_Hierarchy]->" + "(monthNode { fold_Hierarchy_segment:{month} })-[:fold_Hierarchy]->" + "(dayNode { fold_Hierarchy_segment:{day} })-[:fold_Hierarchy]->" + "(hourNode { fold_Hierarchy_segment:{hour} })-[:fold_Hierarchy]->" // + "(minuteNode { fold_Hierarchy_segment:{minute} })" // + " RETURN ID(minuteNode)"; private static final String CYPHER_FIND_MINUTE = "MATCH (epochNode)-[:fold_Hierarchy]->" // + "(yearNode { fold_Hierarchy_segment:{year} })-[:fold_Hierarchy]->" + "(monthNode { fold_Hierarchy_segment:{month} })-[:fold_Hierarchy]->" + "(dayNode { fold_Hierarchy_segment:{day} })-[:fold_Hierarchy]->" + "(hourNode { fold_Hierarchy_segment:{hour} })-[:fold_Hierarchy]->" // + "(minuteNode { fold_Hierarchy_segment:{minute} })" // + " WHERE id(epochNode)={epochNodeId}" // + " RETURN ID(minuteNode)"; public long getMinuteNodeId(long timeMillis, boolean createIfAbsent) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timeMillis);
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.channel.times/src/net/locosoft/fold/channel/times/internal/GetTimesNode.java import java.util.Calendar; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import org.eclipse.core.runtime.IPath; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.channel.times.internal; public class GetTimesNode extends AbstractNodeSketch { public GetTimesNode(long nodeId) { _nodeId = nodeId; } private static final String CYPHER_CREATE_MINUTE = "MATCH epochNode" // + " WHERE id(epochNode)={epochNodeId}" // + " CREATE UNIQUE (epochNode)-[:fold_Hierarchy]->" + "(yearNode { fold_Hierarchy_segment:{year} })-[:fold_Hierarchy]->" + "(monthNode { fold_Hierarchy_segment:{month} })-[:fold_Hierarchy]->" + "(dayNode { fold_Hierarchy_segment:{day} })-[:fold_Hierarchy]->" + "(hourNode { fold_Hierarchy_segment:{hour} })-[:fold_Hierarchy]->" // + "(minuteNode { fold_Hierarchy_segment:{minute} })" // + " RETURN ID(minuteNode)"; private static final String CYPHER_FIND_MINUTE = "MATCH (epochNode)-[:fold_Hierarchy]->" // + "(yearNode { fold_Hierarchy_segment:{year} })-[:fold_Hierarchy]->" + "(monthNode { fold_Hierarchy_segment:{month} })-[:fold_Hierarchy]->" + "(dayNode { fold_Hierarchy_segment:{day} })-[:fold_Hierarchy]->" + "(hourNode { fold_Hierarchy_segment:{hour} })-[:fold_Hierarchy]->" // + "(minuteNode { fold_Hierarchy_segment:{minute} })" // + " WHERE id(epochNode)={epochNodeId}" // + " RETURN ID(minuteNode)"; public long getMinuteNodeId(long timeMillis, boolean createIfAbsent) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timeMillis);
INeo4jService neo4jService = getNeo4jService();
cjdaly/fold
net.locosoft.fold.channel.times/src/net/locosoft/fold/channel/times/internal/GetTimesNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import java.util.Calendar; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import org.eclipse.core.runtime.IPath;
private static final String CYPHER_CREATE_MINUTE = "MATCH epochNode" // + " WHERE id(epochNode)={epochNodeId}" // + " CREATE UNIQUE (epochNode)-[:fold_Hierarchy]->" + "(yearNode { fold_Hierarchy_segment:{year} })-[:fold_Hierarchy]->" + "(monthNode { fold_Hierarchy_segment:{month} })-[:fold_Hierarchy]->" + "(dayNode { fold_Hierarchy_segment:{day} })-[:fold_Hierarchy]->" + "(hourNode { fold_Hierarchy_segment:{hour} })-[:fold_Hierarchy]->" // + "(minuteNode { fold_Hierarchy_segment:{minute} })" // + " RETURN ID(minuteNode)"; private static final String CYPHER_FIND_MINUTE = "MATCH (epochNode)-[:fold_Hierarchy]->" // + "(yearNode { fold_Hierarchy_segment:{year} })-[:fold_Hierarchy]->" + "(monthNode { fold_Hierarchy_segment:{month} })-[:fold_Hierarchy]->" + "(dayNode { fold_Hierarchy_segment:{day} })-[:fold_Hierarchy]->" + "(hourNode { fold_Hierarchy_segment:{hour} })-[:fold_Hierarchy]->" // + "(minuteNode { fold_Hierarchy_segment:{minute} })" // + " WHERE id(epochNode)={epochNodeId}" // + " RETURN ID(minuteNode)"; public long getMinuteNodeId(long timeMillis, boolean createIfAbsent) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timeMillis); INeo4jService neo4jService = getNeo4jService(); String cypherText; if (createIfAbsent) { cypherText = CYPHER_CREATE_MINUTE; } else { cypherText = CYPHER_FIND_MINUTE; }
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.channel.times/src/net/locosoft/fold/channel/times/internal/GetTimesNode.java import java.util.Calendar; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import org.eclipse.core.runtime.IPath; private static final String CYPHER_CREATE_MINUTE = "MATCH epochNode" // + " WHERE id(epochNode)={epochNodeId}" // + " CREATE UNIQUE (epochNode)-[:fold_Hierarchy]->" + "(yearNode { fold_Hierarchy_segment:{year} })-[:fold_Hierarchy]->" + "(monthNode { fold_Hierarchy_segment:{month} })-[:fold_Hierarchy]->" + "(dayNode { fold_Hierarchy_segment:{day} })-[:fold_Hierarchy]->" + "(hourNode { fold_Hierarchy_segment:{hour} })-[:fold_Hierarchy]->" // + "(minuteNode { fold_Hierarchy_segment:{minute} })" // + " RETURN ID(minuteNode)"; private static final String CYPHER_FIND_MINUTE = "MATCH (epochNode)-[:fold_Hierarchy]->" // + "(yearNode { fold_Hierarchy_segment:{year} })-[:fold_Hierarchy]->" + "(monthNode { fold_Hierarchy_segment:{month} })-[:fold_Hierarchy]->" + "(dayNode { fold_Hierarchy_segment:{day} })-[:fold_Hierarchy]->" + "(hourNode { fold_Hierarchy_segment:{hour} })-[:fold_Hierarchy]->" // + "(minuteNode { fold_Hierarchy_segment:{minute} })" // + " WHERE id(epochNode)={epochNodeId}" // + " RETURN ID(minuteNode)"; public long getMinuteNodeId(long timeMillis, boolean createIfAbsent) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timeMillis); INeo4jService neo4jService = getNeo4jService(); String cypherText; if (createIfAbsent) { cypherText = CYPHER_CREATE_MINUTE; } else { cypherText = CYPHER_FIND_MINUTE; }
ICypher cypher = neo4jService.constructCypher(cypherText);
cjdaly/fold
net.locosoft.fold.channel.vitals/src/net/locosoft/fold/channel/vitals/AbstractVitals.java
// Path: net.locosoft.fold.util/src/net/locosoft/fold/util/TypeConvertUtil.java // public class TypeConvertUtil { // // public static Integer toInteger(Object value) { // if (value instanceof Integer) // return (Integer) value; // if (value instanceof String) { // try { // return Integer.parseInt((String) value); // } catch (NumberFormatException ex) { // // // } // } // return null; // } // // public static Long toLong(Object value) { // if (value instanceof Long) // return (Long) value; // if (value instanceof Integer) { // Integer v = (Integer) value; // return v.longValue(); // } // if (value instanceof String) { // try { // return Long.parseLong((String) value); // } catch (NumberFormatException ex) { // // // } // } // return null; // } // // public static Float toFloat(Object value) { // if (value instanceof Float) // return (Float) value; // if (value instanceof String) { // try { // return Float.parseFloat((String) value); // } catch (NumberFormatException ex) { // // // } // } // return null; // } // // public static Double toDouble(Object value) { // if (value instanceof Double) // return (Double) value; // if (value instanceof Float) { // Float v = (Float) value; // return v.doubleValue(); // } // if (value instanceof String) { // try { // return Double.parseDouble((String) value); // } catch (NumberFormatException ex) { // // // } // } // return null; // } // // public static Boolean toBoolean(Object value) { // if (value instanceof Boolean) // return (Boolean) value; // if (value instanceof String) { // try { // return Boolean.parseBoolean((String) value); // } catch (NumberFormatException ex) { // // // } // } // return null; // } // // public static String toString(Object value) { // if (value == null) // return null; // else // return value.toString(); // } // // }
import java.util.ArrayList; import java.util.Collection; import java.util.TreeMap; import net.locosoft.fold.util.TypeConvertUtil; import com.eclipsesource.json.JsonValue;
return; Vital vital = _idToVital.get(id); if (vital != null) { vital.setValue(value); } } protected void recordVital(String id, Boolean value) { if (value == null) return; Vital vital = _idToVital.get(id); if (vital != null) { vital.setValue(value); } } protected void recordVital(String id, String value) { if (value == null) return; Vital vital = _idToVital.get(id); if (vital != null) { vital.setValue(value); } } protected void recordVitalConvertType(String id, Object value) { Vital vital = _idToVital.get(id); if (vital != null) { switch (vital.Datatype) { case "int":
// Path: net.locosoft.fold.util/src/net/locosoft/fold/util/TypeConvertUtil.java // public class TypeConvertUtil { // // public static Integer toInteger(Object value) { // if (value instanceof Integer) // return (Integer) value; // if (value instanceof String) { // try { // return Integer.parseInt((String) value); // } catch (NumberFormatException ex) { // // // } // } // return null; // } // // public static Long toLong(Object value) { // if (value instanceof Long) // return (Long) value; // if (value instanceof Integer) { // Integer v = (Integer) value; // return v.longValue(); // } // if (value instanceof String) { // try { // return Long.parseLong((String) value); // } catch (NumberFormatException ex) { // // // } // } // return null; // } // // public static Float toFloat(Object value) { // if (value instanceof Float) // return (Float) value; // if (value instanceof String) { // try { // return Float.parseFloat((String) value); // } catch (NumberFormatException ex) { // // // } // } // return null; // } // // public static Double toDouble(Object value) { // if (value instanceof Double) // return (Double) value; // if (value instanceof Float) { // Float v = (Float) value; // return v.doubleValue(); // } // if (value instanceof String) { // try { // return Double.parseDouble((String) value); // } catch (NumberFormatException ex) { // // // } // } // return null; // } // // public static Boolean toBoolean(Object value) { // if (value instanceof Boolean) // return (Boolean) value; // if (value instanceof String) { // try { // return Boolean.parseBoolean((String) value); // } catch (NumberFormatException ex) { // // // } // } // return null; // } // // public static String toString(Object value) { // if (value == null) // return null; // else // return value.toString(); // } // // } // Path: net.locosoft.fold.channel.vitals/src/net/locosoft/fold/channel/vitals/AbstractVitals.java import java.util.ArrayList; import java.util.Collection; import java.util.TreeMap; import net.locosoft.fold.util.TypeConvertUtil; import com.eclipsesource.json.JsonValue; return; Vital vital = _idToVital.get(id); if (vital != null) { vital.setValue(value); } } protected void recordVital(String id, Boolean value) { if (value == null) return; Vital vital = _idToVital.get(id); if (vital != null) { vital.setValue(value); } } protected void recordVital(String id, String value) { if (value == null) return; Vital vital = _idToVital.get(id); if (vital != null) { vital.setValue(value); } } protected void recordVitalConvertType(String id, Object value) { Vital vital = _idToVital.get(id); if (vital != null) { switch (vital.Datatype) { case "int":
recordVital(id, TypeConvertUtil.toInteger(value));
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/MultiPropertyAccessNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class MultiPropertyAccessNode extends AbstractNodeSketch { private String _propertyNamePrefix;
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/MultiPropertyAccessNode.java import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class MultiPropertyAccessNode extends AbstractNodeSketch { private String _propertyNamePrefix;
private ICypher _cypher;
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/MultiPropertyAccessNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class MultiPropertyAccessNode extends AbstractNodeSketch { private String _propertyNamePrefix; private ICypher _cypher; private StringBuilder _cypherStatement; private boolean _firstProperty; public MultiPropertyAccessNode(long nodeId) { this(nodeId, ""); } public MultiPropertyAccessNode(long nodeId, String propertyNamePrefix) { _nodeId = nodeId; _propertyNamePrefix = propertyNamePrefix == null ? "" : propertyNamePrefix; reset(); } public void reset() {
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/MultiPropertyAccessNode.java import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class MultiPropertyAccessNode extends AbstractNodeSketch { private String _propertyNamePrefix; private ICypher _cypher; private StringBuilder _cypherStatement; private boolean _firstProperty; public MultiPropertyAccessNode(long nodeId) { this(nodeId, ""); } public MultiPropertyAccessNode(long nodeId, String propertyNamePrefix) { _nodeId = nodeId; _propertyNamePrefix = propertyNamePrefix == null ? "" : propertyNamePrefix; reset(); } public void reset() {
INeo4jService neo4jService = getNeo4jService();
cjdaly/fold
net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/Neo4jUtil.java // public class Neo4jUtil { // // public static INeo4jService getNeo4jService() { // return FoldUtil.getService(INeo4jService.class); // } // }
import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.neo4j.Neo4jUtil;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch; public abstract class AbstractNodeSketch implements INodeSketch { protected long _nodeId = -1; public long getNodeId() { return _nodeId; }
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/Neo4jUtil.java // public class Neo4jUtil { // // public static INeo4jService getNeo4jService() { // return FoldUtil.getService(INeo4jService.class); // } // } // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.neo4j.Neo4jUtil; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch; public abstract class AbstractNodeSketch implements INodeSketch { protected long _nodeId = -1; public long getNodeId() { return _nodeId; }
private INeo4jService _neo4jService;
cjdaly/fold
net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/Neo4jUtil.java // public class Neo4jUtil { // // public static INeo4jService getNeo4jService() { // return FoldUtil.getService(INeo4jService.class); // } // }
import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.neo4j.Neo4jUtil;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch; public abstract class AbstractNodeSketch implements INodeSketch { protected long _nodeId = -1; public long getNodeId() { return _nodeId; } private INeo4jService _neo4jService; public INeo4jService getNeo4jService() { if (_neo4jService == null) {
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/Neo4jUtil.java // public class Neo4jUtil { // // public static INeo4jService getNeo4jService() { // return FoldUtil.getService(INeo4jService.class); // } // } // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.neo4j.Neo4jUtil; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch; public abstract class AbstractNodeSketch implements INodeSketch { protected long _nodeId = -1; public long getNodeId() { return _nodeId; } private INeo4jService _neo4jService; public INeo4jService getNeo4jService() { if (_neo4jService == null) {
_neo4jService = Neo4jUtil.getNeo4jService();
cjdaly/fold
net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannel.java
// Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/IChannelItemDetails.java // public interface IChannelItemDetails extends ISketch { // // String getItemLabel(); // // String getItemKind(); // // long getTimestamp(); // // long getOrdinal(); // // JsonObject getJson(); // // String getUrlPath(); // // String[] getDataLines(); // }
import net.locosoft.fold.sketch.IChannelItemDetails;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.channel; public interface IChannel { String getChannelId(); String getChannelData(String key, String... params);
// Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/IChannelItemDetails.java // public interface IChannelItemDetails extends ISketch { // // String getItemLabel(); // // String getItemKind(); // // long getTimestamp(); // // long getOrdinal(); // // JsonObject getJson(); // // String getUrlPath(); // // String[] getDataLines(); // } // Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannel.java import net.locosoft.fold.sketch.IChannelItemDetails; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.channel; public interface IChannel { String getChannelId(); String getChannelData(String key, String... params);
IChannelItemDetails getChannelItemDetails(String itemLabel, long itemOrdinal);
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/CounterPropertyNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class CounterPropertyNode extends AbstractNodeSketch { public CounterPropertyNode(long nodeId) { _nodeId = nodeId; } private long crementCounter(String counterPropertyName, boolean isIncrement) {
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/CounterPropertyNode.java import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class CounterPropertyNode extends AbstractNodeSketch { public CounterPropertyNode(long nodeId) { _nodeId = nodeId; } private long crementCounter(String counterPropertyName, boolean isIncrement) {
INeo4jService neo4jService = getNeo4jService();
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/CounterPropertyNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class CounterPropertyNode extends AbstractNodeSketch { public CounterPropertyNode(long nodeId) { _nodeId = nodeId; } private long crementCounter(String counterPropertyName, boolean isIncrement) { INeo4jService neo4jService = getNeo4jService(); char crementOp = isIncrement ? '+' : '-'; String cypherText = "MATCH node WHERE id(node)={nodeId}" + " SET node.`" + counterPropertyName + "`=COALESCE(node.`" + counterPropertyName + "`, 0) " + crementOp + " 1" + " RETURN node.`" + counterPropertyName + "`";
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/CounterPropertyNode.java import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonValue; import net.locosoft.fold.neo4j.ICypher; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class CounterPropertyNode extends AbstractNodeSketch { public CounterPropertyNode(long nodeId) { _nodeId = nodeId; } private long crementCounter(String counterPropertyName, boolean isIncrement) { INeo4jService neo4jService = getNeo4jService(); char crementOp = isIncrement ? '+' : '-'; String cypherText = "MATCH node WHERE id(node)={nodeId}" + " SET node.`" + counterPropertyName + "`=COALESCE(node.`" + counterPropertyName + "`, 0) " + crementOp + " 1" + " RETURN node.`" + counterPropertyName + "`";
ICypher cypher = neo4jService.constructCypher(cypherText);
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/ChannelItemNode.java
// Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelInternal.java // public interface IChannelInternal extends IChannel { // // IChannelService getChannelService(); // // void init(String channelId, IChannelService channelService, // String channelDescription); // // void init(); // // void fini(); // // boolean channelSecurity(HttpServletRequest request, // HttpServletResponse response) throws IOException; // // void channelHttp(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException; // // Properties getChannelConfigProperties(String propertiesFilePrefix); // // IProject getChannelProject(); // // long getChannelNodeId(); // }
import net.locosoft.fold.channel.IChannelInternal;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class ChannelItemNode extends OrdinalNode { private String _itemLabel;
// Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelInternal.java // public interface IChannelInternal extends IChannel { // // IChannelService getChannelService(); // // void init(String channelId, IChannelService channelService, // String channelDescription); // // void init(); // // void fini(); // // boolean channelSecurity(HttpServletRequest request, // HttpServletResponse response) throws IOException; // // void channelHttp(HttpServletRequest request, HttpServletResponse response) // throws ServletException, IOException; // // Properties getChannelConfigProperties(String propertiesFilePrefix); // // IProject getChannelProject(); // // long getChannelNodeId(); // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/ChannelItemNode.java import net.locosoft.fold.channel.IChannelInternal; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class ChannelItemNode extends OrdinalNode { private String _itemLabel;
public ChannelItemNode(IChannelInternal channel, String itemLabel) {
cjdaly/fold
net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelService.java
// Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/IChannelItemDetails.java // public interface IChannelItemDetails extends ISketch { // // String getItemLabel(); // // String getItemKind(); // // long getTimestamp(); // // long getOrdinal(); // // JsonObject getJson(); // // String getUrlPath(); // // String[] getDataLines(); // }
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.locosoft.fold.sketch.IChannelItemDetails;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.channel; public interface IChannelService { IChannel[] getAllChannels(); IChannel getChannel(String channelId); <T extends IChannel> T getChannel(Class<T> channelInterface); String getChannelData(String channelId, String key, String... params);
// Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/IChannelItemDetails.java // public interface IChannelItemDetails extends ISketch { // // String getItemLabel(); // // String getItemKind(); // // long getTimestamp(); // // long getOrdinal(); // // JsonObject getJson(); // // String getUrlPath(); // // String[] getDataLines(); // } // Path: net.locosoft.fold.channel/src/net/locosoft/fold/channel/IChannelService.java import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.locosoft.fold.sketch.IChannelItemDetails; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.channel; public interface IChannelService { IChannel[] getAllChannels(); IChannel getChannel(String channelId); <T extends IChannel> T getChannel(Class<T> channelInterface); String getChannelData(String channelId, String key, String... params);
IChannelItemDetails getChannelItemDetails(String channelId,
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/HierarchyNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class HierarchyNode extends AbstractNodeSketch { public HierarchyNode(long nodeId) { _nodeId = nodeId; } public void setNodeId(long nodeId) { _nodeId = nodeId; } public long getSupId() {
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/HierarchyNode.java import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class HierarchyNode extends AbstractNodeSketch { public HierarchyNode(long nodeId) { _nodeId = nodeId; } public void setNodeId(long nodeId) { _nodeId = nodeId; } public long getSupId() {
INeo4jService neo4jService = getNeo4jService();
cjdaly/fold
net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/HierarchyNode.java
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // }
import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue;
/***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class HierarchyNode extends AbstractNodeSketch { public HierarchyNode(long nodeId) { _nodeId = nodeId; } public void setNodeId(long nodeId) { _nodeId = nodeId; } public long getSupId() { INeo4jService neo4jService = getNeo4jService(); String cypherText = "MATCH (sup)-[:fold_Hierarchy]->(sub)" + " WHERE ID(sub)={subId}" // + " RETURN ID(sup)";
// Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/ICypher.java // public interface ICypher { // // boolean allowParallelInvocation(); // // void allowParallelInvocation(boolean parallelInvocation); // // String getStatementText(); // // void setStatementText(String statementText); // // JsonObject getRequest(); // // void addStatement(String statementText); // // void addParameter(String name, JsonValue value); // // void addParameter(String name, int value); // // void addParameter(String name, long value); // // void addParameter(String name, float value); // // void addParameter(String name, double value); // // void addParameter(String name, boolean value); // // void addParameter(String name, String value); // // JsonObject getResponse(); // // JsonArray getResultData(); // // JsonArray getResultData(int resultSet); // // int getResultDataRowCount(); // // int getResultDataRowCount(int resultSet); // // JsonValue getResultDataRow(int index); // // JsonValue getResultDataRow(int resultSet, int index); // // JsonArray getErrors(); // // int getErrorCount(); // } // // Path: net.locosoft.fold.neo4j/src/net/locosoft/fold/neo4j/INeo4jService.java // public interface INeo4jService { // // boolean isNeo4jReady(); // // int getNeo4jPID(); // // ICypher constructCypher(); // // ICypher constructCypher(String statement); // // void invokeCypher(ICypher cypher); // // void invokeCypher(ICypher cypher, boolean logErrors); // // } // // Path: net.locosoft.fold.sketch/src/net/locosoft/fold/sketch/AbstractNodeSketch.java // public abstract class AbstractNodeSketch implements INodeSketch { // // protected long _nodeId = -1; // // public long getNodeId() { // return _nodeId; // } // // private INeo4jService _neo4jService; // // public INeo4jService getNeo4jService() { // if (_neo4jService == null) { // _neo4jService = Neo4jUtil.getNeo4jService(); // } // return _neo4jService; // } // // } // Path: net.locosoft.fold.sketch.pad/src/net/locosoft/fold/sketch/pad/neo4j/HierarchyNode.java import net.locosoft.fold.neo4j.ICypher; import net.locosoft.fold.neo4j.INeo4jService; import net.locosoft.fold.sketch.AbstractNodeSketch; import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; /***************************************************************************** * Copyright (c) 2015 Chris J Daly (github user cjdaly) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * cjdaly - initial API and implementation ****************************************************************************/ package net.locosoft.fold.sketch.pad.neo4j; public class HierarchyNode extends AbstractNodeSketch { public HierarchyNode(long nodeId) { _nodeId = nodeId; } public void setNodeId(long nodeId) { _nodeId = nodeId; } public long getSupId() { INeo4jService neo4jService = getNeo4jService(); String cypherText = "MATCH (sup)-[:fold_Hierarchy]->(sub)" + " WHERE ID(sub)={subId}" // + " RETURN ID(sup)";
ICypher cypher = neo4jService.constructCypher(cypherText);
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/sys/security/credentials/JsonWebTokenCredentialsMatcher.java
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/token/JsonWebToken.java // public class JsonWebToken implements AuthenticationToken { // // private static final long serialVersionUID = 1389130131607655713L; // private String token; // // public JsonWebToken(String token) { // this.token = token; // } // // public String getToken() { // return token; // } // // public void setToken(String token) { // this.token = token; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getPrincipal() // */ // @Override // public Object getPrincipal() { // return ""; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getCredentials() // */ // @Override // public Object getCredentials() { // return getToken(); // } // // }
import io.github.howiefh.jeews.modules.sys.security.token.JsonWebToken; import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SignatureException; import java.util.Map; import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authc.SimpleAuthenticationInfo; import org.apache.shiro.authc.credential.CredentialsMatcher; import org.apache.shiro.subject.SimplePrincipalCollection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.auth0.jwt.JWTVerifier; import com.auth0.jwt.JWTVerifyException;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.security.credentials; /** * * * @author howiefh */ public class JsonWebTokenCredentialsMatcher implements CredentialsMatcher { private static final Logger log = LoggerFactory.getLogger(JsonWebTokenCredentialsMatcher.class); private String audience; private String secret; public String getAudience() { return audience; } public void setAudience(String audience) { this.audience = audience; } public String getSecret() { return secret; } public void setSecret(String secret) { this.secret = secret; } /* * (non-Javadoc) * * @see * org.apache.shiro.authc.credential.CredentialsMatcher#doCredentialsMatch * (org.apache.shiro.authc.AuthenticationToken, * org.apache.shiro.authc.AuthenticationInfo) */ @Override public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/token/JsonWebToken.java // public class JsonWebToken implements AuthenticationToken { // // private static final long serialVersionUID = 1389130131607655713L; // private String token; // // public JsonWebToken(String token) { // this.token = token; // } // // public String getToken() { // return token; // } // // public void setToken(String token) { // this.token = token; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getPrincipal() // */ // @Override // public Object getPrincipal() { // return ""; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getCredentials() // */ // @Override // public Object getCredentials() { // return getToken(); // } // // } // Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/credentials/JsonWebTokenCredentialsMatcher.java import io.github.howiefh.jeews.modules.sys.security.token.JsonWebToken; import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SignatureException; import java.util.Map; import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authc.SimpleAuthenticationInfo; import org.apache.shiro.authc.credential.CredentialsMatcher; import org.apache.shiro.subject.SimplePrincipalCollection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.auth0.jwt.JWTVerifier; import com.auth0.jwt.JWTVerifyException; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.security.credentials; /** * * * @author howiefh */ public class JsonWebTokenCredentialsMatcher implements CredentialsMatcher { private static final Logger log = LoggerFactory.getLogger(JsonWebTokenCredentialsMatcher.class); private String audience; private String secret; public String getAudience() { return audience; } public void setAudience(String audience) { this.audience = audience; } public String getSecret() { return secret; } public void setSecret(String secret) { this.secret = secret; } /* * (non-Javadoc) * * @see * org.apache.shiro.authc.credential.CredentialsMatcher#doCredentialsMatch * (org.apache.shiro.authc.AuthenticationToken, * org.apache.shiro.authc.AuthenticationInfo) */ @Override public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
JsonWebToken jsonWebToken = (JsonWebToken) token;
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/dao/ClientDao.java // @Repository // public interface ClientDao extends PagingAndSortingDao<Client, Long> { // Client findByClientName(String clientName); // // Client findByClientId(String clientId); // // Client findByClientSecret(String clientSecret); // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // }
import java.util.List; import java.util.UUID; import io.github.howiefh.jeews.modules.oauth2.dao.ClientDao; import io.github.howiefh.jeews.modules.oauth2.entity.Client; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.service; /** * * * @author howiefh */ @Service public class ClientService { @Autowired
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/dao/ClientDao.java // @Repository // public interface ClientDao extends PagingAndSortingDao<Client, Long> { // Client findByClientName(String clientName); // // Client findByClientId(String clientId); // // Client findByClientSecret(String clientSecret); // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java import java.util.List; import java.util.UUID; import io.github.howiefh.jeews.modules.oauth2.dao.ClientDao; import io.github.howiefh.jeews.modules.oauth2.entity.Client; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.service; /** * * * @author howiefh */ @Service public class ClientService { @Autowired
private ClientDao clientDao;
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/dao/ClientDao.java // @Repository // public interface ClientDao extends PagingAndSortingDao<Client, Long> { // Client findByClientName(String clientName); // // Client findByClientId(String clientId); // // Client findByClientSecret(String clientSecret); // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // }
import java.util.List; import java.util.UUID; import io.github.howiefh.jeews.modules.oauth2.dao.ClientDao; import io.github.howiefh.jeews.modules.oauth2.entity.Client; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.service; /** * * * @author howiefh */ @Service public class ClientService { @Autowired private ClientDao clientDao;
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/dao/ClientDao.java // @Repository // public interface ClientDao extends PagingAndSortingDao<Client, Long> { // Client findByClientName(String clientName); // // Client findByClientId(String clientId); // // Client findByClientSecret(String clientSecret); // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java import java.util.List; import java.util.UUID; import io.github.howiefh.jeews.modules.oauth2.dao.ClientDao; import io.github.howiefh.jeews.modules.oauth2.entity.Client; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.service; /** * * * @author howiefh */ @Service public class ClientService { @Autowired private ClientDao clientDao;
public int save(Client client) {
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java // @RestController // @RequestMapping("/clients") // @ExposesResourceFor(Client.class) // public class ClientController { // @Autowired // private ClientService clientService; // // @Autowired // private EntityLinks entityLinks; // // @Autowired // private PagedResourcesAssembler<Client> assembler; // // @RequiresPermissions("clients:view") // @RequestMapping(value = "", method = RequestMethod.GET) // public HttpEntity<PagedResources<ClientResource>> getList( // @PageableDefault(size = 10, page = 0, sort = { "id" }, direction = Direction.ASC) Pageable pageable, // Client Client) { // Page<Client> Clients = clientService.findPageBy(pageable, Client); // return new ResponseEntity<>(assembler.toResource(Clients, new ClientResourceAssembler()), HttpStatus.OK); // } // // @RequiresPermissions("clients:view") // @RequestMapping(value = "/{id}", method = RequestMethod.GET) // public ClientResource get(@PathVariable long id) { // return new ClientResourceAssembler().toResource(clientService.findOne(id)); // } // // @RequiresPermissions("clients:create") // @RequestMapping(value = "", method = RequestMethod.POST) // public ResponseEntity<ClientResource> create(HttpEntity<Client> entity, HttpServletRequest request) // throws URISyntaxException { // Client Client = entity.getBody(); // clientService.save(Client); // HttpHeaders headers = new HttpHeaders(); // ClientResource ClientResource = new ClientResourceAssembler().toResource(Client); // headers.setLocation(entityLinks.linkForSingleResource(Client.class, Client.getId()).toUri()); // ResponseEntity<ClientResource> responseEntity = new ResponseEntity<ClientResource>(ClientResource, headers, // HttpStatus.CREATED); // return responseEntity; // } // // @RequiresPermissions("clients:update") // @RequestMapping(value = "/{id}", method = RequestMethod.PUT) // public ClientResource update(@RequestBody Client client) { // clientService.update(client); // return new ClientResourceAssembler().toResource(client); // } // // @RequiresPermissions("clients:delete") // @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void delete(@PathVariable("id") Long id) { // clientService.delete(id); // } // // @RequiresPermissions("clients:delete") // @RequestMapping(value = "", method = RequestMethod.DELETE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void deleteBatch(@RequestBody List<Long> ids) { // clientService.deleteBatch(ids); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // }
import io.github.howiefh.jeews.modules.oauth2.entity.Client; import org.springframework.hateoas.mvc.ResourceAssemblerSupport; import io.github.howiefh.jeews.modules.oauth2.controller.ClientController;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.resource; /** * * * @author howiefh */ public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> { public ClientResourceAssembler() {
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java // @RestController // @RequestMapping("/clients") // @ExposesResourceFor(Client.class) // public class ClientController { // @Autowired // private ClientService clientService; // // @Autowired // private EntityLinks entityLinks; // // @Autowired // private PagedResourcesAssembler<Client> assembler; // // @RequiresPermissions("clients:view") // @RequestMapping(value = "", method = RequestMethod.GET) // public HttpEntity<PagedResources<ClientResource>> getList( // @PageableDefault(size = 10, page = 0, sort = { "id" }, direction = Direction.ASC) Pageable pageable, // Client Client) { // Page<Client> Clients = clientService.findPageBy(pageable, Client); // return new ResponseEntity<>(assembler.toResource(Clients, new ClientResourceAssembler()), HttpStatus.OK); // } // // @RequiresPermissions("clients:view") // @RequestMapping(value = "/{id}", method = RequestMethod.GET) // public ClientResource get(@PathVariable long id) { // return new ClientResourceAssembler().toResource(clientService.findOne(id)); // } // // @RequiresPermissions("clients:create") // @RequestMapping(value = "", method = RequestMethod.POST) // public ResponseEntity<ClientResource> create(HttpEntity<Client> entity, HttpServletRequest request) // throws URISyntaxException { // Client Client = entity.getBody(); // clientService.save(Client); // HttpHeaders headers = new HttpHeaders(); // ClientResource ClientResource = new ClientResourceAssembler().toResource(Client); // headers.setLocation(entityLinks.linkForSingleResource(Client.class, Client.getId()).toUri()); // ResponseEntity<ClientResource> responseEntity = new ResponseEntity<ClientResource>(ClientResource, headers, // HttpStatus.CREATED); // return responseEntity; // } // // @RequiresPermissions("clients:update") // @RequestMapping(value = "/{id}", method = RequestMethod.PUT) // public ClientResource update(@RequestBody Client client) { // clientService.update(client); // return new ClientResourceAssembler().toResource(client); // } // // @RequiresPermissions("clients:delete") // @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void delete(@PathVariable("id") Long id) { // clientService.delete(id); // } // // @RequiresPermissions("clients:delete") // @RequestMapping(value = "", method = RequestMethod.DELETE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void deleteBatch(@RequestBody List<Long> ids) { // clientService.deleteBatch(ids); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java import io.github.howiefh.jeews.modules.oauth2.entity.Client; import org.springframework.hateoas.mvc.ResourceAssemblerSupport; import io.github.howiefh.jeews.modules.oauth2.controller.ClientController; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.resource; /** * * * @author howiefh */ public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> { public ClientResourceAssembler() {
super(ClientController.class, ClientResource.class);
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResource.java // public class ClientResource extends Resource<Client> { // public ClientResource(Client client) { // super(client); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java // public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> { // // public ClientResourceAssembler() { // super(ClientController.class, ClientResource.class); // } // // @Override // public ClientResource toResource(Client entity) { // ClientResource resource = createResourceWithId(entity.getId(), entity); // return resource; // } // // @Override // protected ClientResource instantiateResource(Client entity) { // return new ClientResource(entity); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java // @Service // public class ClientService { // @Autowired // private ClientDao clientDao; // // public int save(Client client) { // client.setClientId(UUID.randomUUID().toString()); // client.setClientSecret(UUID.randomUUID().toString()); // return clientDao.save(client); // } // // public int update(Client client) { // return clientDao.update(client); // } // // public int delete(Long id) { // return clientDao.delete(id); // } // // public int deleteBatch(List<Long> ids) { // return clientDao.deleteBatch(ids); // } // // public Client findOne(Long id) { // return clientDao.findOne(id); // } // // public List<Client> findAll() { // return clientDao.findAll(); // } // // public Page<Client> findPageBy(Pageable pageable, Client client) { // List<Client> clients = (List<Client>) clientDao.findPageBy(pageable, client); // long count = clientDao.countBy(client); // return new PageImpl<Client>(clients, pageable, count); // } // // public Client findByClientName(String clientName) { // return clientDao.findByClientName(clientName); // } // // public Client findByClientId(String clientId) { // return clientDao.findByClientId(clientId); // } // // public Client findByClientSecret(String clientSecret) { // return clientDao.findByClientSecret(clientSecret); // } // }
import io.github.howiefh.jeews.modules.oauth2.entity.Client; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResource; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResourceAssembler; import io.github.howiefh.jeews.modules.oauth2.service.ClientService; import java.net.URISyntaxException; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PagedResourcesAssembler; import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.ExposesResourceFor; import org.springframework.hateoas.PagedResources; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.controller; /** * * * @author howiefh */ @RestController @RequestMapping("/clients")
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResource.java // public class ClientResource extends Resource<Client> { // public ClientResource(Client client) { // super(client); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java // public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> { // // public ClientResourceAssembler() { // super(ClientController.class, ClientResource.class); // } // // @Override // public ClientResource toResource(Client entity) { // ClientResource resource = createResourceWithId(entity.getId(), entity); // return resource; // } // // @Override // protected ClientResource instantiateResource(Client entity) { // return new ClientResource(entity); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java // @Service // public class ClientService { // @Autowired // private ClientDao clientDao; // // public int save(Client client) { // client.setClientId(UUID.randomUUID().toString()); // client.setClientSecret(UUID.randomUUID().toString()); // return clientDao.save(client); // } // // public int update(Client client) { // return clientDao.update(client); // } // // public int delete(Long id) { // return clientDao.delete(id); // } // // public int deleteBatch(List<Long> ids) { // return clientDao.deleteBatch(ids); // } // // public Client findOne(Long id) { // return clientDao.findOne(id); // } // // public List<Client> findAll() { // return clientDao.findAll(); // } // // public Page<Client> findPageBy(Pageable pageable, Client client) { // List<Client> clients = (List<Client>) clientDao.findPageBy(pageable, client); // long count = clientDao.countBy(client); // return new PageImpl<Client>(clients, pageable, count); // } // // public Client findByClientName(String clientName) { // return clientDao.findByClientName(clientName); // } // // public Client findByClientId(String clientId) { // return clientDao.findByClientId(clientId); // } // // public Client findByClientSecret(String clientSecret) { // return clientDao.findByClientSecret(clientSecret); // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java import io.github.howiefh.jeews.modules.oauth2.entity.Client; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResource; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResourceAssembler; import io.github.howiefh.jeews.modules.oauth2.service.ClientService; import java.net.URISyntaxException; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PagedResourcesAssembler; import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.ExposesResourceFor; import org.springframework.hateoas.PagedResources; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.controller; /** * * * @author howiefh */ @RestController @RequestMapping("/clients")
@ExposesResourceFor(Client.class)
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResource.java // public class ClientResource extends Resource<Client> { // public ClientResource(Client client) { // super(client); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java // public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> { // // public ClientResourceAssembler() { // super(ClientController.class, ClientResource.class); // } // // @Override // public ClientResource toResource(Client entity) { // ClientResource resource = createResourceWithId(entity.getId(), entity); // return resource; // } // // @Override // protected ClientResource instantiateResource(Client entity) { // return new ClientResource(entity); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java // @Service // public class ClientService { // @Autowired // private ClientDao clientDao; // // public int save(Client client) { // client.setClientId(UUID.randomUUID().toString()); // client.setClientSecret(UUID.randomUUID().toString()); // return clientDao.save(client); // } // // public int update(Client client) { // return clientDao.update(client); // } // // public int delete(Long id) { // return clientDao.delete(id); // } // // public int deleteBatch(List<Long> ids) { // return clientDao.deleteBatch(ids); // } // // public Client findOne(Long id) { // return clientDao.findOne(id); // } // // public List<Client> findAll() { // return clientDao.findAll(); // } // // public Page<Client> findPageBy(Pageable pageable, Client client) { // List<Client> clients = (List<Client>) clientDao.findPageBy(pageable, client); // long count = clientDao.countBy(client); // return new PageImpl<Client>(clients, pageable, count); // } // // public Client findByClientName(String clientName) { // return clientDao.findByClientName(clientName); // } // // public Client findByClientId(String clientId) { // return clientDao.findByClientId(clientId); // } // // public Client findByClientSecret(String clientSecret) { // return clientDao.findByClientSecret(clientSecret); // } // }
import io.github.howiefh.jeews.modules.oauth2.entity.Client; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResource; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResourceAssembler; import io.github.howiefh.jeews.modules.oauth2.service.ClientService; import java.net.URISyntaxException; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PagedResourcesAssembler; import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.ExposesResourceFor; import org.springframework.hateoas.PagedResources; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.controller; /** * * * @author howiefh */ @RestController @RequestMapping("/clients") @ExposesResourceFor(Client.class) public class ClientController { @Autowired
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResource.java // public class ClientResource extends Resource<Client> { // public ClientResource(Client client) { // super(client); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java // public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> { // // public ClientResourceAssembler() { // super(ClientController.class, ClientResource.class); // } // // @Override // public ClientResource toResource(Client entity) { // ClientResource resource = createResourceWithId(entity.getId(), entity); // return resource; // } // // @Override // protected ClientResource instantiateResource(Client entity) { // return new ClientResource(entity); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java // @Service // public class ClientService { // @Autowired // private ClientDao clientDao; // // public int save(Client client) { // client.setClientId(UUID.randomUUID().toString()); // client.setClientSecret(UUID.randomUUID().toString()); // return clientDao.save(client); // } // // public int update(Client client) { // return clientDao.update(client); // } // // public int delete(Long id) { // return clientDao.delete(id); // } // // public int deleteBatch(List<Long> ids) { // return clientDao.deleteBatch(ids); // } // // public Client findOne(Long id) { // return clientDao.findOne(id); // } // // public List<Client> findAll() { // return clientDao.findAll(); // } // // public Page<Client> findPageBy(Pageable pageable, Client client) { // List<Client> clients = (List<Client>) clientDao.findPageBy(pageable, client); // long count = clientDao.countBy(client); // return new PageImpl<Client>(clients, pageable, count); // } // // public Client findByClientName(String clientName) { // return clientDao.findByClientName(clientName); // } // // public Client findByClientId(String clientId) { // return clientDao.findByClientId(clientId); // } // // public Client findByClientSecret(String clientSecret) { // return clientDao.findByClientSecret(clientSecret); // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java import io.github.howiefh.jeews.modules.oauth2.entity.Client; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResource; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResourceAssembler; import io.github.howiefh.jeews.modules.oauth2.service.ClientService; import java.net.URISyntaxException; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PagedResourcesAssembler; import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.ExposesResourceFor; import org.springframework.hateoas.PagedResources; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.controller; /** * * * @author howiefh */ @RestController @RequestMapping("/clients") @ExposesResourceFor(Client.class) public class ClientController { @Autowired
private ClientService clientService;
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResource.java // public class ClientResource extends Resource<Client> { // public ClientResource(Client client) { // super(client); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java // public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> { // // public ClientResourceAssembler() { // super(ClientController.class, ClientResource.class); // } // // @Override // public ClientResource toResource(Client entity) { // ClientResource resource = createResourceWithId(entity.getId(), entity); // return resource; // } // // @Override // protected ClientResource instantiateResource(Client entity) { // return new ClientResource(entity); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java // @Service // public class ClientService { // @Autowired // private ClientDao clientDao; // // public int save(Client client) { // client.setClientId(UUID.randomUUID().toString()); // client.setClientSecret(UUID.randomUUID().toString()); // return clientDao.save(client); // } // // public int update(Client client) { // return clientDao.update(client); // } // // public int delete(Long id) { // return clientDao.delete(id); // } // // public int deleteBatch(List<Long> ids) { // return clientDao.deleteBatch(ids); // } // // public Client findOne(Long id) { // return clientDao.findOne(id); // } // // public List<Client> findAll() { // return clientDao.findAll(); // } // // public Page<Client> findPageBy(Pageable pageable, Client client) { // List<Client> clients = (List<Client>) clientDao.findPageBy(pageable, client); // long count = clientDao.countBy(client); // return new PageImpl<Client>(clients, pageable, count); // } // // public Client findByClientName(String clientName) { // return clientDao.findByClientName(clientName); // } // // public Client findByClientId(String clientId) { // return clientDao.findByClientId(clientId); // } // // public Client findByClientSecret(String clientSecret) { // return clientDao.findByClientSecret(clientSecret); // } // }
import io.github.howiefh.jeews.modules.oauth2.entity.Client; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResource; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResourceAssembler; import io.github.howiefh.jeews.modules.oauth2.service.ClientService; import java.net.URISyntaxException; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PagedResourcesAssembler; import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.ExposesResourceFor; import org.springframework.hateoas.PagedResources; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.controller; /** * * * @author howiefh */ @RestController @RequestMapping("/clients") @ExposesResourceFor(Client.class) public class ClientController { @Autowired private ClientService clientService; @Autowired private EntityLinks entityLinks; @Autowired private PagedResourcesAssembler<Client> assembler; @RequiresPermissions("clients:view") @RequestMapping(value = "", method = RequestMethod.GET)
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResource.java // public class ClientResource extends Resource<Client> { // public ClientResource(Client client) { // super(client); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java // public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> { // // public ClientResourceAssembler() { // super(ClientController.class, ClientResource.class); // } // // @Override // public ClientResource toResource(Client entity) { // ClientResource resource = createResourceWithId(entity.getId(), entity); // return resource; // } // // @Override // protected ClientResource instantiateResource(Client entity) { // return new ClientResource(entity); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java // @Service // public class ClientService { // @Autowired // private ClientDao clientDao; // // public int save(Client client) { // client.setClientId(UUID.randomUUID().toString()); // client.setClientSecret(UUID.randomUUID().toString()); // return clientDao.save(client); // } // // public int update(Client client) { // return clientDao.update(client); // } // // public int delete(Long id) { // return clientDao.delete(id); // } // // public int deleteBatch(List<Long> ids) { // return clientDao.deleteBatch(ids); // } // // public Client findOne(Long id) { // return clientDao.findOne(id); // } // // public List<Client> findAll() { // return clientDao.findAll(); // } // // public Page<Client> findPageBy(Pageable pageable, Client client) { // List<Client> clients = (List<Client>) clientDao.findPageBy(pageable, client); // long count = clientDao.countBy(client); // return new PageImpl<Client>(clients, pageable, count); // } // // public Client findByClientName(String clientName) { // return clientDao.findByClientName(clientName); // } // // public Client findByClientId(String clientId) { // return clientDao.findByClientId(clientId); // } // // public Client findByClientSecret(String clientSecret) { // return clientDao.findByClientSecret(clientSecret); // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java import io.github.howiefh.jeews.modules.oauth2.entity.Client; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResource; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResourceAssembler; import io.github.howiefh.jeews.modules.oauth2.service.ClientService; import java.net.URISyntaxException; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PagedResourcesAssembler; import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.ExposesResourceFor; import org.springframework.hateoas.PagedResources; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.controller; /** * * * @author howiefh */ @RestController @RequestMapping("/clients") @ExposesResourceFor(Client.class) public class ClientController { @Autowired private ClientService clientService; @Autowired private EntityLinks entityLinks; @Autowired private PagedResourcesAssembler<Client> assembler; @RequiresPermissions("clients:view") @RequestMapping(value = "", method = RequestMethod.GET)
public HttpEntity<PagedResources<ClientResource>> getList(
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResource.java // public class ClientResource extends Resource<Client> { // public ClientResource(Client client) { // super(client); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java // public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> { // // public ClientResourceAssembler() { // super(ClientController.class, ClientResource.class); // } // // @Override // public ClientResource toResource(Client entity) { // ClientResource resource = createResourceWithId(entity.getId(), entity); // return resource; // } // // @Override // protected ClientResource instantiateResource(Client entity) { // return new ClientResource(entity); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java // @Service // public class ClientService { // @Autowired // private ClientDao clientDao; // // public int save(Client client) { // client.setClientId(UUID.randomUUID().toString()); // client.setClientSecret(UUID.randomUUID().toString()); // return clientDao.save(client); // } // // public int update(Client client) { // return clientDao.update(client); // } // // public int delete(Long id) { // return clientDao.delete(id); // } // // public int deleteBatch(List<Long> ids) { // return clientDao.deleteBatch(ids); // } // // public Client findOne(Long id) { // return clientDao.findOne(id); // } // // public List<Client> findAll() { // return clientDao.findAll(); // } // // public Page<Client> findPageBy(Pageable pageable, Client client) { // List<Client> clients = (List<Client>) clientDao.findPageBy(pageable, client); // long count = clientDao.countBy(client); // return new PageImpl<Client>(clients, pageable, count); // } // // public Client findByClientName(String clientName) { // return clientDao.findByClientName(clientName); // } // // public Client findByClientId(String clientId) { // return clientDao.findByClientId(clientId); // } // // public Client findByClientSecret(String clientSecret) { // return clientDao.findByClientSecret(clientSecret); // } // }
import io.github.howiefh.jeews.modules.oauth2.entity.Client; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResource; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResourceAssembler; import io.github.howiefh.jeews.modules.oauth2.service.ClientService; import java.net.URISyntaxException; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PagedResourcesAssembler; import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.ExposesResourceFor; import org.springframework.hateoas.PagedResources; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.controller; /** * * * @author howiefh */ @RestController @RequestMapping("/clients") @ExposesResourceFor(Client.class) public class ClientController { @Autowired private ClientService clientService; @Autowired private EntityLinks entityLinks; @Autowired private PagedResourcesAssembler<Client> assembler; @RequiresPermissions("clients:view") @RequestMapping(value = "", method = RequestMethod.GET) public HttpEntity<PagedResources<ClientResource>> getList( @PageableDefault(size = 10, page = 0, sort = { "id" }, direction = Direction.ASC) Pageable pageable, Client Client) { Page<Client> Clients = clientService.findPageBy(pageable, Client);
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/entity/Client.java // public class Client extends BasicEntity { // private static final long serialVersionUID = 1534976572117011533L; // private String clientId; // private String clientName; // private String clientSecret; // // public String getClientId() { // return clientId; // } // // public void setClientId(String clientId) { // this.clientId = clientId; // } // // public String getClientName() { // return clientName; // } // // public void setClientName(String clientName) { // this.clientName = clientName; // } // // public String getClientSecret() { // return clientSecret; // } // // public void setClientSecret(String clientSecret) { // this.clientSecret = clientSecret; // } // // @Override // public String toString() { // return "Client [clientId=" + clientId + ", clientName=" + clientName + ", clientSecret=" + clientSecret + "]"; // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResource.java // public class ClientResource extends Resource<Client> { // public ClientResource(Client client) { // super(client); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/resource/ClientResourceAssembler.java // public class ClientResourceAssembler extends ResourceAssemblerSupport<Client, ClientResource> { // // public ClientResourceAssembler() { // super(ClientController.class, ClientResource.class); // } // // @Override // public ClientResource toResource(Client entity) { // ClientResource resource = createResourceWithId(entity.getId(), entity); // return resource; // } // // @Override // protected ClientResource instantiateResource(Client entity) { // return new ClientResource(entity); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/ClientService.java // @Service // public class ClientService { // @Autowired // private ClientDao clientDao; // // public int save(Client client) { // client.setClientId(UUID.randomUUID().toString()); // client.setClientSecret(UUID.randomUUID().toString()); // return clientDao.save(client); // } // // public int update(Client client) { // return clientDao.update(client); // } // // public int delete(Long id) { // return clientDao.delete(id); // } // // public int deleteBatch(List<Long> ids) { // return clientDao.deleteBatch(ids); // } // // public Client findOne(Long id) { // return clientDao.findOne(id); // } // // public List<Client> findAll() { // return clientDao.findAll(); // } // // public Page<Client> findPageBy(Pageable pageable, Client client) { // List<Client> clients = (List<Client>) clientDao.findPageBy(pageable, client); // long count = clientDao.countBy(client); // return new PageImpl<Client>(clients, pageable, count); // } // // public Client findByClientName(String clientName) { // return clientDao.findByClientName(clientName); // } // // public Client findByClientId(String clientId) { // return clientDao.findByClientId(clientId); // } // // public Client findByClientSecret(String clientSecret) { // return clientDao.findByClientSecret(clientSecret); // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/controller/ClientController.java import io.github.howiefh.jeews.modules.oauth2.entity.Client; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResource; import io.github.howiefh.jeews.modules.oauth2.resource.ClientResourceAssembler; import io.github.howiefh.jeews.modules.oauth2.service.ClientService; import java.net.URISyntaxException; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PagedResourcesAssembler; import org.springframework.hateoas.EntityLinks; import org.springframework.hateoas.ExposesResourceFor; import org.springframework.hateoas.PagedResources; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.controller; /** * * * @author howiefh */ @RestController @RequestMapping("/clients") @ExposesResourceFor(Client.class) public class ClientController { @Autowired private ClientService clientService; @Autowired private EntityLinks entityLinks; @Autowired private PagedResourcesAssembler<Client> assembler; @RequiresPermissions("clients:view") @RequestMapping(value = "", method = RequestMethod.GET) public HttpEntity<PagedResources<ClientResource>> getList( @PageableDefault(size = 10, page = 0, sort = { "id" }, direction = Direction.ASC) Pageable pageable, Client Client) { Page<Client> Clients = clientService.findPageBy(pageable, Client);
return new ResponseEntity<>(assembler.toResource(Clients, new ClientResourceAssembler()), HttpStatus.OK);
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/sys/security/filter/StatelessAuthenticationFilter.java
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/token/JsonWebToken.java // public class JsonWebToken implements AuthenticationToken { // // private static final long serialVersionUID = 1389130131607655713L; // private String token; // // public JsonWebToken(String token) { // this.token = token; // } // // public String getToken() { // return token; // } // // public void setToken(String token) { // this.token = token; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getPrincipal() // */ // @Override // public Object getPrincipal() { // return ""; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getCredentials() // */ // @Override // public Object getCredentials() { // return getToken(); // } // // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/token/TokenType.java // public class TokenType { // // /** // * 当在由HTTP/1.1[RFC2617]定义的“Authorization”请求头部字段中发送访问令牌时,客户端使用“Bearer” // * 身份验证方案来传输访问令牌 // */ // public static final String BEARER_AUTH = "Bearer"; // }
import io.github.howiefh.jeews.modules.sys.security.token.JsonWebToken; import io.github.howiefh.jeews.modules.sys.security.token.TokenType; import java.util.HashSet; import java.util.Locale; import java.util.Set; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.web.filter.authc.AuthenticatingFilter; import org.apache.shiro.web.util.WebUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.security.filter; /** * * * @author howiefh */ public class StatelessAuthenticationFilter extends AuthenticatingFilter { protected static final String DEFAULT_LOGIN_URL = "/login"; protected static final String DEFAULT_SIGNUP_URL = "/signup"; protected static final String DEFAULT_FORGET_PASSWORD_URL = "/signup"; /** * This class's private logger. */ private static final Logger log = LoggerFactory.getLogger(StatelessAuthenticationFilter.class); /** * HTTP Authorization 头部, 值为<code>Authorization</code> */ protected static final String AUTHORIZATION_HEADER = "Authorization"; /** * HTTP Authentication 头部, 值为<code>WWW-Authenticate</code> */ protected static final String AUTHENTICATE_HEADER = "WWW-Authenticate"; /** * 应用名将出现在查询令牌时,默认是<code>application</code>。 可以通过 * {@link #setApplicationName(String) setApplicationName} 方法覆盖 */ private String applicationName = "application"; /** * The authcScheme 在<code>Authorization</code>头部, 默认是<code>Bearer</code> */
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/token/JsonWebToken.java // public class JsonWebToken implements AuthenticationToken { // // private static final long serialVersionUID = 1389130131607655713L; // private String token; // // public JsonWebToken(String token) { // this.token = token; // } // // public String getToken() { // return token; // } // // public void setToken(String token) { // this.token = token; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getPrincipal() // */ // @Override // public Object getPrincipal() { // return ""; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getCredentials() // */ // @Override // public Object getCredentials() { // return getToken(); // } // // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/token/TokenType.java // public class TokenType { // // /** // * 当在由HTTP/1.1[RFC2617]定义的“Authorization”请求头部字段中发送访问令牌时,客户端使用“Bearer” // * 身份验证方案来传输访问令牌 // */ // public static final String BEARER_AUTH = "Bearer"; // } // Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/filter/StatelessAuthenticationFilter.java import io.github.howiefh.jeews.modules.sys.security.token.JsonWebToken; import io.github.howiefh.jeews.modules.sys.security.token.TokenType; import java.util.HashSet; import java.util.Locale; import java.util.Set; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.web.filter.authc.AuthenticatingFilter; import org.apache.shiro.web.util.WebUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.security.filter; /** * * * @author howiefh */ public class StatelessAuthenticationFilter extends AuthenticatingFilter { protected static final String DEFAULT_LOGIN_URL = "/login"; protected static final String DEFAULT_SIGNUP_URL = "/signup"; protected static final String DEFAULT_FORGET_PASSWORD_URL = "/signup"; /** * This class's private logger. */ private static final Logger log = LoggerFactory.getLogger(StatelessAuthenticationFilter.class); /** * HTTP Authorization 头部, 值为<code>Authorization</code> */ protected static final String AUTHORIZATION_HEADER = "Authorization"; /** * HTTP Authentication 头部, 值为<code>WWW-Authenticate</code> */ protected static final String AUTHENTICATE_HEADER = "WWW-Authenticate"; /** * 应用名将出现在查询令牌时,默认是<code>application</code>。 可以通过 * {@link #setApplicationName(String) setApplicationName} 方法覆盖 */ private String applicationName = "application"; /** * The authcScheme 在<code>Authorization</code>头部, 默认是<code>Bearer</code> */
private String authcScheme = TokenType.BEARER_AUTH;
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/sys/security/filter/StatelessAuthenticationFilter.java
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/token/JsonWebToken.java // public class JsonWebToken implements AuthenticationToken { // // private static final long serialVersionUID = 1389130131607655713L; // private String token; // // public JsonWebToken(String token) { // this.token = token; // } // // public String getToken() { // return token; // } // // public void setToken(String token) { // this.token = token; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getPrincipal() // */ // @Override // public Object getPrincipal() { // return ""; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getCredentials() // */ // @Override // public Object getCredentials() { // return getToken(); // } // // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/token/TokenType.java // public class TokenType { // // /** // * 当在由HTTP/1.1[RFC2617]定义的“Authorization”请求头部字段中发送访问令牌时,客户端使用“Bearer” // * 身份验证方案来传输访问令牌 // */ // public static final String BEARER_AUTH = "Bearer"; // }
import io.github.howiefh.jeews.modules.sys.security.token.JsonWebToken; import io.github.howiefh.jeews.modules.sys.security.token.TokenType; import java.util.HashSet; import java.util.Locale; import java.util.Set; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.web.filter.authc.AuthenticatingFilter; import org.apache.shiro.web.util.WebUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
* 响应 * @return false */ protected boolean sendChallenge(ServletRequest request, ServletResponse response) { if (log.isDebugEnabled()) { log.debug("Authentication required: sending 401 Authentication challenge response."); } HttpServletResponse httpResponse = WebUtils.toHttp(response); httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED); String authcHeader = getAuthcScheme() + " realm=\"" + getApplicationName() + "\""; httpResponse.setHeader(AUTHENTICATE_HEADER, authcHeader); return false; } /** * 创建 AuthenticationToken * <p/> * * @param request * 请求 * @param response * 响应 * @return AuthenticationToken */ @Override protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) { String authorizationHeader = getAuthzHeader(request); if (authorizationHeader == null || authorizationHeader.length() == 0) { // Create an empty authentication token since there is no // Authorization header.
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/token/JsonWebToken.java // public class JsonWebToken implements AuthenticationToken { // // private static final long serialVersionUID = 1389130131607655713L; // private String token; // // public JsonWebToken(String token) { // this.token = token; // } // // public String getToken() { // return token; // } // // public void setToken(String token) { // this.token = token; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getPrincipal() // */ // @Override // public Object getPrincipal() { // return ""; // } // // /* // * (non-Javadoc) // * // * @see org.apache.shiro.authc.AuthenticationToken#getCredentials() // */ // @Override // public Object getCredentials() { // return getToken(); // } // // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/token/TokenType.java // public class TokenType { // // /** // * 当在由HTTP/1.1[RFC2617]定义的“Authorization”请求头部字段中发送访问令牌时,客户端使用“Bearer” // * 身份验证方案来传输访问令牌 // */ // public static final String BEARER_AUTH = "Bearer"; // } // Path: src/main/java/io/github/howiefh/jeews/modules/sys/security/filter/StatelessAuthenticationFilter.java import io.github.howiefh.jeews.modules.sys.security.token.JsonWebToken; import io.github.howiefh.jeews.modules.sys.security.token.TokenType; import java.util.HashSet; import java.util.Locale; import java.util.Set; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.web.filter.authc.AuthenticatingFilter; import org.apache.shiro.web.util.WebUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; * 响应 * @return false */ protected boolean sendChallenge(ServletRequest request, ServletResponse response) { if (log.isDebugEnabled()) { log.debug("Authentication required: sending 401 Authentication challenge response."); } HttpServletResponse httpResponse = WebUtils.toHttp(response); httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED); String authcHeader = getAuthcScheme() + " realm=\"" + getApplicationName() + "\""; httpResponse.setHeader(AUTHENTICATE_HEADER, authcHeader); return false; } /** * 创建 AuthenticationToken * <p/> * * @param request * 请求 * @param response * 响应 * @return AuthenticationToken */ @Override protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) { String authorizationHeader = getAuthzHeader(request); if (authorizationHeader == null || authorizationHeader.length() == 0) { // Create an empty authentication token since there is no // Authorization header.
return new JsonWebToken("");
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/oauth2/shiro/filter/TokenFilter.java
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/Constants.java // public class Constants { // public static final String RESOURCE_SERVER_NAME = "jeews-server"; // public static final String INVALID_CLIENT_DESCRIPTION = "客户端验证失败,如错误的client_id/client_secret。"; // public static final String INVALID_OAUTH_CODE = "授权码错误"; // public static final String INVALID_REFRESH_TOKEN = "refresh_token 错误"; // public static final String INVALID_USER_PASSWORD = "用户名或密码错误"; // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/OAuthService.java // @Service // public class OAuthService { // // private Cache cache; // // @Autowired // private ClientService clientService; // // @Autowired // public OAuthService(CacheManager cacheManager) { // this.cache = cacheManager.getCache("code-cache"); // } // // public void addAuthCode(String authCode, String username) { // cache.put(authCode, username); // } // // public void addAccessToken(String accessToken, String username) { // cache.put(accessToken, username); // } // // public void addRefreshToken(String refreshToken, String username) { // cache.put(refreshToken, username); // } // // public String getUsernameByAuthCode(String authCode) { // return (String) cache.get(authCode).get(); // } // // public String getUsernameByAccessToken(String accessToken) { // return (String) cache.get(accessToken).get(); // } // // public boolean checkAuthCode(String authCode) { // return cache.get(authCode) != null; // } // // public boolean checkAccessToken(String accessToken) { // return cache.get(accessToken) != null; // } // // public boolean checkRefreshToken(String refreshToken) { // return cache.get(refreshToken) != null; // } // // public boolean checkClientId(String clientId) { // return clientService.findByClientId(clientId) != null; // } // // public boolean checkClientSecret(String clientSecret) { // return clientService.findByClientSecret(clientSecret) != null; // } // // public long getExpireIn() { // return 3600L; // } // }
import io.github.howiefh.jeews.modules.oauth2.Constants; import io.github.howiefh.jeews.modules.oauth2.service.OAuthService; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.oltu.oauth2.common.OAuth; import org.apache.oltu.oauth2.common.error.OAuthError; import org.apache.oltu.oauth2.common.exception.OAuthProblemException; import org.apache.oltu.oauth2.common.message.OAuthResponse; import org.apache.oltu.oauth2.common.message.types.ParameterStyle; import org.apache.oltu.oauth2.common.utils.OAuthUtils; import org.apache.oltu.oauth2.rs.request.OAuthAccessResourceRequest; import org.apache.oltu.oauth2.rs.response.OAuthRSResponse; import org.apache.shiro.web.filter.AccessControlFilter; import org.springframework.beans.factory.annotation.Autowired;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.shiro.filter; /** * * * @author howiefh */ public class TokenFilter extends AccessControlFilter { @Autowired
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/Constants.java // public class Constants { // public static final String RESOURCE_SERVER_NAME = "jeews-server"; // public static final String INVALID_CLIENT_DESCRIPTION = "客户端验证失败,如错误的client_id/client_secret。"; // public static final String INVALID_OAUTH_CODE = "授权码错误"; // public static final String INVALID_REFRESH_TOKEN = "refresh_token 错误"; // public static final String INVALID_USER_PASSWORD = "用户名或密码错误"; // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/OAuthService.java // @Service // public class OAuthService { // // private Cache cache; // // @Autowired // private ClientService clientService; // // @Autowired // public OAuthService(CacheManager cacheManager) { // this.cache = cacheManager.getCache("code-cache"); // } // // public void addAuthCode(String authCode, String username) { // cache.put(authCode, username); // } // // public void addAccessToken(String accessToken, String username) { // cache.put(accessToken, username); // } // // public void addRefreshToken(String refreshToken, String username) { // cache.put(refreshToken, username); // } // // public String getUsernameByAuthCode(String authCode) { // return (String) cache.get(authCode).get(); // } // // public String getUsernameByAccessToken(String accessToken) { // return (String) cache.get(accessToken).get(); // } // // public boolean checkAuthCode(String authCode) { // return cache.get(authCode) != null; // } // // public boolean checkAccessToken(String accessToken) { // return cache.get(accessToken) != null; // } // // public boolean checkRefreshToken(String refreshToken) { // return cache.get(refreshToken) != null; // } // // public boolean checkClientId(String clientId) { // return clientService.findByClientId(clientId) != null; // } // // public boolean checkClientSecret(String clientSecret) { // return clientService.findByClientSecret(clientSecret) != null; // } // // public long getExpireIn() { // return 3600L; // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/shiro/filter/TokenFilter.java import io.github.howiefh.jeews.modules.oauth2.Constants; import io.github.howiefh.jeews.modules.oauth2.service.OAuthService; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.oltu.oauth2.common.OAuth; import org.apache.oltu.oauth2.common.error.OAuthError; import org.apache.oltu.oauth2.common.exception.OAuthProblemException; import org.apache.oltu.oauth2.common.message.OAuthResponse; import org.apache.oltu.oauth2.common.message.types.ParameterStyle; import org.apache.oltu.oauth2.common.utils.OAuthUtils; import org.apache.oltu.oauth2.rs.request.OAuthAccessResourceRequest; import org.apache.oltu.oauth2.rs.response.OAuthRSResponse; import org.apache.shiro.web.filter.AccessControlFilter; import org.springframework.beans.factory.annotation.Autowired; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.shiro.filter; /** * * * @author howiefh */ public class TokenFilter extends AccessControlFilter { @Autowired
private OAuthService oAuthService;
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/oauth2/shiro/filter/TokenFilter.java
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/Constants.java // public class Constants { // public static final String RESOURCE_SERVER_NAME = "jeews-server"; // public static final String INVALID_CLIENT_DESCRIPTION = "客户端验证失败,如错误的client_id/client_secret。"; // public static final String INVALID_OAUTH_CODE = "授权码错误"; // public static final String INVALID_REFRESH_TOKEN = "refresh_token 错误"; // public static final String INVALID_USER_PASSWORD = "用户名或密码错误"; // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/OAuthService.java // @Service // public class OAuthService { // // private Cache cache; // // @Autowired // private ClientService clientService; // // @Autowired // public OAuthService(CacheManager cacheManager) { // this.cache = cacheManager.getCache("code-cache"); // } // // public void addAuthCode(String authCode, String username) { // cache.put(authCode, username); // } // // public void addAccessToken(String accessToken, String username) { // cache.put(accessToken, username); // } // // public void addRefreshToken(String refreshToken, String username) { // cache.put(refreshToken, username); // } // // public String getUsernameByAuthCode(String authCode) { // return (String) cache.get(authCode).get(); // } // // public String getUsernameByAccessToken(String accessToken) { // return (String) cache.get(accessToken).get(); // } // // public boolean checkAuthCode(String authCode) { // return cache.get(authCode) != null; // } // // public boolean checkAccessToken(String accessToken) { // return cache.get(accessToken) != null; // } // // public boolean checkRefreshToken(String refreshToken) { // return cache.get(refreshToken) != null; // } // // public boolean checkClientId(String clientId) { // return clientService.findByClientId(clientId) != null; // } // // public boolean checkClientSecret(String clientSecret) { // return clientService.findByClientSecret(clientSecret) != null; // } // // public long getExpireIn() { // return 3600L; // } // }
import io.github.howiefh.jeews.modules.oauth2.Constants; import io.github.howiefh.jeews.modules.oauth2.service.OAuthService; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.oltu.oauth2.common.OAuth; import org.apache.oltu.oauth2.common.error.OAuthError; import org.apache.oltu.oauth2.common.exception.OAuthProblemException; import org.apache.oltu.oauth2.common.message.OAuthResponse; import org.apache.oltu.oauth2.common.message.types.ParameterStyle; import org.apache.oltu.oauth2.common.utils.OAuthUtils; import org.apache.oltu.oauth2.rs.request.OAuthAccessResourceRequest; import org.apache.oltu.oauth2.rs.response.OAuthRSResponse; import org.apache.shiro.web.filter.AccessControlFilter; import org.springframework.beans.factory.annotation.Autowired;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.shiro.filter; /** * * * @author howiefh */ public class TokenFilter extends AccessControlFilter { @Autowired private OAuthService oAuthService; @Override protected boolean onAccessDenied(ServletRequest req, ServletResponse resp) throws Exception { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) resp; try { // 构建OAuth资源请求 OAuthAccessResourceRequest oauthRequest = new OAuthAccessResourceRequest(request, ParameterStyle.HEADER); // 获取Access Token String accessToken = oauthRequest.getAccessToken(); // 验证Access Token if (!oAuthService.checkAccessToken(accessToken)) { // 如果不存在/过期了,返回未验证错误,需重新验证 OAuthResponse oauthResponse = OAuthRSResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED)
// Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/Constants.java // public class Constants { // public static final String RESOURCE_SERVER_NAME = "jeews-server"; // public static final String INVALID_CLIENT_DESCRIPTION = "客户端验证失败,如错误的client_id/client_secret。"; // public static final String INVALID_OAUTH_CODE = "授权码错误"; // public static final String INVALID_REFRESH_TOKEN = "refresh_token 错误"; // public static final String INVALID_USER_PASSWORD = "用户名或密码错误"; // } // // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/service/OAuthService.java // @Service // public class OAuthService { // // private Cache cache; // // @Autowired // private ClientService clientService; // // @Autowired // public OAuthService(CacheManager cacheManager) { // this.cache = cacheManager.getCache("code-cache"); // } // // public void addAuthCode(String authCode, String username) { // cache.put(authCode, username); // } // // public void addAccessToken(String accessToken, String username) { // cache.put(accessToken, username); // } // // public void addRefreshToken(String refreshToken, String username) { // cache.put(refreshToken, username); // } // // public String getUsernameByAuthCode(String authCode) { // return (String) cache.get(authCode).get(); // } // // public String getUsernameByAccessToken(String accessToken) { // return (String) cache.get(accessToken).get(); // } // // public boolean checkAuthCode(String authCode) { // return cache.get(authCode) != null; // } // // public boolean checkAccessToken(String accessToken) { // return cache.get(accessToken) != null; // } // // public boolean checkRefreshToken(String refreshToken) { // return cache.get(refreshToken) != null; // } // // public boolean checkClientId(String clientId) { // return clientService.findByClientId(clientId) != null; // } // // public boolean checkClientSecret(String clientSecret) { // return clientService.findByClientSecret(clientSecret) != null; // } // // public long getExpireIn() { // return 3600L; // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/oauth2/shiro/filter/TokenFilter.java import io.github.howiefh.jeews.modules.oauth2.Constants; import io.github.howiefh.jeews.modules.oauth2.service.OAuthService; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.oltu.oauth2.common.OAuth; import org.apache.oltu.oauth2.common.error.OAuthError; import org.apache.oltu.oauth2.common.exception.OAuthProblemException; import org.apache.oltu.oauth2.common.message.OAuthResponse; import org.apache.oltu.oauth2.common.message.types.ParameterStyle; import org.apache.oltu.oauth2.common.utils.OAuthUtils; import org.apache.oltu.oauth2.rs.request.OAuthAccessResourceRequest; import org.apache.oltu.oauth2.rs.response.OAuthRSResponse; import org.apache.shiro.web.filter.AccessControlFilter; import org.springframework.beans.factory.annotation.Autowired; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.oauth2.shiro.filter; /** * * * @author howiefh */ public class TokenFilter extends AccessControlFilter { @Autowired private OAuthService oAuthService; @Override protected boolean onAccessDenied(ServletRequest req, ServletResponse resp) throws Exception { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) resp; try { // 构建OAuth资源请求 OAuthAccessResourceRequest oauthRequest = new OAuthAccessResourceRequest(request, ParameterStyle.HEADER); // 获取Access Token String accessToken = oauthRequest.getAccessToken(); // 验证Access Token if (!oAuthService.checkAccessToken(accessToken)) { // 如果不存在/过期了,返回未验证错误,需重新验证 OAuthResponse oauthResponse = OAuthRSResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED)
.setRealm(Constants.RESOURCE_SERVER_NAME).setError(OAuthError.ResourceResponse.INVALID_TOKEN)
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/sys/resource/RoleResourceAssembler.java
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/controller/RoleController.java // @RestController // @RequestMapping("/roles") // @ExposesResourceFor(Role.class) // public class RoleController { // @Autowired // private RoleService roleService; // // @Autowired // private EntityLinks entityLinks; // // @RequiresPermissions("role:view") // @RequestMapping(value = "", method = RequestMethod.GET) // public HttpEntity<Resources<RoleResource>> getList() { // List<Role> roles = roleService.findAll(); // Resources<RoleResource> resources = ResourcesAssembler.toResources(roles, new RoleResourceAssembler(), // RoleController.class); // return new ResponseEntity<>(resources, HttpStatus.OK); // } // // @RequiresPermissions("role:view") // @RequestMapping(value = "/{id}", method = RequestMethod.GET) // public RoleResource get(@PathVariable long id) { // return new RoleResourceAssembler().toResource(roleService.findOne(id)); // } // // @RequiresPermissions("role:create") // @RequestMapping(value = "", method = RequestMethod.POST) // public ResponseEntity<RoleResource> create(HttpEntity<Role> entity, HttpServletRequest request) // throws URISyntaxException { // Role role = entity.getBody(); // roleService.save(role); // HttpHeaders headers = new HttpHeaders(); // RoleResource roleResource = new RoleResourceAssembler().toResource(role); // headers.setLocation(entityLinks.linkForSingleResource(Role.class, role.getId()).toUri()); // ResponseEntity<RoleResource> responseEntity = new ResponseEntity<RoleResource>(roleResource, headers, // HttpStatus.CREATED); // return responseEntity; // } // // @RequiresPermissions("role:update") // @RequestMapping(value = "/{id}", method = RequestMethod.PUT) // public RoleResource update(@RequestBody Role role) { // roleService.update(role); // return new RoleResourceAssembler().toResource(role); // } // // @RequiresPermissions("role:delete") // @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void delete(@PathVariable("id") Long id) { // roleService.delete(id); // } // // @RequiresPermissions("role:delete") // @RequestMapping(value = "", method = RequestMethod.DELETE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void deleteBatch(@RequestBody List<Long> ids) { // roleService.deleteBatch(ids); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/entity/Role.java // @Relation(value = "role", collectionRelation = "roles") // public class Role extends DataEntity { // private static final long serialVersionUID = 1744395330761664879L; // // /** // * 名称 - sys_role.name // */ // private String name; // // /** // * 中文名称 - sys_role.cnname // */ // private String cnname; // // /** // * 是否可用 - sys_role.available // */ // private Boolean available; // // /** // * 角色可以访问的菜单 // */ // private Set<Menu> menus; // // public Role() { // } // // /** // * 构造器,从json整型数据可以构造该对象 // */ // public Role(Long id) { // this.id = id; // } // // /** // * Gets the value of the database column sys_role.name // * // * @return 名称 // */ // public String getName() { // return name; // } // // /** // * Sets the value of the database column sys_role.name // * // * @param name // * 名称 // */ // public void setName(String name) { // this.name = name == null ? null : name.trim(); // } // // /** // * Gets the value of the database column sys_role.cnname // * // * @return 中文名称 // */ // public String getCnname() { // return cnname; // } // // /** // * Sets the value of the database column sys_role.cnname // * // * @param cnname // * 中文名称 // */ // public void setCnname(String cnname) { // this.cnname = cnname == null ? null : cnname.trim(); // } // // /** // * Gets the value of the database column sys_role.available // * // * @return 是否可用 // */ // public Boolean getAvailable() { // return available; // } // // /** // * Sets the value of the database column sys_role.available // * // * @param available // * 是否可用 // */ // public void setAvailable(Boolean available) { // this.available = available; // } // // public Set<Menu> getMenus() { // return menus; // } // // public void setMenus(Set<Menu> menus) { // this.menus = menus; // } // }
import io.github.howiefh.jeews.modules.sys.controller.RoleController; import io.github.howiefh.jeews.modules.sys.entity.Role; import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
package io.github.howiefh.jeews.modules.sys.resource; public class RoleResourceAssembler extends ResourceAssemblerSupport<Role, RoleResource> { public RoleResourceAssembler() {
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/controller/RoleController.java // @RestController // @RequestMapping("/roles") // @ExposesResourceFor(Role.class) // public class RoleController { // @Autowired // private RoleService roleService; // // @Autowired // private EntityLinks entityLinks; // // @RequiresPermissions("role:view") // @RequestMapping(value = "", method = RequestMethod.GET) // public HttpEntity<Resources<RoleResource>> getList() { // List<Role> roles = roleService.findAll(); // Resources<RoleResource> resources = ResourcesAssembler.toResources(roles, new RoleResourceAssembler(), // RoleController.class); // return new ResponseEntity<>(resources, HttpStatus.OK); // } // // @RequiresPermissions("role:view") // @RequestMapping(value = "/{id}", method = RequestMethod.GET) // public RoleResource get(@PathVariable long id) { // return new RoleResourceAssembler().toResource(roleService.findOne(id)); // } // // @RequiresPermissions("role:create") // @RequestMapping(value = "", method = RequestMethod.POST) // public ResponseEntity<RoleResource> create(HttpEntity<Role> entity, HttpServletRequest request) // throws URISyntaxException { // Role role = entity.getBody(); // roleService.save(role); // HttpHeaders headers = new HttpHeaders(); // RoleResource roleResource = new RoleResourceAssembler().toResource(role); // headers.setLocation(entityLinks.linkForSingleResource(Role.class, role.getId()).toUri()); // ResponseEntity<RoleResource> responseEntity = new ResponseEntity<RoleResource>(roleResource, headers, // HttpStatus.CREATED); // return responseEntity; // } // // @RequiresPermissions("role:update") // @RequestMapping(value = "/{id}", method = RequestMethod.PUT) // public RoleResource update(@RequestBody Role role) { // roleService.update(role); // return new RoleResourceAssembler().toResource(role); // } // // @RequiresPermissions("role:delete") // @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void delete(@PathVariable("id") Long id) { // roleService.delete(id); // } // // @RequiresPermissions("role:delete") // @RequestMapping(value = "", method = RequestMethod.DELETE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void deleteBatch(@RequestBody List<Long> ids) { // roleService.deleteBatch(ids); // } // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/entity/Role.java // @Relation(value = "role", collectionRelation = "roles") // public class Role extends DataEntity { // private static final long serialVersionUID = 1744395330761664879L; // // /** // * 名称 - sys_role.name // */ // private String name; // // /** // * 中文名称 - sys_role.cnname // */ // private String cnname; // // /** // * 是否可用 - sys_role.available // */ // private Boolean available; // // /** // * 角色可以访问的菜单 // */ // private Set<Menu> menus; // // public Role() { // } // // /** // * 构造器,从json整型数据可以构造该对象 // */ // public Role(Long id) { // this.id = id; // } // // /** // * Gets the value of the database column sys_role.name // * // * @return 名称 // */ // public String getName() { // return name; // } // // /** // * Sets the value of the database column sys_role.name // * // * @param name // * 名称 // */ // public void setName(String name) { // this.name = name == null ? null : name.trim(); // } // // /** // * Gets the value of the database column sys_role.cnname // * // * @return 中文名称 // */ // public String getCnname() { // return cnname; // } // // /** // * Sets the value of the database column sys_role.cnname // * // * @param cnname // * 中文名称 // */ // public void setCnname(String cnname) { // this.cnname = cnname == null ? null : cnname.trim(); // } // // /** // * Gets the value of the database column sys_role.available // * // * @return 是否可用 // */ // public Boolean getAvailable() { // return available; // } // // /** // * Sets the value of the database column sys_role.available // * // * @param available // * 是否可用 // */ // public void setAvailable(Boolean available) { // this.available = available; // } // // public Set<Menu> getMenus() { // return menus; // } // // public void setMenus(Set<Menu> menus) { // this.menus = menus; // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/sys/resource/RoleResourceAssembler.java import io.github.howiefh.jeews.modules.sys.controller.RoleController; import io.github.howiefh.jeews.modules.sys.entity.Role; import org.springframework.hateoas.mvc.ResourceAssemblerSupport; package io.github.howiefh.jeews.modules.sys.resource; public class RoleResourceAssembler extends ResourceAssemblerSupport<Role, RoleResource> { public RoleResourceAssembler() {
super(RoleController.class, RoleResource.class);
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/sys/service/OrganizationService.java
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/dao/OrganizationDao.java // @Repository // public interface OrganizationDao extends CrudDao<Organization, Long> { // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/entity/Organization.java // @Relation(value = "organization", collectionRelation = "organizations") // public class Organization extends DataEntity { // private static final long serialVersionUID = -5397696221970296107L; // // /** // * 名称 - sys_organization.name // */ // private String name; // // /** // * 类型 - sys_organization.type // */ // private String type; // // /** // * 父级编号 - sys_organization.parent_id // */ // private Long parentId; // // /** // * 所有父级编号 - sys_organization.parent_ids // */ // private String parentIds; // // /** // * 排序 - sys_organization.sort // */ // private Integer sort; // // /** // * 是否显示 - sys_organization.is_show // */ // private Boolean isShow; // // public Organization() { // } // // /** // * 构造器,从json整型数据可以构造该对象 // */ // public Organization(Long id) { // this.id = id; // } // // /** // * Gets the value of the database column sys_organization.name // * // * @return 名称 // */ // public String getName() { // return name; // } // // /** // * Sets the value of the database column sys_organization.name // * // * @param name // * 名称 // */ // public void setName(String name) { // this.name = name == null ? null : name.trim(); // } // // /** // * Gets the value of the database column sys_organization.type // * // * @return 类型 // */ // public String getType() { // return type; // } // // /** // * Sets the value of the database column sys_organization.type // * // * @param type // * 类型 // */ // public void setType(String type) { // this.type = type == null ? null : type.trim(); // } // // /** // * Gets the value of the database column sys_organization.parent_id // * // * @return 父级编号 // */ // public Long getParentId() { // return parentId; // } // // /** // * Sets the value of the database column sys_organization.parent_id // * // * @param parentId // * 父级编号 // */ // public void setParentId(Long parentId) { // this.parentId = parentId; // } // // /** // * Gets the value of the database column sys_organization.parent_ids // * // * @return 所有父级编号 // */ // public String getParentIds() { // return parentIds; // } // // /** // * Sets the value of the database column sys_organization.parent_ids // * // * @param parentIds // * 所有父级编号 // */ // public void setParentIds(String parentIds) { // this.parentIds = parentIds == null ? null : parentIds.trim(); // } // // /** // * Gets the value of the database column sys_organization.sort // * // * @return 排序 // */ // public Integer getSort() { // return sort; // } // // /** // * Sets the value of the database column sys_organization.sort // * // * @param sort // * 排序 // */ // public void setSort(Integer sort) { // this.sort = sort; // } // // /** // * Gets the value of the database column sys_organization.is_show // * // * @return 是否显示 // */ // public Boolean getIsShow() { // return isShow; // } // // /** // * Sets the value of the database column sys_organization.is_show // * // * @param isShow // * 是否显示 // */ // public void setIsShow(Boolean isShow) { // this.isShow = isShow; // } // }
import io.github.howiefh.jeews.modules.sys.dao.OrganizationDao; import io.github.howiefh.jeews.modules.sys.entity.Organization; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.service; /** * * * @author howiefh */ @Service public class OrganizationService { @Autowired
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/dao/OrganizationDao.java // @Repository // public interface OrganizationDao extends CrudDao<Organization, Long> { // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/entity/Organization.java // @Relation(value = "organization", collectionRelation = "organizations") // public class Organization extends DataEntity { // private static final long serialVersionUID = -5397696221970296107L; // // /** // * 名称 - sys_organization.name // */ // private String name; // // /** // * 类型 - sys_organization.type // */ // private String type; // // /** // * 父级编号 - sys_organization.parent_id // */ // private Long parentId; // // /** // * 所有父级编号 - sys_organization.parent_ids // */ // private String parentIds; // // /** // * 排序 - sys_organization.sort // */ // private Integer sort; // // /** // * 是否显示 - sys_organization.is_show // */ // private Boolean isShow; // // public Organization() { // } // // /** // * 构造器,从json整型数据可以构造该对象 // */ // public Organization(Long id) { // this.id = id; // } // // /** // * Gets the value of the database column sys_organization.name // * // * @return 名称 // */ // public String getName() { // return name; // } // // /** // * Sets the value of the database column sys_organization.name // * // * @param name // * 名称 // */ // public void setName(String name) { // this.name = name == null ? null : name.trim(); // } // // /** // * Gets the value of the database column sys_organization.type // * // * @return 类型 // */ // public String getType() { // return type; // } // // /** // * Sets the value of the database column sys_organization.type // * // * @param type // * 类型 // */ // public void setType(String type) { // this.type = type == null ? null : type.trim(); // } // // /** // * Gets the value of the database column sys_organization.parent_id // * // * @return 父级编号 // */ // public Long getParentId() { // return parentId; // } // // /** // * Sets the value of the database column sys_organization.parent_id // * // * @param parentId // * 父级编号 // */ // public void setParentId(Long parentId) { // this.parentId = parentId; // } // // /** // * Gets the value of the database column sys_organization.parent_ids // * // * @return 所有父级编号 // */ // public String getParentIds() { // return parentIds; // } // // /** // * Sets the value of the database column sys_organization.parent_ids // * // * @param parentIds // * 所有父级编号 // */ // public void setParentIds(String parentIds) { // this.parentIds = parentIds == null ? null : parentIds.trim(); // } // // /** // * Gets the value of the database column sys_organization.sort // * // * @return 排序 // */ // public Integer getSort() { // return sort; // } // // /** // * Sets the value of the database column sys_organization.sort // * // * @param sort // * 排序 // */ // public void setSort(Integer sort) { // this.sort = sort; // } // // /** // * Gets the value of the database column sys_organization.is_show // * // * @return 是否显示 // */ // public Boolean getIsShow() { // return isShow; // } // // /** // * Sets the value of the database column sys_organization.is_show // * // * @param isShow // * 是否显示 // */ // public void setIsShow(Boolean isShow) { // this.isShow = isShow; // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/sys/service/OrganizationService.java import io.github.howiefh.jeews.modules.sys.dao.OrganizationDao; import io.github.howiefh.jeews.modules.sys.entity.Organization; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.service; /** * * * @author howiefh */ @Service public class OrganizationService { @Autowired
private OrganizationDao organizationDao;
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/sys/service/OrganizationService.java
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/dao/OrganizationDao.java // @Repository // public interface OrganizationDao extends CrudDao<Organization, Long> { // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/entity/Organization.java // @Relation(value = "organization", collectionRelation = "organizations") // public class Organization extends DataEntity { // private static final long serialVersionUID = -5397696221970296107L; // // /** // * 名称 - sys_organization.name // */ // private String name; // // /** // * 类型 - sys_organization.type // */ // private String type; // // /** // * 父级编号 - sys_organization.parent_id // */ // private Long parentId; // // /** // * 所有父级编号 - sys_organization.parent_ids // */ // private String parentIds; // // /** // * 排序 - sys_organization.sort // */ // private Integer sort; // // /** // * 是否显示 - sys_organization.is_show // */ // private Boolean isShow; // // public Organization() { // } // // /** // * 构造器,从json整型数据可以构造该对象 // */ // public Organization(Long id) { // this.id = id; // } // // /** // * Gets the value of the database column sys_organization.name // * // * @return 名称 // */ // public String getName() { // return name; // } // // /** // * Sets the value of the database column sys_organization.name // * // * @param name // * 名称 // */ // public void setName(String name) { // this.name = name == null ? null : name.trim(); // } // // /** // * Gets the value of the database column sys_organization.type // * // * @return 类型 // */ // public String getType() { // return type; // } // // /** // * Sets the value of the database column sys_organization.type // * // * @param type // * 类型 // */ // public void setType(String type) { // this.type = type == null ? null : type.trim(); // } // // /** // * Gets the value of the database column sys_organization.parent_id // * // * @return 父级编号 // */ // public Long getParentId() { // return parentId; // } // // /** // * Sets the value of the database column sys_organization.parent_id // * // * @param parentId // * 父级编号 // */ // public void setParentId(Long parentId) { // this.parentId = parentId; // } // // /** // * Gets the value of the database column sys_organization.parent_ids // * // * @return 所有父级编号 // */ // public String getParentIds() { // return parentIds; // } // // /** // * Sets the value of the database column sys_organization.parent_ids // * // * @param parentIds // * 所有父级编号 // */ // public void setParentIds(String parentIds) { // this.parentIds = parentIds == null ? null : parentIds.trim(); // } // // /** // * Gets the value of the database column sys_organization.sort // * // * @return 排序 // */ // public Integer getSort() { // return sort; // } // // /** // * Sets the value of the database column sys_organization.sort // * // * @param sort // * 排序 // */ // public void setSort(Integer sort) { // this.sort = sort; // } // // /** // * Gets the value of the database column sys_organization.is_show // * // * @return 是否显示 // */ // public Boolean getIsShow() { // return isShow; // } // // /** // * Sets the value of the database column sys_organization.is_show // * // * @param isShow // * 是否显示 // */ // public void setIsShow(Boolean isShow) { // this.isShow = isShow; // } // }
import io.github.howiefh.jeews.modules.sys.dao.OrganizationDao; import io.github.howiefh.jeews.modules.sys.entity.Organization; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.service; /** * * * @author howiefh */ @Service public class OrganizationService { @Autowired private OrganizationDao organizationDao;
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/dao/OrganizationDao.java // @Repository // public interface OrganizationDao extends CrudDao<Organization, Long> { // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/entity/Organization.java // @Relation(value = "organization", collectionRelation = "organizations") // public class Organization extends DataEntity { // private static final long serialVersionUID = -5397696221970296107L; // // /** // * 名称 - sys_organization.name // */ // private String name; // // /** // * 类型 - sys_organization.type // */ // private String type; // // /** // * 父级编号 - sys_organization.parent_id // */ // private Long parentId; // // /** // * 所有父级编号 - sys_organization.parent_ids // */ // private String parentIds; // // /** // * 排序 - sys_organization.sort // */ // private Integer sort; // // /** // * 是否显示 - sys_organization.is_show // */ // private Boolean isShow; // // public Organization() { // } // // /** // * 构造器,从json整型数据可以构造该对象 // */ // public Organization(Long id) { // this.id = id; // } // // /** // * Gets the value of the database column sys_organization.name // * // * @return 名称 // */ // public String getName() { // return name; // } // // /** // * Sets the value of the database column sys_organization.name // * // * @param name // * 名称 // */ // public void setName(String name) { // this.name = name == null ? null : name.trim(); // } // // /** // * Gets the value of the database column sys_organization.type // * // * @return 类型 // */ // public String getType() { // return type; // } // // /** // * Sets the value of the database column sys_organization.type // * // * @param type // * 类型 // */ // public void setType(String type) { // this.type = type == null ? null : type.trim(); // } // // /** // * Gets the value of the database column sys_organization.parent_id // * // * @return 父级编号 // */ // public Long getParentId() { // return parentId; // } // // /** // * Sets the value of the database column sys_organization.parent_id // * // * @param parentId // * 父级编号 // */ // public void setParentId(Long parentId) { // this.parentId = parentId; // } // // /** // * Gets the value of the database column sys_organization.parent_ids // * // * @return 所有父级编号 // */ // public String getParentIds() { // return parentIds; // } // // /** // * Sets the value of the database column sys_organization.parent_ids // * // * @param parentIds // * 所有父级编号 // */ // public void setParentIds(String parentIds) { // this.parentIds = parentIds == null ? null : parentIds.trim(); // } // // /** // * Gets the value of the database column sys_organization.sort // * // * @return 排序 // */ // public Integer getSort() { // return sort; // } // // /** // * Sets the value of the database column sys_organization.sort // * // * @param sort // * 排序 // */ // public void setSort(Integer sort) { // this.sort = sort; // } // // /** // * Gets the value of the database column sys_organization.is_show // * // * @return 是否显示 // */ // public Boolean getIsShow() { // return isShow; // } // // /** // * Sets the value of the database column sys_organization.is_show // * // * @param isShow // * 是否显示 // */ // public void setIsShow(Boolean isShow) { // this.isShow = isShow; // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/sys/service/OrganizationService.java import io.github.howiefh.jeews.modules.sys.dao.OrganizationDao; import io.github.howiefh.jeews.modules.sys.entity.Organization; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.service; /** * * * @author howiefh */ @Service public class OrganizationService { @Autowired private OrganizationDao organizationDao;
public void save(Organization organization) {
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/sys/service/RoleService.java
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/dao/RoleDao.java // @Repository // public interface RoleDao extends CrudDao<Role, Long> { // /** // * 通过名称查找角色 // * // * @param name // * @return // */ // public Role findByName(String name); // // /** // * 通过中文名称查找角色 // * // * @param cnname // * @return // */ // public Role findByCNName(String cnname); // // /** // * 删除角色菜单关联数据 // * // * @param role // * @return // */ // public int deleteRoleMenu(Role role); // // /** // * 插入角色菜单关联数据 // * // * @param role // * @return // */ // public int saveRoleMenu(Role role); // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/entity/Role.java // @Relation(value = "role", collectionRelation = "roles") // public class Role extends DataEntity { // private static final long serialVersionUID = 1744395330761664879L; // // /** // * 名称 - sys_role.name // */ // private String name; // // /** // * 中文名称 - sys_role.cnname // */ // private String cnname; // // /** // * 是否可用 - sys_role.available // */ // private Boolean available; // // /** // * 角色可以访问的菜单 // */ // private Set<Menu> menus; // // public Role() { // } // // /** // * 构造器,从json整型数据可以构造该对象 // */ // public Role(Long id) { // this.id = id; // } // // /** // * Gets the value of the database column sys_role.name // * // * @return 名称 // */ // public String getName() { // return name; // } // // /** // * Sets the value of the database column sys_role.name // * // * @param name // * 名称 // */ // public void setName(String name) { // this.name = name == null ? null : name.trim(); // } // // /** // * Gets the value of the database column sys_role.cnname // * // * @return 中文名称 // */ // public String getCnname() { // return cnname; // } // // /** // * Sets the value of the database column sys_role.cnname // * // * @param cnname // * 中文名称 // */ // public void setCnname(String cnname) { // this.cnname = cnname == null ? null : cnname.trim(); // } // // /** // * Gets the value of the database column sys_role.available // * // * @return 是否可用 // */ // public Boolean getAvailable() { // return available; // } // // /** // * Sets the value of the database column sys_role.available // * // * @param available // * 是否可用 // */ // public void setAvailable(Boolean available) { // this.available = available; // } // // public Set<Menu> getMenus() { // return menus; // } // // public void setMenus(Set<Menu> menus) { // this.menus = menus; // } // }
import io.github.howiefh.jeews.modules.sys.dao.RoleDao; import io.github.howiefh.jeews.modules.sys.entity.Role; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.service; /** * * * @author howiefh */ @Service public class RoleService { @Autowired
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/dao/RoleDao.java // @Repository // public interface RoleDao extends CrudDao<Role, Long> { // /** // * 通过名称查找角色 // * // * @param name // * @return // */ // public Role findByName(String name); // // /** // * 通过中文名称查找角色 // * // * @param cnname // * @return // */ // public Role findByCNName(String cnname); // // /** // * 删除角色菜单关联数据 // * // * @param role // * @return // */ // public int deleteRoleMenu(Role role); // // /** // * 插入角色菜单关联数据 // * // * @param role // * @return // */ // public int saveRoleMenu(Role role); // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/entity/Role.java // @Relation(value = "role", collectionRelation = "roles") // public class Role extends DataEntity { // private static final long serialVersionUID = 1744395330761664879L; // // /** // * 名称 - sys_role.name // */ // private String name; // // /** // * 中文名称 - sys_role.cnname // */ // private String cnname; // // /** // * 是否可用 - sys_role.available // */ // private Boolean available; // // /** // * 角色可以访问的菜单 // */ // private Set<Menu> menus; // // public Role() { // } // // /** // * 构造器,从json整型数据可以构造该对象 // */ // public Role(Long id) { // this.id = id; // } // // /** // * Gets the value of the database column sys_role.name // * // * @return 名称 // */ // public String getName() { // return name; // } // // /** // * Sets the value of the database column sys_role.name // * // * @param name // * 名称 // */ // public void setName(String name) { // this.name = name == null ? null : name.trim(); // } // // /** // * Gets the value of the database column sys_role.cnname // * // * @return 中文名称 // */ // public String getCnname() { // return cnname; // } // // /** // * Sets the value of the database column sys_role.cnname // * // * @param cnname // * 中文名称 // */ // public void setCnname(String cnname) { // this.cnname = cnname == null ? null : cnname.trim(); // } // // /** // * Gets the value of the database column sys_role.available // * // * @return 是否可用 // */ // public Boolean getAvailable() { // return available; // } // // /** // * Sets the value of the database column sys_role.available // * // * @param available // * 是否可用 // */ // public void setAvailable(Boolean available) { // this.available = available; // } // // public Set<Menu> getMenus() { // return menus; // } // // public void setMenus(Set<Menu> menus) { // this.menus = menus; // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/sys/service/RoleService.java import io.github.howiefh.jeews.modules.sys.dao.RoleDao; import io.github.howiefh.jeews.modules.sys.entity.Role; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.service; /** * * * @author howiefh */ @Service public class RoleService { @Autowired
private RoleDao roleDao;
howiefh/jee-restful-web
src/main/java/io/github/howiefh/jeews/modules/sys/service/RoleService.java
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/dao/RoleDao.java // @Repository // public interface RoleDao extends CrudDao<Role, Long> { // /** // * 通过名称查找角色 // * // * @param name // * @return // */ // public Role findByName(String name); // // /** // * 通过中文名称查找角色 // * // * @param cnname // * @return // */ // public Role findByCNName(String cnname); // // /** // * 删除角色菜单关联数据 // * // * @param role // * @return // */ // public int deleteRoleMenu(Role role); // // /** // * 插入角色菜单关联数据 // * // * @param role // * @return // */ // public int saveRoleMenu(Role role); // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/entity/Role.java // @Relation(value = "role", collectionRelation = "roles") // public class Role extends DataEntity { // private static final long serialVersionUID = 1744395330761664879L; // // /** // * 名称 - sys_role.name // */ // private String name; // // /** // * 中文名称 - sys_role.cnname // */ // private String cnname; // // /** // * 是否可用 - sys_role.available // */ // private Boolean available; // // /** // * 角色可以访问的菜单 // */ // private Set<Menu> menus; // // public Role() { // } // // /** // * 构造器,从json整型数据可以构造该对象 // */ // public Role(Long id) { // this.id = id; // } // // /** // * Gets the value of the database column sys_role.name // * // * @return 名称 // */ // public String getName() { // return name; // } // // /** // * Sets the value of the database column sys_role.name // * // * @param name // * 名称 // */ // public void setName(String name) { // this.name = name == null ? null : name.trim(); // } // // /** // * Gets the value of the database column sys_role.cnname // * // * @return 中文名称 // */ // public String getCnname() { // return cnname; // } // // /** // * Sets the value of the database column sys_role.cnname // * // * @param cnname // * 中文名称 // */ // public void setCnname(String cnname) { // this.cnname = cnname == null ? null : cnname.trim(); // } // // /** // * Gets the value of the database column sys_role.available // * // * @return 是否可用 // */ // public Boolean getAvailable() { // return available; // } // // /** // * Sets the value of the database column sys_role.available // * // * @param available // * 是否可用 // */ // public void setAvailable(Boolean available) { // this.available = available; // } // // public Set<Menu> getMenus() { // return menus; // } // // public void setMenus(Set<Menu> menus) { // this.menus = menus; // } // }
import io.github.howiefh.jeews.modules.sys.dao.RoleDao; import io.github.howiefh.jeews.modules.sys.entity.Role; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
/** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.service; /** * * * @author howiefh */ @Service public class RoleService { @Autowired private RoleDao roleDao;
// Path: src/main/java/io/github/howiefh/jeews/modules/sys/dao/RoleDao.java // @Repository // public interface RoleDao extends CrudDao<Role, Long> { // /** // * 通过名称查找角色 // * // * @param name // * @return // */ // public Role findByName(String name); // // /** // * 通过中文名称查找角色 // * // * @param cnname // * @return // */ // public Role findByCNName(String cnname); // // /** // * 删除角色菜单关联数据 // * // * @param role // * @return // */ // public int deleteRoleMenu(Role role); // // /** // * 插入角色菜单关联数据 // * // * @param role // * @return // */ // public int saveRoleMenu(Role role); // } // // Path: src/main/java/io/github/howiefh/jeews/modules/sys/entity/Role.java // @Relation(value = "role", collectionRelation = "roles") // public class Role extends DataEntity { // private static final long serialVersionUID = 1744395330761664879L; // // /** // * 名称 - sys_role.name // */ // private String name; // // /** // * 中文名称 - sys_role.cnname // */ // private String cnname; // // /** // * 是否可用 - sys_role.available // */ // private Boolean available; // // /** // * 角色可以访问的菜单 // */ // private Set<Menu> menus; // // public Role() { // } // // /** // * 构造器,从json整型数据可以构造该对象 // */ // public Role(Long id) { // this.id = id; // } // // /** // * Gets the value of the database column sys_role.name // * // * @return 名称 // */ // public String getName() { // return name; // } // // /** // * Sets the value of the database column sys_role.name // * // * @param name // * 名称 // */ // public void setName(String name) { // this.name = name == null ? null : name.trim(); // } // // /** // * Gets the value of the database column sys_role.cnname // * // * @return 中文名称 // */ // public String getCnname() { // return cnname; // } // // /** // * Sets the value of the database column sys_role.cnname // * // * @param cnname // * 中文名称 // */ // public void setCnname(String cnname) { // this.cnname = cnname == null ? null : cnname.trim(); // } // // /** // * Gets the value of the database column sys_role.available // * // * @return 是否可用 // */ // public Boolean getAvailable() { // return available; // } // // /** // * Sets the value of the database column sys_role.available // * // * @param available // * 是否可用 // */ // public void setAvailable(Boolean available) { // this.available = available; // } // // public Set<Menu> getMenus() { // return menus; // } // // public void setMenus(Set<Menu> menus) { // this.menus = menus; // } // } // Path: src/main/java/io/github/howiefh/jeews/modules/sys/service/RoleService.java import io.github.howiefh.jeews.modules.sys.dao.RoleDao; import io.github.howiefh.jeews.modules.sys.entity.Role; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * Copyright (c) 2015 https://github.com/howiefh * * Licensed under the Apache License, Version 2.0 (the "License"); */ package io.github.howiefh.jeews.modules.sys.service; /** * * * @author howiefh */ @Service public class RoleService { @Autowired private RoleDao roleDao;
public void save(Role role) {
Turkcell/Obsolete_Curio_android_SDK_Eclipse
CurioSDK/src/com/turkcell/curio/model/OnlineRequest.java
// Path: CurioSDK/src/com/turkcell/curio/ICurioResultListener.java // public interface ICurioResultListener { // public void handleResult(int htppStatusCode, JSONObject result); // }
import java.util.Map; import com.turkcell.curio.ICurioResultListener;
/* * Copyright (C) 2014 Turkcell * * Created by Can Ciloglu on 10 Haz 2014 * */ package com.turkcell.curio.model; /** * Holder class for online request structure. * * @author Can Ciloglu * */ public class OnlineRequest { private String url; private Map<String, Object> params;
// Path: CurioSDK/src/com/turkcell/curio/ICurioResultListener.java // public interface ICurioResultListener { // public void handleResult(int htppStatusCode, JSONObject result); // } // Path: CurioSDK/src/com/turkcell/curio/model/OnlineRequest.java import java.util.Map; import com.turkcell.curio.ICurioResultListener; /* * Copyright (C) 2014 Turkcell * * Created by Can Ciloglu on 10 Haz 2014 * */ package com.turkcell.curio.model; /** * Holder class for online request structure. * * @author Can Ciloglu * */ public class OnlineRequest { private String url; private Map<String, Object> params;
private ICurioResultListener callback;
Turkcell/Obsolete_Curio_android_SDK_Eclipse
CurioSDK/src/com/turkcell/curio/utils/NetworkUtil.java
// Path: CurioSDK/src/com/turkcell/curio/INetworkConnectivityChangeListener.java // public interface INetworkConnectivityChangeListener { // // /** // * Notifies network connectivity changes. // * // * @param isConnected // */ // public void networkConnectivityChanged(boolean isConnected); // }
import com.turkcell.curio.INetworkConnectivityChangeListener; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.NetworkInfo;
/* * Copyright (C) 2014 Turkcell * * Created by Can Ciloglu on 16 Haz 2014 * */ package com.turkcell.curio.utils; /** * Utility class for data network connection changes and connection types. * * @author Can Ciloglu * */ public class NetworkUtil { private static NetworkUtil instance; private boolean isConnected; private boolean previosConnectionState; private String connectionType;
// Path: CurioSDK/src/com/turkcell/curio/INetworkConnectivityChangeListener.java // public interface INetworkConnectivityChangeListener { // // /** // * Notifies network connectivity changes. // * // * @param isConnected // */ // public void networkConnectivityChanged(boolean isConnected); // } // Path: CurioSDK/src/com/turkcell/curio/utils/NetworkUtil.java import com.turkcell.curio.INetworkConnectivityChangeListener; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.NetworkInfo; /* * Copyright (C) 2014 Turkcell * * Created by Can Ciloglu on 16 Haz 2014 * */ package com.turkcell.curio.utils; /** * Utility class for data network connection changes and connection types. * * @author Can Ciloglu * */ public class NetworkUtil { private static NetworkUtil instance; private boolean isConnected; private boolean previosConnectionState; private String connectionType;
private INetworkConnectivityChangeListener listener;
Jamling/Android-ORM
cn.ieclipse.aorm.core/src/cn/ieclipse/aorm/SessionObserver.java
// Path: cn.ieclipse.aorm.mock/src/android/database/ContentObserver.java // public abstract class ContentObserver { // private final Object mLock = new Object(); // // Handler mHandler; // // /** // * Creates a content observer. // * // * @param handler // * The handler to run {@link #onChange} on, or null if none. // */ // public ContentObserver(Handler handler) { // mHandler = handler; // } // // /** // * This method is called when a content change occurs. // * <p> // * Subclasses should override this method to handle content changes. // * </p> // * // * @param selfChange // * True if this is a self-change notification. // */ // public void onChange(boolean selfChange) { // // Do nothing. Subclass should override. // } // // /** // * This method is called when a content change occurs. Includes the changed // * content Uri when available. // * <p> // * Subclasses should override this method to handle content changes. To // * ensure correct operation on older versions of the framework that did not // * provide a Uri argument, applications should also implement the // * {@link #onChange(boolean)} overload of this method whenever they // * implement the {@link #onChange(boolean, Uri)} overload. // * </p> // * <p> // * Example implementation: // * // * <pre> // * <code> // * // Implement the onChange(boolean) method to delegate the change notification to // * // the onChange(boolean, Uri) method to ensure correct operation on older versions // * // of the framework that did not have the onChange(boolean, Uri) method. // * {@literal @Override} // * public void onChange(boolean selfChange) { // * onChange(selfChange, null); // * } // * // * // Implement the onChange(boolean, Uri) method to take advantage of the new Uri argument. // * {@literal @Override} // * public void onChange(boolean selfChange, Uri uri) { // * // Handle change. // * } // * </code> // * </pre> // * // * </p> // * // * @param selfChange // * True if this is a self-change notification. // * @param uri // * The Uri of the changed content, or null if unknown. // */ // public void onChange(boolean selfChange, Uri uri) { // onChange(selfChange); // } // // } // // Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // // Path: cn.ieclipse.aorm.mock/src/android/os/Handler.java // public class Handler { // // }
import android.database.ContentObserver; import android.net.Uri; import android.os.Handler;
/* * Copyright 2010-2014 Jamling(li.jamling@gmail.com). * * 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 cn.ieclipse.aorm; /** * @author Jamling * */ class SessionObserver extends ContentObserver { private Session session;
// Path: cn.ieclipse.aorm.mock/src/android/database/ContentObserver.java // public abstract class ContentObserver { // private final Object mLock = new Object(); // // Handler mHandler; // // /** // * Creates a content observer. // * // * @param handler // * The handler to run {@link #onChange} on, or null if none. // */ // public ContentObserver(Handler handler) { // mHandler = handler; // } // // /** // * This method is called when a content change occurs. // * <p> // * Subclasses should override this method to handle content changes. // * </p> // * // * @param selfChange // * True if this is a self-change notification. // */ // public void onChange(boolean selfChange) { // // Do nothing. Subclass should override. // } // // /** // * This method is called when a content change occurs. Includes the changed // * content Uri when available. // * <p> // * Subclasses should override this method to handle content changes. To // * ensure correct operation on older versions of the framework that did not // * provide a Uri argument, applications should also implement the // * {@link #onChange(boolean)} overload of this method whenever they // * implement the {@link #onChange(boolean, Uri)} overload. // * </p> // * <p> // * Example implementation: // * // * <pre> // * <code> // * // Implement the onChange(boolean) method to delegate the change notification to // * // the onChange(boolean, Uri) method to ensure correct operation on older versions // * // of the framework that did not have the onChange(boolean, Uri) method. // * {@literal @Override} // * public void onChange(boolean selfChange) { // * onChange(selfChange, null); // * } // * // * // Implement the onChange(boolean, Uri) method to take advantage of the new Uri argument. // * {@literal @Override} // * public void onChange(boolean selfChange, Uri uri) { // * // Handle change. // * } // * </code> // * </pre> // * // * </p> // * // * @param selfChange // * True if this is a self-change notification. // * @param uri // * The Uri of the changed content, or null if unknown. // */ // public void onChange(boolean selfChange, Uri uri) { // onChange(selfChange); // } // // } // // Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // // Path: cn.ieclipse.aorm.mock/src/android/os/Handler.java // public class Handler { // // } // Path: cn.ieclipse.aorm.core/src/cn/ieclipse/aorm/SessionObserver.java import android.database.ContentObserver; import android.net.Uri; import android.os.Handler; /* * Copyright 2010-2014 Jamling(li.jamling@gmail.com). * * 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 cn.ieclipse.aorm; /** * @author Jamling * */ class SessionObserver extends ContentObserver { private Session session;
public SessionObserver(Handler handler, Session session) {
Jamling/Android-ORM
cn.ieclipse.aorm.core/src/cn/ieclipse/aorm/SessionObserver.java
// Path: cn.ieclipse.aorm.mock/src/android/database/ContentObserver.java // public abstract class ContentObserver { // private final Object mLock = new Object(); // // Handler mHandler; // // /** // * Creates a content observer. // * // * @param handler // * The handler to run {@link #onChange} on, or null if none. // */ // public ContentObserver(Handler handler) { // mHandler = handler; // } // // /** // * This method is called when a content change occurs. // * <p> // * Subclasses should override this method to handle content changes. // * </p> // * // * @param selfChange // * True if this is a self-change notification. // */ // public void onChange(boolean selfChange) { // // Do nothing. Subclass should override. // } // // /** // * This method is called when a content change occurs. Includes the changed // * content Uri when available. // * <p> // * Subclasses should override this method to handle content changes. To // * ensure correct operation on older versions of the framework that did not // * provide a Uri argument, applications should also implement the // * {@link #onChange(boolean)} overload of this method whenever they // * implement the {@link #onChange(boolean, Uri)} overload. // * </p> // * <p> // * Example implementation: // * // * <pre> // * <code> // * // Implement the onChange(boolean) method to delegate the change notification to // * // the onChange(boolean, Uri) method to ensure correct operation on older versions // * // of the framework that did not have the onChange(boolean, Uri) method. // * {@literal @Override} // * public void onChange(boolean selfChange) { // * onChange(selfChange, null); // * } // * // * // Implement the onChange(boolean, Uri) method to take advantage of the new Uri argument. // * {@literal @Override} // * public void onChange(boolean selfChange, Uri uri) { // * // Handle change. // * } // * </code> // * </pre> // * // * </p> // * // * @param selfChange // * True if this is a self-change notification. // * @param uri // * The Uri of the changed content, or null if unknown. // */ // public void onChange(boolean selfChange, Uri uri) { // onChange(selfChange); // } // // } // // Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // // Path: cn.ieclipse.aorm.mock/src/android/os/Handler.java // public class Handler { // // }
import android.database.ContentObserver; import android.net.Uri; import android.os.Handler;
/* * Copyright 2010-2014 Jamling(li.jamling@gmail.com). * * 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 cn.ieclipse.aorm; /** * @author Jamling * */ class SessionObserver extends ContentObserver { private Session session; public SessionObserver(Handler handler, Session session) { super(handler); this.session = session; } @Override public void onChange(boolean selfChange) { session.onChange(selfChange, null); } @Override
// Path: cn.ieclipse.aorm.mock/src/android/database/ContentObserver.java // public abstract class ContentObserver { // private final Object mLock = new Object(); // // Handler mHandler; // // /** // * Creates a content observer. // * // * @param handler // * The handler to run {@link #onChange} on, or null if none. // */ // public ContentObserver(Handler handler) { // mHandler = handler; // } // // /** // * This method is called when a content change occurs. // * <p> // * Subclasses should override this method to handle content changes. // * </p> // * // * @param selfChange // * True if this is a self-change notification. // */ // public void onChange(boolean selfChange) { // // Do nothing. Subclass should override. // } // // /** // * This method is called when a content change occurs. Includes the changed // * content Uri when available. // * <p> // * Subclasses should override this method to handle content changes. To // * ensure correct operation on older versions of the framework that did not // * provide a Uri argument, applications should also implement the // * {@link #onChange(boolean)} overload of this method whenever they // * implement the {@link #onChange(boolean, Uri)} overload. // * </p> // * <p> // * Example implementation: // * // * <pre> // * <code> // * // Implement the onChange(boolean) method to delegate the change notification to // * // the onChange(boolean, Uri) method to ensure correct operation on older versions // * // of the framework that did not have the onChange(boolean, Uri) method. // * {@literal @Override} // * public void onChange(boolean selfChange) { // * onChange(selfChange, null); // * } // * // * // Implement the onChange(boolean, Uri) method to take advantage of the new Uri argument. // * {@literal @Override} // * public void onChange(boolean selfChange, Uri uri) { // * // Handle change. // * } // * </code> // * </pre> // * // * </p> // * // * @param selfChange // * True if this is a self-change notification. // * @param uri // * The Uri of the changed content, or null if unknown. // */ // public void onChange(boolean selfChange, Uri uri) { // onChange(selfChange); // } // // } // // Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // // Path: cn.ieclipse.aorm.mock/src/android/os/Handler.java // public class Handler { // // } // Path: cn.ieclipse.aorm.core/src/cn/ieclipse/aorm/SessionObserver.java import android.database.ContentObserver; import android.net.Uri; import android.os.Handler; /* * Copyright 2010-2014 Jamling(li.jamling@gmail.com). * * 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 cn.ieclipse.aorm; /** * @author Jamling * */ class SessionObserver extends ContentObserver { private Session session; public SessionObserver(Handler handler, Session session) { super(handler); this.session = session; } @Override public void onChange(boolean selfChange) { session.onChange(selfChange, null); } @Override
public void onChange(boolean selfChange, Uri uri) {
Jamling/Android-ORM
cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/CriteriaTest.java
// Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Person.java // @Table(name = "person") // public class Person { // // @Column(id = true, name = "_id") // public long id; // // @Column(name = "_name", notNull = true) // public String name; // // @Column(name = "_age") // public int age; // // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // } // // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // public long id; // // @Column(name="_name") // public String name; // // @Column(name = "_age") // public int age; // // @Column(name = "_phone") // public String phone; // // public String address; // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // // // // public String getPhone() { // // return phone; // // } // // // // public void setPhone(String phone) { // // this.phone = phone; // // } // // // // public String getAddress() { // // return address; // // } // // // // public void setAddress(String address) { // // this.address = address; // // } // public static void main(String[] args) { // List<String> cols = Mapping.getInstance().getColumns(null, Student.class); // System.out.println(cols); // } // }
import junit.framework.TestCase; import org.junit.After; import org.junit.Assert; import org.junit.Before; import cn.ieclipse.aorm.bean.Person; import cn.ieclipse.aorm.bean.Student;
/* * Copyright 2010-2014 Jamling(li.jamling@gmail.com). * * 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 cn.ieclipse.aorm; /** * @author Jamling * */ public class CriteriaTest extends TestCase { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } public void testCreate() {
// Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Person.java // @Table(name = "person") // public class Person { // // @Column(id = true, name = "_id") // public long id; // // @Column(name = "_name", notNull = true) // public String name; // // @Column(name = "_age") // public int age; // // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // } // // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // public long id; // // @Column(name="_name") // public String name; // // @Column(name = "_age") // public int age; // // @Column(name = "_phone") // public String phone; // // public String address; // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // // // // public String getPhone() { // // return phone; // // } // // // // public void setPhone(String phone) { // // this.phone = phone; // // } // // // // public String getAddress() { // // return address; // // } // // // // public void setAddress(String address) { // // this.address = address; // // } // public static void main(String[] args) { // List<String> cols = Mapping.getInstance().getColumns(null, Student.class); // System.out.println(cols); // } // } // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/CriteriaTest.java import junit.framework.TestCase; import org.junit.After; import org.junit.Assert; import org.junit.Before; import cn.ieclipse.aorm.bean.Person; import cn.ieclipse.aorm.bean.Student; /* * Copyright 2010-2014 Jamling(li.jamling@gmail.com). * * 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 cn.ieclipse.aorm; /** * @author Jamling * */ public class CriteriaTest extends TestCase { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } public void testCreate() {
Criteria criteria = Criteria.create(Person.class);
Jamling/Android-ORM
cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/CriteriaTest.java
// Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Person.java // @Table(name = "person") // public class Person { // // @Column(id = true, name = "_id") // public long id; // // @Column(name = "_name", notNull = true) // public String name; // // @Column(name = "_age") // public int age; // // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // } // // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // public long id; // // @Column(name="_name") // public String name; // // @Column(name = "_age") // public int age; // // @Column(name = "_phone") // public String phone; // // public String address; // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // // // // public String getPhone() { // // return phone; // // } // // // // public void setPhone(String phone) { // // this.phone = phone; // // } // // // // public String getAddress() { // // return address; // // } // // // // public void setAddress(String address) { // // this.address = address; // // } // public static void main(String[] args) { // List<String> cols = Mapping.getInstance().getColumns(null, Student.class); // System.out.println(cols); // } // }
import junit.framework.TestCase; import org.junit.After; import org.junit.Assert; import org.junit.Before; import cn.ieclipse.aorm.bean.Person; import cn.ieclipse.aorm.bean.Student;
/* * Copyright 2010-2014 Jamling(li.jamling@gmail.com). * * 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 cn.ieclipse.aorm; /** * @author Jamling * */ public class CriteriaTest extends TestCase { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } public void testCreate() { Criteria criteria = Criteria.create(Person.class); String expected = "SELECT _id, _name, _age FROM person"; Assert.assertEquals(expected, criteria.toSQL()); } public void testCreateWithAlias() { Criteria criteria = Criteria.create(Person.class, "p"); String expected = "SELECT p._id, p._name, p._age FROM person AS p"; Assert.assertEquals(expected, criteria.toSQL()); } public void testAddChild() { Criteria criteria = Criteria.create(Person.class, "p");
// Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Person.java // @Table(name = "person") // public class Person { // // @Column(id = true, name = "_id") // public long id; // // @Column(name = "_name", notNull = true) // public String name; // // @Column(name = "_age") // public int age; // // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // } // // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // public long id; // // @Column(name="_name") // public String name; // // @Column(name = "_age") // public int age; // // @Column(name = "_phone") // public String phone; // // public String address; // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // // // // public String getPhone() { // // return phone; // // } // // // // public void setPhone(String phone) { // // this.phone = phone; // // } // // // // public String getAddress() { // // return address; // // } // // // // public void setAddress(String address) { // // this.address = address; // // } // public static void main(String[] args) { // List<String> cols = Mapping.getInstance().getColumns(null, Student.class); // System.out.println(cols); // } // } // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/CriteriaTest.java import junit.framework.TestCase; import org.junit.After; import org.junit.Assert; import org.junit.Before; import cn.ieclipse.aorm.bean.Person; import cn.ieclipse.aorm.bean.Student; /* * Copyright 2010-2014 Jamling(li.jamling@gmail.com). * * 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 cn.ieclipse.aorm; /** * @author Jamling * */ public class CriteriaTest extends TestCase { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } public void testCreate() { Criteria criteria = Criteria.create(Person.class); String expected = "SELECT _id, _name, _age FROM person"; Assert.assertEquals(expected, criteria.toSQL()); } public void testCreateWithAlias() { Criteria criteria = Criteria.create(Person.class, "p"); String expected = "SELECT p._id, p._name, p._age FROM person AS p"; Assert.assertEquals(expected, criteria.toSQL()); } public void testAddChild() { Criteria criteria = Criteria.create(Person.class, "p");
criteria.addChild(Student.class, "s");
Jamling/Android-ORM
cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/RestrictionsTest.java
// Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Grade.java // @Table(name = "grade") // public class Grade implements Serializable { // // private static final long serialVersionUID = -8976200526604051847L; // // private static final int PASS_GRADE = 60; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_sid") // private long sid; // // @Column(name = "_cid") // private long cid; // // @Column(name = "_score") // public float score; // // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public long getSid() { // // return sid; // // } // // // // public void setSid(long sid) { // // this.sid = sid; // // } // // // // public long getCid() { // // return cid; // // } // // // // public void setCid(long cid) { // // this.cid = cid; // // } // // // // public float getScore() { // // return score; // // } // // // // public void setScore(float score) { // // this.score = score; // // } // // // // public boolean isPass() { // // return this.score >= PASS_GRADE; // // } // } // // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // public long id; // // @Column(name="_name") // public String name; // // @Column(name = "_age") // public int age; // // @Column(name = "_phone") // public String phone; // // public String address; // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // // // // public String getPhone() { // // return phone; // // } // // // // public void setPhone(String phone) { // // this.phone = phone; // // } // // // // public String getAddress() { // // return address; // // } // // // // public void setAddress(String address) { // // this.address = address; // // } // public static void main(String[] args) { // List<String> cols = Mapping.getInstance().getColumns(null, Student.class); // System.out.println(cols); // } // }
import junit.framework.TestCase; import org.junit.Assert; import cn.ieclipse.aorm.bean.Grade; import cn.ieclipse.aorm.bean.Student;
/* * Copyright 2010-2014 Jamling(li.jamling@gmail.com). * * 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 cn.ieclipse.aorm; /** * @author Jamling * */ public class RestrictionsTest extends TestCase { public void testAnd() {
// Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Grade.java // @Table(name = "grade") // public class Grade implements Serializable { // // private static final long serialVersionUID = -8976200526604051847L; // // private static final int PASS_GRADE = 60; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_sid") // private long sid; // // @Column(name = "_cid") // private long cid; // // @Column(name = "_score") // public float score; // // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public long getSid() { // // return sid; // // } // // // // public void setSid(long sid) { // // this.sid = sid; // // } // // // // public long getCid() { // // return cid; // // } // // // // public void setCid(long cid) { // // this.cid = cid; // // } // // // // public float getScore() { // // return score; // // } // // // // public void setScore(float score) { // // this.score = score; // // } // // // // public boolean isPass() { // // return this.score >= PASS_GRADE; // // } // } // // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // public long id; // // @Column(name="_name") // public String name; // // @Column(name = "_age") // public int age; // // @Column(name = "_phone") // public String phone; // // public String address; // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // // // // public String getPhone() { // // return phone; // // } // // // // public void setPhone(String phone) { // // this.phone = phone; // // } // // // // public String getAddress() { // // return address; // // } // // // // public void setAddress(String address) { // // this.address = address; // // } // public static void main(String[] args) { // List<String> cols = Mapping.getInstance().getColumns(null, Student.class); // System.out.println(cols); // } // } // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/RestrictionsTest.java import junit.framework.TestCase; import org.junit.Assert; import cn.ieclipse.aorm.bean.Grade; import cn.ieclipse.aorm.bean.Student; /* * Copyright 2010-2014 Jamling(li.jamling@gmail.com). * * 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 cn.ieclipse.aorm; /** * @author Jamling * */ public class RestrictionsTest extends TestCase { public void testAnd() {
Criteria criteria = Criteria.create(Student.class);
Jamling/Android-ORM
cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/RestrictionsTest.java
// Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Grade.java // @Table(name = "grade") // public class Grade implements Serializable { // // private static final long serialVersionUID = -8976200526604051847L; // // private static final int PASS_GRADE = 60; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_sid") // private long sid; // // @Column(name = "_cid") // private long cid; // // @Column(name = "_score") // public float score; // // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public long getSid() { // // return sid; // // } // // // // public void setSid(long sid) { // // this.sid = sid; // // } // // // // public long getCid() { // // return cid; // // } // // // // public void setCid(long cid) { // // this.cid = cid; // // } // // // // public float getScore() { // // return score; // // } // // // // public void setScore(float score) { // // this.score = score; // // } // // // // public boolean isPass() { // // return this.score >= PASS_GRADE; // // } // } // // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // public long id; // // @Column(name="_name") // public String name; // // @Column(name = "_age") // public int age; // // @Column(name = "_phone") // public String phone; // // public String address; // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // // // // public String getPhone() { // // return phone; // // } // // // // public void setPhone(String phone) { // // this.phone = phone; // // } // // // // public String getAddress() { // // return address; // // } // // // // public void setAddress(String address) { // // this.address = address; // // } // public static void main(String[] args) { // List<String> cols = Mapping.getInstance().getColumns(null, Student.class); // System.out.println(cols); // } // }
import junit.framework.TestCase; import org.junit.Assert; import cn.ieclipse.aorm.bean.Grade; import cn.ieclipse.aorm.bean.Student;
.add(Restrictions.isNull("name")) .add(Restrictions.isNotNull("phone")); String sql = criteria.toSQL(); String expected = "(_name IS NULL AND _phone IS NOT NULL)"; Assert.assertEquals(expected, criteria.getWhere()); } public void testBetween() { Criteria criteria = Criteria.create(Student.class) .add(Restrictions.isNull("name")) .add(Restrictions.between("age", 10, 20)); String sql = criteria.toSQL(); String expected = "(_name IS NULL AND _age BETWEEN ? AND ?)"; Assert.assertEquals(expected, criteria.getWhere()); Assert.assertArrayEquals(new Object[] { 10, 20 }, criteria.getArgs() .toArray()); } public void testEq() { Criteria criteria = Criteria.create(Student.class).add( Restrictions.eq("id", 2)); String sql = criteria.toSQL(); String expected = "_id = ?"; Assert.assertEquals(expected, criteria.getWhere()); Assert.assertArrayEquals(new Object[] { 2 }, criteria.getArgs() .toArray()); } public void testEqProperty() { Criteria criteria = Criteria.create(Student.class, "s")
// Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Grade.java // @Table(name = "grade") // public class Grade implements Serializable { // // private static final long serialVersionUID = -8976200526604051847L; // // private static final int PASS_GRADE = 60; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_sid") // private long sid; // // @Column(name = "_cid") // private long cid; // // @Column(name = "_score") // public float score; // // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public long getSid() { // // return sid; // // } // // // // public void setSid(long sid) { // // this.sid = sid; // // } // // // // public long getCid() { // // return cid; // // } // // // // public void setCid(long cid) { // // this.cid = cid; // // } // // // // public float getScore() { // // return score; // // } // // // // public void setScore(float score) { // // this.score = score; // // } // // // // public boolean isPass() { // // return this.score >= PASS_GRADE; // // } // } // // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // public long id; // // @Column(name="_name") // public String name; // // @Column(name = "_age") // public int age; // // @Column(name = "_phone") // public String phone; // // public String address; // // // public long getId() { // // return id; // // } // // // // public void setId(long id) { // // this.id = id; // // } // // // // public String getName() { // // return name; // // } // // // // public void setName(String name) { // // this.name = name; // // } // // // // public int getAge() { // // return age; // // } // // // // public void setAge(int age) { // // this.age = age; // // } // // // // public String getPhone() { // // return phone; // // } // // // // public void setPhone(String phone) { // // this.phone = phone; // // } // // // // public String getAddress() { // // return address; // // } // // // // public void setAddress(String address) { // // this.address = address; // // } // public static void main(String[] args) { // List<String> cols = Mapping.getInstance().getColumns(null, Student.class); // System.out.println(cols); // } // } // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/RestrictionsTest.java import junit.framework.TestCase; import org.junit.Assert; import cn.ieclipse.aorm.bean.Grade; import cn.ieclipse.aorm.bean.Student; .add(Restrictions.isNull("name")) .add(Restrictions.isNotNull("phone")); String sql = criteria.toSQL(); String expected = "(_name IS NULL AND _phone IS NOT NULL)"; Assert.assertEquals(expected, criteria.getWhere()); } public void testBetween() { Criteria criteria = Criteria.create(Student.class) .add(Restrictions.isNull("name")) .add(Restrictions.between("age", 10, 20)); String sql = criteria.toSQL(); String expected = "(_name IS NULL AND _age BETWEEN ? AND ?)"; Assert.assertEquals(expected, criteria.getWhere()); Assert.assertArrayEquals(new Object[] { 10, 20 }, criteria.getArgs() .toArray()); } public void testEq() { Criteria criteria = Criteria.create(Student.class).add( Restrictions.eq("id", 2)); String sql = criteria.toSQL(); String expected = "_id = ?"; Assert.assertEquals(expected, criteria.getWhere()); Assert.assertArrayEquals(new Object[] { 2 }, criteria.getArgs() .toArray()); } public void testEqProperty() { Criteria criteria = Criteria.create(Student.class, "s")
.add(Restrictions.eq("id", 2)).addChild(Grade.class, "g")
Jamling/Android-ORM
cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/CourseListActivity.java
// Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Course.java // @Table(name = "course") // public class Course implements Serializable { // // private static final long serialVersionUID = 4957742859044875650L; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_name") // private String name; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // }
import java.util.List; import android.content.Context; import android.content.Intent; import android.view.View; import android.widget.AdapterView; import android.widget.ListAdapter; import android.widget.TextView; import cn.ieclipse.aorm.example.bean.Course;
/** * */ package cn.ieclipse.aorm.example; /** * @author Jamling * */ public class CourseListActivity extends ListActivity { private CourseAdapter adapter; @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Course.java // @Table(name = "course") // public class Course implements Serializable { // // private static final long serialVersionUID = 4957742859044875650L; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_name") // private String name; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // } // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/CourseListActivity.java import java.util.List; import android.content.Context; import android.content.Intent; import android.view.View; import android.widget.AdapterView; import android.widget.ListAdapter; import android.widget.TextView; import cn.ieclipse.aorm.example.bean.Course; /** * */ package cn.ieclipse.aorm.example; /** * @author Jamling * */ public class CourseListActivity extends ListActivity { private CourseAdapter adapter; @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Course s = adapter.getItem(position);
Jamling/Android-ORM
cn.ieclipse.aorm.mock/src/android/database/ContentObserver.java
// Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // // Path: cn.ieclipse.aorm.mock/src/android/os/Handler.java // public class Handler { // // }
import android.net.Uri; import android.os.Handler;
/* * Copyright (C) 2007 The Android Open Source Project * * 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 android.database; /** * Receives call backs for changes to content. Must be implemented by objects * which are added to a {@link ContentObservable}. */ public abstract class ContentObserver { private final Object mLock = new Object();
// Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // // Path: cn.ieclipse.aorm.mock/src/android/os/Handler.java // public class Handler { // // } // Path: cn.ieclipse.aorm.mock/src/android/database/ContentObserver.java import android.net.Uri; import android.os.Handler; /* * Copyright (C) 2007 The Android Open Source Project * * 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 android.database; /** * Receives call backs for changes to content. Must be implemented by objects * which are added to a {@link ContentObservable}. */ public abstract class ContentObserver { private final Object mLock = new Object();
Handler mHandler;
Jamling/Android-ORM
cn.ieclipse.aorm.mock/src/android/database/ContentObserver.java
// Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // // Path: cn.ieclipse.aorm.mock/src/android/os/Handler.java // public class Handler { // // }
import android.net.Uri; import android.os.Handler;
/* * Copyright (C) 2007 The Android Open Source Project * * 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 android.database; /** * Receives call backs for changes to content. Must be implemented by objects * which are added to a {@link ContentObservable}. */ public abstract class ContentObserver { private final Object mLock = new Object(); Handler mHandler; /** * Creates a content observer. * * @param handler * The handler to run {@link #onChange} on, or null if none. */ public ContentObserver(Handler handler) { mHandler = handler; } /** * This method is called when a content change occurs. * <p> * Subclasses should override this method to handle content changes. * </p> * * @param selfChange * True if this is a self-change notification. */ public void onChange(boolean selfChange) { // Do nothing. Subclass should override. } /** * This method is called when a content change occurs. Includes the changed * content Uri when available. * <p> * Subclasses should override this method to handle content changes. To * ensure correct operation on older versions of the framework that did not * provide a Uri argument, applications should also implement the * {@link #onChange(boolean)} overload of this method whenever they * implement the {@link #onChange(boolean, Uri)} overload. * </p> * <p> * Example implementation: * * <pre> * <code> * // Implement the onChange(boolean) method to delegate the change notification to * // the onChange(boolean, Uri) method to ensure correct operation on older versions * // of the framework that did not have the onChange(boolean, Uri) method. * {@literal @Override} * public void onChange(boolean selfChange) { * onChange(selfChange, null); * } * * // Implement the onChange(boolean, Uri) method to take advantage of the new Uri argument. * {@literal @Override} * public void onChange(boolean selfChange, Uri uri) { * // Handle change. * } * </code> * </pre> * * </p> * * @param selfChange * True if this is a self-change notification. * @param uri * The Uri of the changed content, or null if unknown. */
// Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // // Path: cn.ieclipse.aorm.mock/src/android/os/Handler.java // public class Handler { // // } // Path: cn.ieclipse.aorm.mock/src/android/database/ContentObserver.java import android.net.Uri; import android.os.Handler; /* * Copyright (C) 2007 The Android Open Source Project * * 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 android.database; /** * Receives call backs for changes to content. Must be implemented by objects * which are added to a {@link ContentObservable}. */ public abstract class ContentObserver { private final Object mLock = new Object(); Handler mHandler; /** * Creates a content observer. * * @param handler * The handler to run {@link #onChange} on, or null if none. */ public ContentObserver(Handler handler) { mHandler = handler; } /** * This method is called when a content change occurs. * <p> * Subclasses should override this method to handle content changes. * </p> * * @param selfChange * True if this is a self-change notification. */ public void onChange(boolean selfChange) { // Do nothing. Subclass should override. } /** * This method is called when a content change occurs. Includes the changed * content Uri when available. * <p> * Subclasses should override this method to handle content changes. To * ensure correct operation on older versions of the framework that did not * provide a Uri argument, applications should also implement the * {@link #onChange(boolean)} overload of this method whenever they * implement the {@link #onChange(boolean, Uri)} overload. * </p> * <p> * Example implementation: * * <pre> * <code> * // Implement the onChange(boolean) method to delegate the change notification to * // the onChange(boolean, Uri) method to ensure correct operation on older versions * // of the framework that did not have the onChange(boolean, Uri) method. * {@literal @Override} * public void onChange(boolean selfChange) { * onChange(selfChange, null); * } * * // Implement the onChange(boolean, Uri) method to take advantage of the new Uri argument. * {@literal @Override} * public void onChange(boolean selfChange, Uri uri) { * // Handle change. * } * </code> * </pre> * * </p> * * @param selfChange * True if this is a self-change notification. * @param uri * The Uri of the changed content, or null if unknown. */
public void onChange(boolean selfChange, Uri uri) {
Jamling/Android-ORM
cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/StudentGradeDetailActivity.java
// Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Course.java // @Table(name = "course") // public class Course implements Serializable { // // private static final long serialVersionUID = 4957742859044875650L; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_name") // private String name; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // } // // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Grade.java // @Table(name = "grade") // public class Grade implements Serializable { // // private static final long serialVersionUID = -8976200526604051847L; // // private static final int PASS_GRADE = 60; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_sid") // private long sid; // // @Column(name = "_cid") // private long cid; // // @Column(name = "_score") // private float score; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public long getSid() { // return sid; // } // // public void setSid(long sid) { // this.sid = sid; // } // // public long getCid() { // return cid; // } // // public void setCid(long cid) { // this.cid = cid; // } // // public float getScore() { // return score; // } // // public void setScore(float score) { // this.score = score; // } // // public boolean isPass() { // return this.score >= PASS_GRADE; // } // } // // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_name") // private String name; // // @Column(name = "_age") // private int age; // // @Column(name = "_phone") // private String phone; // // private String address; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getAddress() { // return address; // } // // public void setAddress(String address) { // this.address = address; // } // // }
import java.util.List; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import cn.ieclipse.aorm.example.bean.Course; import cn.ieclipse.aorm.example.bean.Grade; import cn.ieclipse.aorm.example.bean.Student;
/** * */ package cn.ieclipse.aorm.example; /** * @author Jamling * */ public class StudentGradeDetailActivity extends DetailActivity { private Student student;
// Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Course.java // @Table(name = "course") // public class Course implements Serializable { // // private static final long serialVersionUID = 4957742859044875650L; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_name") // private String name; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // } // // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Grade.java // @Table(name = "grade") // public class Grade implements Serializable { // // private static final long serialVersionUID = -8976200526604051847L; // // private static final int PASS_GRADE = 60; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_sid") // private long sid; // // @Column(name = "_cid") // private long cid; // // @Column(name = "_score") // private float score; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public long getSid() { // return sid; // } // // public void setSid(long sid) { // this.sid = sid; // } // // public long getCid() { // return cid; // } // // public void setCid(long cid) { // this.cid = cid; // } // // public float getScore() { // return score; // } // // public void setScore(float score) { // this.score = score; // } // // public boolean isPass() { // return this.score >= PASS_GRADE; // } // } // // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_name") // private String name; // // @Column(name = "_age") // private int age; // // @Column(name = "_phone") // private String phone; // // private String address; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getAddress() { // return address; // } // // public void setAddress(String address) { // this.address = address; // } // // } // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/StudentGradeDetailActivity.java import java.util.List; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import cn.ieclipse.aorm.example.bean.Course; import cn.ieclipse.aorm.example.bean.Grade; import cn.ieclipse.aorm.example.bean.Student; /** * */ package cn.ieclipse.aorm.example; /** * @author Jamling * */ public class StudentGradeDetailActivity extends DetailActivity { private Student student;
private Grade grade;
Jamling/Android-ORM
cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/StudentGradeDetailActivity.java
// Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Course.java // @Table(name = "course") // public class Course implements Serializable { // // private static final long serialVersionUID = 4957742859044875650L; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_name") // private String name; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // } // // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Grade.java // @Table(name = "grade") // public class Grade implements Serializable { // // private static final long serialVersionUID = -8976200526604051847L; // // private static final int PASS_GRADE = 60; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_sid") // private long sid; // // @Column(name = "_cid") // private long cid; // // @Column(name = "_score") // private float score; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public long getSid() { // return sid; // } // // public void setSid(long sid) { // this.sid = sid; // } // // public long getCid() { // return cid; // } // // public void setCid(long cid) { // this.cid = cid; // } // // public float getScore() { // return score; // } // // public void setScore(float score) { // this.score = score; // } // // public boolean isPass() { // return this.score >= PASS_GRADE; // } // } // // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_name") // private String name; // // @Column(name = "_age") // private int age; // // @Column(name = "_phone") // private String phone; // // private String address; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getAddress() { // return address; // } // // public void setAddress(String address) { // this.address = address; // } // // }
import java.util.List; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import cn.ieclipse.aorm.example.bean.Course; import cn.ieclipse.aorm.example.bean.Grade; import cn.ieclipse.aorm.example.bean.Student;
/** * */ package cn.ieclipse.aorm.example; /** * @author Jamling * */ public class StudentGradeDetailActivity extends DetailActivity { private Student student; private Grade grade; private EditText etName; private Spinner spnCourse; private EditText etScore;
// Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Course.java // @Table(name = "course") // public class Course implements Serializable { // // private static final long serialVersionUID = 4957742859044875650L; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_name") // private String name; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // } // // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Grade.java // @Table(name = "grade") // public class Grade implements Serializable { // // private static final long serialVersionUID = -8976200526604051847L; // // private static final int PASS_GRADE = 60; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_sid") // private long sid; // // @Column(name = "_cid") // private long cid; // // @Column(name = "_score") // private float score; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public long getSid() { // return sid; // } // // public void setSid(long sid) { // this.sid = sid; // } // // public long getCid() { // return cid; // } // // public void setCid(long cid) { // this.cid = cid; // } // // public float getScore() { // return score; // } // // public void setScore(float score) { // this.score = score; // } // // public boolean isPass() { // return this.score >= PASS_GRADE; // } // } // // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/bean/Student.java // @Table(name = "student") // public class Student implements Serializable { // // private static final long serialVersionUID = 8010508999597447226L; // // @Column(name = "_id", id = true) // private long id; // // @Column(name = "_name") // private String name; // // @Column(name = "_age") // private int age; // // @Column(name = "_phone") // private String phone; // // private String address; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getAddress() { // return address; // } // // public void setAddress(String address) { // this.address = address; // } // // } // Path: cn.ieclipse.aorm.example/src/main/java/cn/ieclipse/aorm/example/StudentGradeDetailActivity.java import java.util.List; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import cn.ieclipse.aorm.example.bean.Course; import cn.ieclipse.aorm.example.bean.Grade; import cn.ieclipse.aorm.example.bean.Student; /** * */ package cn.ieclipse.aorm.example; /** * @author Jamling * */ public class StudentGradeDetailActivity extends DetailActivity { private Student student; private Grade grade; private EditText etName; private Spinner spnCourse; private EditText etScore;
private List<Course> courseList;
Jamling/Android-ORM
cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Student.java
// Path: cn.ieclipse.aorm.core/src/cn/ieclipse/aorm/Mapping.java // public class Mapping { // private static Mapping instance = null; // // public synchronized static Mapping getInstance() { // if (instance == null) { // instance = new Mapping(); // } // return instance; // } // // private HashMap<Class<?>, TableWrap> tables = new HashMap<Class<?>, TableWrap>(); // // private TableWrap getTableWrap(Class<?> clazz) { // TableWrap wrap = tables.get(clazz); // if (wrap == null) { // wrap = new TableWrap(clazz); // tables.put(clazz, wrap); // } // return wrap; // } // // public Table getTable(Class<?> clazz) { // Table t = clazz.getAnnotation(Table.class); // if (t == null) { // throw new ORMException("No mapping to " + clazz // + ", did you forget add @Table to your class?"); // } // return t; // } // // public String getTableName(Class<?> clazz) { // return getTableWrap(clazz).getTableName(); // } // // /** // * <p> // * Get mapping table class by specified table name. // * </p> // * <strong>Warning:</strong> If class not in mapping table, will return // * null. // * // * @param table // * table name in database // * @return mapped class. // */ // public Class<?> getTableClass(String table) { // for (TableWrap wrap : tables.values()) { // if (wrap.getTableName().equals(table)) { // return wrap.getTableClass(); // } // } // return null; // } // // public List<String> getColumns(String alias, Class<?> clazz) { // return getTableWrap(clazz).getColumnProjection(alias); // } // // public String getColumnName(String property, Class<?> clazz) { // String name = getTableWrap(clazz).getColumn(property); // if (name == null) { // throw new ORMException( // "Mapping Error: no such column mapping to " + property); // } // return name; // } // // public String getPropertyName(String column, Class<?> clazz) { // return getTableWrap(clazz).getProperty(column); // } // // public String getPK(Class<?> clazz) { // return getTableWrap(clazz).getPK(); // } // // public String getPKProperty(Class<?> clazz) { // return getTableWrap(clazz).getPKProperty(); // } // // public Field getPKField(Class<?> clazz) { // return getTableWrap(clazz).getPKField(); // } // // /* package */ColumnWrap getColumn(String property, Class<?> clazz) { // return getTableWrap(clazz).getColumnWrap(property); // } // // /* package */List<ColumnWrap> getColumns(Class<?> clazz) { // return getTableWrap(clazz).getColumnWraps(); // } // // @Deprecated // /* package */Method getGetterByColumn(String column, Class<?> clazz) { // return getTableWrap(clazz).getGetterByColumn(column); // } // // @Deprecated // /* package */Method getSetterByColumn(String column, Class<?> clazz) { // return getTableWrap(clazz).getSetterByColumn(column); // } // // /* package */Field getColumnField(String column, Class<?> clazz) { // return getTableWrap(clazz).getColumnField(column); // } // }
import java.io.Serializable; import java.util.List; import cn.ieclipse.aorm.Mapping; import cn.ieclipse.aorm.annotation.Column; import cn.ieclipse.aorm.annotation.Table;
/** * */ package cn.ieclipse.aorm.bean; /** * @author Jamling * */ @Table(name = "student") public class Student implements Serializable { private static final long serialVersionUID = 8010508999597447226L; @Column(name = "_id", id = true) public long id; @Column(name="_name") public String name; @Column(name = "_age") public int age; @Column(name = "_phone") public String phone; public String address; // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getAddress() { // return address; // } // // public void setAddress(String address) { // this.address = address; // } public static void main(String[] args) {
// Path: cn.ieclipse.aorm.core/src/cn/ieclipse/aorm/Mapping.java // public class Mapping { // private static Mapping instance = null; // // public synchronized static Mapping getInstance() { // if (instance == null) { // instance = new Mapping(); // } // return instance; // } // // private HashMap<Class<?>, TableWrap> tables = new HashMap<Class<?>, TableWrap>(); // // private TableWrap getTableWrap(Class<?> clazz) { // TableWrap wrap = tables.get(clazz); // if (wrap == null) { // wrap = new TableWrap(clazz); // tables.put(clazz, wrap); // } // return wrap; // } // // public Table getTable(Class<?> clazz) { // Table t = clazz.getAnnotation(Table.class); // if (t == null) { // throw new ORMException("No mapping to " + clazz // + ", did you forget add @Table to your class?"); // } // return t; // } // // public String getTableName(Class<?> clazz) { // return getTableWrap(clazz).getTableName(); // } // // /** // * <p> // * Get mapping table class by specified table name. // * </p> // * <strong>Warning:</strong> If class not in mapping table, will return // * null. // * // * @param table // * table name in database // * @return mapped class. // */ // public Class<?> getTableClass(String table) { // for (TableWrap wrap : tables.values()) { // if (wrap.getTableName().equals(table)) { // return wrap.getTableClass(); // } // } // return null; // } // // public List<String> getColumns(String alias, Class<?> clazz) { // return getTableWrap(clazz).getColumnProjection(alias); // } // // public String getColumnName(String property, Class<?> clazz) { // String name = getTableWrap(clazz).getColumn(property); // if (name == null) { // throw new ORMException( // "Mapping Error: no such column mapping to " + property); // } // return name; // } // // public String getPropertyName(String column, Class<?> clazz) { // return getTableWrap(clazz).getProperty(column); // } // // public String getPK(Class<?> clazz) { // return getTableWrap(clazz).getPK(); // } // // public String getPKProperty(Class<?> clazz) { // return getTableWrap(clazz).getPKProperty(); // } // // public Field getPKField(Class<?> clazz) { // return getTableWrap(clazz).getPKField(); // } // // /* package */ColumnWrap getColumn(String property, Class<?> clazz) { // return getTableWrap(clazz).getColumnWrap(property); // } // // /* package */List<ColumnWrap> getColumns(Class<?> clazz) { // return getTableWrap(clazz).getColumnWraps(); // } // // @Deprecated // /* package */Method getGetterByColumn(String column, Class<?> clazz) { // return getTableWrap(clazz).getGetterByColumn(column); // } // // @Deprecated // /* package */Method getSetterByColumn(String column, Class<?> clazz) { // return getTableWrap(clazz).getSetterByColumn(column); // } // // /* package */Field getColumnField(String column, Class<?> clazz) { // return getTableWrap(clazz).getColumnField(column); // } // } // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/Student.java import java.io.Serializable; import java.util.List; import cn.ieclipse.aorm.Mapping; import cn.ieclipse.aorm.annotation.Column; import cn.ieclipse.aorm.annotation.Table; /** * */ package cn.ieclipse.aorm.bean; /** * @author Jamling * */ @Table(name = "student") public class Student implements Serializable { private static final long serialVersionUID = 8010508999597447226L; @Column(name = "_id", id = true) public long id; @Column(name="_name") public String name; @Column(name = "_age") public int age; @Column(name = "_phone") public String phone; public String address; // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getAge() { // return age; // } // // public void setAge(int age) { // this.age = age; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // // public String getAddress() { // return address; // } // // public void setAddress(String address) { // this.address = address; // } public static void main(String[] args) {
List<String> cols = Mapping.getInstance().getColumns(null, Student.class);
Jamling/Android-ORM
cn.ieclipse.aorm.mock/src/android/database/Cursor.java
// Path: cn.ieclipse.aorm.mock/src/android/content/ContentResolver.java // public abstract class ContentResolver { // /** // * Register an observer class that gets callbacks when data identified by a // * given content URI changes. // * // * @param uri // * The URI to watch for changes. This can be a specific row URI, // * or a base URI for a whole class of content. // * @param notifyForDescendents // * If <code>true</code> changes to URIs beginning with // * <code>uri</code> will also cause notifications to be sent. If // * <code>false</code> only changes to the exact URI specified by // * <em>uri</em> will cause notifications to be sent. If true, // * than any URI values at or below the specified URI will also // * trigger a match. // * @param observer // * The object that receives callbacks when changes occur. // * @see #unregisterContentObserver // */ // public final void registerContentObserver(Uri uri, // boolean notifyForDescendents, ContentObserver observer) { // // } // // /** // * Unregisters a change observer. // * // * @param observer // * The previously registered observer that is no longer needed. // * @see #registerContentObserver // */ // public final void unregisterContentObserver(ContentObserver observer) { // } // // /** // * Notify registered observers that a row was updated and attempt to sync changes // * to the network. // * To register, call {@link #registerContentObserver(android.net.Uri , boolean, android.database.ContentObserver) registerContentObserver()}. // * By default, CursorAdapter objects will get this notification. // * // * @param uri The uri of the content that was changed. // * @param observer The observer that originated the change, may be <code>null</null>. // * The observer that originated the change will only receive the notification if it // * has requested to receive self-change notifications by implementing // * {@link ContentObserver#deliverSelfNotifications()} to return true. // */ // public void notifyChange(Uri uri, ContentObserver observer) { // notifyChange(uri, observer, true /* sync to network */); // } // // /** // * Notify registered observers that a row was updated. // * To register, call {@link #registerContentObserver(android.net.Uri , boolean, android.database.ContentObserver) registerContentObserver()}. // * By default, CursorAdapter objects will get this notification. // * If syncToNetwork is true, this will attempt to schedule a local sync using the sync // * adapter that's registered for the authority of the provided uri. No account will be // * passed to the sync adapter, so all matching accounts will be synchronized. // * // * @param uri The uri of the content that was changed. // * @param observer The observer that originated the change, may be <code>null</null>. // * The observer that originated the change will only receive the notification if it // * has requested to receive self-change notifications by implementing // * {@link ContentObserver#deliverSelfNotifications()} to return true. // * @param syncToNetwork If true, attempt to sync the change to the network. // * @see #requestSync(android.accounts.Account, String, android.os.Bundle) // */ // public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) { // // notifyChange(uri, observer, syncToNetwork, UserHandle.myUserId()); // } // } // // Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // }
import java.io.Closeable; import android.content.ContentResolver; import android.net.Uri;
* {@link #requery()} is called. * * @param observer * the object that gets notified when the content backing the * cursor changes. * @see #unregisterContentObserver(ContentObserver) */ void registerContentObserver(ContentObserver observer); /** * Unregister an observer that has previously been registered with this * cursor via {@link #registerContentObserver}. * * @param observer * the object to unregister. * @see #registerContentObserver(ContentObserver) */ void unregisterContentObserver(ContentObserver observer); /** * Register to watch a content URI for changes. This can be the URI of a * specific data row (for example, "content://my_provider_type/23"), or a a * generic URI for a content type. * * @param cr * The content resolver from the caller's context. The listener * attached to this resolver will be notified. * @param uri * The content URI to watch. */
// Path: cn.ieclipse.aorm.mock/src/android/content/ContentResolver.java // public abstract class ContentResolver { // /** // * Register an observer class that gets callbacks when data identified by a // * given content URI changes. // * // * @param uri // * The URI to watch for changes. This can be a specific row URI, // * or a base URI for a whole class of content. // * @param notifyForDescendents // * If <code>true</code> changes to URIs beginning with // * <code>uri</code> will also cause notifications to be sent. If // * <code>false</code> only changes to the exact URI specified by // * <em>uri</em> will cause notifications to be sent. If true, // * than any URI values at or below the specified URI will also // * trigger a match. // * @param observer // * The object that receives callbacks when changes occur. // * @see #unregisterContentObserver // */ // public final void registerContentObserver(Uri uri, // boolean notifyForDescendents, ContentObserver observer) { // // } // // /** // * Unregisters a change observer. // * // * @param observer // * The previously registered observer that is no longer needed. // * @see #registerContentObserver // */ // public final void unregisterContentObserver(ContentObserver observer) { // } // // /** // * Notify registered observers that a row was updated and attempt to sync changes // * to the network. // * To register, call {@link #registerContentObserver(android.net.Uri , boolean, android.database.ContentObserver) registerContentObserver()}. // * By default, CursorAdapter objects will get this notification. // * // * @param uri The uri of the content that was changed. // * @param observer The observer that originated the change, may be <code>null</null>. // * The observer that originated the change will only receive the notification if it // * has requested to receive self-change notifications by implementing // * {@link ContentObserver#deliverSelfNotifications()} to return true. // */ // public void notifyChange(Uri uri, ContentObserver observer) { // notifyChange(uri, observer, true /* sync to network */); // } // // /** // * Notify registered observers that a row was updated. // * To register, call {@link #registerContentObserver(android.net.Uri , boolean, android.database.ContentObserver) registerContentObserver()}. // * By default, CursorAdapter objects will get this notification. // * If syncToNetwork is true, this will attempt to schedule a local sync using the sync // * adapter that's registered for the authority of the provided uri. No account will be // * passed to the sync adapter, so all matching accounts will be synchronized. // * // * @param uri The uri of the content that was changed. // * @param observer The observer that originated the change, may be <code>null</null>. // * The observer that originated the change will only receive the notification if it // * has requested to receive self-change notifications by implementing // * {@link ContentObserver#deliverSelfNotifications()} to return true. // * @param syncToNetwork If true, attempt to sync the change to the network. // * @see #requestSync(android.accounts.Account, String, android.os.Bundle) // */ // public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) { // // notifyChange(uri, observer, syncToNetwork, UserHandle.myUserId()); // } // } // // Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // Path: cn.ieclipse.aorm.mock/src/android/database/Cursor.java import java.io.Closeable; import android.content.ContentResolver; import android.net.Uri; * {@link #requery()} is called. * * @param observer * the object that gets notified when the content backing the * cursor changes. * @see #unregisterContentObserver(ContentObserver) */ void registerContentObserver(ContentObserver observer); /** * Unregister an observer that has previously been registered with this * cursor via {@link #registerContentObserver}. * * @param observer * the object to unregister. * @see #registerContentObserver(ContentObserver) */ void unregisterContentObserver(ContentObserver observer); /** * Register to watch a content URI for changes. This can be the URI of a * specific data row (for example, "content://my_provider_type/23"), or a a * generic URI for a content type. * * @param cr * The content resolver from the caller's context. The listener * attached to this resolver will be notified. * @param uri * The content URI to watch. */
void setNotificationUri(ContentResolver cr, Uri uri);
Jamling/Android-ORM
cn.ieclipse.aorm.mock/src/android/database/Cursor.java
// Path: cn.ieclipse.aorm.mock/src/android/content/ContentResolver.java // public abstract class ContentResolver { // /** // * Register an observer class that gets callbacks when data identified by a // * given content URI changes. // * // * @param uri // * The URI to watch for changes. This can be a specific row URI, // * or a base URI for a whole class of content. // * @param notifyForDescendents // * If <code>true</code> changes to URIs beginning with // * <code>uri</code> will also cause notifications to be sent. If // * <code>false</code> only changes to the exact URI specified by // * <em>uri</em> will cause notifications to be sent. If true, // * than any URI values at or below the specified URI will also // * trigger a match. // * @param observer // * The object that receives callbacks when changes occur. // * @see #unregisterContentObserver // */ // public final void registerContentObserver(Uri uri, // boolean notifyForDescendents, ContentObserver observer) { // // } // // /** // * Unregisters a change observer. // * // * @param observer // * The previously registered observer that is no longer needed. // * @see #registerContentObserver // */ // public final void unregisterContentObserver(ContentObserver observer) { // } // // /** // * Notify registered observers that a row was updated and attempt to sync changes // * to the network. // * To register, call {@link #registerContentObserver(android.net.Uri , boolean, android.database.ContentObserver) registerContentObserver()}. // * By default, CursorAdapter objects will get this notification. // * // * @param uri The uri of the content that was changed. // * @param observer The observer that originated the change, may be <code>null</null>. // * The observer that originated the change will only receive the notification if it // * has requested to receive self-change notifications by implementing // * {@link ContentObserver#deliverSelfNotifications()} to return true. // */ // public void notifyChange(Uri uri, ContentObserver observer) { // notifyChange(uri, observer, true /* sync to network */); // } // // /** // * Notify registered observers that a row was updated. // * To register, call {@link #registerContentObserver(android.net.Uri , boolean, android.database.ContentObserver) registerContentObserver()}. // * By default, CursorAdapter objects will get this notification. // * If syncToNetwork is true, this will attempt to schedule a local sync using the sync // * adapter that's registered for the authority of the provided uri. No account will be // * passed to the sync adapter, so all matching accounts will be synchronized. // * // * @param uri The uri of the content that was changed. // * @param observer The observer that originated the change, may be <code>null</null>. // * The observer that originated the change will only receive the notification if it // * has requested to receive self-change notifications by implementing // * {@link ContentObserver#deliverSelfNotifications()} to return true. // * @param syncToNetwork If true, attempt to sync the change to the network. // * @see #requestSync(android.accounts.Account, String, android.os.Bundle) // */ // public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) { // // notifyChange(uri, observer, syncToNetwork, UserHandle.myUserId()); // } // } // // Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // }
import java.io.Closeable; import android.content.ContentResolver; import android.net.Uri;
* {@link #requery()} is called. * * @param observer * the object that gets notified when the content backing the * cursor changes. * @see #unregisterContentObserver(ContentObserver) */ void registerContentObserver(ContentObserver observer); /** * Unregister an observer that has previously been registered with this * cursor via {@link #registerContentObserver}. * * @param observer * the object to unregister. * @see #registerContentObserver(ContentObserver) */ void unregisterContentObserver(ContentObserver observer); /** * Register to watch a content URI for changes. This can be the URI of a * specific data row (for example, "content://my_provider_type/23"), or a a * generic URI for a content type. * * @param cr * The content resolver from the caller's context. The listener * attached to this resolver will be notified. * @param uri * The content URI to watch. */
// Path: cn.ieclipse.aorm.mock/src/android/content/ContentResolver.java // public abstract class ContentResolver { // /** // * Register an observer class that gets callbacks when data identified by a // * given content URI changes. // * // * @param uri // * The URI to watch for changes. This can be a specific row URI, // * or a base URI for a whole class of content. // * @param notifyForDescendents // * If <code>true</code> changes to URIs beginning with // * <code>uri</code> will also cause notifications to be sent. If // * <code>false</code> only changes to the exact URI specified by // * <em>uri</em> will cause notifications to be sent. If true, // * than any URI values at or below the specified URI will also // * trigger a match. // * @param observer // * The object that receives callbacks when changes occur. // * @see #unregisterContentObserver // */ // public final void registerContentObserver(Uri uri, // boolean notifyForDescendents, ContentObserver observer) { // // } // // /** // * Unregisters a change observer. // * // * @param observer // * The previously registered observer that is no longer needed. // * @see #registerContentObserver // */ // public final void unregisterContentObserver(ContentObserver observer) { // } // // /** // * Notify registered observers that a row was updated and attempt to sync changes // * to the network. // * To register, call {@link #registerContentObserver(android.net.Uri , boolean, android.database.ContentObserver) registerContentObserver()}. // * By default, CursorAdapter objects will get this notification. // * // * @param uri The uri of the content that was changed. // * @param observer The observer that originated the change, may be <code>null</null>. // * The observer that originated the change will only receive the notification if it // * has requested to receive self-change notifications by implementing // * {@link ContentObserver#deliverSelfNotifications()} to return true. // */ // public void notifyChange(Uri uri, ContentObserver observer) { // notifyChange(uri, observer, true /* sync to network */); // } // // /** // * Notify registered observers that a row was updated. // * To register, call {@link #registerContentObserver(android.net.Uri , boolean, android.database.ContentObserver) registerContentObserver()}. // * By default, CursorAdapter objects will get this notification. // * If syncToNetwork is true, this will attempt to schedule a local sync using the sync // * adapter that's registered for the authority of the provided uri. No account will be // * passed to the sync adapter, so all matching accounts will be synchronized. // * // * @param uri The uri of the content that was changed. // * @param observer The observer that originated the change, may be <code>null</null>. // * The observer that originated the change will only receive the notification if it // * has requested to receive self-change notifications by implementing // * {@link ContentObserver#deliverSelfNotifications()} to return true. // * @param syncToNetwork If true, attempt to sync the change to the network. // * @see #requestSync(android.accounts.Account, String, android.os.Bundle) // */ // public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) { // // notifyChange(uri, observer, syncToNetwork, UserHandle.myUserId()); // } // } // // Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // Path: cn.ieclipse.aorm.mock/src/android/database/Cursor.java import java.io.Closeable; import android.content.ContentResolver; import android.net.Uri; * {@link #requery()} is called. * * @param observer * the object that gets notified when the content backing the * cursor changes. * @see #unregisterContentObserver(ContentObserver) */ void registerContentObserver(ContentObserver observer); /** * Unregister an observer that has previously been registered with this * cursor via {@link #registerContentObserver}. * * @param observer * the object to unregister. * @see #registerContentObserver(ContentObserver) */ void unregisterContentObserver(ContentObserver observer); /** * Register to watch a content URI for changes. This can be the URI of a * specific data row (for example, "content://my_provider_type/23"), or a a * generic URI for a content type. * * @param cr * The content resolver from the caller's context. The listener * attached to this resolver will be notified. * @param uri * The content URI to watch. */
void setNotificationUri(ContentResolver cr, Uri uri);
Jamling/Android-ORM
cn.ieclipse.aorm.mock/src/android/content/ContentResolver.java
// Path: cn.ieclipse.aorm.mock/src/android/database/ContentObserver.java // public abstract class ContentObserver { // private final Object mLock = new Object(); // // Handler mHandler; // // /** // * Creates a content observer. // * // * @param handler // * The handler to run {@link #onChange} on, or null if none. // */ // public ContentObserver(Handler handler) { // mHandler = handler; // } // // /** // * This method is called when a content change occurs. // * <p> // * Subclasses should override this method to handle content changes. // * </p> // * // * @param selfChange // * True if this is a self-change notification. // */ // public void onChange(boolean selfChange) { // // Do nothing. Subclass should override. // } // // /** // * This method is called when a content change occurs. Includes the changed // * content Uri when available. // * <p> // * Subclasses should override this method to handle content changes. To // * ensure correct operation on older versions of the framework that did not // * provide a Uri argument, applications should also implement the // * {@link #onChange(boolean)} overload of this method whenever they // * implement the {@link #onChange(boolean, Uri)} overload. // * </p> // * <p> // * Example implementation: // * // * <pre> // * <code> // * // Implement the onChange(boolean) method to delegate the change notification to // * // the onChange(boolean, Uri) method to ensure correct operation on older versions // * // of the framework that did not have the onChange(boolean, Uri) method. // * {@literal @Override} // * public void onChange(boolean selfChange) { // * onChange(selfChange, null); // * } // * // * // Implement the onChange(boolean, Uri) method to take advantage of the new Uri argument. // * {@literal @Override} // * public void onChange(boolean selfChange, Uri uri) { // * // Handle change. // * } // * </code> // * </pre> // * // * </p> // * // * @param selfChange // * True if this is a self-change notification. // * @param uri // * The Uri of the changed content, or null if unknown. // */ // public void onChange(boolean selfChange, Uri uri) { // onChange(selfChange); // } // // } // // Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // }
import android.database.ContentObserver; import android.net.Uri;
/* * Copyright (C) 2006 The Android Open Source Project * * 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 android.content; /** * This class provides applications access to the content model. * * <div class="special reference"> <h3>Developer Guides</h3> * <p> * For more information about using a ContentResolver with content providers, * read the <a href="{@docRoot} * guide/topics/providers/content-providers.html">Content Providers</a> * developer guide. * </p> */ public abstract class ContentResolver { /** * Register an observer class that gets callbacks when data identified by a * given content URI changes. * * @param uri * The URI to watch for changes. This can be a specific row URI, * or a base URI for a whole class of content. * @param notifyForDescendents * If <code>true</code> changes to URIs beginning with * <code>uri</code> will also cause notifications to be sent. If * <code>false</code> only changes to the exact URI specified by * <em>uri</em> will cause notifications to be sent. If true, * than any URI values at or below the specified URI will also * trigger a match. * @param observer * The object that receives callbacks when changes occur. * @see #unregisterContentObserver */ public final void registerContentObserver(Uri uri,
// Path: cn.ieclipse.aorm.mock/src/android/database/ContentObserver.java // public abstract class ContentObserver { // private final Object mLock = new Object(); // // Handler mHandler; // // /** // * Creates a content observer. // * // * @param handler // * The handler to run {@link #onChange} on, or null if none. // */ // public ContentObserver(Handler handler) { // mHandler = handler; // } // // /** // * This method is called when a content change occurs. // * <p> // * Subclasses should override this method to handle content changes. // * </p> // * // * @param selfChange // * True if this is a self-change notification. // */ // public void onChange(boolean selfChange) { // // Do nothing. Subclass should override. // } // // /** // * This method is called when a content change occurs. Includes the changed // * content Uri when available. // * <p> // * Subclasses should override this method to handle content changes. To // * ensure correct operation on older versions of the framework that did not // * provide a Uri argument, applications should also implement the // * {@link #onChange(boolean)} overload of this method whenever they // * implement the {@link #onChange(boolean, Uri)} overload. // * </p> // * <p> // * Example implementation: // * // * <pre> // * <code> // * // Implement the onChange(boolean) method to delegate the change notification to // * // the onChange(boolean, Uri) method to ensure correct operation on older versions // * // of the framework that did not have the onChange(boolean, Uri) method. // * {@literal @Override} // * public void onChange(boolean selfChange) { // * onChange(selfChange, null); // * } // * // * // Implement the onChange(boolean, Uri) method to take advantage of the new Uri argument. // * {@literal @Override} // * public void onChange(boolean selfChange, Uri uri) { // * // Handle change. // * } // * </code> // * </pre> // * // * </p> // * // * @param selfChange // * True if this is a self-change notification. // * @param uri // * The Uri of the changed content, or null if unknown. // */ // public void onChange(boolean selfChange, Uri uri) { // onChange(selfChange); // } // // } // // Path: cn.ieclipse.aorm.mock/src/android/net/Uri.java // public abstract class Uri { // // } // Path: cn.ieclipse.aorm.mock/src/android/content/ContentResolver.java import android.database.ContentObserver; import android.net.Uri; /* * Copyright (C) 2006 The Android Open Source Project * * 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 android.content; /** * This class provides applications access to the content model. * * <div class="special reference"> <h3>Developer Guides</h3> * <p> * For more information about using a ContentResolver with content providers, * read the <a href="{@docRoot} * guide/topics/providers/content-providers.html">Content Providers</a> * developer guide. * </p> */ public abstract class ContentResolver { /** * Register an observer class that gets callbacks when data identified by a * given content URI changes. * * @param uri * The URI to watch for changes. This can be a specific row URI, * or a base URI for a whole class of content. * @param notifyForDescendents * If <code>true</code> changes to URIs beginning with * <code>uri</code> will also cause notifications to be sent. If * <code>false</code> only changes to the exact URI specified by * <em>uri</em> will cause notifications to be sent. If true, * than any URI values at or below the specified URI will also * trigger a match. * @param observer * The object that receives callbacks when changes occur. * @see #unregisterContentObserver */ public final void registerContentObserver(Uri uri,
boolean notifyForDescendents, ContentObserver observer) {
Jamling/Android-ORM
cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/AormTest.java
// Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/FullBean.java // @Table(name = "test") // public class FullBean { // @Column(name = "_id", id = true) // public int id; // // @Column() // public Integer oid; // // @Column() // public long size; // // @Column() // public Long osize; // @Column() // public short age; // @Column() // public Short oage; // @Column() // public boolean exist; // @Column() // public Boolean oexist; // @Column() // public float weight; // @Column() // public Float oweight; // @Column() // public double balance; // @Column() // public Double obalance; // @Column() // public byte[] blob; // @Column() // public Byte[] oblob; // @Column() // public String address; // }
import cn.ieclipse.aorm.bean.FullBean; import junit.framework.TestCase;
/* * Copyright 2014-2015 ieclipse.cn. * * 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 cn.ieclipse.aorm; /** * Description * * @author Jamling * @date 2016-01-18 * */ public class AormTest extends TestCase { public void testCreateDDL() {
// Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/bean/FullBean.java // @Table(name = "test") // public class FullBean { // @Column(name = "_id", id = true) // public int id; // // @Column() // public Integer oid; // // @Column() // public long size; // // @Column() // public Long osize; // @Column() // public short age; // @Column() // public Short oage; // @Column() // public boolean exist; // @Column() // public Boolean oexist; // @Column() // public float weight; // @Column() // public Float oweight; // @Column() // public double balance; // @Column() // public Double obalance; // @Column() // public byte[] blob; // @Column() // public Byte[] oblob; // @Column() // public String address; // } // Path: cn.ieclipse.aorm.core/test/cn/ieclipse/aorm/AormTest.java import cn.ieclipse.aorm.bean.FullBean; import junit.framework.TestCase; /* * Copyright 2014-2015 ieclipse.cn. * * 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 cn.ieclipse.aorm; /** * Description * * @author Jamling * @date 2016-01-18 * */ public class AormTest extends TestCase { public void testCreateDDL() {
String sql = Aorm.generateCreateDDL(FullBean.class);
NeuralEnsemble/neuroConstruct
src/ucl/physiol/neuroconstruct/project/Project.java
// Path: src/ucl/physiol/neuroconstruct/neuroml/NeuroMLConstants.java // public enum NeuroMLLevel // { // NEUROML_LEVEL_1 // { // @Override // public String toString() // { // return "Level 1"; // } // }, // NEUROML_LEVEL_2 // { // @Override // public String toString() // { // return "Level 2"; // } // }, // NEUROML_LEVEL_3 // { // @Override // public String toString() // { // return "Level 3"; // } // }, // NEUROML_VERSION_2_SPIKING_CELL // { // @Override // public String toString() // { // return "Full Cell v"+NeuroMLVersion.getLatestVersion(); // } // } // };
import javax.swing.event.*; import ucl.physiol.neuroconstruct.cell.*; import ucl.physiol.neuroconstruct.cell.converters.*; import ucl.physiol.neuroconstruct.cell.utils.*; import ucl.physiol.neuroconstruct.genesis.*; import ucl.physiol.neuroconstruct.neuron.*; import ucl.physiol.neuroconstruct.psics.*; import ucl.physiol.neuroconstruct.pynn.*; import ucl.physiol.neuroconstruct.mechanisms.*; import ucl.physiol.neuroconstruct.simulation.*; import ucl.physiol.neuroconstruct.utils.*; import ucl.physiol.neuroconstruct.neuroml.*; import javax.swing.*; import ucl.physiol.neuroconstruct.neuroml.NeuroMLConstants.NeuroMLLevel; import java.beans.*; import java.io.*; import java.util.*;
filesDone.add(xmlFile.getName()); } else if (projProperties.getPreferredSaveFormat().equals(ProjectStructure.NEUROML1_FORMAT)) { boolean canSaveInNml = true; if (!cell.getApPropSpeedsVsGroups().isEmpty()) { canSaveInNml = false; GuiUtils.showWarningMessage(logger, "Cell "+cell+" cannot be saved in NeuroML format, as it contains ApPropSpeedsVsGroups. " + "\n\nChange save format in Project Properties. Saving in Java XML format for now...", null); } if (!cell.getAxonalArbours().isEmpty()) { canSaveInNml = false; GuiUtils.showWarningMessage(logger, "Cell "+cell+" cannot be saved in NeuroML format, as it contains Axonal arbours. " + "\n\nChange save format in Project Properties. Saving in Java XML format for now...", null); } if (canSaveInNml) { File nmlFile = new File(dirForProjectMorphologies, cell.getInstanceName() + ProjectStructure.getNeuroML1FileExtension()); MorphMLConverter.saveCellInNeuroMLFormat(cell, this, nmlFile,
// Path: src/ucl/physiol/neuroconstruct/neuroml/NeuroMLConstants.java // public enum NeuroMLLevel // { // NEUROML_LEVEL_1 // { // @Override // public String toString() // { // return "Level 1"; // } // }, // NEUROML_LEVEL_2 // { // @Override // public String toString() // { // return "Level 2"; // } // }, // NEUROML_LEVEL_3 // { // @Override // public String toString() // { // return "Level 3"; // } // }, // NEUROML_VERSION_2_SPIKING_CELL // { // @Override // public String toString() // { // return "Full Cell v"+NeuroMLVersion.getLatestVersion(); // } // } // }; // Path: src/ucl/physiol/neuroconstruct/project/Project.java import javax.swing.event.*; import ucl.physiol.neuroconstruct.cell.*; import ucl.physiol.neuroconstruct.cell.converters.*; import ucl.physiol.neuroconstruct.cell.utils.*; import ucl.physiol.neuroconstruct.genesis.*; import ucl.physiol.neuroconstruct.neuron.*; import ucl.physiol.neuroconstruct.psics.*; import ucl.physiol.neuroconstruct.pynn.*; import ucl.physiol.neuroconstruct.mechanisms.*; import ucl.physiol.neuroconstruct.simulation.*; import ucl.physiol.neuroconstruct.utils.*; import ucl.physiol.neuroconstruct.neuroml.*; import javax.swing.*; import ucl.physiol.neuroconstruct.neuroml.NeuroMLConstants.NeuroMLLevel; import java.beans.*; import java.io.*; import java.util.*; filesDone.add(xmlFile.getName()); } else if (projProperties.getPreferredSaveFormat().equals(ProjectStructure.NEUROML1_FORMAT)) { boolean canSaveInNml = true; if (!cell.getApPropSpeedsVsGroups().isEmpty()) { canSaveInNml = false; GuiUtils.showWarningMessage(logger, "Cell "+cell+" cannot be saved in NeuroML format, as it contains ApPropSpeedsVsGroups. " + "\n\nChange save format in Project Properties. Saving in Java XML format for now...", null); } if (!cell.getAxonalArbours().isEmpty()) { canSaveInNml = false; GuiUtils.showWarningMessage(logger, "Cell "+cell+" cannot be saved in NeuroML format, as it contains Axonal arbours. " + "\n\nChange save format in Project Properties. Saving in Java XML format for now...", null); } if (canSaveInNml) { File nmlFile = new File(dirForProjectMorphologies, cell.getInstanceName() + ProjectStructure.getNeuroML1FileExtension()); MorphMLConverter.saveCellInNeuroMLFormat(cell, this, nmlFile,
NeuroMLLevel.NEUROML_LEVEL_3,
code4craft/tiny-spring
src+/main/java/com/ysj/tinySpring/aop/AspectJExpressionPointcutAdvisor.java
// Path: src+/部分aopalliance分析/Advice.java // public interface Advice { // // }
import org.aopalliance.aop.Advice;
package com.ysj.tinySpring.aop; /** * AspectJ表达式切点通知器 * */ public class AspectJExpressionPointcutAdvisor implements PointcutAdvisor { /** * AspectJ表达式切点匹配器 * AspectJ表达式匹配的切点,默认有初始化。也默认有了MethodMatcher(AspectJExpressionPointcut实现了MethodMatcher接口) */ private AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); /** * 方法拦截器 * 这个要用户自己去xml文件里配置方法拦截器(MethodInterceptor继承了Advice接口), * 在AspectJAwareAdvisorAutoProxyCreator设置代理对象的方法拦截器时将Advispr强转为MethodInterceptor */
// Path: src+/部分aopalliance分析/Advice.java // public interface Advice { // // } // Path: src+/main/java/com/ysj/tinySpring/aop/AspectJExpressionPointcutAdvisor.java import org.aopalliance.aop.Advice; package com.ysj.tinySpring.aop; /** * AspectJ表达式切点通知器 * */ public class AspectJExpressionPointcutAdvisor implements PointcutAdvisor { /** * AspectJ表达式切点匹配器 * AspectJ表达式匹配的切点,默认有初始化。也默认有了MethodMatcher(AspectJExpressionPointcut实现了MethodMatcher接口) */ private AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); /** * 方法拦截器 * 这个要用户自己去xml文件里配置方法拦截器(MethodInterceptor继承了Advice接口), * 在AspectJAwareAdvisorAutoProxyCreator设置代理对象的方法拦截器时将Advispr强转为MethodInterceptor */
private Advice advice;
code4craft/tiny-spring
src+/main/java/com/ysj/tinySpring/beans/AbstractBeanDefinitionReader.java
// Path: src+/main/java/com/ysj/tinySpring/beans/io/ResourceLoader.java // public class ResourceLoader { // // /** // * 获取一个 Resouce 对象 // * @param location // * @return // */ // public Resource getResource(String location){ // // 通过给定名称查找资源 // URL resource = this.getClass().getClassLoader().getResource(location); // /* // * 注: 这里在设计上有一定的问题,ResourceLoader 直接返回了一个 UrlResource,更好的方法是声明 // * 一个 ResourceLoader 接口,再实现一个 UrlResourceLoader 类用于加载 UrlResource。 // */ // return new UrlResource(resource); // } // // }
import java.util.HashMap; import java.util.Map; import com.ysj.tinySpring.beans.io.ResourceLoader;
package com.ysj.tinySpring.beans; /** * 实现 BeanDefinitionReader 接口的抽象类(未具体实现 loadBeanDefinitions,而是规范了 * BeanDefinitionReader 的基本结构) */ public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader { /** * 通过String - beanDefinition 键值对保存IoC容器里的类定义。 */ private Map<String, BeanDefinition> registry; /** * 保存了类加载器,使用时,只需要向其 loadBeanDefinitions() 传入一个资源地址,就可以自动调用其类加载器, * 并把解析到的 BeanDefinition 保存到 registry 中去。 */
// Path: src+/main/java/com/ysj/tinySpring/beans/io/ResourceLoader.java // public class ResourceLoader { // // /** // * 获取一个 Resouce 对象 // * @param location // * @return // */ // public Resource getResource(String location){ // // 通过给定名称查找资源 // URL resource = this.getClass().getClassLoader().getResource(location); // /* // * 注: 这里在设计上有一定的问题,ResourceLoader 直接返回了一个 UrlResource,更好的方法是声明 // * 一个 ResourceLoader 接口,再实现一个 UrlResourceLoader 类用于加载 UrlResource。 // */ // return new UrlResource(resource); // } // // } // Path: src+/main/java/com/ysj/tinySpring/beans/AbstractBeanDefinitionReader.java import java.util.HashMap; import java.util.Map; import com.ysj.tinySpring.beans.io.ResourceLoader; package com.ysj.tinySpring.beans; /** * 实现 BeanDefinitionReader 接口的抽象类(未具体实现 loadBeanDefinitions,而是规范了 * BeanDefinitionReader 的基本结构) */ public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader { /** * 通过String - beanDefinition 键值对保存IoC容器里的类定义。 */ private Map<String, BeanDefinition> registry; /** * 保存了类加载器,使用时,只需要向其 loadBeanDefinitions() 传入一个资源地址,就可以自动调用其类加载器, * 并把解析到的 BeanDefinition 保存到 registry 中去。 */
private ResourceLoader resourceLoader;
code4craft/tiny-spring
src+/main/java/com/ysj/tinySpring/beans/factory/AutowireCapableBeanFactory.java
// Path: src+/main/java/com/ysj/tinySpring/BeanReference.java // public class BeanReference { // // public String name; // // public Object bean; // // public BeanReference(String name){ // this.name = name; // } // // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/BeanFactoryAware.java // public interface BeanFactoryAware { // // void setBeanFactory(BeanFactory beanFactory) throws Exception; // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/BeanDefinition.java // public class BeanDefinition { // // private Object bean; // // /** // * bean的类型 // * 根据其 类型 可以生成一个类实例,然后可以把 属性 注入进去。 // */ // private Class beanClass; // // /** // * bean的名字 // */ // private String beanClassName; // // /** // * bean的属性集合 // * 每个属性都是键值对 String - Object // */ // private PropertyValues propertyValues = new PropertyValues(); // // public BeanDefinition() { } // // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // public Class getBeanClass() { // return beanClass; // } // // public void setBeanClass(Class beanClass) { // this.beanClass = beanClass; // } // // public String getBeanClassName() { // return beanClassName; // } // // public void setBeanClassName(String beanClassName) { // this.beanClassName = beanClassName; // try { // this.beanClass = Class.forName(beanClassName); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } // } // // public PropertyValues getPropertyValues() { // return propertyValues; // } // // public void setPropertyValues(PropertyValues propertyValues) { // this.propertyValues = propertyValues; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/PropertyValue.java // public class PropertyValue { // // private final String name; // // /** // * 在 Spring 的 XML 中的 property 中,键是 key ,值是 value 或者 ref。对于 value 只要直接注入属性就行 // * 了,但是 ref 要先进行解析,转化为对应的实际 Object。 // */ // private final Object value; // // public PropertyValue(String name, Object value) { // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public Object getValue() { // return value; // } // // }
import java.lang.reflect.Field; import java.lang.reflect.Method; import com.ysj.tinySpring.BeanReference; import com.ysj.tinySpring.aop.BeanFactoryAware; import com.ysj.tinySpring.beans.BeanDefinition; import com.ysj.tinySpring.beans.PropertyValue;
package com.ysj.tinySpring.beans.factory; /** * 可实现自动装配的BeanFactory * */ public class AutowireCapableBeanFactory extends AbstractBeanFactory{ /** * 通过反射自动装配bean的所有属性 */ protected void applyPropertyValues(Object bean, BeanDefinition beanDefinition) throws Exception {
// Path: src+/main/java/com/ysj/tinySpring/BeanReference.java // public class BeanReference { // // public String name; // // public Object bean; // // public BeanReference(String name){ // this.name = name; // } // // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/BeanFactoryAware.java // public interface BeanFactoryAware { // // void setBeanFactory(BeanFactory beanFactory) throws Exception; // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/BeanDefinition.java // public class BeanDefinition { // // private Object bean; // // /** // * bean的类型 // * 根据其 类型 可以生成一个类实例,然后可以把 属性 注入进去。 // */ // private Class beanClass; // // /** // * bean的名字 // */ // private String beanClassName; // // /** // * bean的属性集合 // * 每个属性都是键值对 String - Object // */ // private PropertyValues propertyValues = new PropertyValues(); // // public BeanDefinition() { } // // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // public Class getBeanClass() { // return beanClass; // } // // public void setBeanClass(Class beanClass) { // this.beanClass = beanClass; // } // // public String getBeanClassName() { // return beanClassName; // } // // public void setBeanClassName(String beanClassName) { // this.beanClassName = beanClassName; // try { // this.beanClass = Class.forName(beanClassName); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } // } // // public PropertyValues getPropertyValues() { // return propertyValues; // } // // public void setPropertyValues(PropertyValues propertyValues) { // this.propertyValues = propertyValues; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/PropertyValue.java // public class PropertyValue { // // private final String name; // // /** // * 在 Spring 的 XML 中的 property 中,键是 key ,值是 value 或者 ref。对于 value 只要直接注入属性就行 // * 了,但是 ref 要先进行解析,转化为对应的实际 Object。 // */ // private final Object value; // // public PropertyValue(String name, Object value) { // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public Object getValue() { // return value; // } // // } // Path: src+/main/java/com/ysj/tinySpring/beans/factory/AutowireCapableBeanFactory.java import java.lang.reflect.Field; import java.lang.reflect.Method; import com.ysj.tinySpring.BeanReference; import com.ysj.tinySpring.aop.BeanFactoryAware; import com.ysj.tinySpring.beans.BeanDefinition; import com.ysj.tinySpring.beans.PropertyValue; package com.ysj.tinySpring.beans.factory; /** * 可实现自动装配的BeanFactory * */ public class AutowireCapableBeanFactory extends AbstractBeanFactory{ /** * 通过反射自动装配bean的所有属性 */ protected void applyPropertyValues(Object bean, BeanDefinition beanDefinition) throws Exception {
if (bean instanceof BeanFactoryAware) {
code4craft/tiny-spring
src+/main/java/com/ysj/tinySpring/beans/factory/AutowireCapableBeanFactory.java
// Path: src+/main/java/com/ysj/tinySpring/BeanReference.java // public class BeanReference { // // public String name; // // public Object bean; // // public BeanReference(String name){ // this.name = name; // } // // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/BeanFactoryAware.java // public interface BeanFactoryAware { // // void setBeanFactory(BeanFactory beanFactory) throws Exception; // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/BeanDefinition.java // public class BeanDefinition { // // private Object bean; // // /** // * bean的类型 // * 根据其 类型 可以生成一个类实例,然后可以把 属性 注入进去。 // */ // private Class beanClass; // // /** // * bean的名字 // */ // private String beanClassName; // // /** // * bean的属性集合 // * 每个属性都是键值对 String - Object // */ // private PropertyValues propertyValues = new PropertyValues(); // // public BeanDefinition() { } // // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // public Class getBeanClass() { // return beanClass; // } // // public void setBeanClass(Class beanClass) { // this.beanClass = beanClass; // } // // public String getBeanClassName() { // return beanClassName; // } // // public void setBeanClassName(String beanClassName) { // this.beanClassName = beanClassName; // try { // this.beanClass = Class.forName(beanClassName); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } // } // // public PropertyValues getPropertyValues() { // return propertyValues; // } // // public void setPropertyValues(PropertyValues propertyValues) { // this.propertyValues = propertyValues; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/PropertyValue.java // public class PropertyValue { // // private final String name; // // /** // * 在 Spring 的 XML 中的 property 中,键是 key ,值是 value 或者 ref。对于 value 只要直接注入属性就行 // * 了,但是 ref 要先进行解析,转化为对应的实际 Object。 // */ // private final Object value; // // public PropertyValue(String name, Object value) { // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public Object getValue() { // return value; // } // // }
import java.lang.reflect.Field; import java.lang.reflect.Method; import com.ysj.tinySpring.BeanReference; import com.ysj.tinySpring.aop.BeanFactoryAware; import com.ysj.tinySpring.beans.BeanDefinition; import com.ysj.tinySpring.beans.PropertyValue;
package com.ysj.tinySpring.beans.factory; /** * 可实现自动装配的BeanFactory * */ public class AutowireCapableBeanFactory extends AbstractBeanFactory{ /** * 通过反射自动装配bean的所有属性 */ protected void applyPropertyValues(Object bean, BeanDefinition beanDefinition) throws Exception { if (bean instanceof BeanFactoryAware) { ((BeanFactoryAware) bean).setBeanFactory(this); }
// Path: src+/main/java/com/ysj/tinySpring/BeanReference.java // public class BeanReference { // // public String name; // // public Object bean; // // public BeanReference(String name){ // this.name = name; // } // // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/BeanFactoryAware.java // public interface BeanFactoryAware { // // void setBeanFactory(BeanFactory beanFactory) throws Exception; // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/BeanDefinition.java // public class BeanDefinition { // // private Object bean; // // /** // * bean的类型 // * 根据其 类型 可以生成一个类实例,然后可以把 属性 注入进去。 // */ // private Class beanClass; // // /** // * bean的名字 // */ // private String beanClassName; // // /** // * bean的属性集合 // * 每个属性都是键值对 String - Object // */ // private PropertyValues propertyValues = new PropertyValues(); // // public BeanDefinition() { } // // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // public Class getBeanClass() { // return beanClass; // } // // public void setBeanClass(Class beanClass) { // this.beanClass = beanClass; // } // // public String getBeanClassName() { // return beanClassName; // } // // public void setBeanClassName(String beanClassName) { // this.beanClassName = beanClassName; // try { // this.beanClass = Class.forName(beanClassName); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } // } // // public PropertyValues getPropertyValues() { // return propertyValues; // } // // public void setPropertyValues(PropertyValues propertyValues) { // this.propertyValues = propertyValues; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/PropertyValue.java // public class PropertyValue { // // private final String name; // // /** // * 在 Spring 的 XML 中的 property 中,键是 key ,值是 value 或者 ref。对于 value 只要直接注入属性就行 // * 了,但是 ref 要先进行解析,转化为对应的实际 Object。 // */ // private final Object value; // // public PropertyValue(String name, Object value) { // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public Object getValue() { // return value; // } // // } // Path: src+/main/java/com/ysj/tinySpring/beans/factory/AutowireCapableBeanFactory.java import java.lang.reflect.Field; import java.lang.reflect.Method; import com.ysj.tinySpring.BeanReference; import com.ysj.tinySpring.aop.BeanFactoryAware; import com.ysj.tinySpring.beans.BeanDefinition; import com.ysj.tinySpring.beans.PropertyValue; package com.ysj.tinySpring.beans.factory; /** * 可实现自动装配的BeanFactory * */ public class AutowireCapableBeanFactory extends AbstractBeanFactory{ /** * 通过反射自动装配bean的所有属性 */ protected void applyPropertyValues(Object bean, BeanDefinition beanDefinition) throws Exception { if (bean instanceof BeanFactoryAware) { ((BeanFactoryAware) bean).setBeanFactory(this); }
for (PropertyValue propertyValue : beanDefinition.getPropertyValues().getPropertyValuesList()) {
code4craft/tiny-spring
src+/main/java/com/ysj/tinySpring/beans/factory/AutowireCapableBeanFactory.java
// Path: src+/main/java/com/ysj/tinySpring/BeanReference.java // public class BeanReference { // // public String name; // // public Object bean; // // public BeanReference(String name){ // this.name = name; // } // // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/BeanFactoryAware.java // public interface BeanFactoryAware { // // void setBeanFactory(BeanFactory beanFactory) throws Exception; // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/BeanDefinition.java // public class BeanDefinition { // // private Object bean; // // /** // * bean的类型 // * 根据其 类型 可以生成一个类实例,然后可以把 属性 注入进去。 // */ // private Class beanClass; // // /** // * bean的名字 // */ // private String beanClassName; // // /** // * bean的属性集合 // * 每个属性都是键值对 String - Object // */ // private PropertyValues propertyValues = new PropertyValues(); // // public BeanDefinition() { } // // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // public Class getBeanClass() { // return beanClass; // } // // public void setBeanClass(Class beanClass) { // this.beanClass = beanClass; // } // // public String getBeanClassName() { // return beanClassName; // } // // public void setBeanClassName(String beanClassName) { // this.beanClassName = beanClassName; // try { // this.beanClass = Class.forName(beanClassName); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } // } // // public PropertyValues getPropertyValues() { // return propertyValues; // } // // public void setPropertyValues(PropertyValues propertyValues) { // this.propertyValues = propertyValues; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/PropertyValue.java // public class PropertyValue { // // private final String name; // // /** // * 在 Spring 的 XML 中的 property 中,键是 key ,值是 value 或者 ref。对于 value 只要直接注入属性就行 // * 了,但是 ref 要先进行解析,转化为对应的实际 Object。 // */ // private final Object value; // // public PropertyValue(String name, Object value) { // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public Object getValue() { // return value; // } // // }
import java.lang.reflect.Field; import java.lang.reflect.Method; import com.ysj.tinySpring.BeanReference; import com.ysj.tinySpring.aop.BeanFactoryAware; import com.ysj.tinySpring.beans.BeanDefinition; import com.ysj.tinySpring.beans.PropertyValue;
package com.ysj.tinySpring.beans.factory; /** * 可实现自动装配的BeanFactory * */ public class AutowireCapableBeanFactory extends AbstractBeanFactory{ /** * 通过反射自动装配bean的所有属性 */ protected void applyPropertyValues(Object bean, BeanDefinition beanDefinition) throws Exception { if (bean instanceof BeanFactoryAware) { ((BeanFactoryAware) bean).setBeanFactory(this); } for (PropertyValue propertyValue : beanDefinition.getPropertyValues().getPropertyValuesList()) { Object value = propertyValue.getValue(); // 如果属性是ref而不是value类型就先实例化那个ref的bean,然后装载到这个value里
// Path: src+/main/java/com/ysj/tinySpring/BeanReference.java // public class BeanReference { // // public String name; // // public Object bean; // // public BeanReference(String name){ // this.name = name; // } // // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/BeanFactoryAware.java // public interface BeanFactoryAware { // // void setBeanFactory(BeanFactory beanFactory) throws Exception; // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/BeanDefinition.java // public class BeanDefinition { // // private Object bean; // // /** // * bean的类型 // * 根据其 类型 可以生成一个类实例,然后可以把 属性 注入进去。 // */ // private Class beanClass; // // /** // * bean的名字 // */ // private String beanClassName; // // /** // * bean的属性集合 // * 每个属性都是键值对 String - Object // */ // private PropertyValues propertyValues = new PropertyValues(); // // public BeanDefinition() { } // // // public Object getBean() { // return bean; // } // // public void setBean(Object bean) { // this.bean = bean; // } // // public Class getBeanClass() { // return beanClass; // } // // public void setBeanClass(Class beanClass) { // this.beanClass = beanClass; // } // // public String getBeanClassName() { // return beanClassName; // } // // public void setBeanClassName(String beanClassName) { // this.beanClassName = beanClassName; // try { // this.beanClass = Class.forName(beanClassName); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } // } // // public PropertyValues getPropertyValues() { // return propertyValues; // } // // public void setPropertyValues(PropertyValues propertyValues) { // this.propertyValues = propertyValues; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/beans/PropertyValue.java // public class PropertyValue { // // private final String name; // // /** // * 在 Spring 的 XML 中的 property 中,键是 key ,值是 value 或者 ref。对于 value 只要直接注入属性就行 // * 了,但是 ref 要先进行解析,转化为对应的实际 Object。 // */ // private final Object value; // // public PropertyValue(String name, Object value) { // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public Object getValue() { // return value; // } // // } // Path: src+/main/java/com/ysj/tinySpring/beans/factory/AutowireCapableBeanFactory.java import java.lang.reflect.Field; import java.lang.reflect.Method; import com.ysj.tinySpring.BeanReference; import com.ysj.tinySpring.aop.BeanFactoryAware; import com.ysj.tinySpring.beans.BeanDefinition; import com.ysj.tinySpring.beans.PropertyValue; package com.ysj.tinySpring.beans.factory; /** * 可实现自动装配的BeanFactory * */ public class AutowireCapableBeanFactory extends AbstractBeanFactory{ /** * 通过反射自动装配bean的所有属性 */ protected void applyPropertyValues(Object bean, BeanDefinition beanDefinition) throws Exception { if (bean instanceof BeanFactoryAware) { ((BeanFactoryAware) bean).setBeanFactory(this); } for (PropertyValue propertyValue : beanDefinition.getPropertyValues().getPropertyValuesList()) { Object value = propertyValue.getValue(); // 如果属性是ref而不是value类型就先实例化那个ref的bean,然后装载到这个value里
if (value instanceof BeanReference) {
code4craft/tiny-spring
src+/test/java/com/ysj/aop/AspectJExpressionPointcutTest.java
// Path: src+/test/java/com/ysj/HelloWorldService.java // public interface HelloWorldService { // // void helloWorld(); // } // // Path: src+/test/java/com/ysj/HelloWorldServiceImpl.java // public class HelloWorldServiceImpl implements HelloWorldService { // // private String text; // // private OutputService outputService; // // @Override // public void helloWorld() { // outputService.output(text); // } // // public void setText(String text) { // this.text = text; // } // // public void setOutputService(OutputService outputService) { // this.outputService = outputService; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/AspectJExpressionPointcut.java // public class AspectJExpressionPointcut implements Pointcut, ClassFilter, MethodMatcher { // // private PointcutParser pointcutParser; // // private String expression; // // private PointcutExpression pointcutExpression; // // private static final Set<PointcutPrimitive> DEFAULT_SUPPORTED_PRIMITIVES = new HashSet<PointcutPrimitive>(); // // static { // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.EXECUTION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.REFERENCE); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.THIS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.TARGET); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ANNOTATION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_TARGET); // } // // public AspectJExpressionPointcut() { // this(DEFAULT_SUPPORTED_PRIMITIVES); // } // // public AspectJExpressionPointcut(Set<PointcutPrimitive> supportedPrimitives) { // pointcutParser = PointcutParser // .getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(supportedPrimitives); // } // // protected void checkReadyToMatch() { // if (pointcutExpression == null) { // pointcutExpression = buildPointcutExpression(); // } // } // // private PointcutExpression buildPointcutExpression() { // return pointcutParser.parsePointcutExpression(expression); // } // // public void setExpression(String expression) { // this.expression = expression; // } // // @Override // public ClassFilter getClassFilter() { // return this; // } // // @Override // public MethodMatcher getMethodMatcher() { // return this; // } // // @Override // public boolean matches(Class targetClass) { // checkReadyToMatch(); // return pointcutExpression.couldMatchJoinPointsInType(targetClass); // } // // @Override // public boolean matches(Method method, Class targetClass) { // checkReadyToMatch(); // ShadowMatch shadowMatch = pointcutExpression.matchesMethodExecution(method); // if (shadowMatch.alwaysMatches()) { // return true; // } else if (shadowMatch.neverMatches()) { // return false; // } // // TODO:其他情况不判断了!见org.springframework.aop.aspectj.RuntimeTestWalker // return false; // } // // }
import org.junit.Assert; import org.junit.Test; import com.ysj.HelloWorldService; import com.ysj.HelloWorldServiceImpl; import com.ysj.tinySpring.aop.AspectJExpressionPointcut;
package com.ysj.aop; /** * @author yihua.huang@dianping.com */ public class AspectJExpressionPointcutTest { @Test public void testClassFilter() throws Exception { String expression = "execution(* us.codecraft.tinyioc.*.*(..))";
// Path: src+/test/java/com/ysj/HelloWorldService.java // public interface HelloWorldService { // // void helloWorld(); // } // // Path: src+/test/java/com/ysj/HelloWorldServiceImpl.java // public class HelloWorldServiceImpl implements HelloWorldService { // // private String text; // // private OutputService outputService; // // @Override // public void helloWorld() { // outputService.output(text); // } // // public void setText(String text) { // this.text = text; // } // // public void setOutputService(OutputService outputService) { // this.outputService = outputService; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/AspectJExpressionPointcut.java // public class AspectJExpressionPointcut implements Pointcut, ClassFilter, MethodMatcher { // // private PointcutParser pointcutParser; // // private String expression; // // private PointcutExpression pointcutExpression; // // private static final Set<PointcutPrimitive> DEFAULT_SUPPORTED_PRIMITIVES = new HashSet<PointcutPrimitive>(); // // static { // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.EXECUTION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.REFERENCE); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.THIS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.TARGET); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ANNOTATION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_TARGET); // } // // public AspectJExpressionPointcut() { // this(DEFAULT_SUPPORTED_PRIMITIVES); // } // // public AspectJExpressionPointcut(Set<PointcutPrimitive> supportedPrimitives) { // pointcutParser = PointcutParser // .getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(supportedPrimitives); // } // // protected void checkReadyToMatch() { // if (pointcutExpression == null) { // pointcutExpression = buildPointcutExpression(); // } // } // // private PointcutExpression buildPointcutExpression() { // return pointcutParser.parsePointcutExpression(expression); // } // // public void setExpression(String expression) { // this.expression = expression; // } // // @Override // public ClassFilter getClassFilter() { // return this; // } // // @Override // public MethodMatcher getMethodMatcher() { // return this; // } // // @Override // public boolean matches(Class targetClass) { // checkReadyToMatch(); // return pointcutExpression.couldMatchJoinPointsInType(targetClass); // } // // @Override // public boolean matches(Method method, Class targetClass) { // checkReadyToMatch(); // ShadowMatch shadowMatch = pointcutExpression.matchesMethodExecution(method); // if (shadowMatch.alwaysMatches()) { // return true; // } else if (shadowMatch.neverMatches()) { // return false; // } // // TODO:其他情况不判断了!见org.springframework.aop.aspectj.RuntimeTestWalker // return false; // } // // } // Path: src+/test/java/com/ysj/aop/AspectJExpressionPointcutTest.java import org.junit.Assert; import org.junit.Test; import com.ysj.HelloWorldService; import com.ysj.HelloWorldServiceImpl; import com.ysj.tinySpring.aop.AspectJExpressionPointcut; package com.ysj.aop; /** * @author yihua.huang@dianping.com */ public class AspectJExpressionPointcutTest { @Test public void testClassFilter() throws Exception { String expression = "execution(* us.codecraft.tinyioc.*.*(..))";
AspectJExpressionPointcut aspectJExpressionPointcut = new AspectJExpressionPointcut();
code4craft/tiny-spring
src+/test/java/com/ysj/aop/AspectJExpressionPointcutTest.java
// Path: src+/test/java/com/ysj/HelloWorldService.java // public interface HelloWorldService { // // void helloWorld(); // } // // Path: src+/test/java/com/ysj/HelloWorldServiceImpl.java // public class HelloWorldServiceImpl implements HelloWorldService { // // private String text; // // private OutputService outputService; // // @Override // public void helloWorld() { // outputService.output(text); // } // // public void setText(String text) { // this.text = text; // } // // public void setOutputService(OutputService outputService) { // this.outputService = outputService; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/AspectJExpressionPointcut.java // public class AspectJExpressionPointcut implements Pointcut, ClassFilter, MethodMatcher { // // private PointcutParser pointcutParser; // // private String expression; // // private PointcutExpression pointcutExpression; // // private static final Set<PointcutPrimitive> DEFAULT_SUPPORTED_PRIMITIVES = new HashSet<PointcutPrimitive>(); // // static { // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.EXECUTION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.REFERENCE); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.THIS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.TARGET); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ANNOTATION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_TARGET); // } // // public AspectJExpressionPointcut() { // this(DEFAULT_SUPPORTED_PRIMITIVES); // } // // public AspectJExpressionPointcut(Set<PointcutPrimitive> supportedPrimitives) { // pointcutParser = PointcutParser // .getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(supportedPrimitives); // } // // protected void checkReadyToMatch() { // if (pointcutExpression == null) { // pointcutExpression = buildPointcutExpression(); // } // } // // private PointcutExpression buildPointcutExpression() { // return pointcutParser.parsePointcutExpression(expression); // } // // public void setExpression(String expression) { // this.expression = expression; // } // // @Override // public ClassFilter getClassFilter() { // return this; // } // // @Override // public MethodMatcher getMethodMatcher() { // return this; // } // // @Override // public boolean matches(Class targetClass) { // checkReadyToMatch(); // return pointcutExpression.couldMatchJoinPointsInType(targetClass); // } // // @Override // public boolean matches(Method method, Class targetClass) { // checkReadyToMatch(); // ShadowMatch shadowMatch = pointcutExpression.matchesMethodExecution(method); // if (shadowMatch.alwaysMatches()) { // return true; // } else if (shadowMatch.neverMatches()) { // return false; // } // // TODO:其他情况不判断了!见org.springframework.aop.aspectj.RuntimeTestWalker // return false; // } // // }
import org.junit.Assert; import org.junit.Test; import com.ysj.HelloWorldService; import com.ysj.HelloWorldServiceImpl; import com.ysj.tinySpring.aop.AspectJExpressionPointcut;
package com.ysj.aop; /** * @author yihua.huang@dianping.com */ public class AspectJExpressionPointcutTest { @Test public void testClassFilter() throws Exception { String expression = "execution(* us.codecraft.tinyioc.*.*(..))"; AspectJExpressionPointcut aspectJExpressionPointcut = new AspectJExpressionPointcut(); aspectJExpressionPointcut.setExpression(expression);
// Path: src+/test/java/com/ysj/HelloWorldService.java // public interface HelloWorldService { // // void helloWorld(); // } // // Path: src+/test/java/com/ysj/HelloWorldServiceImpl.java // public class HelloWorldServiceImpl implements HelloWorldService { // // private String text; // // private OutputService outputService; // // @Override // public void helloWorld() { // outputService.output(text); // } // // public void setText(String text) { // this.text = text; // } // // public void setOutputService(OutputService outputService) { // this.outputService = outputService; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/AspectJExpressionPointcut.java // public class AspectJExpressionPointcut implements Pointcut, ClassFilter, MethodMatcher { // // private PointcutParser pointcutParser; // // private String expression; // // private PointcutExpression pointcutExpression; // // private static final Set<PointcutPrimitive> DEFAULT_SUPPORTED_PRIMITIVES = new HashSet<PointcutPrimitive>(); // // static { // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.EXECUTION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.REFERENCE); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.THIS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.TARGET); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ANNOTATION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_TARGET); // } // // public AspectJExpressionPointcut() { // this(DEFAULT_SUPPORTED_PRIMITIVES); // } // // public AspectJExpressionPointcut(Set<PointcutPrimitive> supportedPrimitives) { // pointcutParser = PointcutParser // .getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(supportedPrimitives); // } // // protected void checkReadyToMatch() { // if (pointcutExpression == null) { // pointcutExpression = buildPointcutExpression(); // } // } // // private PointcutExpression buildPointcutExpression() { // return pointcutParser.parsePointcutExpression(expression); // } // // public void setExpression(String expression) { // this.expression = expression; // } // // @Override // public ClassFilter getClassFilter() { // return this; // } // // @Override // public MethodMatcher getMethodMatcher() { // return this; // } // // @Override // public boolean matches(Class targetClass) { // checkReadyToMatch(); // return pointcutExpression.couldMatchJoinPointsInType(targetClass); // } // // @Override // public boolean matches(Method method, Class targetClass) { // checkReadyToMatch(); // ShadowMatch shadowMatch = pointcutExpression.matchesMethodExecution(method); // if (shadowMatch.alwaysMatches()) { // return true; // } else if (shadowMatch.neverMatches()) { // return false; // } // // TODO:其他情况不判断了!见org.springframework.aop.aspectj.RuntimeTestWalker // return false; // } // // } // Path: src+/test/java/com/ysj/aop/AspectJExpressionPointcutTest.java import org.junit.Assert; import org.junit.Test; import com.ysj.HelloWorldService; import com.ysj.HelloWorldServiceImpl; import com.ysj.tinySpring.aop.AspectJExpressionPointcut; package com.ysj.aop; /** * @author yihua.huang@dianping.com */ public class AspectJExpressionPointcutTest { @Test public void testClassFilter() throws Exception { String expression = "execution(* us.codecraft.tinyioc.*.*(..))"; AspectJExpressionPointcut aspectJExpressionPointcut = new AspectJExpressionPointcut(); aspectJExpressionPointcut.setExpression(expression);
boolean matches = aspectJExpressionPointcut.getClassFilter().matches(HelloWorldService.class);
code4craft/tiny-spring
src+/test/java/com/ysj/aop/AspectJExpressionPointcutTest.java
// Path: src+/test/java/com/ysj/HelloWorldService.java // public interface HelloWorldService { // // void helloWorld(); // } // // Path: src+/test/java/com/ysj/HelloWorldServiceImpl.java // public class HelloWorldServiceImpl implements HelloWorldService { // // private String text; // // private OutputService outputService; // // @Override // public void helloWorld() { // outputService.output(text); // } // // public void setText(String text) { // this.text = text; // } // // public void setOutputService(OutputService outputService) { // this.outputService = outputService; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/AspectJExpressionPointcut.java // public class AspectJExpressionPointcut implements Pointcut, ClassFilter, MethodMatcher { // // private PointcutParser pointcutParser; // // private String expression; // // private PointcutExpression pointcutExpression; // // private static final Set<PointcutPrimitive> DEFAULT_SUPPORTED_PRIMITIVES = new HashSet<PointcutPrimitive>(); // // static { // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.EXECUTION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.REFERENCE); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.THIS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.TARGET); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ANNOTATION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_TARGET); // } // // public AspectJExpressionPointcut() { // this(DEFAULT_SUPPORTED_PRIMITIVES); // } // // public AspectJExpressionPointcut(Set<PointcutPrimitive> supportedPrimitives) { // pointcutParser = PointcutParser // .getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(supportedPrimitives); // } // // protected void checkReadyToMatch() { // if (pointcutExpression == null) { // pointcutExpression = buildPointcutExpression(); // } // } // // private PointcutExpression buildPointcutExpression() { // return pointcutParser.parsePointcutExpression(expression); // } // // public void setExpression(String expression) { // this.expression = expression; // } // // @Override // public ClassFilter getClassFilter() { // return this; // } // // @Override // public MethodMatcher getMethodMatcher() { // return this; // } // // @Override // public boolean matches(Class targetClass) { // checkReadyToMatch(); // return pointcutExpression.couldMatchJoinPointsInType(targetClass); // } // // @Override // public boolean matches(Method method, Class targetClass) { // checkReadyToMatch(); // ShadowMatch shadowMatch = pointcutExpression.matchesMethodExecution(method); // if (shadowMatch.alwaysMatches()) { // return true; // } else if (shadowMatch.neverMatches()) { // return false; // } // // TODO:其他情况不判断了!见org.springframework.aop.aspectj.RuntimeTestWalker // return false; // } // // }
import org.junit.Assert; import org.junit.Test; import com.ysj.HelloWorldService; import com.ysj.HelloWorldServiceImpl; import com.ysj.tinySpring.aop.AspectJExpressionPointcut;
package com.ysj.aop; /** * @author yihua.huang@dianping.com */ public class AspectJExpressionPointcutTest { @Test public void testClassFilter() throws Exception { String expression = "execution(* us.codecraft.tinyioc.*.*(..))"; AspectJExpressionPointcut aspectJExpressionPointcut = new AspectJExpressionPointcut(); aspectJExpressionPointcut.setExpression(expression); boolean matches = aspectJExpressionPointcut.getClassFilter().matches(HelloWorldService.class); Assert.assertTrue(matches); } @Test public void testMethodInterceptor() throws Exception { String expression = "execution(* com.ysj.*.*(..))"; AspectJExpressionPointcut aspectJExpressionPointcut = new AspectJExpressionPointcut(); aspectJExpressionPointcut.setExpression(expression); boolean matches = aspectJExpressionPointcut.getMethodMatcher()
// Path: src+/test/java/com/ysj/HelloWorldService.java // public interface HelloWorldService { // // void helloWorld(); // } // // Path: src+/test/java/com/ysj/HelloWorldServiceImpl.java // public class HelloWorldServiceImpl implements HelloWorldService { // // private String text; // // private OutputService outputService; // // @Override // public void helloWorld() { // outputService.output(text); // } // // public void setText(String text) { // this.text = text; // } // // public void setOutputService(OutputService outputService) { // this.outputService = outputService; // } // // } // // Path: src+/main/java/com/ysj/tinySpring/aop/AspectJExpressionPointcut.java // public class AspectJExpressionPointcut implements Pointcut, ClassFilter, MethodMatcher { // // private PointcutParser pointcutParser; // // private String expression; // // private PointcutExpression pointcutExpression; // // private static final Set<PointcutPrimitive> DEFAULT_SUPPORTED_PRIMITIVES = new HashSet<PointcutPrimitive>(); // // static { // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.EXECUTION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.REFERENCE); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.THIS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.TARGET); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ANNOTATION); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_WITHIN); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ARGS); // DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_TARGET); // } // // public AspectJExpressionPointcut() { // this(DEFAULT_SUPPORTED_PRIMITIVES); // } // // public AspectJExpressionPointcut(Set<PointcutPrimitive> supportedPrimitives) { // pointcutParser = PointcutParser // .getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(supportedPrimitives); // } // // protected void checkReadyToMatch() { // if (pointcutExpression == null) { // pointcutExpression = buildPointcutExpression(); // } // } // // private PointcutExpression buildPointcutExpression() { // return pointcutParser.parsePointcutExpression(expression); // } // // public void setExpression(String expression) { // this.expression = expression; // } // // @Override // public ClassFilter getClassFilter() { // return this; // } // // @Override // public MethodMatcher getMethodMatcher() { // return this; // } // // @Override // public boolean matches(Class targetClass) { // checkReadyToMatch(); // return pointcutExpression.couldMatchJoinPointsInType(targetClass); // } // // @Override // public boolean matches(Method method, Class targetClass) { // checkReadyToMatch(); // ShadowMatch shadowMatch = pointcutExpression.matchesMethodExecution(method); // if (shadowMatch.alwaysMatches()) { // return true; // } else if (shadowMatch.neverMatches()) { // return false; // } // // TODO:其他情况不判断了!见org.springframework.aop.aspectj.RuntimeTestWalker // return false; // } // // } // Path: src+/test/java/com/ysj/aop/AspectJExpressionPointcutTest.java import org.junit.Assert; import org.junit.Test; import com.ysj.HelloWorldService; import com.ysj.HelloWorldServiceImpl; import com.ysj.tinySpring.aop.AspectJExpressionPointcut; package com.ysj.aop; /** * @author yihua.huang@dianping.com */ public class AspectJExpressionPointcutTest { @Test public void testClassFilter() throws Exception { String expression = "execution(* us.codecraft.tinyioc.*.*(..))"; AspectJExpressionPointcut aspectJExpressionPointcut = new AspectJExpressionPointcut(); aspectJExpressionPointcut.setExpression(expression); boolean matches = aspectJExpressionPointcut.getClassFilter().matches(HelloWorldService.class); Assert.assertTrue(matches); } @Test public void testMethodInterceptor() throws Exception { String expression = "execution(* com.ysj.*.*(..))"; AspectJExpressionPointcut aspectJExpressionPointcut = new AspectJExpressionPointcut(); aspectJExpressionPointcut.setExpression(expression); boolean matches = aspectJExpressionPointcut.getMethodMatcher()
.matches(HelloWorldServiceImpl.class.getDeclaredMethod("helloWorld"), HelloWorldServiceImpl.class);