blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
131 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
32 values
content
stringlengths
3
9.45M
authors
sequencelengths
1
1
author_id
stringlengths
0
313
ed673b4b0f2946efc9d55ef573f3334aa20d1f47
76db7db6a4016595000086c3e3a2ec94dbd841a0
/src/main/java/com/studentmicroservice/StudentService/student/StudentController.java
619dbff3eda1080cc72ed585ef2a459d5cf5a4aa
[ "MIT" ]
permissive
jacobespana/student-service
9d94b9bdfc6d7cb0300426f954b39e19f2d89aa8
3e52389f7d9fbe1d5927a55c966b8d067c76b543
refs/heads/master
2020-04-28T17:59:44.616080
2019-03-13T20:55:03
2019-03-13T20:55:03
175,464,088
0
0
null
null
null
null
UTF-8
Java
false
false
1,502
java
package com.studentmicroservice.StudentService.student; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @RestController public class StudentController { @Autowired private StudentService studentService; @GetMapping("/students") public List<Student> retrieveAllStudents() { return studentService.retrieveAllStudents(); } @GetMapping("/students/{id}") public Student retrieveStudent(@PathVariable long id) throws Exception { return studentService.retrieveStudent(id); } @DeleteMapping("/students/{id}") public void deleteStudent(@PathVariable long id) { studentService.deleteStudent(id); } @PostMapping("/students") public ResponseEntity<Object> createStudent(@RequestBody Student student) throws Exception { return studentService.createStudent(student); } @PutMapping("/students/{id}") public ResponseEntity<Object> updateStudent(@RequestBody Student student, @PathVariable long id) { return studentService.updateStudent(student, id); } }
3e1fe21359b4a03493a4957acd373ae51c6fba41
62b7683dc011f43062ba92bafbfa1daea06b2f20
/src/main/java/isahasa/htmlmarchaller/hasa/Italic.java
022def66dd5750af23c8326ad45c35db050742cb
[]
no_license
ibrone/training-solutions
cf44150388437ab6173331d26e1521fde1cd9d9f
60b5be73bc24b911e2ac0c6eebf8c6c4c60bcbcc
refs/heads/master
2023-03-11T03:11:15.928962
2021-02-26T18:25:40
2021-02-26T18:25:40
308,020,478
0
0
null
null
null
null
UTF-8
Java
false
false
324
java
package isahasa.htmlmarchaller.hasa; import isahasa.htmlmarchaller.TextSource; public class Italic extends TextDecorator { public Italic(TextSource textSource) { super(textSource); } @Override public String getPlainText() { return "<i>" + getTextSource().getPlainText() + "</i>"; } }
ab328b930c27188aa5fa7b0ae8e3dd21bb32b2e3
329aea3d0a12233691abfdd25973fc4aec975dca
/TextDisplayWindow.java
0b269263f931b1e8ddb3ae8ae2d8bc14ba5dfc73
[ "BSD-3-Clause" ]
permissive
hamish222/ECrypt
d59dbb3f9da60b5c4e93fec191f083e45f3d4f3b
d1e902e42a24c6f3c1c22703b8c24dcf40f1ddca
refs/heads/master
2021-01-22T01:42:39.202219
2016-09-16T17:24:15
2016-09-16T17:24:15
68,398,977
2
0
null
null
null
null
UTF-8
Java
false
false
8,959
java
import java.awt.Color; import java.awt.Font; import java.awt.Point; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.border.BevelBorder; import javax.swing.border.Border; import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileNameExtensionFilter; public class TextDisplayWindow extends JFrame{ TextDisplayWindow me = this; //public ViewButtonListener buttonListener = new ViewButtonListener(); public JTextArea text = new JTextArea(10,50); private JScrollPane pane = new JScrollPane(text); // create a menu bar and use it in this JFrame JMenuBar menuBar = new JMenuBar( ); static String filePath=null; // Constructor public TextDisplayWindow(String title, int yLoc){ Font font = new Font("Courier", Font.PLAIN, 12); // Font settings: PLAIN, BOLD, ITALIC setIconImage(MainWindow.ECryptIcon.getImage()); setSize(580,300); setTitle(title); // create the File menu JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); // file reading and writing JMenuItem clearText = new JMenuItem("Clear"); JMenuItem cleanText = new JMenuItem("Clean"); JMenuItem openFile = new JMenuItem("Open"); JMenuItem saveFile = new JMenuItem("Save"); fileMenu.add(clearText); fileMenu.add(cleanText); fileMenu.addSeparator( ); fileMenu.add(openFile); fileMenu.add(saveFile); clearText.addActionListener(new ClearListener()); cleanText.addActionListener(new CleanListener()); saveFile.addActionListener(new ActionListener( ) { public void actionPerformed(ActionEvent e) { savefile(text.getText()); } }); openFile.addActionListener(new OpenFileListener()); menuBar.add(fileMenu); menuBar.add(makeAnalysisMenu()); setJMenuBar(menuBar); add(pane); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setLocation(200,yLoc); text.setFont(font); text.setForeground(Color.BLACK); // Colors: BLACK, BLUE, CYAN, DARK_GRAY, GRAY, GREEN, LIGHT_GRAY, MAGENTA, ORANGE, PINK, RED, WHITE, YELLOW text.setBackground(Color.LIGHT_GRAY); text.setLineWrap(true); setVisible(false); } public JMenu makeAnalysisMenu(){ JMenu analyzeMenu = new JMenu("Analysis"); JMenuItem highlightText = new JMenuItem("Highlight Text"); JMenuItem monographFreq = new JMenuItem("Monograph Frequencies"); JMenuItem polygraphFreq = new JMenuItem("Polygraph Frequencies"); JMenuItem kasiskiTest = new JMenuItem("Kasiski Test"); JMenuItem IoC = new JMenuItem("Index of Coincidence"); JMenuItem Friedman = new JMenuItem("Friedman's Formula"); analyzeMenu.add(highlightText); highlightText.addActionListener(new HighlightTextActionListener()); analyzeMenu.addSeparator(); analyzeMenu.add(monographFreq); monographFreq.addActionListener(new MonographActionListener()); analyzeMenu.add(polygraphFreq); polygraphFreq.addActionListener(new PolygraphActionListener()); analyzeMenu.add(kasiskiTest); kasiskiTest.addActionListener(new KasiskiActionListener()); analyzeMenu.add(IoC); IoC.addActionListener(new IoCActionListener()); analyzeMenu.add(Friedman); Friedman.addActionListener(new FriedmanActionListener()); //analyzeText.addActionListener(new AnalyzeListener()); return analyzeMenu; } public void changeTitle(String newTitle){ setTitle(newTitle); } private class OpenFileListener implements ActionListener{ public void actionPerformed(ActionEvent e) { String in = readFile(); if (in!="CANCEL") text.setText(in); } } /* public class ViewButtonListener implements ActionListener{ public void actionPerformed(ActionEvent e){ setVisible(true); } } */ private class ClearListener implements ActionListener{ public void actionPerformed(ActionEvent e){ text.setText(""); } } private class CleanListener implements ActionListener{ public void actionPerformed(ActionEvent e){ text.setText(MainWindow.cleanText(text.getText())); } } public class HighlightTextActionListener implements ActionListener{ public void actionPerformed(ActionEvent e){ int xLoc, yLoc; Point temp = getContentPane().getLocationOnScreen(); xLoc = (int)Math.round(temp.getX()); xLoc = xLoc + 572; yLoc = (int)Math.round(temp.getY()); yLoc = yLoc - 53; new HighlightText(getTitle(), text, xLoc, yLoc); } } public class MonographActionListener implements ActionListener{ public void actionPerformed(ActionEvent e){ int xLoc, yLoc; Point temp = getContentPane().getLocationOnScreen(); xLoc = (int)Math.round(temp.getX()); xLoc = xLoc + 572; yLoc = (int)Math.round(temp.getY()); yLoc = yLoc - 53; new Monograph(getTitle(),text,xLoc,yLoc); } } public class PolygraphActionListener implements ActionListener{ public void actionPerformed(ActionEvent e){ int xLoc, yLoc; Point temp = getContentPane().getLocationOnScreen(); xLoc = (int)Math.round(temp.getX()); xLoc = xLoc + 572; yLoc = (int)Math.round(temp.getY()); yLoc = yLoc - 53; new Polygraph(getTitle(),text,xLoc,yLoc); } } public class KasiskiActionListener implements ActionListener{ public void actionPerformed(ActionEvent e){ int xLoc, yLoc; Point temp = getContentPane().getLocationOnScreen(); xLoc = (int)Math.round(temp.getX()); xLoc = xLoc + 572; yLoc = (int)Math.round(temp.getY()); yLoc = yLoc - 53; new Kasiski(getTitle(),text,xLoc,yLoc); } } public class IoCActionListener implements ActionListener{ public void actionPerformed(ActionEvent e){ int xLoc, yLoc; Point temp = getContentPane().getLocationOnScreen(); xLoc = (int)Math.round(temp.getX()); xLoc = xLoc + 572; yLoc = (int)Math.round(temp.getY()); yLoc = yLoc - 53; new IoC(getTitle(),text,xLoc,yLoc); } } public class FriedmanActionListener implements ActionListener{ public void actionPerformed(ActionEvent e){ int xLoc, yLoc; Point temp = getContentPane().getLocationOnScreen(); xLoc = (int)Math.round(temp.getX()); xLoc = xLoc + 572; yLoc = (int)Math.round(temp.getY()); yLoc = yLoc - 53; new Friedman(getTitle(),text,xLoc,yLoc); } } protected String readFile() { final JFileChooser fc = new JFileChooser(filePath); final FileFilter filter = new FileNameExtensionFilter("Text Files", "txt"); String text=""; fc.addChoosableFileFilter(filter); // int returnVal = fc.showDialog(getParent(),"Save"); int returnVal = fc.showOpenDialog(me); File file = fc.getSelectedFile(); try { filePath = file.getPath(); } catch (NullPointerException e){ return "CANCEL"; } if(returnVal == JFileChooser.APPROVE_OPTION) { try { BufferedReader reader = new BufferedReader(new FileReader(filePath)); String line; while((line = reader.readLine())!= null) { text+=line; text+='\n'; } reader.close(); } catch (IOException e1) { JOptionPane.showMessageDialog(null, "Error reading the selected file, " + file.getPath(),"Error",JOptionPane.ERROR_MESSAGE); //e1.printStackTrace(); } } else if (returnVal != JFileChooser.CANCEL_OPTION) JOptionPane.showMessageDialog(null, "Error locating the selected file " + file.getPath(),"Error",JOptionPane.ERROR_MESSAGE); return text; } protected void savefile(String text) { final JFileChooser fc = new JFileChooser(filePath); final FileFilter filter = new FileNameExtensionFilter("Text Files", "txt"); fc.addChoosableFileFilter(filter); // int returnVal = fc.showSaveDialog(getParent()); int returnVal = fc.showSaveDialog(me); File file = fc.getSelectedFile(); try { filePath = file.getPath(); } catch (NullPointerException e){ return; } String ext; if (filePath.length()>3) ext = filePath.substring(filePath.length()-4,filePath.length()); else ext=""; if (!ext.equals(".txt")) filePath += ".txt"; //System.out.println("Saving: "+filePath); if(returnVal == JFileChooser.APPROVE_OPTION) { try { BufferedWriter writer = new BufferedWriter(new FileWriter(filePath)); writer.write(text); writer.close(); } catch (IOException e1) { JOptionPane.showMessageDialog(null, "Error writing to the selected file, " + file.getPath(),"Error",JOptionPane.ERROR_MESSAGE); //e1.printStackTrace(); } } else if (returnVal != JFileChooser.CANCEL_OPTION) JOptionPane.showMessageDialog(null, "Error locating the selected file " + file.getPath(),"Error",JOptionPane.ERROR_MESSAGE); } }
c7afa33c649b5eb47bab1e426c511644db627707
cb4041fe45b3cab7fb845424228d9443672e8071
/netty-server-sdk/src/main/java/com/pb/server/sdk/pusher/PBMessagePusher.java
a3b3559d6aac5fbc3491440fe29d8dcc3b4d160f
[]
no_license
piecebook/netty-server-app
d12157435f9926b5064ea5805ed2e17d88955815
46322e73b535f2c01658e3a4bfdcfa38325c462b
refs/heads/master
2020-09-22T20:32:17.386616
2016-11-11T15:30:50
2016-11-11T15:30:50
66,820,141
0
1
null
null
null
null
UTF-8
Java
false
false
1,691
java
package com.pb.server.sdk.pusher; import com.pb.server.cache.redisUtil.RedisUtil; import com.pb.server.sdk.MessageFactory.OfflineMessageManager; import com.pb.server.sdk.session.PBSession; import com.pb.server.sdk.session.PBSessionManage; import com.pb.server.sdk.util.ContexHolder; import pb.server.dao.model.Message; /** * Created by piecebook on 2016/8/8. */ /** * 该类处理 所有 服务端推送给客户端的消息 */ public class PBMessagePusher implements MessagePusher { /** * * @param msg 需要发送的消息体 * * 功能:将消息推送到接收用户的 */ @Override public String push(Message msg) { PBSessionManage sessionManager = (PBSessionManage) ContexHolder.getBean("sessionManager"); PBSession receiver_session = sessionManager.get(msg.get("r_uid"));//得到接收用户连接的session if(receiver_session == null){ //用户不在线 ((OfflineMessageManager) ContexHolder.getBean("offlineMessageManager")).add(msg); return "fl"; }else { //用户在线 String msg_key = msg.get("s_uid")+ "-" + msg.getMsg_id(); //msg.setTime(System.currentTimeMillis()); //把时间放进消息体传输 msg.setParam("tm", msg.getTime().toString()); //MessageHolder.send_messages.put(msg_key,msg); RedisUtil redisUtil = (RedisUtil) ContexHolder.getBean("redisUtil"); redisUtil.list_right_push("message_mysql_list", msg); redisUtil.setForAHashMap("message", msg_key, msg); receiver_session.write(msg); return "sc"; } } }
cc10170e041b097fbf7b4b30442062c38700dba4
e5f262b89b272ef7c24edb74d165c9b8ec8f20e4
/Douwei Solutions/WhatIsTheNthBit.java
22655b6a7f0a6a7d8ed7eab98bec5c843da5b348
[]
no_license
magicalsoup/Competitive-Programming-Solutions-Library
289b9b891589cb773da0295274246b18e1334fd7
edcc6928e74c82edd8546aefb118bacc15efe10e
refs/heads/master
2023-01-13T19:52:30.773734
2022-12-27T21:13:30
2022-12-27T21:13:30
134,091,852
37
18
null
2018-05-20T14:34:53
2018-05-19T19:26:33
Java
UTF-8
Java
false
false
446
java
package Douwei; import java.util.Scanner; public class WhatIsTheNthBit{ public static void isKthBitSet(int n,int k) { if ((n & (1 << (k-1))) >= 1) System.out.print( "1" ); else System.out.print( "0" ); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), k = sc.nextInt(); isKthBitSet(n , k); } }
bdfa305fba9c4dacbd9bb41cea437de654db8e7a
03b424e7be8a091f034725388599f5310aa56446
/src/sample/Main.java
0de8e8a74208339e3173195d5f0dd83158446682
[]
no_license
3levate/BetterWordFinal
b9f1bed27e966ecfe9e3f939fca9831421dd6343
70f046e423bf1e5628c892189f83468b12c91acd
refs/heads/master
2023-06-04T05:19:59.357400
2021-06-17T22:04:54
2021-06-17T22:04:54
377,014,032
0
0
null
null
null
null
UTF-8
Java
false
false
1,044
java
package sample; import javafx.application.Application; import javafx.concurrent.Task; import javafx.concurrent.WorkerStateEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.MenuBar; import javafx.scene.control.TextArea; import javafx.scene.input.KeyEvent; import javafx.scene.layout.BorderPane; import javafx.scene.layout.GridPane; import javafx.stage.Stage; import java.io.IOException; import java.util.Scanner; public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception{ Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); // root.getStylesheets().add("package/css1.css"); primaryStage.setTitle("BetterWord"); Scene scene = new Scene(root, 1920, 1080); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
f9accde2d97fd3105ed5b697845749d9fdabb492
d4d18123d3bc92e169f323c3f037ad4e09db563a
/app/src/main/java/com/example/publictransport/Line.java
87de2f87a9e9114896c433e389de3e6619b0661c
[]
no_license
sarah-salaheldeen/Public-Transport
e83ee142c898e6423a10d2bc79819742cf907a49
d2fa9008a8bad8ca98111624a793794ceb67a36d
refs/heads/master
2020-11-28T20:15:50.544443
2020-06-30T07:44:59
2020-06-30T07:44:59
223,138,737
1
0
null
null
null
null
UTF-8
Java
false
false
2,162
java
package com.example.publictransport; import org.neo4j.driver.types.Point; import java.util.List; public class Line { private Point startStation; private Point endStation; private List<Point> line1WayPoints; private List<Point> line2WayPoints; private String line1Name; private String line2Name; private String line1Fees; private String line2Fees; private Double line1Distance; private Long line1Duration; private Double line2Distance; private Long line2Duration; public Line(Point startStation, Point endStation, List<Point> line1WayPoints, Double line1Distance, Long line1Duration, List<Point> line2WayPoints, String line1Name, String line2Name, String line1Fees, String line2Fees, Double line2Distance, Long line2Duration) { this.startStation = startStation; this.endStation = endStation; this.line1WayPoints = line1WayPoints; this.line2WayPoints = line2WayPoints; this.line1Name = line1Name; this.line2Name = line2Name; this.line1Fees = line1Fees; this.line2Fees = line2Fees; this.line1Distance = line1Distance; this.line1Duration = line1Duration; this.line2Distance = line2Distance; this.line2Duration = line2Duration; } public Point getStartStation() { return startStation; } public Point getEndStation() { return endStation; } public List<Point> getLine1WayPoints(){ return line1WayPoints; } public List<Point> getLine2WayPoints(){ return line2WayPoints; } public String getLine1Name() { return line1Name; } public String getLine2Name() { return line2Name; } public String getLine1Fees() { return line1Fees; } public String getLine2Fees() { return line2Fees; } public Double getLine1Distance() { return line1Distance; } public Long getLine1Duration() { return line1Duration; } public Double getLine2Distance() { return line2Distance; } public Long getLine2Duration() { return line2Duration; } }
430a563b5a8cb03ef83c4454c6004bfb2bdd14f5
f7453885a521e776ec53a47f8c18e2509eb6578f
/src/com/ruslanito/Core/Core_String_Char/String_Split.java
f768fa16445ce7f45aa921c0989b168ea2b1a65f
[]
no_license
Ruslanito/JavaX
e22953b2e091c5f6835ea0baf32772f4c31ffd8e
c1598c30c13c08e9c1f950a76e2c334afc69fd86
refs/heads/master
2020-03-21T08:27:31.952745
2018-08-24T14:07:27
2018-08-24T14:07:27
138,344,964
1
0
null
null
null
null
UTF-8
Java
false
false
411
java
package com.ruslanito.Core.Core_String_Char; /** * Created by Ruslanito on 25.02.2017. */ public class String_Split { public static void main(String[] args) { String s = "мама мыла раму"; System.out.println(s); String s1[] = s.split(""); int a = s.length(); for (int i=0; i<a;i++){ System.out.println("s1["+i+"]="+s1[i]); } } }
6969a6a7cda4185a06cb3d5360075678c218657b
d6dce0e3b0c5f3c055fdcbd72f8dacb10a78dc08
/src/main/java/com/fresherfinal/dao/FilesRepository.java
e4f59f32803454813bf1b6956c5bb2a89c77cc52
[]
no_license
nganle2701/CSC-mini-files-sharing
7ebf6f19297d5dc4d7ab4c4743c55ee8bdfdc1a7
42e30b835f38359f7950a0e107913818a9641627
refs/heads/master
2021-01-17T20:20:19.574078
2017-03-06T10:03:32
2017-03-06T10:03:32
null
0
0
null
null
null
null
UTF-8
Java
false
false
207
java
package com.fresherfinal.dao; import org.springframework.data.jpa.repository.JpaRepository; import com.fresherfinal.dto.Files; public interface FilesRepository extends JpaRepository<Files, Integer> { }
249264669f9d74d124bf91f3a7bcb2c824f5bae2
ec897c1152f53fa1efe994e7842cb73d5bd82d08
/mdgen/src/hamy/mdgen/api/generator/format/aseXML/RebateType.java
cafe889066142e037a0464d031d8a95260165e75
[ "MIT" ]
permissive
hemantmurthy/mdgen
4b69e5f6805526bd35a532c1c61610dae052ad78
31333e4d7687526103d08b6f6772a1805cd12c7a
refs/heads/master
2020-12-27T22:16:34.251746
2020-06-11T00:21:10
2020-06-11T00:21:10
238,079,485
0
0
null
null
null
null
UTF-8
Java
false
false
1,900
java
// // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2020.03.18 at 10:36:34 AM AEDT // package hamy.mdgen.api.generator.format.aseXML; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for RebateType. * * <p>The following schema fragment specifies the expected content contained within this class. * <p> * <pre> * &lt;simpleType name="RebateType"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string"> * &lt;enumeration value="Pension Card"/> * &lt;enumeration value="Health Care Card"/> * &lt;enumeration value="Health Benefit Card"/> * &lt;enumeration value="Veteran Affairs Card"/> * &lt;/restriction> * &lt;/simpleType> * </pre> * */ @XmlType(name = "RebateType") @XmlEnum public enum RebateType { @XmlEnumValue("Pension Card") PENSION_CARD("Pension Card"), @XmlEnumValue("Health Care Card") HEALTH_CARE_CARD("Health Care Card"), @XmlEnumValue("Health Benefit Card") HEALTH_BENEFIT_CARD("Health Benefit Card"), @XmlEnumValue("Veteran Affairs Card") VETERAN_AFFAIRS_CARD("Veteran Affairs Card"); private final String value; RebateType(String v) { value = v; } public String value() { return value; } public static RebateType fromValue(String v) { for (RebateType c: RebateType.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); } }
3cf5eae38ff1179a4842c911b9b5a884925fb9ee
cb869f7c9af4faca4f857d05f3e8409a879c7e08
/src/main/java/utils/ErrorComputer.java
c0ca1ec67cb681f3de7fe3c385b1b3e81684378c
[]
no_license
Shijia-Guo/Big-data-project
1bba4f7b6ae995d141053af7bd88cab1baada2c8
aea754f059f60b411d55e738eebea03271e5a87e
refs/heads/master
2020-05-03T07:59:44.069466
2019-04-15T20:22:21
2019-04-15T20:22:21
178,513,926
0
0
null
null
null
null
UTF-8
Java
false
false
1,175
java
package utils; import org.apache.spark.api.java.JavaPairRDD; import org.apache.spark.api.java.function.Function; import scala.Tuple2; @SuppressWarnings("serial") public class ErrorComputer { // error: wrong classifications/total classifications // INPUT: predicted, test public double wrongRate(JavaPairRDD<Double, Double> predictionAndLabel){ return 1.0 * predictionAndLabel.filter(new Function<Tuple2<Double, Double>, Boolean>() { public Boolean call(Tuple2<Double, Double> pl) { return !pl._1().equals(pl._2()); } }).count() / predictionAndLabel.count(); } // F=2PR/(P+R) // P=Tp/(Tp+Fp) // R=Tp/(Tp+Fn) // INPUT: predicted, test public double fMeasure(JavaPairRDD<Double, Double> predictionAndLabel){ double tp = 1.0 * predictionAndLabel.filter(w->w._1() == 1.0).filter(pl-> pl._1().equals(pl._2())).count(); double fp = 1.0 * predictionAndLabel.filter(w->w._1() == 1.0).filter(pl-> !pl._1().equals(pl._2()) ).count(); double fn = 1.0 * predictionAndLabel.filter(w->w._1() == 0.0).filter(pl-> !pl._1().equals(pl._2())).count(); //precision and recall double p = tp/(tp+fp); double r = tp/(tp+fn); return 2*p*r/(p+r); } }
6fb1b8ca34b01d6ccc846f43bc282cbae33204d6
573a66e4f4753cc0f145de8d60340b4dd6206607
/JS-CS-Detection-byExample/Dataset (ALERT 5 GB)/817694/guava19/guava-19.0/guava-gwt/test-super/com/google/common/collect/super/com/google/common/collect/ArrayTableTest.java
817ce6847604a07579e39d5b597d79cb788cadca
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
mkaouer/Code-Smells-Detection-in-JavaScript
3919ec0d445637a7f7c5f570c724082d42248e1b
7130351703e19347884f95ce6d6ab1fb4f5cfbff
refs/heads/master
2023-03-09T18:04:26.971934
2022-03-23T22:04:28
2022-03-23T22:04:28
73,915,037
8
3
null
2023-02-28T23:00:07
2016-11-16T11:47:44
null
UTF-8
Java
false
false
14,872
java
/* * Copyright (C) 2009 The Guava Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.google.common.collect; import static com.google.common.truth.Truth.assertThat; import static java.util.Arrays.asList; import com.google.common.annotations.GwtCompatible; import com.google.common.base.Objects; import com.google.common.collect.Table.Cell; import com.google.common.testing.EqualsTester; import com.google.common.testing.SerializableTester; import java.util.Arrays; import java.util.Map; /** * Test cases for {@link ArrayTable}. * * @author Jared Levy */ @GwtCompatible(emulated = true) public class ArrayTableTest extends AbstractTableTest { @Override protected ArrayTable<String, Integer, Character> create( Object... data) { // TODO: Specify different numbers of rows and columns, to detect problems // that arise when the wrong size is used. ArrayTable<String, Integer, Character> table = ArrayTable.create(asList("foo", "bar", "cat"), asList(1, 2, 3)); populate(table, data); return table; } @Override protected void assertSize(int expectedSize) { assertEquals(9, table.size()); } @Override protected boolean supportsRemove() { return false; } @Override protected boolean supportsNullValues() { return true; } // Overriding tests of behavior that differs for ArrayTable. @Override public void testContains() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertTrue(table.contains("foo", 1)); assertTrue(table.contains("bar", 1)); assertTrue(table.contains("foo", 3)); assertTrue(table.contains("foo", 2)); assertTrue(table.contains("bar", 3)); assertTrue(table.contains("cat", 1)); assertFalse(table.contains("foo", -1)); assertFalse(table.contains("bad", 1)); assertFalse(table.contains("bad", -1)); assertFalse(table.contains("foo", null)); assertFalse(table.contains(null, 1)); assertFalse(table.contains(null, null)); } @Override public void testContainsRow() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertTrue(table.containsRow("foo")); assertTrue(table.containsRow("bar")); assertTrue(table.containsRow("cat")); assertFalse(table.containsRow("bad")); assertFalse(table.containsRow(null)); } @Override public void testContainsColumn() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertTrue(table.containsColumn(1)); assertTrue(table.containsColumn(3)); assertTrue(table.containsColumn(2)); assertFalse(table.containsColumn(-1)); assertFalse(table.containsColumn(null)); } @Override public void testContainsValue() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertTrue(table.containsValue('a')); assertTrue(table.containsValue('b')); assertTrue(table.containsValue('c')); assertFalse(table.containsValue('x')); assertTrue(table.containsValue(null)); } @Override public void testIsEmpty() { assertFalse(table.isEmpty()); table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertFalse(table.isEmpty()); } @Override public void testEquals() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); Table<String, Integer, Character> hashCopy = HashBasedTable.create(); hashCopy.put("foo", 1, 'a'); hashCopy.put("bar", 1, 'b'); hashCopy.put("foo", 3, 'c'); Table<String, Integer, Character> reordered = create("foo", 3, 'c', "foo", 1, 'a', "bar", 1, 'b'); Table<String, Integer, Character> smaller = create("foo", 1, 'a', "bar", 1, 'b'); Table<String, Integer, Character> swapOuter = create("bar", 1, 'a', "foo", 1, 'b', "bar", 3, 'c'); Table<String, Integer, Character> swapValues = create("foo", 1, 'c', "bar", 1, 'b', "foo", 3, 'a'); new EqualsTester() .addEqualityGroup(table, reordered) .addEqualityGroup(hashCopy) .addEqualityGroup(smaller) .addEqualityGroup(swapOuter) .addEqualityGroup(swapValues) .testEquals(); } @Override public void testHashCode() { table = ArrayTable.create(asList("foo", "bar"), asList(1, 3)); table.put("foo", 1, 'a'); table.put("bar", 1, 'b'); table.put("foo", 3, 'c'); int expected = Objects.hashCode("foo", 1, 'a') + Objects.hashCode("bar", 1, 'b') + Objects.hashCode("foo", 3, 'c') + Objects.hashCode("bar", 3, 0); assertEquals(expected, table.hashCode()); } @Override public void testRow() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); Map<Integer, Character> expected = Maps.newHashMap(); expected.put(1, 'a'); expected.put(3, 'c'); expected.put(2, null); assertEquals(expected, table.row("foo")); } @Override public void testColumn() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); Map<String, Character> expected = Maps.newHashMap(); expected.put("foo", 'a'); expected.put("bar", 'b'); expected.put("cat", null); assertEquals(expected, table.column(1)); } @Override public void testToStringSize1() { table = ArrayTable.create(ImmutableList.of("foo"), ImmutableList.of(1)); table.put("foo", 1, 'a'); assertEquals("{foo={1=a}}", table.toString()); } public void testCreateDuplicateRows() { try { ArrayTable.create(asList("foo", "bar", "foo"), asList(1, 2, 3)); fail(); } catch (IllegalArgumentException expected) {} } public void testCreateDuplicateColumns() { try { ArrayTable.create(asList("foo", "bar"), asList(1, 2, 3, 2)); fail(); } catch (IllegalArgumentException expected) {} } public void testCreateEmptyRows() { try { ArrayTable.create(Arrays.<String>asList(), asList(1, 2, 3)); fail(); } catch (IllegalArgumentException expected) {} } public void testCreateEmptyColumns() { try { ArrayTable.create(asList("foo", "bar"), Arrays.<Integer>asList()); fail(); } catch (IllegalArgumentException expected) {} } public void testCreateCopyArrayTable() { Table<String, Integer, Character> original = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); Table<String, Integer, Character> copy = ArrayTable.create(original); assertEquals(original, copy); original.put("foo", 1, 'd'); assertEquals((Character) 'd', original.get("foo", 1)); assertEquals((Character) 'a', copy.get("foo", 1)); assertEquals(copy.rowKeySet(), original.rowKeySet()); assertEquals(copy.columnKeySet(), original.columnKeySet()); } public void testCreateCopyHashBasedTable() { Table<String, Integer, Character> original = HashBasedTable.create(); original.put("foo", 1, 'a'); original.put("bar", 1, 'b'); original.put("foo", 3, 'c'); Table<String, Integer, Character> copy = ArrayTable.create(original); assertEquals(4, copy.size()); assertEquals((Character) 'a', copy.get("foo", 1)); assertEquals((Character) 'b', copy.get("bar", 1)); assertEquals((Character) 'c', copy.get("foo", 3)); assertNull(copy.get("bar", 3)); original.put("foo", 1, 'd'); assertEquals((Character) 'd', original.get("foo", 1)); assertEquals((Character) 'a', copy.get("foo", 1)); assertEquals(copy.rowKeySet(), ImmutableSet.of("foo", "bar")); assertEquals(copy.columnKeySet(), ImmutableSet.of(1, 3)); } public void testCreateCopyEmptyTable() { Table<String, Integer, Character> original = HashBasedTable.create(); try { ArrayTable.create(original); fail(); } catch (IllegalArgumentException expected) {} } public void testSerialization() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); SerializableTester.reserializeAndAssert(table); } public void testToString_ordered() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertEquals("{foo={1=a, 2=null, 3=c}, " + "bar={1=b, 2=null, 3=null}, " + "cat={1=null, 2=null, 3=null}}", table.toString()); assertEquals("{foo={1=a, 2=null, 3=c}, " + "bar={1=b, 2=null, 3=null}, " + "cat={1=null, 2=null, 3=null}}", table.rowMap().toString()); } public void testCellSetToString_ordered() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertEquals("[(foo,1)=a, (foo,2)=null, (foo,3)=c, " + "(bar,1)=b, (bar,2)=null, (bar,3)=null, " + "(cat,1)=null, (cat,2)=null, (cat,3)=null]", table.cellSet().toString()); } public void testRowKeySetToString_ordered() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertEquals("[foo, bar, cat]", table.rowKeySet().toString()); } public void testColumnKeySetToString_ordered() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertEquals("[1, 2, 3]", table.columnKeySet().toString()); } public void testValuesToString_ordered() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertEquals("[a, null, c, b, null, null, null, null, null]", table.values().toString()); } public void testRowKeyList() { ArrayTable<String, Integer, Character> table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertThat(table.rowKeyList()).containsExactly("foo", "bar", "cat").inOrder(); } public void testColumnKeyList() { ArrayTable<String, Integer, Character> table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertThat(table.columnKeyList()).containsExactly(1, 2, 3).inOrder(); } public void testGetMissingKeys() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertNull(table.get("dog", 1)); assertNull(table.get("foo", 4)); } public void testAt() { ArrayTable<String, Integer, Character> table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertEquals((Character) 'b', table.at(1, 0)); assertEquals((Character) 'c', table.at(0, 2)); assertNull(table.at(1, 2)); try { table.at(1, 3); fail(); } catch (IndexOutOfBoundsException expected) {} try { table.at(1, -1); fail(); } catch (IndexOutOfBoundsException expected) {} try { table.at(3, 2); fail(); } catch (IndexOutOfBoundsException expected) {} try { table.at(-1, 2); fail(); } catch (IndexOutOfBoundsException expected) {} } public void testSet() { ArrayTable<String, Integer, Character> table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertEquals((Character) 'b', table.set(1, 0, 'd')); assertEquals((Character) 'd', table.get("bar", 1)); assertNull(table.set(2, 0, 'e')); assertEquals((Character) 'e', table.get("cat", 1)); assertEquals((Character) 'a', table.set(0, 0, null)); assertNull(table.get("foo", 1)); try { table.set(1, 3, 'z'); fail(); } catch (IndexOutOfBoundsException expected) {} try { table.set(1, -1, 'z'); fail(); } catch (IndexOutOfBoundsException expected) {} try { table.set(3, 2, 'z'); fail(); } catch (IndexOutOfBoundsException expected) {} try { table.set(-1, 2, 'z'); fail(); } catch (IndexOutOfBoundsException expected) {} assertFalse(table.containsValue('z')); } public void testEraseAll() { ArrayTable<String, Integer, Character> table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); table.eraseAll(); assertEquals(9, table.size()); assertNull(table.get("bar", 1)); assertTrue(table.containsRow("foo")); assertFalse(table.containsValue('a')); } public void testPutIllegal() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); try { table.put("dog", 1, 'd'); fail(); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessage("Row dog not in [foo, bar, cat]"); } try { table.put("foo", 4, 'd'); fail(); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessage("Column 4 not in [1, 2, 3]"); } assertFalse(table.containsValue('d')); } public void testErase() { ArrayTable<String, Integer, Character> table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); assertEquals((Character) 'b', table.erase("bar", 1)); assertNull(table.get("bar", 1)); assertEquals(9, table.size()); assertNull(table.erase("bar", 1)); assertNull(table.erase("foo", 2)); assertNull(table.erase("dog", 1)); assertNull(table.erase("bar", 5)); assertNull(table.erase(null, 1)); assertNull(table.erase("bar", null)); } public void testCellReflectsChanges() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); Cell<String, Integer, Character> cell = table.cellSet().iterator().next(); assertEquals(Tables.immutableCell("foo", 1, 'a'), cell); assertEquals((Character) 'a', table.put("foo", 1, 'd')); assertEquals(Tables.immutableCell("foo", 1, 'd'), cell); } public void testRowMissing() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); Map<Integer, Character> row = table.row("dog"); assertTrue(row.isEmpty()); try { row.put(1, 'd'); fail(); } catch (UnsupportedOperationException expected) {} } public void testColumnMissing() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); Map<String, Character> column = table.column(4); assertTrue(column.isEmpty()); try { column.put("foo", 'd'); fail(); } catch (UnsupportedOperationException expected) {} } public void testRowPutIllegal() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); Map<Integer, Character> map = table.row("foo"); try { map.put(4, 'd'); fail(); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessage("Column 4 not in [1, 2, 3]"); } } public void testColumnPutIllegal() { table = create("foo", 1, 'a', "bar", 1, 'b', "foo", 3, 'c'); Map<String, Character> map = table.column(3); try { map.put("dog", 'd'); fail(); } catch (IllegalArgumentException expected) { assertThat(expected).hasMessage("Row dog not in [foo, bar, cat]"); } } }
d992b4c458506a7d4e1fd80293a1b4910f8afc03
8dd451e223db3d7b38afd386b4aa4217d2c64e10
/workflow/src/test/java/org/destiny/activiti/workflow/ProcessEnginesTest.java
aa95bfa73f17f77e626625797d6c0584dae07a66
[]
no_license
StonesMa/activiti-sample
4692c3a47622a708253a678016ad55a0c3bb05b6
d32d42e3e04cef1d383c7ba81c55bbf064da8729
refs/heads/master
2023-03-22T04:41:53.611989
2019-04-24T07:38:05
2019-04-24T07:38:05
null
0
0
null
null
null
null
UTF-8
Java
false
false
653
java
package org.destiny.activiti.workflow; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngines; import org.junit.Assert; import org.junit.Test; /** * @author wangkang * @version 1.8.0_191 * create by 2019-02-28 16:49 * -------------------------------------------------------------- * <p> * -------------------------------------------------------------- * Copyright: Copyright (c) 2019 */ public class ProcessEnginesTest { @Test public void testGetDefaultProcessEngine() { ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); Assert.assertNotNull(processEngine); } }
5c617ce69c7a1ea96da3b0081059320d367ef312
0c0d22cec5c8173ee7b8a385fbea2fae618b47ca
/android-sdk/src/main/java/io/relayr/api/CloudApi.java
04d3bdc30b252eff8d00d623a9824fd58f45ab5a
[ "MIT" ]
permissive
s-maser/android-sdk
35e39d100eb1ccec5abe5eb8cf21a88d9133323c
17fd15736fa5e81aa2b22ede5a938f77b87af374
refs/heads/master
2021-01-21T18:25:10.530827
2015-06-04T16:44:42
2015-06-04T16:44:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
284
java
package io.relayr.api; import java.util.List; import io.relayr.model.LogEvent; import retrofit.http.Body; import retrofit.http.POST; import rx.Observable; public interface CloudApi { @POST("/client/log") public Observable<Void> logMessage(@Body List<LogEvent> events); }
161256337212dd4e048fce5dc8776e55d7c4cd73
e8a38b730846aa1d0b5c00966e628aa2f71f4644
/src/test/java/org/example/InvoiceTest.java
8b32f6a1c629df95e8898fd06c501a72e1ffdcfa
[]
no_license
madri2000/Progtech_Beadando
36aa670900a9caeb1c4f35eb7f4fd478ee87d78e
f3fcc88d210c739479cc8ba3b1903216348bfa01
refs/heads/main
2023-05-03T03:28:16.996424
2021-05-25T10:24:31
2021-05-25T10:24:31
370,648,274
0
0
null
null
null
null
UTF-8
Java
false
false
756
java
package org.example; import org.junit.Assert; import org.junit.Test; public class InvoiceTest { MainStorage mainStorage = MainStorage.getInstance(); @Test public void GiveInvoice() throws CanNotPayException,UnderMinCostException { Product product = new Product(ProductTypeEnum.BoardGame, "Dixit", 10990); mainStorage.ProductImported(product, new ProductSupplier("Reflex Shop","Budapest","06304558756"), 500); Customer customer = new Customer("Adrienn", "Bárna", 100000, new PersonCustomerStrategy(mainStorage)); Invoice actual = customer.Order(product, customer.getBalance(),4); Invoice expected = new Invoice("Adrienn", "Bárna", 4, product); Assert.assertEquals(expected, actual); } }
365c0ea19e3d729d1a520702707f8677b648f729
53d677a55e4ece8883526738f1c9d00fa6560ff7
/com/tencent/mm/plugin/account/model/a$3.java
735125773b2ffff90c609e9c0060914f6b66306f
[]
no_license
0jinxing/wechat-apk-source
544c2d79bfc10261eb36389c1edfdf553d8f312a
f75eefd87e9b9ecf2f76fc6d48dbba8e24afcf3d
refs/heads/master
2020-06-07T20:06:03.580028
2019-06-21T09:17:26
2019-06-21T09:17:26
193,069,132
9
4
null
null
null
null
UTF-8
Java
false
false
3,417
java
package com.tencent.mm.plugin.account.model; import com.tencent.matrix.trace.core.AppMethodBeat; import com.tencent.mm.ai.m; import com.tencent.mm.ai.p; import com.tencent.mm.kernel.g; import com.tencent.mm.plugin.account.friend.a.al; import com.tencent.mm.plugin.account.friend.a.l; import com.tencent.mm.sdk.platformtools.bo; import java.util.ArrayList; import java.util.List; import java.util.Set; final class a$3 implements com.tencent.mm.plugin.account.a.a.b { a$3(a parama) { } public final void cN(boolean paramBoolean) { AppMethodBeat.i(124656); com.tencent.mm.sdk.platformtools.ab.i("MicroMsg.ContactsAutoSyncLogic ", "performSync end, succ:%b", new Object[] { Boolean.valueOf(paramBoolean) }); if (!paramBoolean) AppMethodBeat.o(124656); while (true) { return; Object localObject; if (l.aqb().size() > 0) { com.tencent.mm.sdk.platformtools.ab.i("MicroMsg.ContactsAutoSyncLogic ", "start to upload mobile list"); g.Rg().a(133, this.gyC); System.currentTimeMillis(); l.apX(); localObject = new al(l.aqb(), l.aqa()); g.Rg().a((m)localObject, 0); AppMethodBeat.o(124656); } else { com.tencent.mm.sdk.platformtools.ab.i("MicroMsg.ContactsAutoSyncLogic ", "update mobile friend list"); String[] arrayOfString = (String[])this.gyC.gyz.toArray(new String[0]); this.gyC.gyz.clear(); ArrayList localArrayList = new ArrayList(); int i = arrayOfString.length; int j = 0; if (j < i) { String str = arrayOfString[j]; localObject = com.tencent.mm.plugin.account.a.getAddrUploadStg().vT(str); if ((localObject != null) && (!bo.isNullOrNil(((com.tencent.mm.plugin.account.friend.a.a)localObject).apG()))) { localArrayList.add(((com.tencent.mm.plugin.account.friend.a.a)localObject).apG()); com.tencent.mm.sdk.platformtools.ab.i("MicroMsg.ContactsAutoSyncLogic ", "find mobile %s username %s", new Object[] { ((com.tencent.mm.plugin.account.friend.a.a)localObject).apG(), str }); } while (true) { j++; break; com.tencent.mm.sdk.platformtools.ab.i("MicroMsg.ContactsAutoSyncLogic ", "not find mobile username %s", new Object[] { str }); } } g.Rg().a(32, this.gyC); if (localArrayList.size() == 0) { com.tencent.mm.sdk.platformtools.ab.i("MicroMsg.ContactsAutoSyncLogic ", "sync mobile list is zero"); localObject = new com.tencent.mm.plugin.account.friend.a.ab(); g.Rg().a((m)localObject, 0); AppMethodBeat.o(124656); } else { com.tencent.mm.sdk.platformtools.ab.i("MicroMsg.ContactsAutoSyncLogic ", "sync mobile list is %d", new Object[] { Integer.valueOf(localArrayList.size()) }); localObject = new com.tencent.mm.plugin.account.friend.a.ab(localArrayList, null); g.Rg().a((m)localObject, 0); AppMethodBeat.o(124656); } } } } } /* Location: C:\Users\Lin\Downloads\dex-tools-2.1-SNAPSHOT\dex-tools-2.1-SNAPSHOT\classes8-dex2jar.jar * Qualified Name: com.tencent.mm.plugin.account.model.a.3 * JD-Core Version: 0.6.2 */
3feceedd5276fbe0ab62254a9c7339d715c99eba
42641eb3d2dffee1676659da51708ddcc57ed739
/app/src/main/java/com/campusstreet/entity/JoinInfo.java
5642db654f08a070b02de6289fba23b60df03ff9
[]
no_license
QingXian/CampusStreet
342099d0c3de6fba509e81d6ced9fe6078422603
d2b1b279ab23d10228012835db039aa2006d7778
refs/heads/master
2021-01-19T05:12:35.629213
2017-07-06T03:03:58
2017-07-06T03:03:58
87,418,764
0
0
null
null
null
null
UTF-8
Java
false
false
2,094
java
package com.campusstreet.entity; import java.io.Serializable; /** * 赏金大厅报名信息实体类 * Created by Orange on 2017/4/27. */ public class JoinInfo implements Serializable { /** * username : 式微云雨 * userpic : 3.jpg * id : 1 * state : 0 * fee : 1.0000 * addtime : 2017/3/21 11:40:33 * finishtime : 2017/3/24 14:00:00 * phone : 18959075323 * summary : 12312 */ private String username; private String userpic; private int id; private int state; private String fee; private String addtime; private String finishtime; private String phone; private String summary; private String uid; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getUserpic() { return userpic; } public void setUserpic(String userpic) { this.userpic = userpic; } public int getId() { return id; } public void setId(int id) { this.id = id; } public int getState() { return state; } public void setState(int state) { this.state = state; } public String getFee() { return fee; } public void setFee(String fee) { this.fee = fee; } public String getAddtime() { return addtime; } public void setAddtime(String addtime) { this.addtime = addtime; } public String getFinishtime() { return finishtime; } public void setFinishtime(String finishtime) { this.finishtime = finishtime; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getSummary() { return summary; } public void setSummary(String summary) { this.summary = summary; } public String getUid() { return uid; } public void setUid(String uid) { this.uid = uid; } }
ca35b56595f1883d16ff0c5a56424b8a6fa5e2c3
6bfcfb07c63f95ad89e409aed4d3effb5d17aca6
/M3/src/org/t3/metamediamanager/gui/Searcher.java
f03aad5be06351b3ddaf8f8b4c5592424579a162
[ "Apache-2.0" ]
permissive
vstebe/metamediamanager
d181733260d8f0e75578169f32ee4a240406c5e5
2b6a0db6c433ad3923017e0129be5708ce1f6c50
refs/heads/master
2020-05-16T22:26:31.083927
2014-02-07T17:11:04
2014-02-07T17:11:04
null
0
0
null
null
null
null
UTF-8
Java
false
false
10,963
java
/*Copyright 2014 M3Team 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 org.t3.metamediamanager.gui; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; import java.util.EventListener; import java.util.EventObject; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import javax.swing.SwingWorker; import javax.swing.event.EventListenerList; import org.t3.metamediamanager.Film; import org.t3.metamediamanager.M3Config; import org.t3.metamediamanager.ProviderManager; import org.t3.metamediamanager.ProviderRequest; import org.t3.metamediamanager.ProviderResponse; import org.t3.metamediamanager.Searchable; import org.t3.metamediamanager.Series; import org.t3.metamediamanager.SeriesEpisode; /** * Used to notify when a media has been changed during the search (information added) * @author vincent * */ class SearchableModifiedEvent extends EventObject { /** * */ private static final long serialVersionUID = 1L; private Searchable _Searchable; public SearchableModifiedEvent(Object source, Searchable Searchable) { super(source); _Searchable = Searchable; } public Searchable getSearchable() { return _Searchable; } } interface SearchableModifiedListener extends EventListener { public void onSearchableModified(SearchableModifiedEvent e); } /** * Searcher display a progress bar, and start the search of movies or films. * It uses SwingWorker : the search is done inside a thread. * @author vincent * */ public class Searcher { protected EventListenerList listenerList = new EventListenerList(); protected int _lastNotFoundSearchables = -1; //Number of not found searchables in the last search. Used to know if the current search was useful or not private class Worker extends SwingWorker<List<Entry<Searchable,ProviderResponse>>, Integer> { private Searchable[] _list; private ProgressionDialog _dialog; private EnumSet<ProviderRequest.Additions> _additions; public Worker(Searchable[] ml, ProgressionDialog pd,EnumSet<ProviderRequest.Additions> additions) { _list = ml; _dialog = pd; _additions = additions; //Init the progressbar, executed when its value change (ex : 50% -> 51%) addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("progress".equals(evt.getPropertyName())) { _dialog.setProgression((Integer) evt.getNewValue()); } } }); } /** * Main function of Searcher. It launches the search for each searchable (movie, series, episode...) in the list. * It updates the progress bar right after each media until 80% * Then it saves the information */ @Override protected List<Entry<Searchable,ProviderResponse>> doInBackground() throws Exception { HashMap<Searchable,ProviderResponse> res = new HashMap<Searchable,ProviderResponse>(); //Searchable associated with the response of the providers int i = 0; for(Searchable Searchable : _list) { if(isCancelled()) return null; //If the users closed the progress bar frame ProviderRequest request = null; if(Searchable instanceof Film) request = new ProviderRequest(ProviderRequest.Type.FILM, Searchable.generateSimpleName(), Searchable.getFilename(), M3Config.getInstance().getParam("language")); else if(Searchable instanceof SeriesEpisode) { SeriesEpisode episode = (SeriesEpisode) Searchable; Series series = Series.loadById(episode.getSeriesId()); request = new ProviderRequest(ProviderRequest.Type.EPISODE, series.generateSimpleName(), Searchable.getFilename(), M3Config.getInstance().getParam("language"), episode.getSeasonNumber(), episode.getEpisodeNumber()); } else if(Searchable instanceof Series) { Series s = (Series) Searchable; request = new ProviderRequest(ProviderRequest.Type.SERIES, s.generateSimpleName(), s.getDirectory(), M3Config.getInstance().getParam("language")); } request.setAdditions(_additions); ProviderResponse r = ProviderManager.getInstance().getInfo(Searchable.getInfo(), request); //Progress bar update res.put(Searchable, r); i++; setProgress(i * 80 / _list.length); } i = 0; //For each media, if information has been found, we save it List<Entry<Searchable,ProviderResponse>> SearchableToAsk = new ArrayList<Entry<Searchable,ProviderResponse>>(); int size = res.size(); for(Entry<Searchable, ProviderResponse> entry : res.entrySet()) { if(isCancelled()) return null; //If the user closed the window if(entry.getValue().getType() == ProviderResponse.Type.FOUND) { Searchable Searchable = entry.getKey(); Searchable.setInfo(entry.getValue().getResponse()); Searchable.save(); } else { SearchableToAsk.add(entry); } setProgress(i * 20 / size + 80); i++; } return SearchableToAsk; } @Override protected void done() { _dialog.setVisible(false); try { endSearch(get(), _additions); } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } catch(CancellationException e) { //Nothing to do, the search has been cancelled } } } public Searcher() { } public void addSearchableModifiedListener(SearchableModifiedListener mml) { listenerList.add(SearchableModifiedListener.class, mml); } public void removeSearchableModifiedListener(SearchableModifiedListener mml) { listenerList.remove(SearchableModifiedListener.class, mml); } public void searchList(Searchable[] ml) { searchList(ml, EnumSet.noneOf(ProviderRequest.Additions.class)); } /** * Starts the search with additions * @param ml * @param additions */ public void searchList(Searchable[] ml,EnumSet<ProviderRequest.Additions> additions) { _lastNotFoundSearchables = -1; String[] names = new String[ml.length]; for(int i=0; i<ml.length; i++) names[i] = ml[i].generateSimpleName(); startSearch(ml, additions); } /** * SearchList launches the SwingWorker * @param ml * @param namesToUse * @param additions */ private void startSearch(Searchable[] ml,EnumSet<ProviderRequest.Additions> additions) { //If there are episodes, we must search for the series itself too. //We may want use other names for the medias : they are specified in namesToUse List<Integer> seriesIdToSearch = new ArrayList<Integer>(); List<Integer> seriesIdToNotSearch = new ArrayList<Integer>(); List<Searchable> finalList = new ArrayList<Searchable>(); for(Searchable s : ml) { finalList.add(s); } //We add Series in searchable for(Searchable s : ml) { if(s instanceof SeriesEpisode) { SeriesEpisode episode = (SeriesEpisode) s; int seriesId = episode.getSeriesId(); if(!seriesIdToSearch.contains(seriesId) && !seriesIdToNotSearch.contains(seriesId)) {//If the series of the episode isn't already in the list Series series = Series.loadById(seriesId); seriesIdToSearch.add(seriesId); //We add it if(!finalList.contains(series)) { finalList.add(series); } } } } //List -> Array Searchable[] finalTab = new Searchable[finalList.size()]; finalList.toArray(finalTab); //We create the progress bar window and launch the worker ProgressionDialog pd = new ProgressionDialog(); final Worker w = new Worker(finalTab, pd, additions); pd.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { w.cancel(false); } }); w.execute(); pd.pack(); pd.setVisible(true); } /** * Method called when the search is ended. It opens a new window (SearchResultDialog) if there are unfound media. * @param SearchableToAsk * @param additions */ private void endSearch(List<Entry<Searchable,ProviderResponse>> SearchableToAsk,EnumSet<ProviderRequest.Additions> additions) { if(SearchableToAsk == null || SearchableToAsk.size() == _lastNotFoundSearchables) return; if(SearchableToAsk.size() > 0) { List<Searchable> tosearch = new ArrayList<Searchable>(); //We will not ask the user about episodes. List<Entry<Searchable,ProviderResponse>> SearchableToAskNoEpisodes = new ArrayList<Entry<Searchable,ProviderResponse>>(); for(Entry<Searchable,ProviderResponse> entry : SearchableToAsk) { if(entry.getKey() instanceof SeriesEpisode) { tosearch.add(entry.getKey()); } else { SearchableToAskNoEpisodes.add(entry); } } if(SearchableToAskNoEpisodes.size() > 0) { //We open SearchResultDialog and asks the user if we must search again, and which names to use SearchResultsDialog d = new SearchResultsDialog(SearchableToAskNoEpisodes, ProviderManager.getInstance().getErrorLog()); ProviderManager.getInstance().cleanErrorLog(); d.pack(); d.setVisible(true); tosearch.addAll(Arrays.asList(d.getSearchablesToSearchAgain())); } Searchable[] tosearchTab = new Searchable[tosearch.size()]; tosearch.toArray(tosearchTab); //If there are movies to search again if(tosearchTab.length > 0) { _lastNotFoundSearchables = SearchableToAsk.size(); startSearch(tosearchTab, additions); } } fireEvent(null); } /** * Fire event when medias has been modified * @param m */ private void fireEvent(Searchable m) { Object[] listeners = listenerList.getListenerList(); for (int j = 0; j < listeners.length; j+=2) { if (listeners[j] == SearchableModifiedListener.class) { ((SearchableModifiedListener) listeners[j+1]).onSearchableModified(new SearchableModifiedEvent(this, m)); } } } public void search(Searchable s) { Searchable[] list = new Searchable[1]; list[0] = s; searchList(list); } }
6465baebba8a8ce5d97e3f1dc22f02184b36ab0e
b3b1d4a369c4d16442e502726e60b253dae94a03
/src/test/com/cloudera/sqoop/ThirdPartyTests.java
99c7dbc32db65603ecfcc5a008f279c16b8753da
[ "BSD-3-Clause", "Apache-2.0", "BSD-2-Clause" ]
permissive
sahilsehgal81/Sqoop
ce512e23fb42359d9120c1fbbd286017dc7c7b8e
ae3b8579c69963d64c27aa82923a7ca937fe8ebb
refs/heads/master
2021-01-25T04:52:51.010092
2014-11-20T08:53:53
2014-11-20T08:53:53
null
0
0
null
null
null
null
UTF-8
Java
false
false
6,321
java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cloudera.sqoop; import com.cloudera.sqoop.hbase.HBaseImportAddRowKeyTest; import com.cloudera.sqoop.hbase.HBaseImportNullTest; import com.cloudera.sqoop.hbase.HBaseImportTypesTest; import com.cloudera.sqoop.manager.DB2ManagerImportManualTest; import org.apache.sqoop.hcat.HCatalogExportTest; import org.apache.sqoop.hcat.HCatalogImportTest; import com.cloudera.sqoop.hbase.HBaseImportTest; import com.cloudera.sqoop.hbase.HBaseQueryImportTest; import com.cloudera.sqoop.hbase.HBaseUtilTest; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import com.cloudera.sqoop.manager.DirectMySQLTest; import com.cloudera.sqoop.manager.DirectMySQLExportTest; import com.cloudera.sqoop.manager.JdbcMySQLExportTest; import com.cloudera.sqoop.manager.MySQLAuthTest; import com.cloudera.sqoop.manager.MySQLCompatTest; import com.cloudera.sqoop.manager.OracleExportTest; import com.cloudera.sqoop.manager.OracleManagerTest; import com.cloudera.sqoop.manager.OracleCompatTest; import com.cloudera.sqoop.manager.PostgresqlExportTest; import com.cloudera.sqoop.manager.PostgresqlImportTest; import org.apache.sqoop.manager.mysql.MySqlCallExportTest; import org.apache.sqoop.manager.netezza.DirectNetezzaExportManualTest; import org.apache.sqoop.manager.netezza.DirectNetezzaHCatExportManualTest; import org.apache.sqoop.manager.netezza.DirectNetezzaHCatImportManualTest; import org.apache.sqoop.manager.netezza.NetezzaExportManualTest; import org.apache.sqoop.manager.netezza.NetezzaImportManualTest; import org.apache.sqoop.manager.oracle.OracleCallExportTest; import org.apache.sqoop.manager.oracle.OracleIncrementalImportTest; import org.apache.sqoop.manager.sqlserver.SQLServerDatatypeExportDelimitedFileManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerDatatypeExportSequenceFileManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerDatatypeImportDelimitedFileManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerDatatypeImportSequenceFileManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerHiveImportManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerManagerManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerMultiColsManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerMultiMapsManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerParseMethodsManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerQueryManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerSplitByManualTest; import org.apache.sqoop.manager.sqlserver.SQLServerWhereManualTest; /** * Test battery including all tests of vendor-specific ConnManager * implementations. These tests likely aren't run by Apache Hudson, because * they require configuring and using Oracle, MySQL, etc., which may have * incompatible licenses with Apache. */ public final class ThirdPartyTests extends TestCase { private ThirdPartyTests() { } public static Test suite() { TestSuite suite = new TestSuite("Tests vendor-specific ConnManager " + "implementations in Sqoop and tests with third party dependencies"); // MySQL suite.addTestSuite(DirectMySQLTest.class); suite.addTestSuite(DirectMySQLExportTest.class); suite.addTestSuite(JdbcMySQLExportTest.class); suite.addTestSuite(MySQLAuthTest.class); suite.addTestSuite(MySQLCompatTest.class); // Oracle suite.addTestSuite(OracleExportTest.class); suite.addTestSuite(OracleManagerTest.class); suite.addTestSuite(OracleCompatTest.class); suite.addTestSuite(OracleIncrementalImportTest.class); // SQL Server suite.addTestSuite(SQLServerDatatypeExportDelimitedFileManualTest.class); suite.addTestSuite(SQLServerDatatypeExportSequenceFileManualTest.class); suite.addTestSuite(SQLServerDatatypeImportDelimitedFileManualTest.class); suite.addTestSuite(SQLServerDatatypeImportSequenceFileManualTest.class); suite.addTestSuite(SQLServerHiveImportManualTest.class); suite.addTestSuite(SQLServerManagerManualTest.class); suite.addTestSuite(SQLServerMultiColsManualTest.class); suite.addTestSuite(SQLServerMultiMapsManualTest.class); suite.addTestSuite(SQLServerParseMethodsManualTest.class); suite.addTestSuite(SQLServerQueryManualTest.class); suite.addTestSuite(SQLServerSplitByManualTest.class); suite.addTestSuite(SQLServerWhereManualTest.class); // PostgreSQL suite.addTestSuite(PostgresqlImportTest.class); suite.addTestSuite(PostgresqlExportTest.class); // DB2 suite.addTestSuite(DB2ManagerImportManualTest.class); // Hbase suite.addTestSuite(HBaseImportTest.class); suite.addTestSuite(HBaseImportAddRowKeyTest.class); suite.addTestSuite(HBaseImportNullTest.class); suite.addTestSuite(HBaseImportTypesTest.class); suite.addTestSuite(HBaseQueryImportTest.class); suite.addTestSuite(HBaseUtilTest.class); // HCatalog suite.addTestSuite(HCatalogImportTest.class); suite.addTestSuite(HCatalogExportTest.class); // Call Export tests suite.addTestSuite(MySqlCallExportTest.class); suite.addTestSuite(OracleCallExportTest.class); // Netezza suite.addTestSuite(NetezzaExportManualTest.class); suite.addTestSuite(NetezzaImportManualTest.class); suite.addTestSuite(DirectNetezzaExportManualTest.class); suite.addTestSuite(DirectNetezzaHCatExportManualTest.class); suite.addTestSuite(DirectNetezzaHCatImportManualTest.class); return suite; } }
e6ed47d4fe7c71c6c6d5567fce3de3f99fb295de
c421588e835df71dd7aa5220b78bf4f3a565407d
/buy-stream/src/main/java/com/liyu/BuyStreamApplication.java
dae590142030e0c9f116416e3ff7dd48b85e09b1
[]
no_license
liyuItem/cloud
157faeb4e9b9a82f5466ade4c796ec0dafe3bdd8
7df88956b5f949faa6d3dd59c5e15d6c9fdef57f
refs/heads/master
2022-07-04T05:49:42.195730
2019-05-25T08:38:06
2019-05-25T08:38:06
188,530,597
0
0
null
2022-06-21T01:10:10
2019-05-25T06:42:56
Java
UTF-8
Java
false
false
319
java
package com.liyu; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class BuyStreamApplication { public static void main(String[] args) { SpringApplication.run(BuyStreamApplication.class, args); } }
acc9e3c78d6f5e6da86a49a8e5f92435630bc0ce
8a51562a1bf9f674377fde9215e6db53d2ba71bf
/src/client_serveur/impl/Attachment_Serveur_RPCImpl.java
fd3d366a222e28e3f9238e156bd37f387f4a300c
[]
no_license
loic44650/COSA
3746d7c65af188b678fe0b2d41fcfea7ae848608
7958f185e1dda10f02765dde76bd32d79cbaa6c3
refs/heads/master
2020-04-08T05:06:27.673453
2018-12-10T14:46:01
2018-12-10T14:46:01
159,046,461
0
0
null
null
null
null
UTF-8
Java
false
false
10,986
java
/** */ package client_serveur.impl; import client_serveur.Attachment_Serveur_RPC; import client_serveur.Client_serveurPackage; import client_serveur.Port_Fourni_Serveur; import client_serveur.Role_Requis_RPC_Serveur; import cosa.impl.AttachmentImpl; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Attachment Serveur RPC</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link client_serveur.impl.Attachment_Serveur_RPCImpl#getPort_fourni_serveur <em>Port fourni serveur</em>}</li> * <li>{@link client_serveur.impl.Attachment_Serveur_RPCImpl#getRole_requis_rpc_serveur <em>Role requis rpc serveur</em>}</li> * </ul> * * @generated */ public class Attachment_Serveur_RPCImpl extends AttachmentImpl implements Attachment_Serveur_RPC { /** * The cached value of the '{@link #getPort_fourni_serveur() <em>Port fourni serveur</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getPort_fourni_serveur() * @generated * @ordered */ protected Port_Fourni_Serveur port_fourni_serveur; /** * The cached value of the '{@link #getRole_requis_rpc_serveur() <em>Role requis rpc serveur</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getRole_requis_rpc_serveur() * @generated * @ordered */ protected Role_Requis_RPC_Serveur role_requis_rpc_serveur; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected Attachment_Serveur_RPCImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return Client_serveurPackage.Literals.ATTACHMENT_SERVEUR_RPC; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Port_Fourni_Serveur getPort_fourni_serveur() { if (port_fourni_serveur != null && port_fourni_serveur.eIsProxy()) { InternalEObject oldPort_fourni_serveur = (InternalEObject)port_fourni_serveur; port_fourni_serveur = (Port_Fourni_Serveur)eResolveProxy(oldPort_fourni_serveur); if (port_fourni_serveur != oldPort_fourni_serveur) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__PORT_FOURNI_SERVEUR, oldPort_fourni_serveur, port_fourni_serveur)); } } return port_fourni_serveur; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Port_Fourni_Serveur basicGetPort_fourni_serveur() { return port_fourni_serveur; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetPort_fourni_serveur(Port_Fourni_Serveur newPort_fourni_serveur, NotificationChain msgs) { Port_Fourni_Serveur oldPort_fourni_serveur = port_fourni_serveur; port_fourni_serveur = newPort_fourni_serveur; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__PORT_FOURNI_SERVEUR, oldPort_fourni_serveur, newPort_fourni_serveur); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setPort_fourni_serveur(Port_Fourni_Serveur newPort_fourni_serveur) { if (newPort_fourni_serveur != port_fourni_serveur) { NotificationChain msgs = null; if (port_fourni_serveur != null) msgs = ((InternalEObject)port_fourni_serveur).eInverseRemove(this, Client_serveurPackage.PORT_FOURNI_SERVEUR__ATTACHMENT_SERVEUR_RPC, Port_Fourni_Serveur.class, msgs); if (newPort_fourni_serveur != null) msgs = ((InternalEObject)newPort_fourni_serveur).eInverseAdd(this, Client_serveurPackage.PORT_FOURNI_SERVEUR__ATTACHMENT_SERVEUR_RPC, Port_Fourni_Serveur.class, msgs); msgs = basicSetPort_fourni_serveur(newPort_fourni_serveur, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__PORT_FOURNI_SERVEUR, newPort_fourni_serveur, newPort_fourni_serveur)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Role_Requis_RPC_Serveur getRole_requis_rpc_serveur() { if (role_requis_rpc_serveur != null && role_requis_rpc_serveur.eIsProxy()) { InternalEObject oldRole_requis_rpc_serveur = (InternalEObject)role_requis_rpc_serveur; role_requis_rpc_serveur = (Role_Requis_RPC_Serveur)eResolveProxy(oldRole_requis_rpc_serveur); if (role_requis_rpc_serveur != oldRole_requis_rpc_serveur) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__ROLE_REQUIS_RPC_SERVEUR, oldRole_requis_rpc_serveur, role_requis_rpc_serveur)); } } return role_requis_rpc_serveur; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Role_Requis_RPC_Serveur basicGetRole_requis_rpc_serveur() { return role_requis_rpc_serveur; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetRole_requis_rpc_serveur(Role_Requis_RPC_Serveur newRole_requis_rpc_serveur, NotificationChain msgs) { Role_Requis_RPC_Serveur oldRole_requis_rpc_serveur = role_requis_rpc_serveur; role_requis_rpc_serveur = newRole_requis_rpc_serveur; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__ROLE_REQUIS_RPC_SERVEUR, oldRole_requis_rpc_serveur, newRole_requis_rpc_serveur); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setRole_requis_rpc_serveur(Role_Requis_RPC_Serveur newRole_requis_rpc_serveur) { if (newRole_requis_rpc_serveur != role_requis_rpc_serveur) { NotificationChain msgs = null; if (role_requis_rpc_serveur != null) msgs = ((InternalEObject)role_requis_rpc_serveur).eInverseRemove(this, Client_serveurPackage.ROLE_REQUIS_RPC_SERVEUR__ATTACHMENT_SERVEUR_RPC, Role_Requis_RPC_Serveur.class, msgs); if (newRole_requis_rpc_serveur != null) msgs = ((InternalEObject)newRole_requis_rpc_serveur).eInverseAdd(this, Client_serveurPackage.ROLE_REQUIS_RPC_SERVEUR__ATTACHMENT_SERVEUR_RPC, Role_Requis_RPC_Serveur.class, msgs); msgs = basicSetRole_requis_rpc_serveur(newRole_requis_rpc_serveur, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__ROLE_REQUIS_RPC_SERVEUR, newRole_requis_rpc_serveur, newRole_requis_rpc_serveur)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__PORT_FOURNI_SERVEUR: if (port_fourni_serveur != null) msgs = ((InternalEObject)port_fourni_serveur).eInverseRemove(this, Client_serveurPackage.PORT_FOURNI_SERVEUR__ATTACHMENT_SERVEUR_RPC, Port_Fourni_Serveur.class, msgs); return basicSetPort_fourni_serveur((Port_Fourni_Serveur)otherEnd, msgs); case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__ROLE_REQUIS_RPC_SERVEUR: if (role_requis_rpc_serveur != null) msgs = ((InternalEObject)role_requis_rpc_serveur).eInverseRemove(this, Client_serveurPackage.ROLE_REQUIS_RPC_SERVEUR__ATTACHMENT_SERVEUR_RPC, Role_Requis_RPC_Serveur.class, msgs); return basicSetRole_requis_rpc_serveur((Role_Requis_RPC_Serveur)otherEnd, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__PORT_FOURNI_SERVEUR: return basicSetPort_fourni_serveur(null, msgs); case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__ROLE_REQUIS_RPC_SERVEUR: return basicSetRole_requis_rpc_serveur(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__PORT_FOURNI_SERVEUR: if (resolve) return getPort_fourni_serveur(); return basicGetPort_fourni_serveur(); case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__ROLE_REQUIS_RPC_SERVEUR: if (resolve) return getRole_requis_rpc_serveur(); return basicGetRole_requis_rpc_serveur(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__PORT_FOURNI_SERVEUR: setPort_fourni_serveur((Port_Fourni_Serveur)newValue); return; case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__ROLE_REQUIS_RPC_SERVEUR: setRole_requis_rpc_serveur((Role_Requis_RPC_Serveur)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__PORT_FOURNI_SERVEUR: setPort_fourni_serveur((Port_Fourni_Serveur)null); return; case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__ROLE_REQUIS_RPC_SERVEUR: setRole_requis_rpc_serveur((Role_Requis_RPC_Serveur)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__PORT_FOURNI_SERVEUR: return port_fourni_serveur != null; case Client_serveurPackage.ATTACHMENT_SERVEUR_RPC__ROLE_REQUIS_RPC_SERVEUR: return role_requis_rpc_serveur != null; } return super.eIsSet(featureID); } public void sendResponse(String response) { System.out.println("<-- AttachmentServeurRPC"); ((Role_Requis_RPC_ServeurImpl) role_requis_rpc_serveur).sendResponse(response); } } //Attachment_Serveur_RPCImpl
bbb706780df628bcfc0fb70d65e5c2bf0d260fab
2f784c1a03dd6bb7f631e1ee6abea8ac49bce7c2
/src/main/java/mx/ipn/escom/spee/pagos/mapeo/PagosCorte.java
390f2426c84f2782f32d10e20437eb7fb76acc2f
[]
no_license
RobESCOM/SPEE
5f7a8cdf890dcb3c66f43cdecb607fe8ca562e94
c5718a12f630af3b724483a01407d020eade997b
refs/heads/master
2020-03-29T20:55:37.219224
2018-11-30T19:53:32
2018-11-30T19:53:32
150,339,236
0
0
null
null
null
null
UTF-8
Java
false
false
1,764
java
package mx.ipn.escom.spee.pagos.mapeo; import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import mx.ipn.escom.spee.util.mapeo.Modelo; @Entity @Table(name = "tp08_pagos_corte") public class PagosCorte implements Modelo, Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id_pago_corte") private Integer id; @Column(name = "id_corte_caja") private Integer idCorteCaja; @Column(name = "id_pago") private Integer idPago; @Column(name = "fecha_pago") private Date fechaPago; @Column(name = "id_cuenta") private Integer idCuenta; public PagosCorte() { super(); } public PagosCorte(Integer id, Integer idCorteCaja, Integer idPago, Date fechaPago, Integer idCuenta) { super(); this.id = id; this.idCorteCaja = idCorteCaja; this.idPago = idPago; this.fechaPago = fechaPago; this.idCuenta = idCuenta; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getIdCorteCaja() { return idCorteCaja; } public void setIdCorteCaja(Integer idCorteCaja) { this.idCorteCaja = idCorteCaja; } public Integer getIdPago() { return idPago; } public void setIdPago(Integer idPago) { this.idPago = idPago; } public Date getFechaPago() { return fechaPago; } public void setFechaPago(Date fechaPago) { this.fechaPago = fechaPago; } public Integer getIdCuenta() { return idCuenta; } public void setIdCuenta(Integer idCuenta) { this.idCuenta = idCuenta; } }
5416b61e6411466447052103a724e57c425b27e9
70652d3463127a6bb06dd7f838cb3b4565b67082
/GWTBovoyage/src/fr/GWTBovoyage/server/GWTBovoyageServiceImpl.java
ae00bccff99f0f58fa454d18cb86dfc72f33effb
[]
no_license
phantrang1988/GWTBovoyage
9b867f1814fa600ffa7862796ca7c7d1c1e6e7b0
94b3304cb3686bd0fd89b392c63103a928f866d7
refs/heads/master
2020-12-25T13:51:05.082645
2016-07-27T09:44:21
2016-07-27T09:44:21
64,291,088
0
0
null
null
null
null
UTF-8
Java
false
false
443
java
package fr.GWTBovoyage.server; import java.util.List; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import fr.GWTBovoyage.client.GWTBovoyageService; import fr.GWTBovoyage.shared.Destination; public class GWTBovoyageServiceImpl extends RemoteServiceServlet implements GWTBovoyageService { @Override public List<Destination> getAllDestinations() { // TODO Auto-generated method stub return null; } }
[ "adminl@Parme33" ]
adminl@Parme33
a167874b8e91a7dac06dddb424ecf11b8f279035
92e65adc25797c6a8703843a8ceff1fc48b7406d
/src/main/java/com/usupov/zodiac/Application.java
c0dabaca8c24e5fe26324cc529c4362de6adbaff
[]
no_license
tusupov/zodiac
4639e8d3e8836733dc5277b99c0a6bcbb9b5ce76
3b8cdcd101a0813e44a60ddba615233ac2f08b7e
refs/heads/master
2021-06-25T17:54:40.055870
2017-08-31T11:29:40
2017-08-31T11:29:40
91,175,979
0
0
null
null
null
null
UTF-8
Java
false
false
316
java
package com.usupov.zodiac; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
fdd71f868331b17c145d211ee4bd801771c19d64
88d4eca9c6a111767facd8bbfb31c2342b2cc4e2
/app/build/generated/not_namespaced_r_class_sources/debug/r/androidx/loader/R.java
adb5a53db94d78067f506f8b454296bd99b9972a
[]
no_license
asadbinkhalid/Sportsvaganza
376213f71e92fe32941d23ed305b0fc6f1abbc3b
9319810c1b4e169cd82bf8ca278f4cb292183660
refs/heads/master
2023-05-28T23:32:17.722384
2021-06-06T15:52:42
2021-06-06T15:52:42
211,862,132
0
0
null
null
null
null
UTF-8
Java
false
false
10,446
java
/* AUTO-GENERATED FILE. DO NOT MODIFY. * * This class was automatically generated by the * gradle plugin from the resource data it found. It * should not be modified by hand. */ package androidx.loader; public final class R { private R() {} public static final class attr { private attr() {} public static final int alpha = 0x7f04002b; public static final int font = 0x7f0400f7; public static final int fontProviderAuthority = 0x7f0400f9; public static final int fontProviderCerts = 0x7f0400fa; public static final int fontProviderFetchStrategy = 0x7f0400fb; public static final int fontProviderFetchTimeout = 0x7f0400fc; public static final int fontProviderPackage = 0x7f0400fd; public static final int fontProviderQuery = 0x7f0400fe; public static final int fontStyle = 0x7f0400ff; public static final int fontVariationSettings = 0x7f040100; public static final int fontWeight = 0x7f040101; public static final int ttcIndex = 0x7f040250; } public static final class color { private color() {} public static final int notification_action_color_filter = 0x7f060086; public static final int notification_icon_bg_color = 0x7f060087; public static final int ripple_material_light = 0x7f060093; public static final int secondary_text_default_material_light = 0x7f060095; } public static final class dimen { private dimen() {} public static final int compat_button_inset_horizontal_material = 0x7f070063; public static final int compat_button_inset_vertical_material = 0x7f070064; public static final int compat_button_padding_horizontal_material = 0x7f070065; public static final int compat_button_padding_vertical_material = 0x7f070066; public static final int compat_control_corner_material = 0x7f070067; public static final int compat_notification_large_icon_max_height = 0x7f070068; public static final int compat_notification_large_icon_max_width = 0x7f070069; public static final int notification_action_icon_size = 0x7f0700d6; public static final int notification_action_text_size = 0x7f0700d7; public static final int notification_big_circle_margin = 0x7f0700d8; public static final int notification_content_margin_start = 0x7f0700d9; public static final int notification_large_icon_height = 0x7f0700da; public static final int notification_large_icon_width = 0x7f0700db; public static final int notification_main_column_padding_top = 0x7f0700dc; public static final int notification_media_narrow_margin = 0x7f0700dd; public static final int notification_right_icon_size = 0x7f0700de; public static final int notification_right_side_padding_top = 0x7f0700df; public static final int notification_small_icon_background_padding = 0x7f0700e0; public static final int notification_small_icon_size_as_large = 0x7f0700e1; public static final int notification_subtext_size = 0x7f0700e2; public static final int notification_top_pad = 0x7f0700e3; public static final int notification_top_pad_large_text = 0x7f0700e4; } public static final class drawable { private drawable() {} public static final int notification_action_background = 0x7f080093; public static final int notification_bg = 0x7f080094; public static final int notification_bg_low = 0x7f080095; public static final int notification_bg_low_normal = 0x7f080096; public static final int notification_bg_low_pressed = 0x7f080097; public static final int notification_bg_normal = 0x7f080098; public static final int notification_bg_normal_pressed = 0x7f080099; public static final int notification_icon_background = 0x7f08009a; public static final int notification_template_icon_bg = 0x7f08009b; public static final int notification_template_icon_low_bg = 0x7f08009c; public static final int notification_tile_bg = 0x7f08009d; public static final int notify_panel_notification_icon_bg = 0x7f08009e; } public static final class id { private id() {} public static final int action_container = 0x7f0a002f; public static final int action_divider = 0x7f0a0031; public static final int action_image = 0x7f0a0032; public static final int action_text = 0x7f0a0038; public static final int actions = 0x7f0a0039; public static final int async = 0x7f0a0045; public static final int blocking = 0x7f0a0049; public static final int chronometer = 0x7f0a0061; public static final int forever = 0x7f0a008a; public static final int icon = 0x7f0a0091; public static final int icon_group = 0x7f0a0093; public static final int info = 0x7f0a0099; public static final int italic = 0x7f0a009b; public static final int line1 = 0x7f0a00a0; public static final int line3 = 0x7f0a00a1; public static final int normal = 0x7f0a00b3; public static final int notification_background = 0x7f0a00b4; public static final int notification_main_column = 0x7f0a00b5; public static final int notification_main_column_container = 0x7f0a00b6; public static final int right_icon = 0x7f0a00c7; public static final int right_side = 0x7f0a00c8; public static final int tag_transition_group = 0x7f0a00ff; public static final int tag_unhandled_key_event_manager = 0x7f0a0100; public static final int tag_unhandled_key_listeners = 0x7f0a0101; public static final int text = 0x7f0a0102; public static final int text2 = 0x7f0a0103; public static final int time = 0x7f0a0132; public static final int title = 0x7f0a0133; } public static final class integer { private integer() {} public static final int status_bar_notification_info_maxnum = 0x7f0b0012; } public static final class layout { private layout() {} public static final int notification_action = 0x7f0d0048; public static final int notification_action_tombstone = 0x7f0d0049; public static final int notification_template_custom_big = 0x7f0d0050; public static final int notification_template_icon_group = 0x7f0d0051; public static final int notification_template_part_chronometer = 0x7f0d0055; public static final int notification_template_part_time = 0x7f0d0056; } public static final class string { private string() {} public static final int status_bar_notification_info_overflow = 0x7f10004c; } public static final class style { private style() {} public static final int TextAppearance_Compat_Notification = 0x7f110145; public static final int TextAppearance_Compat_Notification_Info = 0x7f110146; public static final int TextAppearance_Compat_Notification_Line2 = 0x7f110148; public static final int TextAppearance_Compat_Notification_Time = 0x7f11014b; public static final int TextAppearance_Compat_Notification_Title = 0x7f11014d; public static final int Widget_Compat_NotificationActionContainer = 0x7f110200; public static final int Widget_Compat_NotificationActionText = 0x7f110201; } public static final class styleable { private styleable() {} public static final int[] ColorStateListItem = { 0x10101a5, 0x101031f, 0x7f04002b }; public static final int ColorStateListItem_android_color = 0; public static final int ColorStateListItem_android_alpha = 1; public static final int ColorStateListItem_alpha = 2; public static final int[] FontFamily = { 0x7f0400f9, 0x7f0400fa, 0x7f0400fb, 0x7f0400fc, 0x7f0400fd, 0x7f0400fe }; public static final int FontFamily_fontProviderAuthority = 0; public static final int FontFamily_fontProviderCerts = 1; public static final int FontFamily_fontProviderFetchStrategy = 2; public static final int FontFamily_fontProviderFetchTimeout = 3; public static final int FontFamily_fontProviderPackage = 4; public static final int FontFamily_fontProviderQuery = 5; public static final int[] FontFamilyFont = { 0x1010532, 0x1010533, 0x101053f, 0x101056f, 0x1010570, 0x7f0400f7, 0x7f0400ff, 0x7f040100, 0x7f040101, 0x7f040250 }; public static final int FontFamilyFont_android_font = 0; public static final int FontFamilyFont_android_fontWeight = 1; public static final int FontFamilyFont_android_fontStyle = 2; public static final int FontFamilyFont_android_ttcIndex = 3; public static final int FontFamilyFont_android_fontVariationSettings = 4; public static final int FontFamilyFont_font = 5; public static final int FontFamilyFont_fontStyle = 6; public static final int FontFamilyFont_fontVariationSettings = 7; public static final int FontFamilyFont_fontWeight = 8; public static final int FontFamilyFont_ttcIndex = 9; public static final int[] GradientColor = { 0x101019d, 0x101019e, 0x10101a1, 0x10101a2, 0x10101a3, 0x10101a4, 0x1010201, 0x101020b, 0x1010510, 0x1010511, 0x1010512, 0x1010513 }; public static final int GradientColor_android_startColor = 0; public static final int GradientColor_android_endColor = 1; public static final int GradientColor_android_type = 2; public static final int GradientColor_android_centerX = 3; public static final int GradientColor_android_centerY = 4; public static final int GradientColor_android_gradientRadius = 5; public static final int GradientColor_android_tileMode = 6; public static final int GradientColor_android_centerColor = 7; public static final int GradientColor_android_startX = 8; public static final int GradientColor_android_startY = 9; public static final int GradientColor_android_endX = 10; public static final int GradientColor_android_endY = 11; public static final int[] GradientColorItem = { 0x10101a5, 0x1010514 }; public static final int GradientColorItem_android_color = 0; public static final int GradientColorItem_android_offset = 1; } }
2fa732b5692694e412c136677e99641194e71d54
9c5f5798d1ca4d6a1c06cdace8b4eb7a3b8ed91f
/src/main/java/cn/liberg/database/update/Update.java
074578d35f8275820b3b6085d4ae1be94b0016d5
[]
no_license
ablhy/Liberg
f91a09f950eea4316f0d7555a88852b368e5304c
8ee164ac23d1342c2cfaaca7d55cb4fb71b575f2
refs/heads/master
2023-02-09T17:13:51.297405
2021-01-06T09:51:42
2021-01-06T09:51:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,777
java
package cn.liberg.database.update; import cn.liberg.core.Column; import cn.liberg.database.BaseDao; import cn.liberg.database.SqlDefender; import java.util.LinkedHashMap; import java.util.Map; /** * update操作的入口类。 * * <p> * 1、更新哪张表,由构造方法的参数{@code dao}传入。 * 2、通过{@code set(...)}、{@code increment(...)}方法,指定将哪些列更新为什么值。 * 3、通过{@code whereXxx(...)}系列方法将控制权转移给{@link UpdateWhere}。 * * @param <T> 代表实体类的泛型参数 * * @author Liberg * @see UpdateWhere */ public class Update<T> { LinkedHashMap<Column, String> pairs; BaseDao<T> dao; public Update(BaseDao<T> dao) { this.dao = dao; pairs = new LinkedHashMap<>(16); } public Update<T> set(Column<String> column, String value) { pairs.put(column, SqlDefender.format(value)); return this; } public Update<T> set(Column<? extends Number> column, Number value) { pairs.put(column, value.toString()); return this; } public Update<T> increment(Column<? extends Number> column, Number value) { StringBuilder sb = new StringBuilder(column.name); if(value.longValue()>=0) { sb.append('+'); } sb.append(value.toString()); pairs.put(column, sb.toString()); return this; } String buildSql() { StringBuilder sb = new StringBuilder(); for(Map.Entry<Column, String> entry : pairs.entrySet()) { sb.append(entry.getKey().name); sb.append('='); sb.append(entry.getValue()); sb.append(','); } if(sb.length() > 0) { sb.deleteCharAt(sb.length()-1); } return sb.toString(); } /** * 1 = 1 */ public UpdateWhere<T> where() { final UpdateWhere updateWhere = new UpdateWhere(this); return updateWhere; } /** * column = value:String */ public UpdateWhere<T> whereEq(Column<String> column, String value) { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.eq(column, value); return updateWhere; } /** * column = value:Number */ public UpdateWhere<T> whereEq(Column<? extends Number> column, Number value) { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.eq(column, value); return updateWhere; } /** * column <> value:String */ public UpdateWhere<T> whereNe(Column<String> column, String value) { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.ne(column, value); return updateWhere; } /** * column <> value:Number */ public UpdateWhere<T> whereNe(Column<? extends Number> column, Number value) { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.ne(column, value); return updateWhere; } /** * column like value:String */ public UpdateWhere<T> whereLike(Column<String> column, String value) { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.like(column, value); return updateWhere; } /** * column > value:Number */ public UpdateWhere<T> whereGt(Column<String> column, Number value) { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.gt(column, value); return updateWhere; } /** * column >= value:Number */ public UpdateWhere<T> whereGe(Column<String> column, Number value) { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.ge(column, value); return updateWhere; } /** * column < value:Number */ public UpdateWhere<T> whereLt(Column<String> column, Number value) { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.lt(column, value); return updateWhere; } /** * column <= value:Number */ public UpdateWhere<T> whereLe(Column<String> column, Number value) { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.le(column, value); return updateWhere; } /** * not - where后面的条件由not逻辑符开始 */ public UpdateWhere<T> whereNot() { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.not(); return updateWhere; } /** * ( - where后面的条件由左括号开始 */ public UpdateWhere<T> whereBracketStart() { final UpdateWhere updateWhere = new UpdateWhere(this); updateWhere.bracketStart(); return updateWhere; } }
e606a6de8231e49c6bc2062fdd66c0b24ff11447
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/3/3_957d6c034cc5b31b996ef9a44edda0931cd20c9a/MockTemplateResourceTest/3_957d6c034cc5b31b996ef9a44edda0931cd20c9a_MockTemplateResourceTest_s.java
40ec41c6e3e07c38d47edd9011146a5a2cb4f1be
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
2,177
java
/* * Copyright © 2010 Red Hat, Inc. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package com.redhat.rhevm.api.mock.resource; import org.junit.Test; import com.redhat.rhevm.api.model.Template; import com.redhat.rhevm.api.model.Templates; public class MockTemplateResourceTest extends MockTestBase { private MockTestBase.TemplatesResource getService() { return createTemplatesResource(getEntryPoint("templates").getHref()); } private void checkTemplate(Template template) { assertNotNull(template.getName()); assertNotNull(template.getId()); assertNotNull(template.getHref()); assertTrue(template.getHref().endsWith("templates/" + template.getId())); assertNotNull(template.getActions()); assertEquals(template.getActions().getLinks().size(), 0); } @Test public void testGetTemplatesList() throws Exception { MockTestBase.TemplatesResource service = getService(); assertNotNull(service); Templates templates = service.list(); assertNotNull(templates); assertTrue(templates.getTemplates().size() > 0); for (Template template : templates.getTemplates()) { checkTemplate(template); Template t = service.get(template.getId()); checkTemplate(t); assertEquals(template.getId(), t.getId()); } } }
1cde42d9a9a04526db08b6cb65d5559aef8b0173
822818006d87399416e86750c3f8136306a30a66
/Android/lesson16-14.5.17/Service/app/src/main/java/com/example/hackeru/service/MainActivity.java
56c4aa60b2a54f75c8acd2a4c05f52b5a0270bb3
[]
no_license
maayanpolitzer/Android2017JanMorning
c907fc291a937062cc80344eb7ec7ea43985ee74
17aabafd7f80c11e9fce4944c273958d36158417
refs/heads/master
2021-01-11T19:04:58.723269
2017-06-07T14:01:54
2017-06-07T14:01:54
79,312,370
2
1
null
2017-01-22T16:15:09
2017-01-18T06:55:14
Java
UTF-8
Java
false
false
1,961
java
package com.example.hackeru.service; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.media.Image; import android.net.Uri; import android.os.Handler; import android.support.v4.graphics.BitmapCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.ImageView; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; public class MainActivity extends AppCompatActivity { private String link = "https://matadornetwork.com/wp-content/uploads/2011/05/20110317-nz22.jpg"; private BroadcastReceiver myReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { displayImage(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = new Intent(this, DownloadService.class); intent.putExtra("LINK", link); startService(intent); } public void btnClick(View view) { } @Override protected void onResume() { super.onResume(); registerReceiver(myReceiver, new IntentFilter("99fm")); } @Override protected void onPause() { super.onPause(); unregisterReceiver(myReceiver); } private void displayImage(){ ImageView imageView = (ImageView) findViewById(R.id.activity_main_image_view); imageView.setImageURI(Uri.fromFile(new File(getFilesDir(), "image.jpg"))); } }
f0e7dfd8548f95b216a6fd306f8415a1972ea5cd
5ea955e3c70e61142fc819de2284b6d7848ebb98
/src/main/java/com/example/p6exam1/beans/BannerBean.java
969070a43fc7ce8c34760b422b453deab3574a1c
[]
no_license
qq1164110397/Exam2
25c9f61635c727998ddbaea7e7fd398a7f42c1be
363e3ffe870a127ae4334f7c37a87a1f1b861de6
refs/heads/master
2023-02-01T03:43:50.461827
2020-12-18T00:30:32
2020-12-18T00:30:32
322,269,738
0
0
null
null
null
null
UTF-8
Java
false
false
1,851
java
package com.example.p6exam1.beans; import java.util.List; public class BannerBean { /** * message : 请求i成功 * code : 200 * bannerlist : [{"imageurl":"https://yanxuan.nosdn.127.net/14939496197300723.jpg","htmlurl":"http://www.baidu.com"},{"imageurl":"https://yanxuan.nosdn.127.net/14931121822100127.jpg","htmlurl":"http://www.baidu.com"},{"imageurl":"https://yanxuan.nosdn.127.net/14931970965550315.jpg","htmlurl":"http://www.baidu.com"},{"imageurl":"https://yanxuan.nosdn.127.net/14932840600970609.jpg","htmlurl":"http://www.baidu.com"},{"imageurl":"https://yanxuan.nosdn.127.net/14937214454750141.jpg","htmlurl":"http://www.baidu.com"}] */ private String message; private String code; private List<BannerlistBean> bannerlist; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public List<BannerlistBean> getBannerlist() { return bannerlist; } public void setBannerlist(List<BannerlistBean> bannerlist) { this.bannerlist = bannerlist; } public static class BannerlistBean { /** * imageurl : https://yanxuan.nosdn.127.net/14939496197300723.jpg * htmlurl : http://www.baidu.com */ private String imageurl; private String htmlurl; public String getImageurl() { return imageurl; } public void setImageurl(String imageurl) { this.imageurl = imageurl; } public String getHtmlurl() { return htmlurl; } public void setHtmlurl(String htmlurl) { this.htmlurl = htmlurl; } } }
2fe624747c562b9bd8be96c87e82103bd96beace
7463d443ba73fce707dc24853ff8851adfabf68b
/src/willey/app/physics/PolymerAndRodsExperimentApp.java
4a7a1e0c3e0bd98b0dbeddfc3294f7a673187948
[]
no_license
jwilley44/boltzmann
d80c63b39d10c1a6482c2d0b81a3cda14a739423
32d17835cbc73df1419667d81da7998364b968e0
refs/heads/master
2021-01-17T08:00:57.507654
2016-07-10T17:15:25
2016-07-10T17:15:25
32,935,539
0
0
null
null
null
null
UTF-8
Java
false
false
1,900
java
package willey.app.physics; import java.io.File; import java.io.IOException; import willey.lib.physics.polymer.experiment.Experiment; import willey.lib.physics.polymer.experiment.PolymerAndRodsExperiment; import willey.lib.physics.polymer.interactor.PolymerAndRods; import willey.lib.physics.polymer.measurement.Measurements; import willey.lib.physics.polymer.measurement.Measurer; public class PolymerAndRodsExperimentApp extends PhysicsExperimentApp { public static void main(String[] pArgs) throws IOException { PhysicsExperimentApp.runMain(new PolymerAndRodsExperimentApp(), pArgs); } public void run(String pArgs[]) throws Exception { Measurer.Builder<PolymerAndRods> vBuilder = Measurer.builder(); vBuilder .add(Measurements.rodRotation()) .add(Measurements.averageMonomerDistance()) .add(Measurements.polymerFractalization()) .add(Measurements.interactions()) .add(Measurements.polymerRadius()) .add(Measurements.polymerSize()) .add(Measurements.monomerRadius()) .add(Measurements.monomerDirectionCorrelation()) .add(Measurements.orderParameter()) .add(Measurements.averageRodDistance()) .add(Measurements.averageRodDirection()) .add(Measurements.polymerRodCorrelation()) .add(Measurements.occupiedVolume()) .add(Measurements.rodCount()) .add(Measurements.polymerCenter()) .add(Measurements.polymerRodDistance()) .add(Measurements.polymerParallelRadius()) .add(Measurements.polymerPerpendicularRadius()) .add(Measurements.polymerPerpendicularFractilization()) .add(Measurements.monomerRodCorrelation()) .add(Measurements.rodCorrelation()) .add(Measurements.polymerParallelFractilization()) .add(Measurements.rodsStartingState()) .add(Measurements.quenchedRods()) .add(Measurements.hash()); Experiment<PolymerAndRods> vExperiment = new PolymerAndRodsExperiment(new File(pArgs[0]), vBuilder.build()); vExperiment.run(); } }
902c4a6a77ed606bf3c81786621398eb41ed7f10
42955d30f69956a24ba81d6322561e32100574b6
/src/main/java/com/emg/projectsmanage/ctrl/HeadCtrl.java
e2fd5518d1ceefb4756b2911144132f484b6469e
[]
no_license
mindy132/projectsmanage-xiao
2181808f571d1eb84ade9e2b724c2f02e58aa918
699c00eb64de209e502f08cfd22ff7936c325b9c
refs/heads/master
2021-05-08T22:18:05.614322
2018-02-01T02:55:31
2018-02-01T02:55:31
119,668,103
0
0
null
null
null
null
UTF-8
Java
false
false
2,497
java
package com.emg.projectsmanage.ctrl; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.view.json.MappingJackson2JsonView; import com.emg.projectsmanage.common.CommonConstants; import com.emg.projectsmanage.common.ParamUtils; import com.emg.projectsmanage.pojo.EmployeeModel; import com.emg.projectsmanage.pojo.SystemModel; import com.emg.projectsmanage.service.CommService; import com.emg.projectsmanage.service.EmapgoAccountService; import com.emg.projectsmanage.service.MessageModelService; @Controller @RequestMapping("/head.web") public class HeadCtrl extends BaseCtrl { private static final Logger logger = LoggerFactory.getLogger(HeadCtrl.class); @Autowired private CommService commService; @Autowired private EmapgoAccountService emapgoAccountService; @Autowired private MessageModelService messageModelService; @RequestMapping() public String head(Model model, HttpSession session, HttpServletRequest request) { logger.debug("Head-head start."); String account = getLoginAccount(session); logger.debug("account:" + account); EmployeeModel record = new EmployeeModel(); record.setUsername(account); EmployeeModel user = emapgoAccountService.getOneEmployee(record); String fromurl = ParamUtils.getParameter(request, "fromurl"); model.addAttribute("fromurl", fromurl); if ("".equals(account)) { model.addAttribute("islogin", false); } else { model.addAttribute("islogin", true); model.addAttribute("account", user.getRealname()); List<SystemModel> systems = commService.getAllSystems(); model.addAttribute("systems", systems); } logger.debug("Head-head end."); return "head"; } @RequestMapping(params = "atn=changesys") public ModelAndView changeSys(Model model, HttpSession session, HttpServletRequest request) { ModelAndView json = new ModelAndView(new MappingJackson2JsonView()); int sysid = ParamUtils.getIntParameter(request, "sysid", CommonConstants.SYSTEM_POIVIDEOEDIT_ID); session.setAttribute(CommonConstants.SESSION_CURRENTSYSTEMID, sysid); json.addObject("result", 1); return json; } }
a1d327397ef45ed76ba589e5c32154cd8be9b8d3
07a994b8658a537f295b2ff0089239e45dd3f0e7
/src/main/java/com/sunfield/demo/domain/ApiConfig.java
9b0e70500bb7c030c11273e8ebc4dcb33c1357a0
[]
no_license
stratmanqu/sunfiled_demo_qu
45b74b65514e9d9b069be24d8024c6bae667adc4
fd951a62622ade97b680137340e8fd5ed22f6b8d
refs/heads/master
2023-02-18T05:27:49.075269
2021-01-14T08:28:14
2021-01-14T08:28:14
329,326,170
0
0
null
null
null
null
UTF-8
Java
false
false
730
java
package com.sunfield.demo.domain; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity public class ApiConfig { @Id @GeneratedValue(strategy= GenerationType.AUTO) private Integer id; private String name; private Integer num; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Integer getNum() { return num; } public void setNum(Integer num) { this.num = num; } }
9b5960147a21137a5880051d0ca943fb85a577ec
c0fe21b86f141256c85ab82c6ff3acc56b73d3db
/monitor/src/main/java/com/jdcloud/sdk/service/monitor/model/UpdateProductLineSpec.java
a50944e7f32605d2d4f577eb33db235b317c2a5a
[ "Apache-2.0" ]
permissive
jdcloud-api/jdcloud-sdk-java
3fec9cf552693520f07b43a1e445954de60e34a0
bcebe28306c4ccc5b2b793e1a5848b0aac21b910
refs/heads/master
2023-07-25T07:03:36.682248
2023-07-25T06:54:39
2023-07-25T06:54:39
126,275,669
47
61
Apache-2.0
2023-09-07T08:41:24
2018-03-22T03:41:41
Java
UTF-8
Java
false
false
3,448
java
/* * Copyright 2018 JDCLOUD.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. * * * * * * Contact: * * NOTE: This class is auto generated by the jdcloud code generator program. */ package com.jdcloud.sdk.service.monitor.model; import java.util.List; import java.util.ArrayList; import com.jdcloud.sdk.annotation.Required; /** * updateProductLineSpec */ public class UpdateProductLineSpec implements java.io.Serializable { private static final long serialVersionUID = 1L; /** * productLineNameCn * Required:true */ @Required private String productLineNameCn; /** * productLineNameEn * Required:true */ @Required private String productLineNameEn; /** * serviceCodes * Required:true */ @Required private List<ServiceInfoCreateB> serviceCodes; /** * get productLineNameCn * * @return */ public String getProductLineNameCn() { return productLineNameCn; } /** * set productLineNameCn * * @param productLineNameCn */ public void setProductLineNameCn(String productLineNameCn) { this.productLineNameCn = productLineNameCn; } /** * get productLineNameEn * * @return */ public String getProductLineNameEn() { return productLineNameEn; } /** * set productLineNameEn * * @param productLineNameEn */ public void setProductLineNameEn(String productLineNameEn) { this.productLineNameEn = productLineNameEn; } /** * get serviceCodes * * @return */ public List<ServiceInfoCreateB> getServiceCodes() { return serviceCodes; } /** * set serviceCodes * * @param serviceCodes */ public void setServiceCodes(List<ServiceInfoCreateB> serviceCodes) { this.serviceCodes = serviceCodes; } /** * set productLineNameCn * * @param productLineNameCn */ public UpdateProductLineSpec productLineNameCn(String productLineNameCn) { this.productLineNameCn = productLineNameCn; return this; } /** * set productLineNameEn * * @param productLineNameEn */ public UpdateProductLineSpec productLineNameEn(String productLineNameEn) { this.productLineNameEn = productLineNameEn; return this; } /** * set serviceCodes * * @param serviceCodes */ public UpdateProductLineSpec serviceCodes(List<ServiceInfoCreateB> serviceCodes) { this.serviceCodes = serviceCodes; return this; } /** * add item to serviceCodes * * @param serviceCode */ public void addServiceCode(ServiceInfoCreateB serviceCode) { if (this.serviceCodes == null) { this.serviceCodes = new ArrayList<>(); } this.serviceCodes.add(serviceCode); } }
e35739ce235deaa501442e5ed94fc40e102823ef
001535f1cafb0998a5a352276c68a76e9e7e70a8
/src/bookstore/services/CategorieKidsService.java
e9d3a93b08dd4e8fcc16337c558ee0de67c1d70a
[]
no_license
LouzirMohamedAziz/BookStore
98d64c8757103978844aa535aaa6c69fcecb7be7
9c9a577dd1b9b7f77a53087fb5d1148e32d832ba
refs/heads/master
2023-01-24T07:36:34.463353
2020-12-01T21:09:01
2020-12-01T21:09:01
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,097
java
/* * 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 bookstore.services; import bookstore.Testing.DBConnection; import bookstore.entities.CategorieKids; import bookstore.entities.Livre; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; /** * * @author PC-Hamouda */ public class CategorieKidsService { Connection cnx = DBConnection.getInstance().getCnx(); public void ajouterCategorieKids(CategorieKids cat) { try { String sql = "INSERT INTO categoriekids values (?,?) "; PreparedStatement st = cnx.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS); st.setInt(1, cat.getIdCategorieKids()); st.setString(2,cat.getDescription()); st.executeUpdate(); ResultSet rs = st.getGeneratedKeys(); System.out.println("Categorie ajoute"); while(rs.next()){ System.out.println(rs.getInt(1)); } } catch (Exception e) { System.out.println(e.getMessage()); } } public void afficherLesCategorieKids(){ try { String sql = "SELECT * FROM categoriekids"; PreparedStatement st = cnx.prepareStatement(sql); ResultSet rs = st.executeQuery(); while(rs.next()){ System.out.println(rs); } } catch (Exception e) { System.out.println(e.getMessage()); } } public void SupprimerLivreKids(CategorieKids cat){ try { String sql = "DELETE FROM categoriekids where id_categorie_kids = ?"; PreparedStatement st = cnx.prepareStatement(sql); st.setInt(1,cat.getIdCategorieKids()); st.executeUpdate(); System.out.println("Categorie Supprimer"); } catch (Exception e) { System.out.println(e.getMessage()); } } }
4b076121a9a1dbae7b9922f84b07b2bea13aa0c2
4e6448e5756c5910cd433e73bad1798741ac305f
/src/main/java/com/design/creational/builder/Car.java
95469602aacee794162e38e9814ddda7a578a6a8
[]
no_license
umeshmishra099/design-pattern
1da116c35caa772e840c57fa7941876dbe55f9e5
2792aa1ca07870514d470b013546581c895401a2
refs/heads/master
2020-07-06T17:46:35.558904
2019-08-22T03:16:27
2019-08-22T03:16:27
203,094,920
1
0
null
null
null
null
UTF-8
Java
false
false
1,273
java
package com.design.creational.builder; import java.util.Date; public class Car { private String make; private Date dom; private String carType; private String driveType; private Car(String make, Date dom, String carType, String driveType) { this.make = make; this.dom = dom; this.carType = carType; this.driveType = driveType; } @Override public String toString() { return "Car{" + "make='" + make + '\'' + ", dom=" + dom + ", carType='" + carType + '\'' + ", driveType='" + driveType + '\'' + '}'; } public static class Builder { private String make; private Date dom; private String carType; private String driveType; public Builder setMake(String make) { this.make = make; return this; } public Builder setDom(Date dom) { this.dom = dom; return this; } public Builder setCarType(String carType) { this.carType = carType; return this; } public Builder setDriveType(String driveType) { this.driveType = driveType; return this; } public Car build() { return new Car(this.make, this.dom, this.carType, this.driveType); } } }
a7e15010272635c5782747bd21c061631cbf7e17
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/6/6_be43f16a6fed3fd7ef78fa646dd5653ecb711e07/Project/6_be43f16a6fed3fd7ef78fa646dd5653ecb711e07_Project_s.java
c078a6d9c34f4cfc43d6a3992f1f78aa906a5be0
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
74,140
java
package aQute.bnd.build; import java.io.*; import java.lang.reflect.*; import java.net.*; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.locks.*; import java.util.jar.*; import java.util.regex.*; import aQute.bnd.header.*; import aQute.bnd.help.*; import aQute.bnd.maven.support.*; import aQute.bnd.osgi.*; import aQute.bnd.osgi.eclipse.*; import aQute.bnd.service.*; import aQute.bnd.service.RepositoryPlugin.PutResult; import aQute.bnd.service.action.*; import aQute.bnd.version.*; import aQute.lib.collections.*; import aQute.lib.io.*; import aQute.lib.strings.*; import aQute.libg.command.*; import aQute.libg.generics.*; import aQute.libg.glob.*; import aQute.libg.reporter.*; import aQute.libg.sed.*; /** * This class is NOT threadsafe */ public class Project extends Processor { final static Pattern VERSION_ANNOTATION = Pattern .compile("@\\s*(:?aQute\\.bnd\\.annotation\\.)?Version\\s*\\(\\s*(:?value\\s*=\\s*)?\"(\\d+(:?\\.\\d+(:?\\.\\d+(:?\\.[\\d\\w-_]+)?)?)?)\"\\s*\\)"); final static String DEFAULT_ACTIONS = "build; label='Build', test; label='Test', run; label='Run', clean; label='Clean', release; label='Release', refreshAll; label=Refresh, deploy;label=Deploy"; public final static String BNDFILE = "bnd.bnd"; public final static String BNDCNF = "cnf"; final Workspace workspace; boolean preparedPaths; final Collection<Project> dependson = new LinkedHashSet<Project>(); final Collection<Container> classpath = new LinkedHashSet<Container>(); final Collection<Container> buildpath = new LinkedHashSet<Container>(); final Collection<Container> testpath = new LinkedHashSet<Container>(); final Collection<Container> runpath = new LinkedHashSet<Container>(); final Collection<Container> runbundles = new LinkedHashSet<Container>(); final Collection<Container> runfw = new LinkedHashSet<Container>(); File runstorage; final Collection<File> sourcepath = new LinkedHashSet<File>(); final Collection<File> allsourcepath = new LinkedHashSet<File>(); final Collection<Container> bootclasspath = new LinkedHashSet<Container>(); final Lock lock = new ReentrantLock(true); volatile String lockingReason; volatile Thread lockingThread; File output; File target; boolean inPrepare; int revision; File files[]; static List<Project> trail = new ArrayList<Project>(); boolean delayRunDependencies = false; final ProjectMessages msgs = ReporterMessages.base(this, ProjectMessages.class); public Project(Workspace workspace, File projectDir, File buildFile) throws Exception { super(workspace); this.workspace = workspace; setFileMustExist(false); setProperties(buildFile); assert workspace != null; // For backward compatibility reasons, we also read readBuildProperties(); } public Project(Workspace workspace, File buildDir) throws Exception { this(workspace, buildDir, new File(buildDir, BNDFILE)); } private void readBuildProperties() throws Exception { try { File f = getFile("build.properties"); if (f.isFile()) { Properties p = loadProperties(f); for (Enumeration< ? > e = p.propertyNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); String newkey = key; if (key.indexOf('$') >= 0) { newkey = getReplacer().process(key); } setProperty(newkey, p.getProperty(key)); } } } catch (Exception e) { e.printStackTrace(); } } public static Project getUnparented(File propertiesFile) throws Exception { propertiesFile = propertiesFile.getAbsoluteFile(); Workspace workspace = new Workspace(propertiesFile.getParentFile()); Project project = new Project(workspace, propertiesFile.getParentFile()); project.setProperties(propertiesFile); project.setFileMustExist(true); return project; } public synchronized boolean isValid() { return getBase().isDirectory() && getPropertiesFile().isFile(); } /** * Return a new builder that is nicely setup for this project. Please close * this builder after use. * * @param parent * The project builder to use as parent, use this project if null * @return * @throws Exception */ public synchronized ProjectBuilder getBuilder(ProjectBuilder parent) throws Exception { ProjectBuilder builder; if (parent == null) builder = new ProjectBuilder(this); else builder = new ProjectBuilder(parent); builder.setBase(getBase()); builder.setPedantic(isPedantic()); builder.setTrace(isTrace()); return builder; } public synchronized int getChanged() { return revision; } /* * Indicate a change in the external world that affects our build. This will * clear any cached results. */ public synchronized void setChanged() { // if (refresh()) { preparedPaths = false; files = null; revision++; // } } public Workspace getWorkspace() { return workspace; } @Override public String toString() { return getBase().getName(); } /** * Set up all the paths */ public synchronized void prepare() throws Exception { if (!isValid()) { warning("Invalid project attempts to prepare: %s", this); return; } if (inPrepare) throw new CircularDependencyException(trail.toString() + "," + this); trail.add(this); try { if (!preparedPaths) { inPrepare = true; try { dependson.clear(); buildpath.clear(); sourcepath.clear(); allsourcepath.clear(); bootclasspath.clear(); testpath.clear(); runpath.clear(); runbundles.clear(); // We use a builder to construct all the properties for // use. setProperty("basedir", getBase().getAbsolutePath()); // If a bnd.bnd file exists, we read it. // Otherwise, we just do the build properties. if (!getPropertiesFile().isFile() && new File(getBase(), ".classpath").isFile()) { // Get our Eclipse info, we might depend on other // projects // though ideally this should become empty and void doEclipseClasspath(); } // Calculate our source directory File src = getSrc(); if (src.isDirectory()) { sourcepath.add(src); allsourcepath.add(src); } else sourcepath.add(getBase()); // Set default bin directory output = getSrcOutput().getAbsoluteFile(); if (!output.exists()) { if (!output.mkdirs()) { throw new IOException("Could not create directory " + output); } getWorkspace().changedFile(output); } if (!output.isDirectory()) msgs.NoOutputDirectory_(output); else { Container c = new Container(this, output); if (!buildpath.contains(c)) buildpath.add(c); } // Where we store all our generated stuff. target = getTarget0(); // Where the launched OSGi framework stores stuff String runStorageStr = getProperty(Constants.RUNSTORAGE); runstorage = runStorageStr != null ? getFile(runStorageStr) : null; // We might have some other projects we want build // before we do anything, but these projects are not in // our path. The -dependson allows you to build them before. // The values are possibly negated globbing patterns. // dependencies.add( getWorkspace().getProject("cnf")); String dp = getProperty(Constants.DEPENDSON); Set<String> requiredProjectNames = new LinkedHashSet<String>(new Parameters(dp).keySet()); // Allow DependencyConstributors to modify // requiredProjectNames List<DependencyContributor> dcs = getPlugins(DependencyContributor.class); for (DependencyContributor dc : dcs) dc.addDependencies(this, requiredProjectNames); Instructions is = new Instructions(requiredProjectNames); Set<Instruction> unused = new HashSet<Instruction>(); Collection<Project> projects = getWorkspace().getAllProjects(); Collection<Project> dependencies = is.select(projects, unused, false); for (Instruction u : unused) msgs.MissingDependson_(u.getInput()); // We have two paths that consists of repo files, projects, // or some other stuff. The doPath routine adds them to the // path and extracts the projects so we can build them // before. doPath(buildpath, dependencies, parseBuildpath(), bootclasspath, false, BUILDPATH); doPath(testpath, dependencies, parseTestpath(), bootclasspath, false, TESTPATH); if (!delayRunDependencies) { doPath(runfw, dependencies, parseRunFw(), null, false, RUNFW); doPath(runpath, dependencies, parseRunpath(), null, false, RUNPATH); doPath(runbundles, dependencies, parseRunbundles(), null, true, RUNBUNDLES); } // We now know all dependent projects. But we also depend // on whatever those projects depend on. This creates an // ordered list without any duplicates. This of course // assumes // that there is no circularity. However, this is checked // by the inPrepare flag, will throw an exception if we // are circular. Set<Project> done = new HashSet<Project>(); done.add(this); allsourcepath.addAll(sourcepath); for (Project project : dependencies) project.traverse(dependson, done); for (Project project : dependson) { allsourcepath.addAll(project.getSourcePath()); } if (isOk()) preparedPaths = true; } finally { inPrepare = false; } } } finally { trail.remove(this); } } /* * */ private File getTarget0() throws IOException { File target = getTargetDir(); if (!target.exists()) { if (!target.mkdirs()) { throw new IOException("Could not create directory " + target); } getWorkspace().changedFile(target); } return target; } public File getSrc() { String deflt = Workspace.getDefaults().getProperty(Constants.DEFAULT_PROP_SRC_DIR); return getFile(getProperty(Constants.DEFAULT_PROP_SRC_DIR, deflt)); } public File getSrcOutput() { String deflt = Workspace.getDefaults().getProperty(Constants.DEFAULT_PROP_BIN_DIR); return getFile(getProperty(Constants.DEFAULT_PROP_BIN_DIR, deflt)); } public File getTestSrc() { String deflt = Workspace.getDefaults().getProperty(Constants.DEFAULT_PROP_TESTSRC_DIR); return getFile(getProperty(Constants.DEFAULT_PROP_TESTSRC_DIR, deflt)); } public File getTestOutput() { String deflt = Workspace.getDefaults().getProperty(Constants.DEFAULT_PROP_TESTBIN_DIR); return getFile(getProperty(Constants.DEFAULT_PROP_TESTBIN_DIR, deflt)); } public File getTargetDir() { String deflt = Workspace.getDefaults().getProperty(Constants.DEFAULT_PROP_TARGET_DIR); return getFile(getProperty(Constants.DEFAULT_PROP_TARGET_DIR, deflt)); } private void traverse(Collection<Project> dependencies, Set<Project> visited) throws Exception { if (visited.contains(this)) return; visited.add(this); for (Project project : getDependson()) project.traverse(dependencies, visited); dependencies.add(this); } /** * Iterate over the entries and place the projects on the projects list and * all the files of the entries on the resultpath. * * @param resultpath * The list that gets all the files * @param projects * The list that gets any projects that are entries * @param entries * The input list of classpath entries */ private void doPath(Collection<Container> resultpath, Collection<Project> projects, Collection<Container> entries, Collection<Container> bootclasspath, boolean noproject, String name) { for (Container cpe : entries) { if (cpe.getError() != null) error(cpe.getError()); else { if (cpe.getType() == Container.TYPE.PROJECT) { projects.add(cpe.getProject()); if (noproject // && since(About._2_3) // && cpe.getAttributes() != null && VERSION_ATTR_PROJECT.equals(cpe.getAttributes().get(VERSION_ATTRIBUTE))) { // // we're trying to put a project's output directory on // -runbundles list // error("%s is specified with version=project on %s. This version uses the project's output directory, which is not allowed since it must be an actual JAR file for this list.", cpe.getBundleSymbolicName(), name); } } if (bootclasspath != null && (cpe.getBundleSymbolicName().startsWith("ee.") || cpe.getAttributes().containsKey("boot"))) bootclasspath.add(cpe); else resultpath.add(cpe); } } } /** * Parse the list of bundles that are a prerequisite to this project. * Bundles are listed in repo specific names. So we just let our repo * plugins iterate over the list of bundles and we get the highest version * from them. * * @return */ private List<Container> parseBuildpath() throws Exception { List<Container> bundles = getBundles(Strategy.LOWEST, getProperty(Constants.BUILDPATH), Constants.BUILDPATH); return bundles; } private List<Container> parseRunpath() throws Exception { return getBundles(Strategy.HIGHEST, getProperty(Constants.RUNPATH), Constants.RUNPATH); } private List<Container> parseRunbundles() throws Exception { return getBundles(Strategy.HIGHEST, getProperty(Constants.RUNBUNDLES), Constants.RUNBUNDLES); } private List<Container> parseRunFw() throws Exception { return getBundles(Strategy.HIGHEST, getProperty(Constants.RUNFW), Constants.RUNFW); } private List<Container> parseTestpath() throws Exception { return getBundles(Strategy.HIGHEST, getProperty(Constants.TESTPATH), Constants.TESTPATH); } /** * Analyze the header and return a list of files that should be on the * build, test or some other path. The list is assumed to be a list of bsns * with a version specification. The special case of version=project * indicates there is a project in the same workspace. The path to the * output directory is calculated. The default directory ${bin} can be * overridden with the output attribute. * * @param strategy * STRATEGY_LOWEST or STRATEGY_HIGHEST * @param spec * The header * @return */ public List<Container> getBundles(Strategy strategyx, String spec, String source) throws Exception { List<Container> result = new ArrayList<Container>(); Parameters bundles = new Parameters(spec); try { for (Iterator<Entry<String,Attrs>> i = bundles.entrySet().iterator(); i.hasNext();) { Entry<String,Attrs> entry = i.next(); String bsn = removeDuplicateMarker(entry.getKey()); Map<String,String> attrs = entry.getValue(); Container found = null; String versionRange = attrs.get("version"); if (versionRange != null) { if (versionRange.equals(VERSION_ATTR_LATEST) || versionRange.equals(VERSION_ATTR_SNAPSHOT)) { found = getBundle(bsn, versionRange, strategyx, attrs); } } if (found == null) { // // TODO This looks like a duplicate // of what is done in getBundle?? // if (versionRange != null && (versionRange.equals(VERSION_ATTR_PROJECT) || versionRange.equals(VERSION_ATTR_LATEST))) { // // Use the bin directory ... // Project project = getWorkspace().getProject(bsn); if (project != null && project.exists()) { File f = project.getOutput(); found = new Container(project, bsn, versionRange, Container.TYPE.PROJECT, f, null, attrs, null); } else { msgs.NoSuchProject(bsn, spec); continue; } } else if (versionRange != null && versionRange.equals("file")) { File f = getFile(bsn); String error = null; if (!f.exists()) error = "File does not exist: " + f.getAbsolutePath(); if (f.getName().endsWith(".lib")) { found = new Container(this, bsn, "file", Container.TYPE.LIBRARY, f, error, attrs, null); } else { found = new Container(this, bsn, "file", Container.TYPE.EXTERNAL, f, error, attrs, null); } } else { found = getBundle(bsn, versionRange, strategyx, attrs); } } if (found != null) { List<Container> libs = found.getMembers(); for (Container cc : libs) { if (result.contains(cc)) { if (isPedantic()) warning("Multiple bundles with the same final URL: %s, dropped duplicate", cc); } else { if (cc.getError() != null) { warning("Cannot find %s", cc); } result.add(cc); } } } else { // Oops, not a bundle in sight :-( Container x = new Container(this, bsn, versionRange, Container.TYPE.ERROR, null, bsn + ";version=" + versionRange + " not found", attrs, null); result.add(x); warning("Can not find URL for bsn " + bsn); } } } catch (CircularDependencyException e) { String message = e.getMessage(); if (source != null) message = String.format("%s (from property: %s)", message, source); msgs.CircularDependencyContext_Message_(getName(), message); } catch (Exception e) { msgs.Unexpected_Error_(spec, e); } return result; } /** * Just calls a new method with a default parm. * * @throws Exception */ Collection<Container> getBundles(Strategy strategy, String spec) throws Exception { return getBundles(strategy, spec, null); } static void mergeNames(String names, Set<String> set) { StringTokenizer tokenizer = new StringTokenizer(names, ","); while (tokenizer.hasMoreTokens()) set.add(tokenizer.nextToken().trim()); } static String flatten(Set<String> names) { StringBuilder builder = new StringBuilder(); boolean first = true; for (String name : names) { if (!first) builder.append(','); builder.append(name); first = false; } return builder.toString(); } static void addToPackageList(Container container, String newPackageNames) { Set<String> merged = new HashSet<String>(); String packageListStr = container.attributes.get("packages"); if (packageListStr != null) mergeNames(packageListStr, merged); if (newPackageNames != null) mergeNames(newPackageNames, merged); container.putAttribute("packages", flatten(merged)); } /** * The user selected pom in a path. This will place the pom as well as its * dependencies on the list * * @param strategyx * the strategy to use. * @param result * The list of result containers * @param attrs * The attributes * @throws Exception * anything goes wrong */ public void doMavenPom(Strategy strategyx, List<Container> result, String action) throws Exception { File pomFile = getFile("pom.xml"); if (!pomFile.isFile()) msgs.MissingPom(); else { ProjectPom pom = getWorkspace().getMaven().createProjectModel(pomFile); if (action == null) action = "compile"; Pom.Scope act = Pom.Scope.valueOf(action); Set<Pom> dependencies = pom.getDependencies(act); for (Pom sub : dependencies) { File artifact = sub.getArtifact(); Container container = new Container(artifact, null); result.add(container); } } } public Collection<Project> getDependson() throws Exception { prepare(); return dependson; } public Collection<Container> getBuildpath() throws Exception { prepare(); return buildpath; } public Collection<Container> getTestpath() throws Exception { prepare(); return testpath; } /** * Handle dependencies for paths that are calculated on demand. * * @param testpath2 * @param parseTestpath */ private void justInTime(Collection<Container> path, List<Container> entries, boolean noproject, String name) { if (delayRunDependencies && path.isEmpty()) doPath(path, dependson, entries, null, noproject, name); } public Collection<Container> getRunpath() throws Exception { prepare(); justInTime(runpath, parseRunpath(), false, RUNPATH); return runpath; } public Collection<Container> getRunbundles() throws Exception { prepare(); justInTime(runbundles, parseRunbundles(), true, RUNBUNDLES); return runbundles; } /** * Return the run framework * * @throws Exception */ public Collection<Container> getRunFw() throws Exception { prepare(); justInTime(runfw, parseRunFw(), false, RUNFW); return runfw; } public File getRunStorage() throws Exception { prepare(); return runstorage; } public boolean getRunBuilds() { boolean result; String runBuildsStr = getProperty(Constants.RUNBUILDS); if (runBuildsStr == null) result = !getPropertiesFile().getName().toLowerCase().endsWith(Constants.DEFAULT_BNDRUN_EXTENSION); else result = Boolean.parseBoolean(runBuildsStr); return result; } public Collection<File> getSourcePath() throws Exception { prepare(); return sourcepath; } public Collection<File> getAllsourcepath() throws Exception { prepare(); return allsourcepath; } public Collection<Container> getBootclasspath() throws Exception { prepare(); return bootclasspath; } public File getOutput() throws Exception { prepare(); return output; } private void doEclipseClasspath() throws Exception { EclipseClasspath eclipse = new EclipseClasspath(this, getWorkspace().getBase(), getBase()); eclipse.setRecurse(false); // We get the file directories but in this case we need // to tell ant that the project names for (File dependent : eclipse.getDependents()) { Project required = workspace.getProject(dependent.getName()); dependson.add(required); } for (File f : eclipse.getClasspath()) { buildpath.add(new Container(f, null)); } for (File f : eclipse.getBootclasspath()) { bootclasspath.add(new Container(f, null)); } sourcepath.addAll(eclipse.getSourcepath()); allsourcepath.addAll(eclipse.getAllSources()); output = eclipse.getOutput(); } public String _p_dependson(String args[]) throws Exception { return list(args, toFiles(getDependson())); } private Collection< ? > toFiles(Collection<Project> projects) { List<File> files = new ArrayList<File>(); for (Project p : projects) { files.add(p.getBase()); } return files; } public String _p_buildpath(String args[]) throws Exception { return list(args, getBuildpath()); } public String _p_testpath(String args[]) throws Exception { return list(args, getRunpath()); } public String _p_sourcepath(String args[]) throws Exception { return list(args, getSourcePath()); } public String _p_allsourcepath(String args[]) throws Exception { return list(args, getAllsourcepath()); } public String _p_bootclasspath(String args[]) throws Exception { return list(args, getBootclasspath()); } public String _p_output(String args[]) throws Exception { if (args.length != 1) throw new IllegalArgumentException("${output} should not have arguments"); return getOutput().getAbsolutePath(); } private String list(String[] args, Collection< ? > list) { if (args.length > 3) throw new IllegalArgumentException("${" + args[0] + "[;<separator>]} can only take a separator as argument, has " + Arrays.toString(args)); String separator = ","; if (args.length == 2) { separator = args[1]; } return join(list, separator); } @Override protected Object[] getMacroDomains() { return new Object[] { workspace }; } public File release(String jarName, InputStream jarStream) throws Exception { String name = getProperty(Constants.RELEASEREPO); return release(name, jarName, jarStream); } public URI releaseURI(String jarName, InputStream jarStream) throws Exception { String name = getProperty(Constants.RELEASEREPO); return releaseURI(name, jarName, jarStream); } /** * Release * * @param name * The repository name * @param jarName * @param jarStream * @return * @throws Exception */ public File release(String name, String jarName, InputStream jarStream) throws Exception { URI uri = releaseURI(name, jarName, jarStream); if (uri != null && uri.getScheme().equals("file")) { return new File(uri); } return null; } public URI releaseURI(String name, String jarName, InputStream jarStream) throws Exception { trace("release to %s", name); RepositoryPlugin repo = getReleaseRepo(name); if (repo == null) { if (name == null) msgs.NoNameForReleaseRepository(); else msgs.ReleaseRepository_NotFoundIn_(name, getPlugins(RepositoryPlugin.class)); return null; } try { PutResult r = repo.put(jarStream, new RepositoryPlugin.PutOptions()); trace("Released %s to %s in repository %s", jarName, r.artifact, repo); return r.artifact; } catch (Exception e) { msgs.Release_Into_Exception_(jarName, repo, e); return null; } } RepositoryPlugin getReleaseRepo(String releaserepo) { String name = releaserepo == null ? name = getProperty(RELEASEREPO) : releaserepo; List<RepositoryPlugin> plugins = getPlugins(RepositoryPlugin.class); for (RepositoryPlugin plugin : plugins) { if (!plugin.canWrite()) continue; if (name == null) return plugin; if (name.equals(plugin.getName())) return plugin; } return null; } public void release(boolean test) throws Exception { String name = getProperty(Constants.RELEASEREPO); release(name, test); } /** * Release * * @param name * The respository name * @param test * Run testcases * @throws Exception */ public void release(String name, boolean test) throws Exception { trace("release"); File[] jars = build(test); // If build fails jars will be null if (jars == null) { trace("no jars being build"); return; } trace("build ", Arrays.toString(jars)); for (File jar : jars) { release(name, jar.getName(), new BufferedInputStream(new FileInputStream(jar))); } } /** * Get a bundle from one of the plugin repositories. If an exact version is * required we just return the first repository found (in declaration order * in the build.bnd file). * * @param bsn * The bundle symbolic name * @param range * The version range * @param lowest * set to LOWEST or HIGHEST * @return the file object that points to the bundle or null if not found * @throws Exception * when something goes wrong */ public Container getBundle(String bsn, String range, Strategy strategy, Map<String,String> attrs) throws Exception { if (range == null) range = "0"; if (VERSION_ATTR_SNAPSHOT.equals(range) || VERSION_ATTR_PROJECT.equals(range)) { return getBundleFromProject(bsn, attrs); } Strategy useStrategy = strategy; if (VERSION_ATTR_LATEST.equals(range)) { Container c = getBundleFromProject(bsn, attrs); if (c != null) return c; useStrategy = Strategy.HIGHEST; } useStrategy = overrideStrategy(attrs, useStrategy); List<RepositoryPlugin> plugins = workspace.getRepositories(); if (useStrategy == Strategy.EXACT) { if (!Verifier.isVersion(range)) return new Container(this, bsn, range, Container.TYPE.ERROR, null, bsn + ";version=" + range + " Invalid version", null, null); // For an exact range we just iterate over the repos // and return the first we find. Version version = new Version(range); for (RepositoryPlugin plugin : plugins) { DownloadBlocker blocker = new DownloadBlocker(this); File result = plugin.get(bsn, version, attrs, blocker); if (result != null) return toContainer(bsn, range, attrs, result, blocker); } } else { VersionRange versionRange = VERSION_ATTR_LATEST.equals(range) ? new VersionRange("0") : new VersionRange( range); // We have a range search. Gather all the versions in all the repos // and make a decision on that choice. If the same version is found // in // multiple repos we take the first SortedMap<Version,RepositoryPlugin> versions = new TreeMap<Version,RepositoryPlugin>(); for (RepositoryPlugin plugin : plugins) { try { SortedSet<Version> vs = plugin.versions(bsn); if (vs != null) { for (Version v : vs) { if (!versions.containsKey(v) && versionRange.includes(v)) versions.put(v, plugin); } } } catch (UnsupportedOperationException ose) { // We have a plugin that cannot list versions, try // if it has this specific version // The main reaosn for this code was the Maven Remote // Repository // To query, we must have a real version if (!versions.isEmpty() && Verifier.isVersion(range)) { Version version = new Version(range); DownloadBlocker blocker = new DownloadBlocker(this); File file = plugin.get(bsn, version, attrs, blocker); // and the entry must exist // if it does, return this as a result if (file != null) return toContainer(bsn, range, attrs, file, blocker); } } } // Verify if we found any, if so, we use the strategy to pick // the first or last if (!versions.isEmpty()) { Version provider = null; switch (useStrategy) { case HIGHEST : provider = versions.lastKey(); break; case LOWEST : provider = versions.firstKey(); break; case EXACT : // TODO need to handle exact better break; } if (provider != null) { RepositoryPlugin repo = versions.get(provider); String version = provider.toString(); DownloadBlocker blocker = new DownloadBlocker(this); File result = repo.get(bsn, provider, attrs, blocker); if (result != null) return toContainer(bsn, version, attrs, result, blocker); } else msgs.FoundVersions_ForStrategy_ButNoProvider(versions, useStrategy); } } // // If we get this far we ran into an error somewhere // // Check if we try to find a BSN that is in the workspace but marked // latest // if (!range.equals(VERSION_ATTR_LATEST)) { Container c = getBundleFromProject(bsn, attrs); return new Container(this, bsn, range, Container.TYPE.ERROR, null, bsn + ";version=" + range + " Not found because latest was not specified." + " It is, however, present in the workspace. Add '" + bsn + ";version=(latest|snapshot)' to see the bundle in the workspace.", null, null); } return new Container(this, bsn, range, Container.TYPE.ERROR, null, bsn + ";version=" + range + " Not found in " + plugins, null, null); } /** * @param attrs * @param useStrategy * @return */ protected Strategy overrideStrategy(Map<String,String> attrs, Strategy useStrategy) { if (attrs != null) { String overrideStrategy = attrs.get("strategy"); if (overrideStrategy != null) { if ("highest".equalsIgnoreCase(overrideStrategy)) useStrategy = Strategy.HIGHEST; else if ("lowest".equalsIgnoreCase(overrideStrategy)) useStrategy = Strategy.LOWEST; else if ("exact".equalsIgnoreCase(overrideStrategy)) useStrategy = Strategy.EXACT; } } return useStrategy; } /** * @param bsn * @param range * @param attrs * @param result * @return */ protected Container toContainer(String bsn, String range, Map<String,String> attrs, File result, DownloadBlocker db) { File f = result; if (f == null) { msgs.ConfusedNoContainerFile(); f = new File("was null"); } Container container; if (f.getName().endsWith("lib")) container = new Container(this, bsn, range, Container.TYPE.LIBRARY, f, null, attrs, db); else container = new Container(this, bsn, range, Container.TYPE.REPO, f, null, attrs, db); return container; } /** * Look for the bundle in the workspace. The premise is that the bsn must * start with the project name. * * @param bsn * The bsn * @param attrs * Any attributes * @return * @throws Exception */ private Container getBundleFromProject(String bsn, Map<String,String> attrs) throws Exception { String pname = bsn; while (true) { Project p = getWorkspace().getProject(pname); if (p != null && p.isValid()) { Container c = p.getDeliverable(bsn, attrs); return c; } int n = pname.lastIndexOf('.'); if (n <= 0) return null; pname = pname.substring(0, n); } } /** * Deploy the file (which must be a bundle) into the repository. * * @param name * The repository name * @param file * bundle */ public void deploy(String name, File file) throws Exception { List<RepositoryPlugin> plugins = getPlugins(RepositoryPlugin.class); RepositoryPlugin rp = null; for (RepositoryPlugin plugin : plugins) { if (!plugin.canWrite()) { continue; } if (name == null) { rp = plugin; break; } else if (name.equals(plugin.getName())) { rp = plugin; break; } } if (rp != null) { try { rp.put(new BufferedInputStream(new FileInputStream(file)), new RepositoryPlugin.PutOptions()); return; } catch (Exception e) { msgs.DeployingFile_On_Exception_(file, rp.getName(), e); } return; } trace("No repo found " + file); throw new IllegalArgumentException("No repository found for " + file); } /** * Deploy the file (which must be a bundle) into the repository. * * @param file * bundle */ public void deploy(File file) throws Exception { String name = getProperty(Constants.DEPLOYREPO); deploy(name, file); } /** * Deploy the current project to a repository * * @throws Exception */ public void deploy() throws Exception { Parameters deploy = new Parameters(getProperty(DEPLOY)); if (deploy.isEmpty()) { warning("Deploying but %s is not set to any repo", DEPLOY); return; } File[] outputs = getBuildFiles(); for (File output : outputs) { for (Deploy d : getPlugins(Deploy.class)) { trace("Deploying %s to: %s", output.getName(), d); try { if (d.deploy(this, output.getName(), new BufferedInputStream(new FileInputStream(output)))) trace("deployed %s successfully to %s", output, d); } catch (Exception e) { msgs.Deploying(e); } } } } /** * Macro access to the repository ${repo;<bsn>[;<version>[;<low|high>]]} */ static String _repoHelp = "${repo ';'<bsn> [ ; <version> [; ('HIGHEST'|'LOWEST')]}"; public String _repo(String args[]) throws Exception { if (args.length < 2) { msgs.RepoTooFewArguments(_repoHelp, args); return null; } String bsns = args[1]; String version = null; Strategy strategy = Strategy.HIGHEST; if (args.length > 2) { version = args[2]; if (args.length == 4) { if (args[3].equalsIgnoreCase("HIGHEST")) strategy = Strategy.HIGHEST; else if (args[3].equalsIgnoreCase("LOWEST")) strategy = Strategy.LOWEST; else if (args[3].equalsIgnoreCase("EXACT")) strategy = Strategy.EXACT; else msgs.InvalidStrategy(_repoHelp, args); } } Collection<String> parts = split(bsns); List<String> paths = new ArrayList<String>(); for (String bsn : parts) { Container container = getBundle(bsn, version, strategy, null); if (container.getError() != null) { error("${repo} macro refers to an artifact %s-%s (%s) that has an error: %s", bsn, version, strategy, container.getError()); } else add(paths, container); } return join(paths); } private void add(List<String> paths, Container container) throws Exception { if (container.getType() == Container.TYPE.LIBRARY) { List<Container> members = container.getMembers(); for (Container sub : members) { add(paths, sub); } } else { if (container.getError() == null) paths.add(container.getFile().getAbsolutePath()); else { paths.add("<<${repo} = " + container.getBundleSymbolicName() + "-" + container.getVersion() + " : " + container.getError() + ">>"); if (isPedantic()) { warning("Could not expand repo path request: %s ", container); } } } } public File getTarget() throws Exception { prepare(); return target; } /** * This is the external method that will pre-build any dependencies if it is * out of date. * * @param underTest * @return * @throws Exception */ public File[] build(boolean underTest) throws Exception { if (isNoBundles()) return null; if (getProperty("-nope") != null) { warning("Please replace -nope with %s", NOBUNDLES); return null; } if (isStale()) { trace("building " + this); files = buildLocal(underTest); } return files; } /** * Return the files */ public File[] getFiles() { return files; } /** * Check if this project needs building. This is defined as: */ public boolean isStale() throws Exception { if (workspace == null || workspace.isOffline()) { trace("working %s offline, so always stale", this); return true; } Set<Project> visited = new HashSet<Project>(); return isStale(visited); } boolean isStale(Set<Project> visited) throws Exception { // When we do not generate anything ... if (isNoBundles()) return false; if (visited.contains(this)) { msgs.CircularDependencyContext_Message_(this.getName(), visited.toString()); return false; } visited.add(this); long buildTime = 0; files = getBuildFiles(false); if (files == null) return true; for (File f : files) { if (f.lastModified() < lastModified()) return true; if (buildTime < f.lastModified()) buildTime = f.lastModified(); } for (Project dependency : getDependson()) { if (dependency == this) continue; if (dependency.isStale()) return true; if (dependency.isNoBundles()) continue; File[] deps = dependency.getBuildFiles(); for (File f : deps) { if (f.lastModified() >= buildTime) return true; } } return false; } /** * This method must only be called when it is sure that the project has been * build before in the same session. It is a bit yucky, but ant creates * different class spaces which makes it hard to detect we already build it. * This method remembers the files in the appropriate instance vars. * * @return */ public File[] getBuildFiles() throws Exception { return getBuildFiles(true); } public File[] getBuildFiles(boolean buildIfAbsent) throws Exception { if (files != null) return files; File f = new File(getTarget(), BUILDFILES); if (f.isFile()) { BufferedReader rdr = IO.reader(f); try { List<File> files = newList(); for (String s = rdr.readLine(); s != null; s = rdr.readLine()) { s = s.trim(); File ff = new File(s); if (!ff.isFile()) { // Originally we warned the user // but lets just rebuild. That way // the error is not noticed but // it seems better to correct, // See #154 rdr.close(); f.delete(); break; } files.add(ff); } return this.files = files.toArray(new File[files.size()]); } finally { rdr.close(); } } if (buildIfAbsent) return files = buildLocal(false); return files = null; } /** * Build without doing any dependency checking. Make sure any dependent * projects are built first. * * @param underTest * @return * @throws Exception */ public File[] buildLocal(boolean underTest) throws Exception { if (isNoBundles()) return null; File bfs = new File(getTarget(), BUILDFILES); bfs.delete(); files = null; ProjectBuilder builder = getBuilder(null); try { if (underTest) builder.setProperty(Constants.UNDERTEST, "true"); Jar jars[] = builder.builds(); File[] files = new File[jars.length]; getInfo(builder); if (isOk()) { this.files = files; for (int i = 0; i < jars.length; i++) { Jar jar = jars[i]; File file = saveBuild(jar); if (file == null) { getInfo(builder); error("Could not save %s", jar.getName()); return this.files = null; } this.files[i] = file; } // Write out the filenames in the buildfiles file // so we can get them later evenin another process Writer fw = IO.writer(bfs); try { for (File f : files) { fw.append(f.getAbsolutePath()); fw.append("\n"); } } finally { fw.close(); } getWorkspace().changedFile(bfs); return files; } return null; } finally { builder.close(); } } /** * Answer if this project does not have any output * * @return */ public boolean isNoBundles() { return getProperty(NOBUNDLES) != null; } public File saveBuild(Jar jar) throws Exception { try { File f = getOutputFile(jar.getBsn(), jar.getVersion()); String msg = ""; if (!f.exists() || f.lastModified() < jar.lastModified()) { reportNewer(f.lastModified(), jar); f.delete(); File fp = f.getParentFile(); if (!fp.isDirectory()) { if (!fp.exists() && !fp.mkdirs()) { throw new IOException("Could not create directory " + fp); } } jar.write(f); getWorkspace().changedFile(f); } else { msg = "(not modified since " + new Date(f.lastModified()) + ")"; } trace(jar.getName() + " (" + f.getName() + ") " + jar.getResources().size() + " " + msg); return f; } finally { jar.close(); } } /** * Calculate the file for a JAR. The default name is bsn.jar, but this can * be overridden with an * * @param jar * @return * @throws Exception */ public File getOutputFile(String bsn, String version) throws Exception { if (version == null) version = "0"; Processor scoped = new Processor(this); try { scoped.setProperty("@bsn", bsn); scoped.setProperty("@version", version.toString()); String path = scoped.getProperty(OUTPUTMASK, bsn + ".jar"); return IO.getFile(getTarget(), path); } finally { scoped.close(); } } public File getOutputFile(String bsn) throws Exception { return getOutputFile(bsn, "0.0.0"); } private void reportNewer(long lastModified, Jar jar) { if (isTrue(getProperty(Constants.REPORTNEWER))) { StringBuilder sb = new StringBuilder(); String del = "Newer than " + new Date(lastModified); for (Map.Entry<String,Resource> entry : jar.getResources().entrySet()) { if (entry.getValue().lastModified() > lastModified) { sb.append(del); del = ", \n "; sb.append(entry.getKey()); } } if (sb.length() > 0) warning(sb.toString()); } } /** * Refresh if we are based on stale data. This also implies our workspace. */ @Override public boolean refresh() { boolean changed = false; if (isCnf()) { changed = workspace.refresh(); } return super.refresh() || changed; } public boolean isCnf() { return getBase().getName().equals(Workspace.CNFDIR); } @Override public void propertiesChanged() { super.propertiesChanged(); preparedPaths = false; files = null; } public String getName() { return getBase().getName(); } public Map<String,Action> getActions() { Map<String,Action> all = newMap(); Map<String,Action> actions = newMap(); fillActions(all); getWorkspace().fillActions(all); for (Map.Entry<String,Action> action : all.entrySet()) { String key = getReplacer().process(action.getKey()); if (key != null && key.trim().length() != 0) actions.put(key, action.getValue()); } return actions; } public void fillActions(Map<String,Action> all) { List<NamedAction> plugins = getPlugins(NamedAction.class); for (NamedAction a : plugins) all.put(a.getName(), a); Parameters actions = new Parameters(getProperty("-actions", DEFAULT_ACTIONS)); for (Entry<String,Attrs> entry : actions.entrySet()) { String key = Processor.removeDuplicateMarker(entry.getKey()); Action action; if (entry.getValue().get("script") != null) { // TODO check for the type action = new ScriptAction(entry.getValue().get("type"), entry.getValue().get("script")); } else { action = new ReflectAction(key); } String label = entry.getValue().get("label"); all.put(label.toLowerCase(), action); } } public void release() throws Exception { release(false); } @SuppressWarnings("resource") public void export(String runFilePath, boolean keep, File output) throws Exception { prepare(); OutputStream outStream = null; try { Project packageProject; if (runFilePath == null || runFilePath.length() == 0 || ".".equals(runFilePath)) { packageProject = this; } else { File runFile = new File(getBase(), runFilePath); if (!runFile.isFile()) throw new IOException(String.format("Run file %s does not exist (or is not a file).", runFile.getAbsolutePath())); packageProject = new Project(getWorkspace(), getBase(), runFile); packageProject.setParent(this); } packageProject.clear(); ProjectLauncher launcher = packageProject.getProjectLauncher(); launcher.setKeep(keep); Jar jar = launcher.executable(); outStream = new FileOutputStream(output); jar.write(outStream); } finally { IO.close(outStream); } } /** * Release. * * @param name * The repository name * @throws Exception */ public void release(String name) throws Exception { release(name, false); } public void clean() throws Exception { File target = getTarget0(); if (target.isDirectory() && target.getParentFile() != null) { IO.delete(target); if (!target.exists() && !target.mkdirs()) { throw new IOException("Could not create directory " + target); } } File output = getSrcOutput().getAbsoluteFile(); if (getOutput().isDirectory()) IO.delete(output); if (!output.exists() && !output.mkdirs()) { throw new IOException("Could not create directory " + output); } } public File[] build() throws Exception { return build(false); } public void run() throws Exception { ProjectLauncher pl = getProjectLauncher(); pl.setTrace(isTrace()); pl.launch(); } public void test() throws Exception { String testcases = getProperties().getProperty(Constants.TESTCASES); if (testcases == null) { warning("No %s set", Constants.TESTCASES); return; } clear(); ProjectTester tester = getProjectTester(); tester.setContinuous(isTrue(getProperty(Constants.TESTCONTINUOUS))); tester.prepare(); if (!isOk()) { return; } int errors = tester.test(); if (errors == 0) { System.err.println("No Errors"); } else { if (errors > 0) { System.err.println(errors + " Error(s)"); } else System.err.println("Error " + errors); } } /** * Run JUnit * @throws Exception */ public void junit() throws Exception { JUnitLauncher launcher = new JUnitLauncher(this); launcher.launch(); } /** * This methods attempts to turn any jar into a valid jar. If this is a * bundle with manifest, a manifest is added based on defaults. If it is a * bundle, but not r4, we try to add the r4 headers. * * @param descriptor * @param in * @return * @throws Exception */ public Jar getValidJar(File f) throws Exception { Jar jar = new Jar(f); return getValidJar(jar, f.getAbsolutePath()); } public Jar getValidJar(URL url) throws Exception { InputStream in = url.openStream(); try { Jar jar = new Jar(url.getFile().replace('/', '.'), in, System.currentTimeMillis()); return getValidJar(jar, url.toString()); } finally { in.close(); } } public Jar getValidJar(Jar jar, String id) throws Exception { Manifest manifest = jar.getManifest(); if (manifest == null) { trace("Wrapping with all defaults"); Builder b = new Builder(this); this.addClose(b); b.addClasspath(jar); b.setProperty("Bnd-Message", "Wrapped from " + id + "because lacked manifest"); b.setProperty(Constants.EXPORT_PACKAGE, "*"); b.setProperty(Constants.IMPORT_PACKAGE, "*;resolution:=optional"); jar = b.build(); } else if (manifest.getMainAttributes().getValue(Constants.BUNDLE_MANIFESTVERSION) == null) { trace("Not a release 4 bundle, wrapping with manifest as source"); Builder b = new Builder(this); this.addClose(b); b.addClasspath(jar); b.setProperty(Constants.PRIVATE_PACKAGE, "*"); b.mergeManifest(manifest); String imprts = manifest.getMainAttributes().getValue(Constants.IMPORT_PACKAGE); if (imprts == null) imprts = ""; else imprts += ","; imprts += "*;resolution=optional"; b.setProperty(Constants.IMPORT_PACKAGE, imprts); b.setProperty("Bnd-Message", "Wrapped from " + id + "because had incomplete manifest"); jar = b.build(); } return jar; } public String _project(@SuppressWarnings("unused") String args[]) { return getBase().getAbsolutePath(); } /** * Bump the version of this project. First check the main bnd file. If this * does not contain a version, check the include files. If they still do not * contain a version, then check ALL the sub builders. If not, add a version * to the main bnd file. * * @param mask * the mask for bumping, see {@link Macro#_version(String[])} * @throws Exception */ public void bump(String mask) throws Exception { String pattern = "(Bundle-Version\\s*(:|=)\\s*)(([0-9]+(\\.[0-9]+(\\.[0-9]+)?)?))"; String replace = "$1${version;" + mask + ";$3}"; try { // First try our main bnd file if (replace(getPropertiesFile(), pattern, replace)) return; trace("no version in bnd.bnd"); // Try the included filed in reverse order (last has highest // priority) List<File> included = getIncluded(); if (included != null) { List<File> copy = new ArrayList<File>(included); Collections.reverse(copy); for (File file : copy) { if (replace(file, pattern, replace)) { trace("replaced version in file %s", file); return; } } } trace("no version in included files"); boolean found = false; // Replace in all sub builders. for (Builder sub : getSubBuilders()) { found |= replace(sub.getPropertiesFile(), pattern, replace); } if (!found) { trace("no version in sub builders, add it to bnd.bnd"); String bndfile = IO.collect(getPropertiesFile()); bndfile += "\n# Added by by bump\nBundle-Version: 0.0.0\n"; IO.store(bndfile, getPropertiesFile()); } } finally { forceRefresh(); } } boolean replace(File f, String pattern, String replacement) throws IOException { final Macro macro = getReplacer(); Sed sed = new Sed(new Replacer() { public String process(String line) { return macro.process(line); } }, f); sed.replace(pattern, replacement); return sed.doIt() > 0; } public void bump() throws Exception { bump(getProperty(BUMPPOLICY, "=+0")); } public void action(String command) throws Exception { Map<String,Action> actions = getActions(); Action a = actions.get(command); if (a == null) a = new ReflectAction(command); before(this, command); try { a.execute(this, command); } catch (Exception t) { after(this, command, t); throw t; } } /** * Run all before command plugins */ void before(@SuppressWarnings("unused") Project p, String a) { List<CommandPlugin> testPlugins = getPlugins(CommandPlugin.class); for (CommandPlugin testPlugin : testPlugins) { testPlugin.before(this, a); } } /** * Run all after command plugins */ void after(@SuppressWarnings("unused") Project p, String a, Throwable t) { List<CommandPlugin> testPlugins = getPlugins(CommandPlugin.class); for (int i = testPlugins.size() - 1; i >= 0; i--) { testPlugins.get(i).after(this, a, t); } } public String _findfile(String args[]) { File f = getFile(args[1]); List<String> files = new ArrayList<String>(); tree(files, f, "", new Instruction(args[2])); return join(files); } void tree(List<String> list, File current, String path, Instruction instr) { if (path.length() > 0) path = path + "/"; String subs[] = current.list(); if (subs != null) { for (String sub : subs) { File f = new File(current, sub); if (f.isFile()) { if (instr.matches(sub) && !instr.isNegated()) list.add(path + sub); } else tree(list, f, path + sub, instr); } } } public void refreshAll() { workspace.refresh(); refresh(); } @SuppressWarnings("unchecked") public void script(@SuppressWarnings("unused") String type, String script) throws Exception { // TODO check tyiping List<Scripter> scripters = getPlugins(Scripter.class); if (scripters.isEmpty()) { msgs.NoScripters_(script); return; } @SuppressWarnings("rawtypes") Map x = getProperties(); scripters.get(0).eval(x, new StringReader(script)); } public String _repos(@SuppressWarnings("unused") String args[]) throws Exception { List<RepositoryPlugin> repos = getPlugins(RepositoryPlugin.class); List<String> names = new ArrayList<String>(); for (RepositoryPlugin rp : repos) names.add(rp.getName()); return join(names, ", "); } public String _help(String args[]) throws Exception { if (args.length == 1) return "Specify the option or header you want information for"; Syntax syntax = Syntax.HELP.get(args[1]); if (syntax == null) return "No help for " + args[1]; String what = null; if (args.length > 2) what = args[2]; if (what == null || what.equals("lead")) return syntax.getLead(); if (what.equals("example")) return syntax.getExample(); if (what.equals("pattern")) return syntax.getPattern(); if (what.equals("values")) return syntax.getValues(); return "Invalid type specified for help: lead, example, pattern, values"; } /** * Returns containers for the deliverables of this project. The deliverables * is the project builder for this project if no -sub is specified. * Otherwise it contains all the sub bnd files. * * @return A collection of containers * @throws Exception */ public Collection<Container> getDeliverables() throws Exception { List<Container> result = new ArrayList<Container>(); Collection< ? extends Builder> builders = getSubBuilders(); for (Builder builder : builders) { Container c = new Container(this, builder.getBsn(), builder.getVersion(), Container.TYPE.PROJECT, getOutputFile(builder.getBsn()), null, null, null); result.add(c); } return result; } /** * Return the builder associated with the give bnd file or null. The bnd.bnd * file can contain -sub option. This option allows specifying files in the * same directory that should drive the generation of multiple deliverables. * This method figures out if the bndFile is actually one of the bnd files * of a deliverable. * * @param bndFile * A file pointing to a bnd file. * @return null or the builder for a sub file. * @throws Exception */ public Builder getSubBuilder(File bndFile) throws Exception { bndFile = bndFile.getCanonicalFile(); // Verify that we are inside the project. File base = getBase().getCanonicalFile(); if (!bndFile.getAbsolutePath().startsWith(base.getAbsolutePath())) return null; Collection< ? extends Builder> builders = getSubBuilders(); for (Builder sub : builders) { File propertiesFile = sub.getPropertiesFile(); if (propertiesFile != null) { if (propertiesFile.getCanonicalFile().equals(bndFile)) { // Found it! return sub; } } } return null; } /** * Return a build that maps to the sub file. * * @param string * @throws Exception */ public ProjectBuilder getSubBuilder(String string) throws Exception { Collection< ? extends Builder> builders = getSubBuilders(); for (Builder b : builders) { if (b.getBsn().equals(string) || b.getBsn().endsWith("." + string)) return (ProjectBuilder) b; } return null; } /** * Answer the container associated with a given bsn. * * @param bndFile * A file pointing to a bnd file. * @return null or the builder for a sub file. * @throws Exception */ public Container getDeliverable(String bsn, @SuppressWarnings("unused") Map<String,String> attrs) throws Exception { Collection< ? extends Builder> builders = getSubBuilders(); for (Builder sub : builders) { if (sub.getBsn().equals(bsn)) return new Container(this, getOutputFile(bsn, sub.getVersion())); } return null; } /** * Get a list of the sub builders. A bnd.bnd file can contain the -sub * option. This will generate multiple deliverables. This method returns the * builders for each sub file. If no -sub option is present, the list will * contain a builder for the bnd.bnd file. * * @return A list of builders. * @throws Exception */ public Collection< ? extends Builder> getSubBuilders() throws Exception { return getBuilder(null).getSubBuilders(); } /** * Calculate the classpath. We include our own runtime.jar which includes * the test framework and we include the first of the test frameworks * specified. * * @throws Exception */ Collection<File> toFile(Collection<Container> containers) throws Exception { ArrayList<File> files = new ArrayList<File>(); for (Container container : containers) { container.contributeFiles(files, this); } return files; } public Collection<String> getRunVM() { Parameters hdr = getParameters(RUNVM); return hdr.keySet(); } public Collection<String> getRunProgramArgs() { Parameters hdr = getParameters(RUNPROGRAMARGS); return hdr.keySet(); } public Map<String,String> getRunProperties() { return OSGiHeader.parseProperties(getProperty(RUNPROPERTIES)); } /** * Get a launcher. * * @return * @throws Exception */ public ProjectLauncher getProjectLauncher() throws Exception { return getHandler(ProjectLauncher.class, getRunpath(), LAUNCHER_PLUGIN, "biz.aQute.launcher"); } public ProjectTester getProjectTester() throws Exception { return getHandler(ProjectTester.class, getTestpath(), TESTER_PLUGIN, "biz.aQute.junit"); } private <T> T getHandler(Class<T> target, Collection<Container> containers, String header, String defaultHandler) throws Exception { Class< ? extends T> handlerClass = target; // Make sure we find at least one handler, but hope to find an earlier // one List<Container> withDefault = Create.list(); withDefault.addAll(containers); withDefault.addAll(getBundles(Strategy.HIGHEST, defaultHandler, null)); trace("candidates for tester %s", withDefault); for (Container c : withDefault) { Manifest manifest = c.getManifest(); if (manifest != null) { String launcher = manifest.getMainAttributes().getValue(header); if (launcher != null) { Class< ? > clz = getClass(launcher, c.getFile()); if (clz != null) { if (!target.isAssignableFrom(clz)) { msgs.IncompatibleHandler_For_(launcher, defaultHandler); } else { trace("found handler %s from %s", defaultHandler, c); handlerClass = clz.asSubclass(target); Constructor< ? extends T> constructor = handlerClass.getConstructor(Project.class); return constructor.newInstance(this); } } } } } throw new IllegalArgumentException("Default handler for " + header + " not found in " + defaultHandler); } /** * Make this project delay the calculation of the run dependencies. The run * dependencies calculation can be done in prepare or until the dependencies * are actually needed. */ public void setDelayRunDependencies(boolean x) { delayRunDependencies = x; } /** * Sets the package version on an exported package * * @param packageName * The package name * @param version * The new package version */ public void setPackageInfo(String packageName, Version version) { try { Version current = getPackageInfoJavaVersion(packageName); boolean packageInfoJava = false; if (current != null) { updatePackageInfoJavaFile(packageName, version); packageInfoJava = true; } if (!packageInfoJava || getPackageInfoFile(packageName).exists()) { updatePackageInfoFile(packageName, version); } } catch (Exception e) { msgs.SettingPackageInfoException_(e); } } void updatePackageInfoJavaFile(String packageName, final Version newVersion) throws Exception { File file = getPackageInfoJavaFile(packageName); if (!file.exists()) { return; } // If package/classes are copied into the bundle through Private-Package // etc, there will be no source if (!file.getParentFile().exists()) { return; } Version oldVersion = getPackageInfo(packageName); if (newVersion.compareTo(oldVersion) == 0) { return; } Sed sed = new Sed(new Replacer() { public String process(String line) { Matcher m = VERSION_ANNOTATION.matcher(line); if (m.find()) { return line.substring(0, m.start(3)) + newVersion.toString() + line.substring(m.end(3)); } return line; } }, file); sed.replace(VERSION_ANNOTATION.pattern(), "$0"); sed.setBackup(false); sed.doIt(); } void updatePackageInfoFile(String packageName, Version newVersion) throws Exception { File file = getPackageInfoFile(packageName); // If package/classes are copied into the bundle through Private-Package // etc, there will be no source if (!file.getParentFile().exists()) { return; } Version oldVersion = getPackageInfoVersion(packageName); if (oldVersion == null) { oldVersion = Version.emptyVersion; } if (newVersion.compareTo(oldVersion) == 0) { return; } PrintWriter pw = IO.writer(file); pw.println("version " + newVersion); pw.flush(); pw.close(); String path = packageName.replace('.', '/') + "/packageinfo"; File binary = IO.getFile(getOutput(), path); File bp = binary.getParentFile(); if (!bp.exists() && !bp.mkdirs()) { throw new IOException("Could not create directory " + bp); } IO.copy(file, binary); } File getPackageInfoFile(String packageName) { String path = packageName.replace('.', '/') + "/packageinfo"; return IO.getFile(getSrc(), path); } File getPackageInfoJavaFile(String packageName) { String path = packageName.replace('.', '/') + "/package-info.java"; return IO.getFile(getSrc(), path); } public Version getPackageInfo(String packageName) throws IOException { Version version = getPackageInfoJavaVersion(packageName); if (version != null) { return version; } version = getPackageInfoVersion(packageName); if (version != null) { return version; } return Version.emptyVersion; } Version getPackageInfoVersion(String packageName) throws IOException { File packageInfoFile = getPackageInfoFile(packageName); if (!packageInfoFile.exists()) { return null; } BufferedReader reader = IO.reader(packageInfoFile); try { String line; while ((line = reader.readLine()) != null) { line = line.trim(); if (line.startsWith("version ")) { return Version.parseVersion(line.substring(8)); } } } finally { IO.close(reader); } return null; } Version getPackageInfoJavaVersion(String packageName) throws IOException { File packageInfoJavaFile = getPackageInfoJavaFile(packageName); if (!packageInfoJavaFile.exists()) { return null; } BufferedReader reader = null; reader = IO.reader(packageInfoJavaFile); try { String line; while ((line = reader.readLine()) != null) { Matcher matcher = VERSION_ANNOTATION.matcher(line); if (matcher.find()) { return Version.parseVersion(matcher.group(3)); } } } finally { IO.close(reader); } return null; } /** * bnd maintains a class path that is set by the environment, i.e. bnd is * not in charge of it. */ public void addClasspath(File f) { if (!f.isFile() && !f.isDirectory()) { msgs.AddingNonExistentFileToClassPath_(f); } Container container = new Container(f, null); classpath.add(container); } public void clearClasspath() { classpath.clear(); } public Collection<Container> getClasspath() { return classpath; } /** * Pack the project (could be a bndrun file) and save it on disk. Report * errors if they happen. */ static List<String> ignore = new ExtList<String>(BUNDLE_SPECIFIC_HEADERS); public Jar pack(String profile) throws Exception { Collection< ? extends Builder> subBuilders = getSubBuilders(); if (subBuilders.size() != 1) { error("Project has multiple bnd files, please select one of the bnd files"); return null; } Builder b = subBuilders.iterator().next(); ignore.remove(BUNDLE_SYMBOLICNAME); ignore.remove(BUNDLE_VERSION); ignore.add(SERVICE_COMPONENT); ProjectLauncher launcher = getProjectLauncher(); launcher.getRunProperties().put("profile", profile); // TODO remove launcher.getRunProperties().put(PROFILE, profile); Jar jar = launcher.executable(); Manifest m = jar.getManifest(); Attributes main = m.getMainAttributes(); for (String key : getPropertyKeys(true)) { if (Character.isUpperCase(key.charAt(0)) && !ignore.contains(key)) { main.putValue(key, getProperty(key)); } } if (main.getValue(BUNDLE_SYMBOLICNAME) == null) main.putValue(BUNDLE_SYMBOLICNAME, b.getBsn()); if (main.getValue(BUNDLE_SYMBOLICNAME) == null) main.putValue(BUNDLE_SYMBOLICNAME, getName()); if (main.getValue(BUNDLE_VERSION) == null) { main.putValue(BUNDLE_VERSION, Version.LOWEST.toString()); warning("No version set, uses 0.0.0"); } jar.setManifest(m); jar.calcChecksums(new String[] { "SHA1", "MD5" }); return jar; } /** * Do a baseline for this project * * @throws Exception */ public void baseline() throws Exception { ProjectBuilder b = getBuilder(null); for (Builder pb : b.getSubBuilders()) { ProjectBuilder ppb = (ProjectBuilder) pb; Jar build = ppb.build(); getInfo(ppb); } getInfo(b); } /** * Method to verify that the paths are correct, ie no missing dependencies * * @param test * for test cases, also adds -testpath * @throws Exception */ public void verifyDependencies(boolean test) throws Exception { verifyDependencies(RUNBUNDLES, getRunbundles()); verifyDependencies(RUNPATH, getRunpath()); if (test) verifyDependencies(TESTPATH, getTestpath()); verifyDependencies(BUILDPATH, getBuildpath()); } private void verifyDependencies(String title, Collection<Container> path) throws Exception { List<String> msgs = new ArrayList<String>(); for (Container c : new ArrayList<Container>(path)) { for (Container cc : c.getMembers()) { if (cc.getError() != null) msgs.add(cc + " - " + cc.getError()); else if (!cc.getFile().isFile() && !cc.getFile().equals(cc.getProject().getOutput()) && !cc.getFile().equals(cc.getProject().getTestOutput())) msgs.add(cc + " file does not exists: " + cc.getFile()); } } if (msgs.isEmpty()) return; error("%s: has errors: %s", title, Strings.join(msgs)); } /** * Report detailed info from this project * * @throws Exception */ public void report(Map<String,Object> table) throws Exception { super.report(table); report(table, true); } protected void report(Map<String,Object> table, boolean isProject) throws Exception { if (isProject) { table.put("Target", getTarget()); table.put("Source", getSrc()); table.put("Output", getOutput()); File[] buildFiles = getBuildFiles(); if (buildFiles != null) table.put("BuildFiles", Arrays.asList(buildFiles)); table.put("Classpath", getClasspath()); table.put("Actions", getActions()); table.put("AllSourcePath", getAllsourcepath()); table.put("BootClassPath", getBootclasspath()); table.put("BuildPath", getBuildpath()); table.put("Deliverables", getDeliverables()); table.put("DependsOn", getDependson()); table.put("SourcePath", getSourcePath()); } table.put("RunPath", getRunpath()); table.put("TestPath", getTestpath()); table.put("RunProgramArgs", getRunProgramArgs()); table.put("RunVM", getRunVM()); table.put("Runfw", getRunFw()); table.put("Runbundles", getRunbundles()); } // TODO test format parametsr public void compile(boolean test) throws Exception { Command javac = getCommonJavac(false); javac.add("-d", getOutput().getAbsolutePath()); StringBuilder buildpath = new StringBuilder(); String buildpathDel = ""; Collection<Container> bp = Container.flatten(getBuildpath()); trace("buildpath %s", getBuildpath()); for (Container c : bp) { buildpath.append(buildpathDel).append(c.getFile().getAbsolutePath()); buildpathDel = File.pathSeparator; } if (buildpath.length() != 0) { javac.add("-classpath", buildpath.toString()); } List<File> sp = new ArrayList<File>(getAllsourcepath()); StringBuilder sourcepath = new StringBuilder(); String sourcepathDel = ""; for (File sourceDir : sp) { sourcepath.append(sourcepathDel).append(sourceDir.getAbsolutePath()); sourcepathDel = File.pathSeparator; } javac.add("-sourcepath", sourcepath.toString()); Glob javaFiles = new Glob("*.java"); List<File> files = javaFiles.getFiles(getSrc(), true, false); for (File file : files) { javac.add(file.getAbsolutePath()); } if (files.isEmpty()) { trace("Not compiled, no source files"); } else compile(javac, "src"); if (test) { javac = getCommonJavac(true); javac.add("-d", getTestOutput().getAbsolutePath()); Collection<Container> tp = Container.flatten(getTestpath()); for (Container c : tp) { buildpath.append(buildpathDel).append(c.getFile().getAbsolutePath()); buildpathDel = File.pathSeparator; } if (buildpath.length() != 0) { javac.add("-classpath", buildpath.toString()); } sourcepath.append(sourcepathDel).append(getTestSrc().getAbsolutePath()); javac.add("-sourcepath", sourcepath.toString()); javaFiles.getFiles(getTestSrc(), files, true, false); for (File file : files) { javac.add(file.getAbsolutePath()); } if (files.isEmpty()) { trace("Not compiled for test, no test src files"); } else compile(javac, "test"); } } private void compile(Command javac, String what) throws Exception { trace("compile %s %s", what, javac); StringBuilder stdout = new StringBuilder(); StringBuilder stderr = new StringBuilder(); int n = javac.execute(stdout, stderr); trace("javac stdout: ", stdout); trace("javac stderr: ", stderr); if (n != 0) { error("javac failed %s", stderr); } } private Command getCommonJavac(boolean test) throws Exception { Command javac = new Command(); javac.add(getProperty("javac", "javac")); String target = getProperty("javac.target", "1.6"); String source = getProperty("javac.source", "1.6"); String debug = getProperty("javac.debug"); if ("on".equalsIgnoreCase(debug) || "true".equalsIgnoreCase(debug)) debug = "vars,source,lines"; Parameters options = new Parameters(getProperty("java.options")); boolean deprecation = isTrue(getProperty("java.deprecation")); javac.add("-encoding", "UTF-8"); javac.add("-source", source); javac.add("-target", target); if (deprecation) javac.add("-deprecation"); if (test || debug == null) { javac.add("-g:source,lines,vars" + debug); } else { javac.add("-g:" + debug); } for (String option : options.keySet()) javac.add(option); StringBuilder bootclasspath = new StringBuilder(); String bootclasspathDel = "-Xbootclasspath/p:"; Collection<Container> bcp = Container.flatten(getBootclasspath()); for (Container c : bcp) { bootclasspath.append(bootclasspathDel).append(c.getFile().getAbsolutePath()); bootclasspathDel = File.pathSeparator; } if (bootclasspath.length() != 0) { javac.add(bootclasspath.toString()); } return javac; } }
180477822c1e361a150be094ac5cbecd667d2bbf
832c756923d48ace3f338b27ae9dc8327058d088
/src/contest/dmoj/Fibonacci.java
917e4c4ed907988c80930e18eade39e38d762178
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
luchy0120/competitive-programming
1331bd53698c4b05b57a31d90eecc31c167019bd
d0dfc8f3f3a74219ecf16520d6021de04a2bc9f6
refs/heads/master
2020-05-04T15:18:06.150736
2018-11-07T04:15:26
2018-11-07T04:15:26
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,431
java
package contest.dmoj; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigInteger; import java.util.StringTokenizer; public class Fibonacci { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter ps = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static StringTokenizer st; static final long MOD = 1000000007; public static void main (String[] args) throws IOException { BigInteger l = new BigInteger(next()); l = l.subtract(new BigInteger("1")); Matrix[] m = new Matrix[65]; m[0] = new Matrix(1, 1, 1, 0); for (int x = 0; x < 64; x++) { m[x + 1] = multiply(m[x], m[x]); } Matrix result = null; for (int x = 0; x < 64; x++) { if (!l.and(new BigInteger(new Long(1L << x).toString())).toString().equals("0")) { if (result == null) result = m[x]; else result = multiply(result, m[x]); } } System.out.println(result.a); } static Matrix multiply (Matrix m1, Matrix m2) { long a = m1.a; long b = m1.b; long c = m1.c; long d = m1.d; long e = m2.a; long f = m2.b; long g = m2.c; long h = m2.d; long a1 = (a * e) % MOD + (b * g) % MOD; long b1 = (a * f) % MOD + (b * h) % MOD; long c1 = (c * e) % MOD + (d * g) % MOD; long d1 = (c * f) % MOD + (d * h) % MOD; Matrix result = new Matrix(a1 % MOD, b1 % MOD, c1 % MOD, d1 % MOD); return result; } static class Matrix { long a, b, c, d; Matrix (long a, long b, long c, long d) { this.a = a; this.b = b; this.c = c; this.d = d; } } static String next () throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine().trim()); return st.nextToken(); } static long readLong () throws IOException { return Long.parseLong(next()); } static int readInt () throws IOException { return Integer.parseInt(next()); } static double readDouble () throws IOException { return Double.parseDouble(next()); } static char readCharacter () throws IOException { return next().charAt(0); } static String readLine () throws IOException { return br.readLine().trim(); } }
44c70df5c8e36eba30fddaebca54fdfb8b24b49c
17826c1eda3142ba1f2058532f8d293cc6f5fd68
/Maven_Exceptions-Logging/Maven/src/main/java/epam_cvrce/Maven_Exceptions_Logging/SimpleCompoundInterest.java
59cdb6608a90e76f971b8d8706c9a094a8c0d131
[]
no_license
mrinal365/Mrinal_Exceptions-Logging
281479c4f07f08fc48025c616ace23e5a2ae5e32
e7229cb54a275b27e98debd92a22056ec7a4b38d
refs/heads/master
2021-01-26T05:44:16.450823
2020-02-26T18:18:06
2020-02-26T18:18:06
243,332,796
0
0
null
2020-10-13T19:52:46
2020-02-26T18:15:09
Java
UTF-8
Java
false
false
110
java
package com.maven_task.maven_task; public interface SimpleCompoundInterest { double calculateInterest(); }
c64d6f5d55dc947774ab5a683083dde9ab7ca446
a76fab1cb05b80750ac391f6dec02892525962a8
/src/main/java/model/Subscription.java
1773c07e48c3c94e024fc37731dfbda6a1c1eb26
[]
no_license
einoorish/internet_provider_project
3d4c553c13c79e416074b5d637c68f9ae12190dd
61b0b9efd53f79d2c2f1e7d3b4fcef7f98394ed6
refs/heads/main
2023-05-13T21:00:34.614567
2021-06-06T18:37:37
2021-06-06T18:37:37
363,130,618
0
0
null
null
null
null
UTF-8
Java
false
false
729
java
package model; import java.sql.Date; import java.time.LocalDate; public class Subscription { private final long id; private final long userId; private final long tariffId; private final Date startDate; private final Date endDate; public Subscription(long id, long userId, long tariffId, Date startDate, Date endDate) { this.id = id; this.userId = userId; this.tariffId = tariffId; this.startDate = startDate; this.endDate = endDate; } public long getId() { return id; } public long getUserId() { return userId; } public long getTariffId() { return tariffId; } public Date getStartDate() { return startDate; } public Date getEndDate() { return endDate; } }
de777c5ad680e9ecf359be3649bd627374268d7a
31fca89e1d51844919089cecedc1c2e345124410
/api/src/main/java/co/vandenham/telegram/botapi/CommandHandler.java
58e19ace16269abd9ad57db509c79df2f4ef7805
[ "MIT" ]
permissive
ShepherdNetworkLtd/telegram-bots-java-api
4bf01a988ea36b85dde87fd9b9b6fcc0c1171910
b308f532676c77579a42143c88c78f97f0a12c6d
refs/heads/master
2021-01-17T19:59:30.441682
2017-06-21T10:22:01
2017-06-21T10:22:01
55,497,686
0
4
null
2017-06-21T10:22:02
2016-04-05T10:08:34
Java
UTF-8
Java
false
false
206
java
package co.vandenham.telegram.botapi; import java.lang.annotation.*; @Documented @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface CommandHandler { String[] value(); }
e675b9a77c6c368017402cb81864686eb90ac82f
0767e85e8b5575b182a0dca0cc424b8b004df67b
/javaSPI/exchange-rate-app/src/main/java/com/basumatarau/rate/app/MainApp.java
176c516ece4c9eac1758592728dfae29236461c5
[]
no_license
basumatarau/java-spi-example
3e2d2e7d50bca48de3bbf33bff1a4ebc388ffc04
959cbd792163f2a21174b93d68bcd3fc8875b1ec
refs/heads/master
2021-06-29T05:54:07.549007
2019-05-26T21:26:03
2019-05-26T21:26:03
171,141,452
0
0
null
null
null
null
UTF-8
Java
false
false
869
java
package com.basumatarau.rate.app; import com.basumatarau.rate.ExchangeRate; import com.basumatarau.rate.api.Quote; import java.time.LocalDate; import java.util.List; public class MainApp { public static void main(String... args) { System.out.println("test"); ExchangeRate.providers().forEach(provider -> { System.out.println("Retreiving USD quotes from provider :" + provider); List<Quote> quotes = provider.create().getQuotes("USD", LocalDate.now()); System.out.println(String.format("%14s%12s|%12s", "","Ask", "Bid")); System.out.println("----------------------------------------"); quotes.forEach(quote -> { System.out.println("USD --> " + quote.getCurrency() + " : " + String.format("%12f|%12f", quote.getAsk(), quote.getBid())); }); }); } }
f810610f70ce18873d6484691a9bee0a24a2dcfb
e2f74b43886a74c1a9b99fa64af33d5f72ede8f2
/rapidoid-inject/src/main/java/org/rapidoid/ioc/impl/IoCState.java
147d98e990d94ee34f93798018b0b87497ac2ab2
[ "LicenseRef-scancode-proprietary-license", "Apache-2.0" ]
permissive
xwt-benchmarks/rapidoid
9fd711bda90f60d612740f4bd18903f6fd96d7bc
26a41baee15bfba77dff84834b4db0f1affe85ed
refs/heads/master
2022-07-15T15:37:59.186832
2020-05-12T14:23:08
2020-05-12T14:23:08
258,783,476
0
0
Apache-2.0
2020-05-12T14:23:09
2020-04-25T13:33:27
null
UTF-8
Java
false
false
2,364
java
/*- * #%L * rapidoid-inject * %% * Copyright (C) 2014 - 2018 Nikolche Mihajlovski and contributors * %% * 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. * #L% */ package org.rapidoid.ioc.impl; import org.rapidoid.RapidoidThing; import org.rapidoid.annotation.Authors; import org.rapidoid.annotation.Since; import org.rapidoid.collection.Coll; import org.rapidoid.collection.Deep; import org.rapidoid.u.U; import org.rapidoid.util.Msc; import java.util.Map; import java.util.Set; @Authors("Nikolche Mihajlovski") @Since("5.1.0") public class IoCState extends RapidoidThing { final Set<Class<?>> providedClasses = U.set(); final Set<Object> providedInstances = U.set(); final Map<Class<?>, Set<Object>> providersByType = Coll.mapOfSets(); final Set<Object> instances = U.set(); public synchronized void reset() { providedClasses.clear(); providedInstances.clear(); instances.clear(); providersByType.clear(); } public synchronized IoCState copy() { IoCState copy = new IoCState(); Deep.copy(copy.providedClasses, this.providedClasses, null); Deep.copy(copy.providedInstances, this.providedInstances, null); Deep.copy(copy.providersByType, this.providersByType, null); Deep.copy(copy.instances, this.instances, null); return copy; } public synchronized Map<String, Object> info() { return U.map("Provided classes", Deep.copyOf(providedClasses, Msc.TRANSFORM_TO_SIMPLE_CLASS_NAME), "Provided instances", Deep.copyOf(providedInstances, Msc.TRANSFORM_TO_SIMPLE_CLASS_NAME), "Managed instances", Deep.copyOf(instances, Msc.TRANSFORM_TO_SIMPLE_CLASS_NAME), "By type", Deep.copyOf(providersByType, Msc.TRANSFORM_TO_SIMPLE_CLASS_NAME)); } public synchronized boolean isEmpty() { return providedClasses.isEmpty() && providedInstances.isEmpty() && providersByType.isEmpty() && instances.isEmpty(); } }
038dbcf207b88d32ab2519791352e294cca4bc02
604c64d6aaeff1381c41b77682ce5b3e527f4f04
/src/main/java/in/co/rays/proj4/controller/RoleCtl.java
7f9c901ccdab954779202aa592c19afb8d5425ce
[]
no_license
mukesh55-yadav/ORSProj04
21506ce39f6b02f6c78a994f5c9cc673c3fa570f
09665bba54b692488a334da18c525af2ca0ae290
refs/heads/master
2023-03-31T18:36:25.916768
2021-03-31T07:39:23
2021-03-31T07:39:23
351,052,290
0
0
null
null
null
null
UTF-8
Java
false
false
5,785
java
package in.co.rays.proj4.controller; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import in.co.rays.proj4.bean.BaseBean; import in.co.rays.proj4.bean.RoleBean; import in.co.rays.proj4.controller.RoleCtl; import in.co.rays.proj4.exception.ApplicationException; import in.co.rays.proj4.exception.DatabaseException; import in.co.rays.proj4.exception.DuplicateRecordException; import in.co.rays.proj4.model.RoleModel; import in.co.rays.proj4.util.DataUtility; import in.co.rays.proj4.util.DataValidator; import in.co.rays.proj4.util.PropertyReader; import in.co.rays.proj4.util.ServletUtility; import in.co.rays.proj4.controller.ORSView; /** * Role functionality Controller. Performs operation for add, update and get * Role * */ @WebServlet(name="RoleCtl",urlPatterns="/ctl/RoleCtl") public class RoleCtl extends BaseCtl { private static final long serialVersionUID = 1L; private static Logger log=Logger.getLogger(RoleCtl.class); /** * Validates input data entered by User * * @param request * @return */ @Override protected boolean validate(HttpServletRequest request) { log.debug("RoleCtl Method validate Started"); boolean pass = true; if(DataValidator.isNull(request.getParameter("name"))) { request.setAttribute("name", PropertyReader.getValue("error.require", "Name")); pass=false; } if(DataValidator.isNull(request.getParameter("description"))) { request.setAttribute("description", PropertyReader.getValue("error.require","Description")); pass=false; } log.debug("RoleCtl Method validate Ended"); return pass; } /** * Populates bean object from request parameters * * @param request * @return */ @Override protected BaseBean populateBean(HttpServletRequest request) { log.debug("RoleCtl Method populatebean Started"); RoleBean bean=new RoleBean(); bean.setId(DataUtility.getLong(request.getParameter("id"))); bean.setName(DataUtility.getString(request.getParameter("name"))); bean.setDescription(DataUtility.getString(request.getParameter("description"))); populateDTO(bean,request); log.debug("RoleCtl Method populatebean Ended"); return bean; } /** * Contains display logics */ protected void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException { log.debug("RoleCtl Method doGet Started"); String op=DataUtility.getString(request.getParameter("operation")); // get model RoleModel model = new RoleModel(); long id=DataUtility.getLong(request.getParameter("id")); if(id>0||op!=null){ RoleBean bean; try{ bean=model.findByPK(id); ServletUtility.setBean(bean,request); }catch(ApplicationException e){ log.error(e); ServletUtility.handleException(e, request, response); return; } } ServletUtility.forward(getView(), request, response); log.debug("RoleCtl Method doGetEnded"); } protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { log.debug("RoleCtl Method doGet Started"); System.out.println("In do get"); String op=DataUtility.getString(request.getParameter("operation")); // get model RoleModel model = new RoleModel(); long id = DataUtility.getLong(request.getParameter("id")); if(OP_SAVE.equalsIgnoreCase(op)|| OP_UPDATE.equalsIgnoreCase(op)) { RoleBean bean=(RoleBean)populateBean(request); try{ if(id>0) { model.update(bean); ServletUtility.setBean(bean, request); ServletUtility.setSuccessMessage("Data is successfully updated", request); }else{ long pk=model.add(bean); bean.setId(pk); ServletUtility.setBean(bean, request); ServletUtility.setSuccessMessage("Data is successfully saved", request); } }catch(ApplicationException e){ log.error(e); ServletUtility.handleException(e, request, response); return; }catch(DuplicateRecordException e) { ServletUtility.setBean(bean, request); ServletUtility.setErrorMessage("Role already exists", request); } }else if(OP_DELETE.equalsIgnoreCase(op)) { RoleBean bean = (RoleBean) populateBean(request); try { model.delete(bean); ServletUtility.redirect(ORSView.ROLE_LIST_CTL, request, response); return; } catch (ApplicationException e) { log.error(e); ServletUtility.handleException(e, request, response); return; } } else if (OP_CANCEL.equalsIgnoreCase(op)) { ServletUtility.redirect(ORSView.ROLE_LIST_CTL, request, response); return; } ServletUtility.forward(getView(), request, response); log.debug("RoleCtl Method doPOst Ended"); } /** * Returns the VIEW page of this Controller * * @return */ @Override protected String getView() { // TODO Auto-generated method stub return ORSView.ROLE_VIEW; } }
97749a9c6502b88b35b1c54ac9579cefd973c03d
22754251af9d8f3c81a31efda367739e119cfd74
/app/src/test/java/com/example/myapplicationstudentsapp/ExampleUnitTest.java
77957b3e98def869c6a23f0776f070bb520fff6c
[]
no_license
jawadkhan88/MyApplicationStudentsApp
d4b8f8370abef6e93aa8c5d23b6880e90266e347
804265ae7950a6e4fef9f1faa8949f7871db404b
refs/heads/master
2023-01-12T14:08:21.354620
2020-11-14T08:54:11
2020-11-14T08:54:11
312,779,952
1
0
null
null
null
null
UTF-8
Java
false
false
397
java
package com.example.myapplicationstudentsapp; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } }
34da138474258dc712888ae07f8fed7465a0f420
4561dd4a0f713d642db490b51b55f9ae5b6c7c8e
/src/main/java/com/housie/util/HousieNumberUtils.java
6c4dd4869b5475cb822a0267425b434606cfd4cb
[]
no_license
Mohit-Hurkat/Housie
42748fbfa5aaf1bedcd2ffbdf69e07979485d9bf
a5e301828c555be371409756c695b6b60e47f251
refs/heads/master
2023-04-29T06:05:06.276950
2020-04-12T10:49:51
2020-04-12T10:49:51
254,785,395
0
0
null
2023-04-14T17:49:28
2020-04-11T03:28:43
Java
UTF-8
Java
false
false
681
java
package com.housie.util; import java.util.Arrays; import java.util.HashSet; import java.util.Set; public class HousieNumberUtils { public final static Set<Integer> totalNumbersSet = new HashSet<>(Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90)); }
1f87140312f1d7377077a0d14b5e22a5ef524243
90222726ecafa3fe3897fae20740c69d82bbe812
/JDBC application assignment/Register.java
42dfc9599caa3cf84e9b3da5fe2361babafb74de
[]
no_license
VenkateshBhatOP/PGJQP_Venkatesh-bhat
0c17b3bc8b7bd6b349c7bc35dd718af16e408ab5
aef231d06b35c5ccd7016646819f1d7ee18337a9
refs/heads/main
2023-03-31T19:10:19.738974
2021-04-02T10:56:11
2021-04-02T10:56:11
311,357,962
0
0
null
null
null
null
UTF-8
Java
false
false
3,386
java
import java.awt.BorderLayout; import java.awt.ComponentOrientation; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; class Student extends JFrame implements ActionListener { JLabel l1, l2, l3; JTextField tf1, tf2, tf3; JPanel p1, p2; JButton b1, b2, b3; public Student() { setTitle("Registration Form"); p1 = new JPanel(); p1.setLayout(new GridLayout(4, 2)); add(p1, BorderLayout.NORTH); p2 = new JPanel(); p2.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); add(p2, BorderLayout.SOUTH); l1 = new JLabel("Enter Student ID"); p1.add(l1); tf1 = new JTextField(100); p1.add(tf1); l2 = new JLabel("Enter Student Name"); p1.add(l2); tf2 = new JTextField(100); p1.add(tf2); l3 = new JLabel("Enter Student Course"); p1.add(l3); tf3 = new JTextField(100); p1.add(tf3); b1 = new JButton("Register"); b1.addActionListener(this); p2.add(b1); b2 = new JButton("Update"); b2.addActionListener(this); p2.add(b2); b3 = new JButton("Delete"); b3.addActionListener(this); p2.add(b3); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(500, 300); } @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub try { Connection con = DriverManager.getConnection( "jdbc:sqlserver://DESKTOP-K459BPE;databaseName=PGJQP_S210218;user=sa;password=niit@123"); JButton bt = (JButton) e.getSource(); if (bt.getText().equals("Register")) { PreparedStatement statement = con.prepareStatement("insert into student values(?,?,?)"); statement.setInt(1, Integer.parseInt(tf1.getText())); statement.setString(2, tf2.getText()); statement.setString(3, tf3.getText()); int result; result = statement.executeUpdate(); if (result > 0) JOptionPane.showMessageDialog(rootPane, "Registered"); else JOptionPane.showMessageDialog(rootPane, "Not Registered"); } else if (bt.getText().equals("Update")) { PreparedStatement statement = con.prepareCall("update student set name=? where id=?"); statement.setString(1, tf2.getText()); statement.setInt(2, Integer.parseInt(tf1.getText())); int result; result = statement.executeUpdate(); if (result > 0) JOptionPane.showMessageDialog(rootPane, "Updated"); else JOptionPane.showMessageDialog(rootPane, "Not Updated"); } else if (bt.getText().equals("Delete")) { PreparedStatement statement = con.prepareCall("delete from student where id=?"); statement.setInt(1, Integer.parseInt(tf1.getText())); int result; result = statement.executeUpdate(); if (result > 0) JOptionPane.showMessageDialog(rootPane, "Deleted"); else JOptionPane.showMessageDialog(rootPane, "Not Deleted"); } } catch (Exception e1) { System.out.println(e1.getMessage()); } } } public class Register { public static void main(String[] args) { Student stud = new Student(); stud.setVisible(true); } }
d73a63321fa6262364cb2a7efbec69d7c3120bcb
4a785ce0663a231ca22a7c9fa9675a14114536af
/src/test/java/com/hdm_stuttgart/Battleship/CreateGameAreaTest.java
a7b6016bf44f45102181392898faee5a37a8d631
[]
no_license
leabaumgaertner/battleship_project
b10d40594933843cc9c164d64dd6b4bba6f55611
8fd815bf88ef0c9f3268431e1c85444db801882d
refs/heads/master
2023-04-10T23:48:34.068106
2021-04-24T06:38:02
2021-04-24T06:38:02
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,234
java
package com.hdm_stuttgart.Battleship; /** * Test for Creating GameArea * * @author Lea Baumgärtner * @version 1.0 */ import static org.junit.Assert.assertEquals; import java.awt.Point; import org.junit.Test; import game.EDifficulty; import game.GameArea; import gameConfigurations.ComputerPlayer; import gameConfigurations.CreatePlayerException; import gameConfigurations.HumanPlayer; import gameConfigurations.IPlayer; import gameConfigurations.PlayerFactory; import junit.framework.Assert; public class CreateGameAreaTest { // Expected right @Test public void testRightGameAreaCreated() { GameArea area = new GameArea(EDifficulty.EASY); Assert.assertTrue(area instanceof GameArea); } // Expected right @Test public void testRightGameAreaCreated2() { GameArea area = new GameArea(EDifficulty.NORMAL); Assert.assertTrue(area instanceof GameArea); } // Expected right @Test public void testRightGameAreaCreated3() { GameArea area = new GameArea(EDifficulty.HARD); Assert.assertTrue(area instanceof GameArea); } // Expected right @Test public void testRightGameAreaCreated4() { GameArea area = new GameArea(EDifficulty.SUICIDAL); Assert.assertTrue(area instanceof GameArea); } }
46e5ce523ed30627ffcbb3c525b8a5c57edf1e50
2e46156b4234a9a347d2004c906d5ec835ec984b
/src/me/gteam/logman/service/AbsencetypeService.java
3b1831c82605aeb2c263ad40d5c501b7e77c8a18
[]
no_license
zhaoxudong/logman
4484262ddfaef600c02bca5b2c8f3e28b8a35246
b7ce51e82c4eb19e412b2dd22fe4d604754e093b
refs/heads/master
2021-01-23T11:55:54.022163
2015-03-10T07:38:45
2015-03-10T07:38:45
26,519,891
0
3
null
2014-11-12T11:02:12
2014-11-12T04:54:59
Java
UTF-8
Java
false
false
474
java
package me.gteam.logman.service; import java.io.Serializable; import java.util.Collection; import me.gteam.logman.domain.Absencetype; public interface AbsencetypeService { public void saveAbsencetype(Absencetype absencetype); public void updateAbsencetype(Absencetype absencetype); public void deleteAbsencetypeByID(Serializable id,String deleteMode); public Collection<Absencetype> getAllAbsencetype(); public Absencetype getAbsencetypeById(Serializable id); }
c2497419a546db24e1d220953a4609185b6ca6c6
12b5bf729b199c7cccd2faf0c3e50e0e2d6963ec
/src/main/java/com/abnamro/transactionreporting/model/FileRecord.java
5423b0ccebf98299f3f7b4c4ab1aa872d00328ff
[]
no_license
SorabhG/client-transaction-reporting
43b07ae77a64c022b9f1faa84fad5644b1424a7a
c347352e151edfed811196f2c6f3bb01d9c3b378
refs/heads/master
2023-01-14T16:19:33.988236
2020-11-16T01:28:40
2020-11-16T01:28:40
312,499,190
0
0
null
null
null
null
UTF-8
Java
false
false
480
java
package com.abnamro.transactionreporting.model; import lombok.Data; import java.math.BigDecimal; @Data public class FileRecord { private String clientType; private String clientNumber; private String accountNumber; private String subAccountNumber; private String exchangeCode; private String productGroupCode; private String symbol; private String expirationDate; private BigDecimal quantityLong; private BigDecimal getQuantityShort; }
49d302a2f8f67bf73b7940fc6e929e16f08d1033
005c71e2c38d8b4d024232d9c133936b3ba378c3
/src/main/java/com/azad/practice/springrestvalidationsecurity/exception/BookUnSupportedFieldPatchException.java
c7a1b1a2a13b7f3b0846e9ef722236a8dd187cd3
[]
no_license
azhar-azad/spring-rest-validation-security
d287724abec1502d7f8bac8d2000509611d8e6c4
117d4d959f1ad98a3f055b7b32dd8b08f595a09c
refs/heads/master
2021-02-10T02:57:12.090059
2020-03-03T09:01:46
2020-03-03T09:01:46
244,346,752
0
0
null
null
null
null
UTF-8
Java
false
false
383
java
package com.azad.practice.springrestvalidationsecurity.exception; import java.util.Set; public class BookUnSupportedFieldPatchException extends RuntimeException { private static final long serialVersionUID = 4868925806646840715L; public BookUnSupportedFieldPatchException(Set<String> keys) { super("Field " + keys.toString() + " update is not allowed."); } }
d403ebb81e438629d0aebcec5ee714d836f9a771
6089f1f692fea42e92f2ecc34ed42768b436676b
/megasena/src/main/java/br/com/etechoracio/megasena/ResultadoController.java
29099da8aba207d69dce1231ad1bfd4423a1fa87
[]
no_license
BartszGitHub/megasena
87363fe243e6c1f29e293c1e2d8c090016aff5ee
837cf59135bd3b6f1b2801b8a36a0fab0a8af8df
refs/heads/master
2020-05-07T16:21:24.231182
2019-04-11T01:34:43
2019-04-11T01:34:43
180,679,184
0
0
null
null
null
null
UTF-8
Java
false
false
452
java
package br.com.etechoracio.megasena; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/megasena") public class ResultadoController { @GetMapping public String getResultado() throws Exception { Megasena megasena = new Megasena(); return megasena.obterUltimoResultado(); } }
f9cedb6c9149958378b7ddb6d3108d9ffc8520d6
ed5c2537d152e3326b3e44027c2275e1bdb8ecf9
/CoreJava/src/day3/three/FullTimeEmployee.java
289b16c405ac93a4b0cdebdc2b73d8327e56412f
[]
no_license
thirupathireddygopal/CoreJava
364d0b2778abdd37a86e8fa3b2000203fa69aecb
e276f6aebeb96990cd32ed103ab1347297fa3b9d
refs/heads/master
2020-03-17T02:49:45.929859
2018-07-29T05:47:35
2018-07-29T05:47:35
133,207,674
0
0
null
null
null
null
UTF-8
Java
false
false
741
java
package day3.three; public class FullTimeEmployee { private int id; private String name; private String address; private double salary; public FullTimeEmployee() { super(); System.out.println("Hi!! i am FullTimeEmployee constructor"); } public FullTimeEmployee(int id, String name, String address, double salary) { super(); this.id = id; this.name = name; this.address = address; this.salary = salary; } public double computeSalary(){ return salary + 1000; } public void showDetails(){ System.out.println("id: "+ id); System.out.println("name: "+name); System.out.println("address: "+address); System.out.println("salary: "+ salary); System.out.println("Gross salary: "+computeSalary()); } }
[ "Reddy@Lenovo-PC" ]
Reddy@Lenovo-PC
5038cf27a0e081f364f8ddd2be681ad4bd011d34
14d2d3d95b75d501a57c0729987f5cf51b9afb20
/src/mainMember.java
6a3e44e097f41c932ce69320bbc49f75518f8907
[]
no_license
wunselan/soal7
cfb1bc7dee37a4906a4ca1904cdff977841ae443
4444fc13700b2e02a23b4e63c90da3201258d5df
refs/heads/master
2020-12-03T09:36:07.246666
2016-05-04T01:07:36
2016-05-04T01:07:36
58,011,952
0
0
null
2016-05-04T00:59:42
2016-05-04T00:59:42
null
UTF-8
Java
false
false
564
java
public class mainMember { public static void main(String[] args) { Member member [] = new Member [3]; member[0] = new TeamJ("Wunsel","Djakarta"); member[1] = new TeamK("Albert","Kali(Mantan)"); member[2] = new TeamT("Lutfi","Djakarta"); for(int i = 0; i < member.length; i++){ member[i].show(); member[i].yelyel(); member[i].Jekate(); System.out.println("============================================="); } } }
754c2052352622427e16f078337028c9c4cf8296
7a7f3db2ea779424f9949ab168b23d203121d871
/src/main/java/com/colin/javacamp/week1/Hello.java
ef15eb66c27a5e530af82d912e540d27e9c22187
[]
no_license
Winchy/java-camp
42e2d0245b31527a93b8d3ce88fe5e02eaf65450
5d6c0a0fcec45a949b1a243bbf778414af63bbfb
refs/heads/main
2023-01-05T07:35:09.483813
2020-10-18T15:11:06
2020-10-18T15:11:06
305,130,000
0
0
null
null
null
null
UTF-8
Java
false
false
121
java
package com.colin.javacamp.week1; public class Hello { static { System.out.println("Hello Class Initialized!"); } }
8370bb27fb91da6bc0d9fd1829b7cbcd7827b0ff
11b9a30ada6672f428c8292937dec7ce9f35c71b
/src/main/java/com/sun/imageio/plugins/bmp/BMPMetadataFormatResources.java
332c6ed8e2b8d9d3df38d227dbee01ce4060abdf
[]
no_license
bogle-zhao/jdk8
5b0a3978526723b3952a0c5d7221a3686039910b
8a66f021a824acfb48962721a20d27553523350d
refs/heads/master
2022-12-13T10:44:17.426522
2020-09-27T13:37:00
2020-09-27T13:37:00
299,039,533
0
0
null
null
null
null
UTF-8
Java
false
false
1,929
java
/***** Lobxxx Translate Finished ******/ /* * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package com.sun.imageio.plugins.bmp; import java.util.ListResourceBundle; import javax.imageio.metadata.IIOMetadataFormat; import javax.imageio.metadata.IIOMetadataFormatImpl; public class BMPMetadataFormatResources extends ListResourceBundle { public BMPMetadataFormatResources() {} protected Object[][] getContents() { return new Object[][] { // Node name, followed by description { "BMPVersion", "BMP version string" }, { "Width", "The width of the image" }, { "Height","The height of the image" }, { "BitsPerPixel", "" }, { "PixelsPerMeter", "Resolution in pixels per unit distance" }, { "X", "Pixels Per Meter along X" }, { "Y", "Pixels Per Meter along Y" }, { "ColorsUsed", "Number of color indexes in the color table actually used" }, { "ColorsImportant", "Number of color indexes considered important for display" }, { "Mask", "Color masks; present for BI_BITFIELDS compression only"}, { "Intent", "Rendering intent" }, { "Palette", "The color palette" }, { "Red", "Red Mask/Color Palette" }, { "Green", "Green Mask/Color Palette/Gamma" }, { "Blue", "Blue Mask/Color Palette/Gamma" }, { "Alpha", "Alpha Mask/Color Palette/Gamma" }, { "ColorSpaceType", "Color Space Type" }, { "X", "The X coordinate of a point in XYZ color space" }, { "Y", "The Y coordinate of a point in XYZ color space" }, { "Z", "The Z coordinate of a point in XYZ color space" }, }; } }
2f402950e725cb5d23e84681b84870df833df605
94dfed414c3cd6932b65890516d1be7d68af30b9
/app/src/main/java/emresert/tk/whetherapp/Model/Coord.java
eff73b4c3456733141e5588c5abf65128ff359f6
[]
no_license
satheeshbabu/WeatherApp
8644b2692b5a08e3cc2e1e46386c77963b89123d
0366bea284c2e86c5f70dc86c357edf24abb6875
refs/heads/master
2021-10-08T10:01:57.371310
2018-12-10T21:45:34
2018-12-10T21:45:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
453
java
package emresert.tk.whetherapp.Model; public class Coord { private double lat; private double lon; public Coord(double lat,double lon){ this.lat=lat; this.lon=lon; } public double getLat() { return lat; } public void setLat(double lat) { this.lat = lat; } public double getLon() { return lon; } public void setLon(double lon) { this.lon = lon; } }
3959a1871b7856cf00a0dd67f769261601451f3e
81f90dc2326c7ba9f4081918031e46696c02e6ae
/app/src/main/java/social/entourage/android/map/tour/join/received/TourJoinRequestReceivedModule.java
a44ab8b90a2ee6796ce7a3a7476f5bb1cec2375f
[]
no_license
morristech/entourage-android
4fb109d5efcd028d47100317a16719689a146623
bfd4d9945bba1775563aefb911ea07d6c14bbc24
refs/heads/master
2020-03-16T18:31:13.893649
2018-04-18T15:56:30
2018-04-18T15:56:30
null
0
0
null
null
null
null
UTF-8
Java
false
false
528
java
package social.entourage.android.map.tour.join.received; import dagger.Module; import dagger.Provides; /** * Created by mihaiionescu on 18/03/16. */ @Module public class TourJoinRequestReceivedModule { private TourJoinRequestReceivedActivity activity; public TourJoinRequestReceivedModule(final TourJoinRequestReceivedActivity activity) { this.activity = activity; } @Provides public TourJoinRequestReceivedActivity providesTourJoinRequestReceivedActivity() { return activity; } }
6347754322ce6b3818f13d251380dc11f02ebc45
31fc4ecab54687c9986665a0aa2ea6fc82ce7631
/src/day29_Wrapper_ArrayList/List_Intro.java
d4066e5c0f8205a40c7506b6a43fb63882e51233
[]
no_license
ogulle/Java_CyberTek
9f14bd46de2c1595dde5998285a5c1e2f63a4312
79af18f79e89ce61236df96cbbea7085783a06c0
refs/heads/master
2022-11-16T05:17:31.368623
2020-07-06T15:25:20
2020-07-06T15:25:20
258,610,336
0
0
null
null
null
null
UTF-8
Java
false
false
1,025
java
package day29_Wrapper_ArrayList; import java.util.ArrayList; public class List_Intro { public static void main(String[] args) { // ArrayList<DataTpe> listName = new ArrayList<DataType>(); ArrayList<Integer> scores = new ArrayList<Integer>(); // size : 0 // add five elements, size: 5 // remove two elements, size: 3 scores.add(10); //Autoboxing size: 1 scores.add(20); //Autoboxing size: 2 scores.add(30); //size: 3 System.out.println(scores); Integer a1 = scores.get(2); // none int a2 = scores.get(2); //unboxing double a3 = scores.get(2); // unboxing System.out.println(a3); // System.out.println(scores.get(100)); //index out of bound /* 1. create a list of integers 2. add 5 Integers to it 3. return the maximum number from the list Do not use any sorting */ } }
41e010b2e56bd33d2a7b10327d72d32106d07e01
6b536165e3e29da026e5be6a6dd56355e2245300
/SpMVC_12_ToDoListV2/src/main/java/com/biz/todo/service/ToDoServiceV2.java
3e2c56ff06543b961dc113e1927651fe42a1f293
[]
no_license
doolybom1/Spring_MVC
a031555289c3370406b6a60741de02a2946c16c8
0b842a6bf95744fbc191fbf867849de8971c2fd1
refs/heads/master
2022-12-21T04:17:29.121733
2020-02-19T07:43:15
2020-02-19T07:43:15
229,213,869
0
0
null
null
null
null
UTF-8
Java
false
false
768
java
package com.biz.todo.service; import org.springframework.stereotype.Service; import com.biz.todo.domain.ToDoList; @Service("toServiceV2") public class ToDoServiceV2 extends ToDoServiceV1 { @Override public int complete(String strSeq, String tdComplete) { long tdSeq = Long.valueOf(strSeq); tdComplete = tdComplete.equalsIgnoreCase("Y") ? "N" : "Y"; return toDao.complete(tdSeq); } @Override public int alarm(String strSeq, String tdAlarm) { long tdSeq = Long.valueOf(strSeq); tdAlarm = tdAlarm.equalsIgnoreCase("Y") ? "N" : "Y"; return toDao.alarm(tdSeq); } @Override public int update(ToDoList toDoList) { return toDao.update(toDoList); } @Override public int delete(long tdSeq) { return toDao.delete(tdSeq); } }
dee8375821b281fa7571f2611d2b077679ebd6f0
fb8836fd60b9f90d5f8a1bab7e77b616936887dd
/src/testClass.java
274b699a2cbf9c982aac673123b0b88fd55f6973
[]
no_license
kingmanzhang/PantsOnFire
f1b02f0cbe9194542f83700c95810015641de5eb
b45d1c3b1bb3de31eaf631175e8538788a0e9aaf
refs/heads/master
2021-04-28T21:33:59.163917
2017-01-01T07:03:55
2017-01-01T07:03:55
77,768,606
0
0
null
null
null
null
UTF-8
Java
false
false
3,982
java
import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class testClass { static void loadLevel(String level) { Random randGen = new Random(); //a random number generator Hero hero; //main character for game Water [] water = new Water[8]; //waters ejected from hero ArrayList <Pant> pants = new ArrayList<Pant>(); //pant list ArrayList <Fireball> fireballs = new ArrayList<Fireball>(); //fireball list ArrayList <Fire> fires = new ArrayList<Fire>(); //fire list int controlType; //track which control type the player want to use Scanner scnr = new Scanner(level); scnr.next(); controlType = scnr.nextInt(); String gameCharacter; float [] position; while(scnr.hasNextLine()) { //if there is remaining line scnr.nextLine();//go to the next line //first remove the coma(,) so that one can parse out the numbers String newLine = removeComa(scnr.nextLine()); gameCharacter = gameCharacterExtractor(newLine); position = floatExtractor(newLine); if(gameCharacter.equals("HERO")) { //if the next word is "HERO" hero = new Hero(position[0], position[1], controlType); } else if(gameCharacter.equals("FIRE")) { fires.add(new Fire(position[0], position[1], randGen)); } else if (gameCharacter.equals("PANT")) { pants.add(new Pant(position[0], position[1], randGen)); } else ; } } private static String removeComa(String str) { String stringComaRemoved = ""; Scanner scnr = new Scanner(str); for (int i = 0; i < str.length(); i++) { if(str.charAt(i) != ',') { stringComaRemoved += str.charAt(i); } } scnr.close(); return stringComaRemoved; } //extract the first two float numbers from the string //return a float array that contains the first two float numbers private static float[] floatExtractor (String str) { float[] floatNum = new float[2]; Scanner scnr = new Scanner(str); System.out.println(str); int i = 0; while(scnr.hasNext()) { if(scnr.hasNextFloat()) { floatNum[i] = scnr.nextFloat(); i++; } else scnr.next(); if(i == 2) break; } scnr.close(); return floatNum; } //extract the character to be created //return the character private static String gameCharacterExtractor (String str) { String gameCharacter; Scanner scnr = new Scanner(str); gameCharacter = scnr.next(); scnr.close(); if (gameCharacter.equals("HERO") || gameCharacter.equals("FIRE") || gameCharacter.equals("PANT")) { return gameCharacter; } else System.out.println("Game character cannot be found"); return "Game character not found!"; } public static void main (String[] args) { String level1 = "ControlType: 3\nHERO @ 36.0, 552.0\nFIRE @ 115.0, 84.0"; System.out.println(level1); //test removeComa System.out.println(removeComa(level1)); //test gameCharacterExtractor System.out.println(gameCharacterExtractor("HERO @ 36.0 552.0")); //test floatExtractor float [] position1 = floatExtractor("HERO @ 36.0 552.0"); System.out.println(position1[0]); System.out.println(position1[1]); //test loadLevels loadLevel("ControlType: 3\nHERO @ 36.0, 552.0"); //System.out.println(floatExtractor(stringParser(level)).toString()); //System.out.println(scnr.nextInt()); //scnr.nextLine(); //System.out.println(scnr.next()); //System.out.println(scnr.nextFloat()); //System.out.println("Level is " + scnr.nextInt()); //scnr.nextLine(); /* while(scnr.hasNextLine()) { if(scnr.next().equals("HERO")) { System.out.print("Hero found! Position is " + scnr.nextFloat() + " " + scnr.nextFloat()); } else if(scnr.next().equals("FIRE")) { System.out.print("Fire found! Position is " + scnr.nextFloat() + " " + scnr.nextFloat()); } else if (scnr.next().equals("PANT")) { System.out.print("Pant found! Position is " + scnr.nextFloat() + " " + scnr.nextFloat()); } else ; scnr.nextLine(); }; */ } }
9487bb88c1ddaec7b15fa5702982c7d1d19f57b3
60e6150a2dc3bfbe454352a3338c4fabfc605b77
/src/main/java/RomanNumerals.java
4fc5cdf05e59babd5703c6801f010104aa8b1c16
[]
no_license
tyrcho/roman-kata
3d1a60935852c848d48a431f9659e319002c5436
0c94f0a929bcdde36b715d6664986af189360b13
refs/heads/master
2021-01-20T09:20:53.710691
2017-05-04T15:21:06
2017-05-04T15:21:06
90,242,806
0
0
null
null
null
null
UTF-8
Java
false
false
824
java
import java.util.Collections; public class RomanNumerals { public static String toRoman(int number) { if (number < 10) return convertDigit(number, "I", "V", "X"); if (number < 100) return convertDigit(number / 10, "X", "L", "C") + toRoman(number % 10); if (number < 1000) return convertDigit(number / 100, "C", "D", "M") + toRoman(number % 100); return ""; } private static String convertDigit(int digit, String one, String five, String ten) { if (digit < 4) return repeat(digit, one); if (digit == 4) return one + five; if (digit == 9) return one + ten; return five + repeat(digit % 5, one); } static String repeat(int count, String stringToRepeat) { return String.join("", Collections.nCopies(count, stringToRepeat)); } }
8d3049fb2d7f31b75c7d04fd31d558a976b6f732
f38739840976999e8a5777f5c6b427bb76f09c29
/test/level17/lesson04/task04/Solution.java
23accd4aa087b09d90e23bde3f53f8a2a2462e91
[]
no_license
nickame/rush-git-repo
0f3b0ba37e51f5e744e9cac2387f8f5c1720dea1
cfbce4ec7cc485809668d8414c8d7194c7513d7a
refs/heads/master
2021-01-09T19:05:33.286002
2016-07-10T10:59:46
2016-07-10T10:59:46
62,795,118
0
0
null
null
null
null
UTF-8
Java
false
false
838
java
package com.javarush.test.level17.lesson04.task04; /* Синхронизированный президент И снова Singleton паттерн - синхронизация в статическом блоке Внутри класса OurPresident в статическом блоке создайте синхронизированный блок. Внутри синхронизированного блока инициализируйте president. */ public class Solution { public static class OurPresident { private static OurPresident president; private OurPresident() { } public static OurPresident getOurPresident() { return president; } static { synchronized (OurPresident.class){ president= new OurPresident();} } } }
a65d4d54224174268d023b7355a85c520446679c
4ad650ceb22463bf23892b5cf799d22e2c6e0228
/app/src/main/java/ru/net/serbis/mega/service/action/GetFilesList.java
b28543319f8156e2f115f96d20af914248ead45e
[]
no_license
garbarick/SBMega
f241996f81326de2b209ab434322a062278212fb
ce6aa5eec95e409ced32d0188b49c0730286d482
refs/heads/master
2023-07-26T15:41:04.854005
2023-07-23T19:53:46
2023-07-23T19:53:46
100,866,574
2
0
null
null
null
null
UTF-8
Java
false
false
462
java
package ru.net.serbis.mega.service.action; import android.os.*; import ru.net.serbis.mega.*; import ru.net.serbis.mega.task.*; public class GetFilesList extends Action { public GetFilesList(App app, Message msg) { super(app, msg); } @Override public void onFetched() { new FileListTask(megaApi, this).execute(email, path); } @Override public void result(String fileslist) { sendResult(Constants.FILES_LIST, fileslist); } }
399181248de0790ef91cc7fa54e9dd06eca9e99c
acb587ac895aca1b09a920a87258c2899e62b1a9
/Kevytlaskutus/src/test/java/kevytlaskutus/domain/CustomerCompanyServiceTest.java
5b8a89adc236118b94167f2875941f21a10ff10c
[]
no_license
ilkkamaksy/kevytlaskutus
ec025960590906213608d2eee4b4de6c6b474ce5
138eeb648647a56bdcacaa084e1db5fb54118b4e
refs/heads/master
2022-12-27T18:10:40.582201
2020-05-07T11:20:36
2020-05-07T11:20:36
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,007
java
/* * 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 kevytlaskutus.domain; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import kevytlaskutus.dao.CustomerCompanyDao; import kevytlaskutus.dao.InvoiceDaoImpl; import kevytlaskutus.dao.ManagedCompanyDao; import kevytlaskutus.dao.ProductDaoImpl; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; /** * * @author ilkka */ public class CustomerCompanyServiceTest { CustomerCompanyService service; ManagedCompanyDao mockManagedCompanyDao; CustomerCompanyDao mockCustomerCompanyDao; InvoiceDaoImpl mockInvoiceDao; ProductDaoImpl mockProductDao; CustomerCompany mockCustomer; @Before public void setUp() { mockManagedCompanyDao = mock(ManagedCompanyDao.class); mockCustomerCompanyDao = mock(CustomerCompanyDao.class); mockInvoiceDao = mock(InvoiceDaoImpl.class); mockProductDao = mock(ProductDaoImpl.class); DatabaseUtils databaseUtils = new DatabaseUtils( mockManagedCompanyDao, mockCustomerCompanyDao, mockInvoiceDao, mockProductDao, "jdbc:h2:mem:testdb", "sa", "" ); databaseUtils.initDb(); service = new CustomerCompanyService(mockCustomerCompanyDao, databaseUtils); mockCustomer = mock(CustomerCompany.class); when(mockCustomer.getId()).thenReturn(1); when(mockCustomer.getName()).thenReturn("Acme"); } @After public void tearDown() { } @Test public void testCreateCustomerCompany() { try { CustomerCompany customer = new CustomerCompany(); customer.setName("Acme"); when(mockCustomerCompanyDao.create(customer)).thenReturn(true); boolean result = this.service.saveCustomerCompany(customer); verify(this.mockCustomerCompanyDao).create(customer); assertTrue(result); } catch (SQLException e) {} } @Test public void testUpdateCustomerCompany() { try { when(mockCustomerCompanyDao.update(1, mockCustomer)).thenReturn(true); boolean result = this.service.saveCustomerCompany(mockCustomer); verify(this.mockCustomerCompanyDao).update(1, mockCustomer); assertTrue(result); } catch (SQLException e) {} } @Test public void testDeleteCustomerCompany() { try { when(mockCustomerCompanyDao.delete(1)).thenReturn(true); boolean result = this.service.deleteCustomerCompany(1); verify(this.mockCustomerCompanyDao).delete(1); assertTrue(result); } catch (SQLException e) {} } @Test public void testGetCustomerCompanies() { try { when(mockCustomerCompanyDao.getItems()).thenReturn(new ArrayList<>()); List<CustomerCompany> results = this.service.getCustomerCompanies(); verify(this.mockCustomerCompanyDao).getItems(); assertEquals(results.size(), 0); } catch (SQLException e) {} } @Test public void testGetCustomerCompanyByName() { try { when(mockCustomerCompanyDao.getItemByName("Acme")).thenReturn(mockCustomer); CustomerCompany result = this.service.getCustomerCompanyByName("Acme"); verify(this.mockCustomerCompanyDao).getItemByName("Acme"); assertEquals(result.getName(), mockCustomer.getName()); } catch (SQLException e) {} } }
64a90308cbfa17b1a792579f2bf8c731e4b57892
12b14b30fcaf3da3f6e9dc3cb3e717346a35870a
/examples/commons-math3/mutations/mutants-AbstractRealDistribution/31/org/apache/commons/math3/distribution/AbstractRealDistribution.java
0f4d7598dd5c66081bc06462aa743560af3053c5
[ "BSD-3-Clause", "Minpack", "Apache-2.0" ]
permissive
SmartTests/smartTest
b1de326998857e715dcd5075ee322482e4b34fb6
b30e8ec7d571e83e9f38cd003476a6842c06ef39
refs/heads/main
2023-01-03T01:27:05.262904
2020-10-27T20:24:48
2020-10-27T20:24:48
305,502,060
0
0
null
null
null
null
UTF-8
Java
false
false
10,248
java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.math3.distribution; import java.io.Serializable; import org.apache.commons.math3.analysis.UnivariateFunction; import org.apache.commons.math3.analysis.solvers.UnivariateSolverUtils; import org.apache.commons.math3.exception.NotStrictlyPositiveException; import org.apache.commons.math3.exception.NumberIsTooLargeException; import org.apache.commons.math3.exception.OutOfRangeException; import org.apache.commons.math3.exception.util.LocalizedFormats; import org.apache.commons.math3.random.RandomGenerator; import org.apache.commons.math3.random.RandomDataImpl; import org.apache.commons.math3.util.FastMath; /** * Base class for probability distributions on the reals. * Default implementations are provided for some of the methods * that do not vary from distribution to distribution. * * @version $Id$ * @since 3.0 */ public abstract class AbstractRealDistribution implements RealDistribution, Serializable { /** Default accuracy. */ public static final double SOLVER_DEFAULT_ABSOLUTE_ACCURACY = 1e-6; /** Serializable version identifier */ private static final long serialVersionUID = -38038050983108802L; /** * RandomData instance used to generate samples from the distribution. * @deprecated As of 3.1, to be removed in 4.0. Please use the * {@link #random} instance variable instead. */ @Deprecated protected RandomDataImpl randomData = new RandomDataImpl(); /** * RNG instance used to generate samples from the distribution. * @since 3.1 */ protected final RandomGenerator random; /** Solver absolute accuracy for inverse cumulative computation */ private double solverAbsoluteAccuracy = SOLVER_DEFAULT_ABSOLUTE_ACCURACY; /** * @deprecated As of 3.1, to be removed in 4.0. Please use * {@link #AbstractRealDistribution(RandomGenerator)} instead. */ @Deprecated protected AbstractRealDistribution() { // Legacy users are only allowed to access the deprecated "randomData". // New users are forbidden to use this constructor. random = null; } /** * @param rng Random number generator. * @since 3.1 */ protected AbstractRealDistribution(RandomGenerator rng) { random = rng; } /** * {@inheritDoc} * * The default implementation uses the identity * <p>{@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)}</p> * * @deprecated As of 3.1 (to be removed in 4.0). Please use * {@link #probability(double,double)} instead. */ @Deprecated public double cumulativeProbability(double x0, double x1) throws NumberIsTooLargeException { return probability(x0, x1); } /** * For a random variable {@code X} whose values are distributed according * to this distribution, this method returns {@code P(x0 < X <= x1)}. * * @param x0 Lower bound (excluded). * @param x1 Upper bound (included). * @return the probability that a random variable with this distribution * takes a value between {@code x0} and {@code x1}, excluding the lower * and including the upper endpoint. * @throws NumberIsTooLargeException if {@code x0 > x1}. * * The default implementation uses the identity * {@code P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)} * * @since 3.1 */ public double probability(double x0, double x1) { if (x0 > x1) { throw new NumberIsTooLargeException(LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT, x0, x1, true); } return cumulativeProbability(x1) - cumulativeProbability(x0); } /** * {@inheritDoc} * * The default implementation returns * <ul> * <li>{@link #getSupportLowerBound()} for {@code p = 0},</li> * <li>{@link #getSupportUpperBound()} for {@code p = 1}.</li> * </ul> */ public double inverseCumulativeProbability(final double p) throws OutOfRangeException { /* * IMPLEMENTATION NOTES * -------------------- * Where applicable, use is made of the one-sided Chebyshev inequality * to bracket the root. This inequality states that * P(X - mu >= k * sig) <= 1 / (1 + k^2), * mu: mean, sig: standard deviation. Equivalently * 1 - P(X < mu + k * sig) <= 1 / (1 + k^2), * F(mu + k * sig) >= k^2 / (1 + k^2). * * For k = sqrt(p / (1 - p)), we find * F(mu + k * sig) >= p, * and (mu + k * sig) is an upper-bound for the root. * * Then, introducing Y = -X, mean(Y) = -mu, sd(Y) = sig, and * P(Y >= -mu + k * sig) <= 1 / (1 + k^2), * P(-X >= -mu + k * sig) <= 1 / (1 + k^2), * P(X <= mu - k * sig) <= 1 / (1 + k^2), * F(mu - k * sig) <= 1 / (1 + k^2). * * For k = sqrt((1 - p) / p), we find * F(mu - k * sig) <= p, * and (mu - k * sig) is a lower-bound for the root. * * In cases where the Chebyshev inequality does not apply, geometric * progressions 1, 2, 4, ... and -1, -2, -4, ... are used to bracket * the root. */ if (p < 0.0 || p > 1.0) { throw new OutOfRangeException(p, 0, 1); } double lowerBound = 0.0; if (p == 0.0) { return lowerBound; } double upperBound = getSupportUpperBound(); if (p == 1.0) { return upperBound; } final double mu = getNumericalMean(); final double sig = FastMath.sqrt(getNumericalVariance()); final boolean chebyshevApplies; chebyshevApplies = !(Double.isInfinite(mu) || Double.isNaN(mu) || Double.isInfinite(sig) || Double.isNaN(sig)); if (lowerBound == Double.NEGATIVE_INFINITY) { if (chebyshevApplies) { lowerBound = mu - sig * FastMath.sqrt((1. - p) / p); } else { lowerBound = -1.0; while (cumulativeProbability(lowerBound) >= p) { lowerBound *= 2.0; } } } if (upperBound == Double.POSITIVE_INFINITY) { if (chebyshevApplies) { upperBound = mu + sig * FastMath.sqrt(p / (1. - p)); } else { upperBound = 1.0; while (cumulativeProbability(upperBound) < p) { upperBound *= 2.0; } } } final UnivariateFunction toSolve = new UnivariateFunction() { public double value(final double x) { return cumulativeProbability(x) - p; } }; double x = UnivariateSolverUtils.solve(toSolve, lowerBound, upperBound, getSolverAbsoluteAccuracy()); if (!isSupportConnected()) { /* Test for plateau. */ final double dx = getSolverAbsoluteAccuracy(); if (x - dx >= getSupportLowerBound()) { double px = cumulativeProbability(x); if (cumulativeProbability(x - dx) == px) { upperBound = x; while (upperBound - lowerBound > dx) { final double midPoint = 0.5 * (lowerBound + upperBound); if (cumulativeProbability(midPoint) < px) { lowerBound = midPoint; } else { upperBound = midPoint; } } return upperBound; } } } return x; } /** * Returns the solver absolute accuracy for inverse cumulative computation. * You can override this method in order to use a Brent solver with an * absolute accuracy different from the default. * * @return the maximum absolute error in inverse cumulative probability estimates */ protected double getSolverAbsoluteAccuracy() { return solverAbsoluteAccuracy; } /** {@inheritDoc} */ public void reseedRandomGenerator(long seed) { random.setSeed(seed); randomData.reSeed(seed); } /** * {@inheritDoc} * * The default implementation uses the * <a href="http://en.wikipedia.org/wiki/Inverse_transform_sampling"> * inversion method. * </a> */ public double sample() { return inverseCumulativeProbability(random.nextDouble()); } /** * {@inheritDoc} * * The default implementation generates the sample by calling * {@link #sample()} in a loop. */ public double[] sample(int sampleSize) { if (sampleSize <= 0) { throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, sampleSize); } double[] out = new double[sampleSize]; for (int i = 0; i < sampleSize; i++) { out[i] = sample(); } return out; } /** * {@inheritDoc} * * @return zero. * @since 3.1 */ public double probability(double x) { return 0d; } }
1d15f836f0bfc67c4d49e0e6d0bb02b740ac37ce
0b6411044427dee6c311d877ed3220356f0cf55a
/src/main/java/com/stellapps/interview/model/Role.java
dc6916166ca7e8b51bb5d794c69ed4e043947520
[]
no_license
Ravivyas1989/Stellapps
a027c80c3c1abbc8d444c56d2788e83cc0552fce
3c3e5ef21dd571e4535bb419c0e3cb05a315f3e7
refs/heads/master
2022-12-27T11:18:17.355485
2020-07-23T11:12:50
2020-07-23T11:12:50
281,919,817
0
0
null
2020-10-13T23:50:43
2020-07-23T10:20:44
Java
UTF-8
Java
false
false
430
java
package com.stellapps.interview.model; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import javax.persistence.*; @Data @Builder @AllArgsConstructor @NoArgsConstructor @Entity @Table(name = "roles") public class Role { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "role_id") private int id; @Column(name = "role") private String role; }
76ac58d99b260011a5dfd34cb68d293f3165637d
dcddf1e902bbfcc20a600fdaf06851c698f48e17
/src/main/java/com/pxkj/controller/LoginController.java
f66e2153430d91a19c81fb7dd90563ef53e4610e
[]
no_license
YaXiongDong/spring-security-test
132e8a4b1a51f41d300bf64ff9dcf73fa1c134bd
d25779cf5c019da485d0a15c135df1588329a43b
refs/heads/master
2020-04-13T11:03:24.997087
2018-12-26T09:34:20
2018-12-26T09:34:20
163,162,285
0
0
null
null
null
null
UTF-8
Java
false
false
580
java
package com.pxkj.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class LoginController { @RequestMapping(value = "/login") public String login(){ return "login"; } @RequestMapping(value = "/login-error") public String loginError(Model model){ model.addAttribute("error", true); return "login"; } @RequestMapping(value = "/index") public String index(){ return "index"; } }
421e9d1ff00ade3a8dbcad6a6fb1839c1e09e4fe
5e4402c2ff22eed040ec276a450b7454386047d9
/android-stellar-sdk/src/main/java/org/stellar/sdk/responses/OrderBookResponse.java
80f53a32f55528b41860666a20003d15f4c6f7dd
[ "Apache-2.0" ]
permissive
nargroves/android-stellar-sdk
9f8764f2198ecc51934efc060bb220c60d09d6b9
e6dcbdacfb7ae9f48a2fa16ab1f6b5252949e0c0
refs/heads/master
2021-09-05T16:38:05.537307
2018-01-26T17:41:46
2018-01-26T17:41:46
118,684,315
0
0
null
null
null
null
UTF-8
Java
false
false
2,027
java
package org.stellar.sdk.responses; import com.google.gson.annotations.SerializedName; import org.stellar.sdk.Asset; import org.stellar.sdk.Price; import static com.google.common.base.Preconditions.checkNotNull; /** * Represents order book response. * * @see <a href="https://www.stellar.org/developers/horizon/reference/resources/orderbook.html" target="_blank">Order book documentation</a> * @see org.stellar.sdk.requests.OrderBookRequestBuilder * @see org.stellar.sdk.Server#orderBook() */ public class OrderBookResponse extends Response { @SerializedName("base") private final Asset base; @SerializedName("counter") private final Asset counter; @SerializedName("asks") private final Row[] asks; @SerializedName("bids") private final Row[] bids; public OrderBookResponse(Asset base, Asset counter, Row[] asks, Row[] bids) { this.base = base; this.counter = counter; this.asks = asks; this.bids = bids; } public Asset getBase() { return base; } public Asset getCounter() { return counter; } public Row[] getAsks() { return asks; } public Row[] getBids() { return bids; } /** * Represents order book row. */ public static class Row { @SerializedName("amount") private final String amount; @SerializedName("price") private final String price; @SerializedName("price_r") private final Price priceR; Row(String amount, String price, Price priceR) { this.amount = checkNotNull(amount, "amount cannot be null"); this.price = checkNotNull(price, "price cannot be null"); this.priceR = checkNotNull(priceR, "priceR cannot be null"); } public String getAmount() { return amount; } public String getPrice() { return price; } public Price getPriceR() { return priceR; } } }
5edccf7f5f8fe9e7a594b5816e2148d6c039ec3d
499a2806b69faa162ec5ee92fc66e690991c5109
/JavaLearning/src/com/nishan/java/creational/factory/pattern/Constant.java
a7c97adcc02ceb5083b7f66fda80c93f9df08d29
[]
no_license
rawntech/JavaStudyProject
fc6ea41b02aeb90b048e479530682ffd9d5d50cc
859a94816180f6a5a0909dfe7d7fb62a4021b013
refs/heads/master
2021-01-18T09:15:33.027145
2014-12-03T13:39:25
2014-12-03T13:39:25
null
0
0
null
null
null
null
UTF-8
Java
false
false
169
java
package com.nishan.java.creational.factory.pattern; public abstract class Constant { public static final String bus = "b"; public static final String truck = "t"; }
a8d46ac22fc07d278a8dee2d6321874aca48ef2f
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/11/11_fa97abe49debcaa575aa57f27222c7b4ae253a53/GameplayState/11_fa97abe49debcaa575aa57f27222c7b4ae253a53_GameplayState_t.java
2437caaee6671f5cdc07713b9c910a22c3e2ec8d
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
5,610
java
package com.soupcan.aquapulse.state; import com.soupcan.aquapulse.AquapulseGame; import com.soupcan.aquapulse.controller.MovementController; import com.soupcan.aquapulse.model.engine.Level; import com.soupcan.aquapulse.model.engine.LevelGroup; import com.soupcan.aquapulse.model.entity.Player; import org.newdawn.slick.*; import org.newdawn.slick.geom.Shape; import org.newdawn.slick.geom.ShapeRenderer; import org.newdawn.slick.geom.Vector2f; import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.StateBasedGame; public class GameplayState extends BasicGameState { private int stateID; private Image background; private LevelGroup levels; private Player player; private Sound inhaleSound; private Sound exhaleSound; private boolean readyToExhale = true; private Sound normalHeartBeat; private Sound rapidHeartBeat; private Sound slowHeartBeat; private Music music; private Sound heartBeat; private int deltaCount; private MovementController movementController; public GameplayState(int stateID) throws SlickException { this.stateID = stateID; music = new Music("res/sound/game_music.wav"); } @Override public int getID() { return stateID; } @Override public void enter(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException { super.enter(gameContainer, stateBasedGame); player = new Player(new Vector2f(100, 400)); levels = new LevelGroup(); levels.addLevel(new Level("res/map/finalmap01.tmx")); levels.addLevel(new Level("res/map/finalmap02.tmx")); levels.addLevel(new Level("res/map/finalmap03.tmx")); movementController = new MovementController(player, levels); deltaCount = 0; } @Override public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException { background = new Image("res/img/ui/background.png"); inhaleSound = new Sound("res/sound/inhale.wav"); exhaleSound = new Sound("res/sound/exhale.wav"); normalHeartBeat = new Sound("res/sound/meter_normal.wav"); rapidHeartBeat = new Sound("res/sound/meter_rapid.wav"); slowHeartBeat = new Sound("res/sound/meter_slow.wav"); } @Override public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics) throws SlickException { background.draw(0, 0); levels.render(); player.render(); // Draw the heart rate meter as a simple rectangle. graphics.setColor(new Color(player.heartRate / player.MAX_HEART_RATE, .1f, 1 - player.heartRate / player.MAX_HEART_RATE)); graphics.fillRoundRect(20, // x in pixels, from left edge of screen 40, // y in pixels, from top edge of screen player.heartRate * 4, // width of rectangle 10, // height of rectangle 5); // rectangle rounded corner radius in pixels } @Override public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int delta) throws SlickException { deltaCount += delta; if (!music.playing()) music.loop(); // Check collision from map scrolling for(int i = 0; i < levels.size(); i++) { for(int j = 0; j < levels.get(i).bounds.size(); j++) { Shape tileBlock = levels.get(i).bounds.get(j); if(collides(player.bounds, tileBlock) && player.bounds.getMaxX() >= tileBlock.getMinX()) { player.position.x -= LevelGroup.SCROLL_COEFF * delta; } } } // Checks if player is off screen and ends the game if they are. if(player.position.x + Player.WIDTH < 0 || player.position.y - Player.HEIGHT > 600 | player.position.y + Player.HEIGHT < 0) { stateBasedGame.enterState(AquapulseGame.GAME_OVER_STATE); } movementController.processInput(gameContainer.getInput(), delta, stateBasedGame); levels.scroll(delta); player.update(); if ((player.heartRate < player.MIN_HEART_RATE) || (player.heartRate > player.MAX_HEART_RATE)) { stateBasedGame.enterState(AquapulseGame.GAME_OVER_STATE); } // Occasionally play the bubble sound if (Math.random() < .005) // 1 in 200 chance { Sound bubbles = new Sound("res/sound/bubbles.wav"); bubbles.play(); } if(player.heartRate > 150) { if(deltaCount >= 500) { deltaCount = 0; rapidHeartBeat.play(); } } else if(player.heartRate < 150 && player.heartRate > 50) { if(deltaCount >= 1000) { deltaCount = 0; normalHeartBeat.play(); } } else if(player.heartRate < 50) { if (deltaCount >= 2000) { deltaCount = 0; slowHeartBeat.play(); } } // Occasionally play the inhale/exhale sound //if (Math.random()) } private boolean collides(Shape shape1, Shape shape2) { return shape1.intersects(shape2); } }
3784daec5fe92d8cbd4bec14b3703f37f8cb4c49
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/19/19_210d2d9cc4a917668452c3311bbf0abc01797df9/RESTv1/19_210d2d9cc4a917668452c3311bbf0abc01797df9_RESTv1_t.java
057d55c900c9ccd0f1b31f57359cf0b3f46d6597
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
171,842
java
package org.jboss.pressgang.ccms.server.rest.v1; import javax.persistence.criteria.CriteriaQuery; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.PathSegment; import javax.ws.rs.core.Response; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Set; import org.hibernate.Session; import org.hibernate.search.FullTextSession; import org.hibernate.search.Search; import org.jboss.pressgang.ccms.filter.BlobConstantFieldFilter; import org.jboss.pressgang.ccms.filter.CategoryFieldFilter; import org.jboss.pressgang.ccms.filter.ContentSpecFieldFilter; import org.jboss.pressgang.ccms.filter.ContentSpecNodeFieldFilter; import org.jboss.pressgang.ccms.filter.FileFieldFilter; import org.jboss.pressgang.ccms.filter.FilterFieldFilter; import org.jboss.pressgang.ccms.filter.ImageFieldFilter; import org.jboss.pressgang.ccms.filter.IntegerConstantFieldFilter; import org.jboss.pressgang.ccms.filter.ProjectFieldFilter; import org.jboss.pressgang.ccms.filter.PropertyTagCategoryFieldFilter; import org.jboss.pressgang.ccms.filter.PropertyTagFieldFilter; import org.jboss.pressgang.ccms.filter.RoleFieldFilter; import org.jboss.pressgang.ccms.filter.StringConstantFieldFilter; import org.jboss.pressgang.ccms.filter.TagFieldFilter; import org.jboss.pressgang.ccms.filter.TopicFieldFilter; import org.jboss.pressgang.ccms.filter.TranslatedContentSpecFieldFilter; import org.jboss.pressgang.ccms.filter.TranslatedContentSpecNodeFieldFilter; import org.jboss.pressgang.ccms.filter.UserFieldFilter; import org.jboss.pressgang.ccms.filter.builder.BlobConstantFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.CategoryFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.ContentSpecFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.ContentSpecNodeFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.FileFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.FilterFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.ImageFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.IntegerConstantFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.ProjectFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.PropertyTagCategoryFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.PropertyTagFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.RoleFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.StringConstantFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.TagFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.TopicFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.TranslatedContentSpecFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.TranslatedContentSpecNodeFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.TranslatedTopicDataFilterQueryBuilder; import org.jboss.pressgang.ccms.filter.builder.UserFilterQueryBuilder; import org.jboss.pressgang.ccms.model.BlobConstants; import org.jboss.pressgang.ccms.model.Category; import org.jboss.pressgang.ccms.model.File; import org.jboss.pressgang.ccms.model.Filter; import org.jboss.pressgang.ccms.model.ImageFile; import org.jboss.pressgang.ccms.model.IntegerConstants; import org.jboss.pressgang.ccms.model.LanguageFile; import org.jboss.pressgang.ccms.model.LanguageImage; import org.jboss.pressgang.ccms.model.Project; import org.jboss.pressgang.ccms.model.PropertyTag; import org.jboss.pressgang.ccms.model.PropertyTagCategory; import org.jboss.pressgang.ccms.model.Role; import org.jboss.pressgang.ccms.model.StringConstants; import org.jboss.pressgang.ccms.model.Tag; import org.jboss.pressgang.ccms.model.Topic; import org.jboss.pressgang.ccms.model.TranslatedTopicData; import org.jboss.pressgang.ccms.model.User; import org.jboss.pressgang.ccms.model.contentspec.CSNode; import org.jboss.pressgang.ccms.model.contentspec.ContentSpec; import org.jboss.pressgang.ccms.model.contentspec.TranslatedCSNode; import org.jboss.pressgang.ccms.model.contentspec.TranslatedContentSpec; import org.jboss.pressgang.ccms.rest.v1.collections.RESTBlobConstantCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTCategoryCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTFileCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTFilterCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTImageCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTIntegerConstantCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTProjectCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTPropertyCategoryCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTPropertyTagCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTRoleCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTStringConstantCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTTagCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTTopicCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTTranslatedTopicCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.RESTUserCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.contentspec.RESTCSNodeCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.contentspec.RESTContentSpecCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.contentspec.RESTTextContentSpecCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.contentspec.RESTTranslatedCSNodeCollectionV1; import org.jboss.pressgang.ccms.rest.v1.collections.contentspec.RESTTranslatedContentSpecCollectionV1; import org.jboss.pressgang.ccms.rest.v1.components.ComponentTopicV1; import org.jboss.pressgang.ccms.rest.v1.constants.RESTv1Constants; import org.jboss.pressgang.ccms.rest.v1.entities.RESTBlobConstantV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTCategoryV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTFileV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTFilterV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTImageV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTIntegerConstantV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTProjectV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTPropertyCategoryV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTPropertyTagV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTRoleV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTStringConstantV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTTagV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTTopicV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTTranslatedTopicV1; import org.jboss.pressgang.ccms.rest.v1.entities.RESTUserV1; import org.jboss.pressgang.ccms.rest.v1.entities.base.RESTLogDetailsV1; import org.jboss.pressgang.ccms.rest.v1.entities.contentspec.RESTCSNodeV1; import org.jboss.pressgang.ccms.rest.v1.entities.contentspec.RESTContentSpecV1; import org.jboss.pressgang.ccms.rest.v1.entities.contentspec.RESTTextContentSpecV1; import org.jboss.pressgang.ccms.rest.v1.entities.contentspec.RESTTranslatedCSNodeV1; import org.jboss.pressgang.ccms.rest.v1.entities.contentspec.RESTTranslatedContentSpecV1; import org.jboss.pressgang.ccms.rest.v1.entities.enums.RESTXMLDoctype; import org.jboss.pressgang.ccms.rest.v1.entities.wrapper.IntegerWrapper; import org.jboss.pressgang.ccms.rest.v1.expansion.ExpandDataDetails; import org.jboss.pressgang.ccms.rest.v1.expansion.ExpandDataTrunk; import org.jboss.pressgang.ccms.rest.v1.jaxrsinterfaces.RESTBaseInterfaceV1; import org.jboss.pressgang.ccms.rest.v1.jaxrsinterfaces.RESTInterfaceAdvancedV1; import org.jboss.pressgang.ccms.server.rest.v1.base.BaseRESTv1; import org.jboss.pressgang.ccms.server.utils.Constants; import org.jboss.pressgang.ccms.server.utils.ContentSpecUtilities; import org.jboss.pressgang.ccms.server.utils.TopicUtilities; import org.jboss.pressgang.ccms.utils.common.CollectionUtilities; import org.jboss.pressgang.ccms.utils.common.DocBookUtilities; import org.jboss.pressgang.ccms.utils.common.XMLUtilities; import org.jboss.pressgang.ccms.utils.common.ZipUtilities; import org.jboss.pressgang.ccms.utils.constants.CommonConstants; import org.jboss.resteasy.plugins.providers.atom.Feed; import org.jboss.resteasy.specimpl.PathSegmentImpl; import org.jboss.resteasy.spi.BadRequestException; import org.jboss.resteasy.spi.HttpResponse; import org.jboss.resteasy.spi.InternalServerErrorException; import org.jboss.resteasy.spi.NotFoundException; import org.jboss.resteasy.util.Base64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; /** * The PressGang REST interface implementation */ @Path(Constants.BASE_REST_PATH + "/1") public class RESTv1 extends BaseRESTv1 implements RESTBaseInterfaceV1, RESTInterfaceAdvancedV1 { private static final Logger log = LoggerFactory.getLogger(RESTv1.class); @Context HttpResponse response; /* SYSTEM FUNCTIONS */ @Override public void reIndexLuceneDatabase() { try { final Session session = (Session) entityManager.getDelegate(); final FullTextSession fullTextSession = Search.getFullTextSession(session); fullTextSession.createIndexer(Topic.class).start(); } catch (final Exception ex) { log.error("An error reindexing the Lucene database", ex); } } @Override public ExpandDataTrunk getJSONExpandTrunkExample() { final ExpandDataTrunk expand = new ExpandDataTrunk(); final ExpandDataTrunk collection = new ExpandDataTrunk(new ExpandDataDetails("collectionname")); final ExpandDataTrunk subCollection = new ExpandDataTrunk(new ExpandDataDetails("subcollection")); collection.setBranches(CollectionUtilities.toArrayList(subCollection)); expand.setBranches(CollectionUtilities.toArrayList(collection)); return expand; } @Override public IntegerWrapper holdXML(final String xml) { if (xml == null) { throw new BadRequestException("The xml parameter cannot be null"); } // Parse the XML to make sure it's XML Document doc = null; try { doc = XMLUtilities.convertStringToDocument(xml); } catch (Exception e) { throw new BadRequestException(e); } // Make sure the input was XML by seeing if it could be parsed if (doc == null) { throw new BadRequestException("The input XML is not valid XML content"); } // Add the xml to the cache and return the ID final IntegerWrapper retValue = new IntegerWrapper(); retValue.value = xmlEchoCache.addXML(xml); return retValue; } @Override public String echoXML(final Integer id, final String xml) { if (id == null && xml == null) throw new BadRequestException("The id parameter field cannot be null"); if (id != null) { final String foundXML = xmlEchoCache.getXML(id); if (foundXML == null) { throw new NotFoundException("No XML exists for the specified id"); } else { return foundXML; } } else { Document doc = null; try { doc = XMLUtilities.convertStringToDocument(xml); } catch (Exception e) { throw new BadRequestException(e); } if (doc == null) { throw new BadRequestException("The input XML is not valid XML content"); } else { return xml; } } } /* BLOBCONSTANTS FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPBlobConstant(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONBlobConstant(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPBlobConstantRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONBlobConstantRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } public String getJSONPBlobConstants(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONBlobConstants(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPBlobConstantsWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONBlobConstantsWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTBlobConstantV1 getJSONBlobConstant(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(BlobConstants.class, blobConstantFactory, id, expand); } @Override public RESTBlobConstantV1 getJSONBlobConstantRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(BlobConstants.class, blobConstantFactory, id, revision, expand); } @Override public RESTBlobConstantCollectionV1 getJSONBlobConstants(final String expand) { return getJSONResources(RESTBlobConstantCollectionV1.class, BlobConstants.class, blobConstantFactory, RESTv1Constants.BLOBCONSTANTS_EXPANSION_NAME, expand); } @Override public RESTBlobConstantCollectionV1 getJSONBlobConstantsWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTBlobConstantCollectionV1.class, query.getMatrixParameters(), BlobConstantFilterQueryBuilder.class, new BlobConstantFieldFilter(), blobConstantFactory, RESTv1Constants.BLOBCONSTANTS_EXPANSION_NAME, expand); } @Override public RESTBlobConstantV1 updateJSONBlobConstant(final String expand, final RESTBlobConstantV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(BlobConstants.class, dataObject, blobConstantFactory, expand, logDetails); } @Override public RESTBlobConstantCollectionV1 updateJSONBlobConstants(final String expand, final RESTBlobConstantCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTBlobConstantCollectionV1.class, BlobConstants.class, dataObjects, blobConstantFactory, RESTv1Constants.BLOBCONSTANTS_EXPANSION_NAME, expand, logDetails); } @Override public RESTBlobConstantV1 createJSONBlobConstant(final String expand, final RESTBlobConstantV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(BlobConstants.class, dataObject, blobConstantFactory, expand, logDetails); } @Override public RESTBlobConstantCollectionV1 createJSONBlobConstants(final String expand, final RESTBlobConstantCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTBlobConstantCollectionV1.class, BlobConstants.class, dataObjects, blobConstantFactory, RESTv1Constants.BLOBCONSTANTS_EXPANSION_NAME, expand, logDetails); } @Override public RESTBlobConstantV1 deleteJSONBlobConstant(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(BlobConstants.class, blobConstantFactory, id, expand, logDetails); } @Override public RESTBlobConstantCollectionV1 deleteJSONBlobConstants(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The dataObjects parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTBlobConstantCollectionV1.class, BlobConstants.class, blobConstantFactory, dbEntityIds, RESTv1Constants.BLOBCONSTANTS_EXPANSION_NAME, expand, logDetails); } /* RAW FUNCTIONS */ @Override public byte[] getRAWBlobConstant(@PathParam("id") Integer id) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final BlobConstants entity = getEntity(BlobConstants.class, id); response.getOutputHeaders().putSingle("Content-Disposition", "filename=" + entity.getConstantName()); return entity.getConstantValue(); } @Override public byte[] getRAWBlobConstantRevision(@PathParam("id") Integer id, @PathParam("rev") Integer revision) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); final BlobConstants entity = getEntity(BlobConstants.class, id, revision); response.getOutputHeaders().putSingle("Content-Disposition", "filename=" + entity.getConstantName()); return entity.getConstantValue(); } /* PROJECT FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPProject(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONProject(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPProjectRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONProjectRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPProjects(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONProjects(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPProjectsWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONProjectsWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTProjectV1 getJSONProject(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(Project.class, projectFactory, id, expand); } @Override public RESTProjectV1 getJSONProjectRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(Project.class, projectFactory, id, revision, expand); } @Override public RESTProjectCollectionV1 getJSONProjects(final String expand) { return getJSONResources(RESTProjectCollectionV1.class, Project.class, projectFactory, RESTv1Constants.PROJECTS_EXPANSION_NAME, expand); } @Override public RESTProjectCollectionV1 getJSONProjectsWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTProjectCollectionV1.class, query.getMatrixParameters(), ProjectFilterQueryBuilder.class, new ProjectFieldFilter(), projectFactory, RESTv1Constants.PROJECTS_EXPANSION_NAME, expand); } @Override public RESTProjectV1 updateJSONProject(final String expand, final RESTProjectV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(Project.class, dataObject, projectFactory, expand, logDetails); } @Override public RESTProjectCollectionV1 updateJSONProjects(final String expand, final RESTProjectCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTProjectCollectionV1.class, Project.class, dataObjects, projectFactory, RESTv1Constants.PROJECTS_EXPANSION_NAME, expand, logDetails); } @Override public RESTProjectV1 createJSONProject(final String expand, final RESTProjectV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(Project.class, dataObject, projectFactory, expand, logDetails); } @Override public RESTProjectCollectionV1 createJSONProjects(final String expand, final RESTProjectCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTProjectCollectionV1.class, Project.class, dataObjects, projectFactory, RESTv1Constants.PROJECTS_EXPANSION_NAME, expand, logDetails); } @Override public RESTProjectV1 deleteJSONProject(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(Project.class, projectFactory, id, expand, logDetails); } @Override public RESTProjectCollectionV1 deleteJSONProjects(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The dataObjects parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTProjectCollectionV1.class, Project.class, projectFactory, dbEntityIds, RESTv1Constants.PROJECTS_EXPANSION_NAME, expand, logDetails); } /* PROPERYTAG FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPPropertyTag(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONPropertyTag(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPPropertyTagRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONPropertyTagRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPPropertyTags(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONPropertyTags(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPPropertyTagsWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONPropertyTagsWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTPropertyTagV1 getJSONPropertyTag(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(PropertyTag.class, propertyTagFactory, id, expand); } @Override public RESTPropertyTagV1 getJSONPropertyTagRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(PropertyTag.class, propertyTagFactory, id, revision, expand); } @Override public RESTPropertyTagCollectionV1 getJSONPropertyTags(final String expand) { return getJSONResources(RESTPropertyTagCollectionV1.class, PropertyTag.class, propertyTagFactory, RESTv1Constants.PROPERTYTAGS_EXPANSION_NAME, expand); } @Override public RESTPropertyTagCollectionV1 getJSONPropertyTagsWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTPropertyTagCollectionV1.class, query.getMatrixParameters(), PropertyTagFilterQueryBuilder.class, new PropertyTagFieldFilter(), propertyTagFactory, RESTv1Constants.PROPERTYTAGS_EXPANSION_NAME, expand); } @Override public RESTPropertyTagV1 updateJSONPropertyTag(final String expand, final RESTPropertyTagV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(PropertyTag.class, dataObject, propertyTagFactory, expand, logDetails); } @Override public RESTPropertyTagCollectionV1 updateJSONPropertyTags(final String expand, final RESTPropertyTagCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTPropertyTagCollectionV1.class, PropertyTag.class, dataObjects, propertyTagFactory, RESTv1Constants.PROPERTYTAGS_EXPANSION_NAME, expand, logDetails); } @Override public RESTPropertyTagV1 createJSONPropertyTag(final String expand, final RESTPropertyTagV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(PropertyTag.class, dataObject, propertyTagFactory, expand, logDetails); } @Override public RESTPropertyTagCollectionV1 createJSONPropertyTags(final String expand, final RESTPropertyTagCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTPropertyTagCollectionV1.class, PropertyTag.class, dataObjects, propertyTagFactory, RESTv1Constants.PROPERTYTAGS_EXPANSION_NAME, expand, logDetails); } @Override public RESTPropertyTagV1 deleteJSONPropertyTag(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(PropertyTag.class, propertyTagFactory, id, expand, logDetails); } @Override public RESTPropertyTagCollectionV1 deleteJSONPropertyTags(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The dataObjects parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTPropertyTagCollectionV1.class, PropertyTag.class, propertyTagFactory, dbEntityIds, RESTv1Constants.PROPERTYTAGS_EXPANSION_NAME, expand, logDetails); } /* PROPERYCATEGORY FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPPropertyCategory(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONPropertyCategory(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPPropertyCategoryRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONPropertyCategoryRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPPropertyCategories(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONPropertyCategories(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPPropertyCategoriesWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONPropertyCategoriesWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTPropertyCategoryV1 getJSONPropertyCategory(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(PropertyTagCategory.class, propertyCategoryFactory, id, expand); } @Override public RESTPropertyCategoryV1 getJSONPropertyCategoryRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(PropertyTagCategory.class, propertyCategoryFactory, id, revision, expand); } @Override public RESTPropertyCategoryCollectionV1 getJSONPropertyCategories(final String expand) { return getJSONResources(RESTPropertyCategoryCollectionV1.class, PropertyTagCategory.class, propertyCategoryFactory, RESTv1Constants.PROPERTY_CATEGORIES_EXPANSION_NAME, expand); } @Override public RESTPropertyCategoryCollectionV1 getJSONPropertyCategoriesWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTPropertyCategoryCollectionV1.class, query.getMatrixParameters(), PropertyTagCategoryFilterQueryBuilder.class, new PropertyTagCategoryFieldFilter(), propertyCategoryFactory, RESTv1Constants.PROPERTY_CATEGORIES_EXPANSION_NAME, expand); } @Override public RESTPropertyCategoryV1 updateJSONPropertyCategory(final String expand, final RESTPropertyCategoryV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(PropertyTagCategory.class, dataObject, propertyCategoryFactory, expand, logDetails); } @Override public RESTPropertyCategoryCollectionV1 updateJSONPropertyCategories(final String expand, final RESTPropertyCategoryCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTPropertyCategoryCollectionV1.class, PropertyTagCategory.class, dataObjects, propertyCategoryFactory, RESTv1Constants.PROPERTY_CATEGORIES_EXPANSION_NAME, expand, logDetails); } @Override public RESTPropertyCategoryV1 createJSONPropertyCategory(final String expand, final RESTPropertyCategoryV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(PropertyTagCategory.class, dataObject, propertyCategoryFactory, expand, logDetails); } @Override public RESTPropertyCategoryCollectionV1 createJSONPropertyCategories(final String expand, final RESTPropertyCategoryCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTPropertyCategoryCollectionV1.class, PropertyTagCategory.class, dataObjects, propertyCategoryFactory, RESTv1Constants.PROPERTY_CATEGORIES_EXPANSION_NAME, expand, logDetails); } @Override public RESTPropertyCategoryV1 deleteJSONPropertyCategory(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(PropertyTagCategory.class, propertyCategoryFactory, id, expand, logDetails); } @Override public RESTPropertyCategoryCollectionV1 deleteJSONPropertyCategories(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The dataObjects parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTPropertyCategoryCollectionV1.class, PropertyTagCategory.class, propertyCategoryFactory, dbEntityIds, RESTv1Constants.PROPERTY_CATEGORIES_EXPANSION_NAME, expand, logDetails); } /* ROLE FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPRole(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONRole(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPRoleRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONRoleRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPRoles(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONRoles(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPRolesWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONRolesWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTRoleV1 getJSONRole(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(Role.class, roleFactory, id, expand); } @Override public RESTRoleV1 getJSONRoleRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(Role.class, roleFactory, id, expand); } @Override public RESTRoleCollectionV1 getJSONRoles(final String expand) { return getJSONResources(RESTRoleCollectionV1.class, Role.class, roleFactory, RESTv1Constants.ROLES_EXPANSION_NAME, expand); } @Override public RESTRoleCollectionV1 getJSONRolesWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTRoleCollectionV1.class, query.getMatrixParameters(), RoleFilterQueryBuilder.class, new RoleFieldFilter(), roleFactory, RESTv1Constants.ROLES_EXPANSION_NAME, expand); } @Override public RESTRoleV1 updateJSONRole(final String expand, final RESTRoleV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(Role.class, dataObject, roleFactory, expand, logDetails); } @Override public RESTRoleCollectionV1 updateJSONRoles(final String expand, final RESTRoleCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTRoleCollectionV1.class, Role.class, dataObjects, roleFactory, RESTv1Constants.ROLES_EXPANSION_NAME, expand, logDetails); } @Override public RESTRoleV1 createJSONRole(final String expand, final RESTRoleV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(Role.class, dataObject, roleFactory, expand, logDetails); } @Override public RESTRoleCollectionV1 createJSONRoles(final String expand, final RESTRoleCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTRoleCollectionV1.class, Role.class, dataObjects, roleFactory, RESTv1Constants.ROLES_EXPANSION_NAME, expand, logDetails); } @Override public RESTRoleV1 deleteJSONRole(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(Role.class, roleFactory, id, expand, logDetails); } @Override public RESTRoleCollectionV1 deleteJSONRoles(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The dataObjects parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTRoleCollectionV1.class, Role.class, roleFactory, dbEntityIds, RESTv1Constants.ROLES_EXPANSION_NAME, expand, logDetails); } /* TRANSLATEDTOPIC FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPTranslatedTopic(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedTopic(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTranslatedTopicRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedTopicRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTranslatedTopics(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedTopics(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTranslatedTopicsWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedTopicsWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTTranslatedTopicV1 getJSONTranslatedTopic(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(TranslatedTopicData.class, translatedTopicFactory, id, expand); } @Override public RESTTranslatedTopicV1 getJSONTranslatedTopicRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(TranslatedTopicData.class, translatedTopicFactory, id, revision, expand); } @Override public RESTTranslatedTopicCollectionV1 getJSONTranslatedTopicsWithQuery(PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTTranslatedTopicCollectionV1.class, query.getMatrixParameters(), TranslatedTopicDataFilterQueryBuilder.class, new TopicFieldFilter(), translatedTopicFactory, RESTv1Constants.TRANSLATEDTOPICS_EXPANSION_NAME, expand); } @Override public RESTTranslatedTopicCollectionV1 getJSONTranslatedTopics(final String expand) { return getJSONResources(RESTTranslatedTopicCollectionV1.class, TranslatedTopicData.class, translatedTopicFactory, RESTv1Constants.TRANSLATEDTOPICS_EXPANSION_NAME, expand); } @Override public RESTTranslatedTopicV1 updateJSONTranslatedTopic(final String expand, final RESTTranslatedTopicV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(TranslatedTopicData.class, dataObject, translatedTopicFactory, expand, logDetails); } @Override public RESTTranslatedTopicCollectionV1 updateJSONTranslatedTopics(final String expand, final RESTTranslatedTopicCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTTranslatedTopicCollectionV1.class, TranslatedTopicData.class, dataObjects, translatedTopicFactory, RESTv1Constants.TRANSLATEDTOPICS_EXPANSION_NAME, expand, logDetails); } @Override public RESTTranslatedTopicV1 createJSONTranslatedTopic(final String expand, final RESTTranslatedTopicV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(TranslatedTopicData.class, dataObject, translatedTopicFactory, expand, logDetails); } @Override public RESTTranslatedTopicCollectionV1 createJSONTranslatedTopics(final String expand, final RESTTranslatedTopicCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTTranslatedTopicCollectionV1.class, TranslatedTopicData.class, dataObjects, translatedTopicFactory, RESTv1Constants.TRANSLATEDTOPICS_EXPANSION_NAME, expand, logDetails); } @Override public RESTTranslatedTopicV1 deleteJSONTranslatedTopic(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(TranslatedTopicData.class, translatedTopicFactory, id, expand, logDetails); } @Override public RESTTranslatedTopicCollectionV1 deleteJSONTranslatedTopics(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The dataObjects parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTTranslatedTopicCollectionV1.class, TranslatedTopicData.class, translatedTopicFactory, dbEntityIds, RESTv1Constants.TRANSLATEDTOPICS_EXPANSION_NAME, expand, logDetails); } /* STRINGCONSTANT FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPStringConstant(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONStringConstant(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPStringConstantRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONStringConstantRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPStringConstants(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONStringConstants(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPStringConstantsWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONStringConstantsWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTStringConstantV1 getJSONStringConstant(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(StringConstants.class, stringConstantFactory, id, expand); } @Override public RESTStringConstantV1 getJSONStringConstantRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(StringConstants.class, stringConstantFactory, id, revision, expand); } @Override public RESTStringConstantCollectionV1 getJSONStringConstants(final String expand) { return getJSONResources(RESTStringConstantCollectionV1.class, StringConstants.class, stringConstantFactory, RESTv1Constants.STRINGCONSTANTS_EXPANSION_NAME, expand); } @Override public RESTStringConstantCollectionV1 getJSONStringConstantsWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTStringConstantCollectionV1.class, query.getMatrixParameters(), StringConstantFilterQueryBuilder.class, new StringConstantFieldFilter(), stringConstantFactory, RESTv1Constants.STRINGCONSTANTS_EXPANSION_NAME, expand); } @Override public RESTStringConstantV1 updateJSONStringConstant(final String expand, final RESTStringConstantV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(StringConstants.class, dataObject, stringConstantFactory, expand, logDetails); } @Override public RESTStringConstantCollectionV1 updateJSONStringConstants(final String expand, final RESTStringConstantCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTStringConstantCollectionV1.class, StringConstants.class, dataObjects, stringConstantFactory, RESTv1Constants.STRINGCONSTANTS_EXPANSION_NAME, expand, logDetails); } @Override public RESTStringConstantV1 createJSONStringConstant(final String expand, final RESTStringConstantV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(StringConstants.class, dataObject, stringConstantFactory, expand, logDetails); } @Override public RESTStringConstantCollectionV1 createJSONStringConstants(final String expand, final RESTStringConstantCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTStringConstantCollectionV1.class, StringConstants.class, dataObjects, stringConstantFactory, RESTv1Constants.STRINGCONSTANTS_EXPANSION_NAME, expand, logDetails); } @Override public RESTStringConstantV1 deleteJSONStringConstant(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(StringConstants.class, stringConstantFactory, id, expand, logDetails); } @Override public RESTStringConstantCollectionV1 deleteJSONStringConstants(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The ids parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTStringConstantCollectionV1.class, StringConstants.class, stringConstantFactory, dbEntityIds, RESTv1Constants.STRINGCONSTANTS_EXPANSION_NAME, expand, logDetails); } /* USER FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPUser(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONUser(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPUserRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONUserRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPUsers(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONUsers(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPUsersWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONUsersWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTUserV1 getJSONUser(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(User.class, userFactory, id, expand); } @Override public RESTUserV1 getJSONUserRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(User.class, userFactory, id, revision, expand); } @Override public RESTUserCollectionV1 getJSONUsers(final String expand) { return getJSONResources(RESTUserCollectionV1.class, User.class, userFactory, RESTv1Constants.USERS_EXPANSION_NAME, expand); } @Override public RESTUserCollectionV1 getJSONUsersWithQuery(final PathSegment query, final String expand) { return this.getJSONResourcesFromQuery(RESTUserCollectionV1.class, query.getMatrixParameters(), UserFilterQueryBuilder.class, new UserFieldFilter(), userFactory, RESTv1Constants.USERS_EXPANSION_NAME, expand); } @Override public RESTUserV1 updateJSONUser(final String expand, final RESTUserV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(User.class, dataObject, userFactory, expand, logDetails); } @Override public RESTUserCollectionV1 updateJSONUsers(final String expand, final RESTUserCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTUserCollectionV1.class, User.class, dataObjects, userFactory, RESTv1Constants.USERS_EXPANSION_NAME, expand, logDetails); } @Override public RESTUserV1 createJSONUser(final String expand, final RESTUserV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(User.class, dataObject, userFactory, expand, logDetails); } @Override public RESTUserCollectionV1 createJSONUsers(final String expand, final RESTUserCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTUserCollectionV1.class, User.class, dataObjects, userFactory, RESTv1Constants.USERS_EXPANSION_NAME, expand, logDetails); } @Override public RESTUserV1 deleteJSONUser(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(User.class, userFactory, id, expand, logDetails); } @Override public RESTUserCollectionV1 deleteJSONUsers(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The ids parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTUserCollectionV1.class, User.class, userFactory, dbEntityIds, RESTv1Constants.USERS_EXPANSION_NAME, expand, logDetails); } /* TAG FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPTag(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTag(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTagRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTagRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTags(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTags(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTagsWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTagsWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTTagV1 getJSONTag(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(Tag.class, tagFactory, id, expand); } @Override public RESTTagV1 getJSONTagRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(Tag.class, tagFactory, id, revision, expand); } @Override public RESTTagCollectionV1 getJSONTags(final String expand) { return getJSONResources(RESTTagCollectionV1.class, Tag.class, tagFactory, RESTv1Constants.TAGS_EXPANSION_NAME, expand); } @Override public RESTTagCollectionV1 getJSONTagsWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTTagCollectionV1.class, query.getMatrixParameters(), TagFilterQueryBuilder.class, new TagFieldFilter(), tagFactory, RESTv1Constants.TAGS_EXPANSION_NAME, expand); } @Override public RESTTagV1 updateJSONTag(final String expand, final RESTTagV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(Tag.class, dataObject, tagFactory, expand, logDetails); } @Override public RESTTagCollectionV1 updateJSONTags(final String expand, final RESTTagCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTTagCollectionV1.class, Tag.class, dataObjects, tagFactory, RESTv1Constants.TAGS_EXPANSION_NAME, expand, logDetails); } @Override public RESTTagV1 createJSONTag(final String expand, final RESTTagV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(Tag.class, dataObject, tagFactory, expand, logDetails); } @Override public RESTTagCollectionV1 createJSONTags(final String expand, final RESTTagCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTTagCollectionV1.class, Tag.class, dataObjects, tagFactory, RESTv1Constants.TAGS_EXPANSION_NAME, expand, logDetails); } @Override public RESTTagV1 deleteJSONTag(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(Tag.class, tagFactory, id, expand, logDetails); } @Override public RESTTagCollectionV1 deleteJSONTags(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The ids parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTTagCollectionV1.class, Tag.class, tagFactory, dbEntityIds, RESTv1Constants.TAGS_EXPANSION_NAME, expand, logDetails); } /* CATEGORY FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPCategory(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONCategory(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPCategoryRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONCategoryRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPCategories(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONCategories(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPCategoriesWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONCategoriesWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTCategoryCollectionV1 getJSONCategories(final String expand) { return getJSONResources(RESTCategoryCollectionV1.class, Category.class, categoryFactory, RESTv1Constants.CATEGORIES_EXPANSION_NAME, expand); } @Override public RESTCategoryV1 getJSONCategory(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(Category.class, categoryFactory, id, expand); } @Override public RESTCategoryV1 getJSONCategoryRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(Category.class, categoryFactory, id, revision, expand); } @Override public RESTCategoryCollectionV1 getJSONCategoriesWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTCategoryCollectionV1.class, query.getMatrixParameters(), CategoryFilterQueryBuilder.class, new CategoryFieldFilter(), categoryFactory, RESTv1Constants.CATEGORIES_EXPANSION_NAME, expand); } @Override public RESTCategoryV1 updateJSONCategory(final String expand, final RESTCategoryV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(Category.class, dataObject, categoryFactory, expand, logDetails); } @Override public RESTCategoryCollectionV1 updateJSONCategories(final String expand, final RESTCategoryCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTCategoryCollectionV1.class, Category.class, dataObjects, categoryFactory, RESTv1Constants.CATEGORIES_EXPANSION_NAME, expand, logDetails); } @Override public RESTCategoryV1 createJSONCategory(final String expand, final RESTCategoryV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(Category.class, dataObject, categoryFactory, expand, logDetails); } @Override public RESTCategoryCollectionV1 createJSONCategories(final String expand, final RESTCategoryCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTCategoryCollectionV1.class, Category.class, dataObjects, categoryFactory, RESTv1Constants.CATEGORIES_EXPANSION_NAME, expand, logDetails); } @Override public RESTCategoryV1 deleteJSONCategory(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(Category.class, categoryFactory, id, expand, logDetails); } @Override public RESTCategoryCollectionV1 deleteJSONCategories(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The ids parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTCategoryCollectionV1.class, Category.class, categoryFactory, dbEntityIds, RESTv1Constants.CATEGORIES_EXPANSION_NAME, expand, logDetails); } /* IMAGE FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPImage(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONImage(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPImageRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONImageRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPImages(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONImages(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPImagesWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONImagesWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTImageV1 getJSONImage(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(ImageFile.class, imageFactory, id, expand); } @Override public RESTImageV1 getJSONImageRevision(final Integer id, Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(ImageFile.class, imageFactory, id, revision, expand); } @Override public RESTImageCollectionV1 getJSONImages(final String expand) { return getJSONResources(RESTImageCollectionV1.class, ImageFile.class, imageFactory, RESTv1Constants.IMAGES_EXPANSION_NAME, expand); } @Override public RESTImageCollectionV1 getJSONImagesWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTImageCollectionV1.class, query.getMatrixParameters(), ImageFilterQueryBuilder.class, new ImageFieldFilter(), imageFactory, RESTv1Constants.IMAGES_EXPANSION_NAME, expand); } @Override public RESTImageV1 updateJSONImage(final String expand, final RESTImageV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(ImageFile.class, dataObject, imageFactory, expand, logDetails); } @Override public RESTImageCollectionV1 updateJSONImages(final String expand, final RESTImageCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTImageCollectionV1.class, ImageFile.class, dataObjects, imageFactory, RESTv1Constants.IMAGES_EXPANSION_NAME, expand, logDetails); } @Override public RESTImageV1 createJSONImage(final String expand, final RESTImageV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(ImageFile.class, dataObject, imageFactory, expand, logDetails); } @Override public RESTImageCollectionV1 createJSONImages(final String expand, final RESTImageCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTImageCollectionV1.class, ImageFile.class, dataObjects, imageFactory, RESTv1Constants.IMAGES_EXPANSION_NAME, expand, logDetails); } @Override public RESTImageV1 deleteJSONImage(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(ImageFile.class, imageFactory, id, expand, logDetails); } @Override public RESTImageCollectionV1 deleteJSONImages(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The ids parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTImageCollectionV1.class, ImageFile.class, imageFactory, dbEntityIds, RESTv1Constants.IMAGES_EXPANSION_NAME, expand, logDetails); } /* RAW FUNCTIONS */ @Override public Response getRAWImage(final Integer id, final String locale) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final ImageFile entity = getEntity(ImageFile.class, id); final String fixedLocale = locale == null ? CommonConstants.DEFAULT_LOCALE : locale; /* Try and find the locale specified first */ for (final LanguageImage languageImage : entity.getLanguageImages()) { if (fixedLocale.equalsIgnoreCase(languageImage.getLocale())) { return Response.ok(languageImage.getImageData(), languageImage.getMimeType()).build(); } } /* If the specified locale can't be found then use the default */ for (final LanguageImage languageImage : entity.getLanguageImages()) { if (CommonConstants.DEFAULT_LOCALE.equalsIgnoreCase(languageImage.getLocale())) { return Response.ok(languageImage.getImageData(), languageImage.getMimeType()).build(); } } throw new BadRequestException("No image exists for the " + fixedLocale + " locale."); } @Override public Response getRAWImageRevision(final Integer id, final Integer revision, final String locale) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); final ImageFile entity = getEntity(ImageFile.class, id, revision); final String fixedLocale = locale == null ? CommonConstants.DEFAULT_LOCALE : locale; /* Try and find the locale specified first */ for (final LanguageImage languageImage : entity.getLanguageImages()) { if (fixedLocale.equalsIgnoreCase(languageImage.getLocale())) { return Response.ok(languageImage.getImageData(), languageImage.getMimeType()).build(); } } /* If the specified locale can't be found then use the default */ for (final LanguageImage languageImage : entity.getLanguageImages()) { if (CommonConstants.DEFAULT_LOCALE.equalsIgnoreCase(languageImage.getLocale())) { return Response.ok(languageImage.getImageData(), languageImage.getMimeType()).build(); } } throw new BadRequestException("No image exists for the " + fixedLocale + " locale."); } @Override public Response getRAWImageThumbnail(final Integer id, final String locale) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final ImageFile entity = getEntity(ImageFile.class, id); final String fixedLocale = locale == null ? CommonConstants.DEFAULT_LOCALE : locale; try { LanguageImage foundLanguageImage = null; // Try and find the locale specified first for (final LanguageImage languageImage : entity.getLanguageImages()) { if (fixedLocale.equalsIgnoreCase(languageImage.getLocale())) { foundLanguageImage = languageImage; break; } } if (foundLanguageImage == null) { // If the specified locale can't be found then use the default */ for (final LanguageImage languageImage : entity.getLanguageImages()) { if (CommonConstants.DEFAULT_LOCALE.equalsIgnoreCase(languageImage.getLocale())) { foundLanguageImage = languageImage; break; } } } if (foundLanguageImage != null) { byte[] base64Thumbnail = foundLanguageImage.getThumbnailData(); final String mimeType = foundLanguageImage.getMimeType(); if (mimeType.equals("image/svg+xml")) { return Response.ok(Base64.decode(base64Thumbnail), "image/jpg").build(); } else { return Response.ok(Base64.decode(base64Thumbnail), mimeType).build(); } } else { throw new BadRequestException("No image exists for the " + fixedLocale + " locale."); } } catch (IOException e) { throw new InternalServerErrorException(e); } } /* TOPIC FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPTopicsWithQuery(PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTopicsWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTopics(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTopics(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTopic(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTopic(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTopicRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTopicRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTTopicCollectionV1 getJSONTopics(final String expand) { return getJSONResources(RESTTopicCollectionV1.class, Topic.class, topicFactory, RESTv1Constants.TOPICS_EXPANSION_NAME, expand); } @Override public RESTTopicCollectionV1 getJSONTopicsWithQuery(PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTTopicCollectionV1.class, query.getMatrixParameters(), TopicFilterQueryBuilder.class, new TopicFieldFilter(), topicFactory, RESTv1Constants.TOPICS_EXPANSION_NAME, expand); } @Override public Feed getATOMTopicsWithQuery(PathSegment query, final String expand) { final RESTTopicCollectionV1 topics = getJSONTopicsWithQuery(query, expand); return convertTopicsIntoFeed(topics, "Topic Query (" + topics.getSize() + " items)"); } @Override public RESTTopicV1 getJSONTopic(final Integer id, final String expand) { assert id != null : "The id parameter can not be null"; return getJSONResource(Topic.class, topicFactory, id, expand); } @Override public RESTTopicV1 getJSONTopicRevision(final Integer id, final Integer revision, final String expand) { assert id != null : "The id parameter can not be null"; assert revision != null : "The revision parameter can not be null"; return getJSONResource(Topic.class, topicFactory, id, revision, expand); } @Override public RESTTopicV1 updateJSONTopic(final String expand, final RESTTopicV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(Topic.class, dataObject, topicFactory, expand, logDetails); } @Override public RESTTopicCollectionV1 updateJSONTopics(final String expand, final RESTTopicCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTTopicCollectionV1.class, Topic.class, dataObjects, topicFactory, RESTv1Constants.TOPICS_EXPANSION_NAME, expand, logDetails); } @Override public RESTTopicV1 createJSONTopic(final String expand, final RESTTopicV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(Topic.class, dataObject, topicFactory, expand, logDetails); } @Override public RESTTopicCollectionV1 createJSONTopics(final String expand, final RESTTopicCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTTopicCollectionV1.class, Topic.class, dataObjects, topicFactory, RESTv1Constants.TOPICS_EXPANSION_NAME, expand, logDetails); } @Override public RESTTopicV1 deleteJSONTopic(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(Topic.class, topicFactory, id, expand, logDetails); } @Override public RESTTopicCollectionV1 deleteJSONTopics(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The ids parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTTopicCollectionV1.class, Topic.class, topicFactory, dbEntityIds, RESTv1Constants.TOPICS_EXPANSION_NAME, expand, logDetails); } // XML TOPIC FUNCTIONS @Override public RESTTopicCollectionV1 getXMLTopics(final String expand) { return getXMLResources(RESTTopicCollectionV1.class, Topic.class, topicFactory, RESTv1Constants.TOPICS_EXPANSION_NAME, expand); } @Override public RESTTopicV1 getXMLTopic(final Integer id) { assert id != null : "The id parameter can not be null"; return getXMLResource(Topic.class, topicFactory, id, null); } @Override public RESTTopicV1 getXMLTopicRevision(final Integer id, final Integer revision) { assert id != null : "The id parameter can not be null"; return getXMLResource(Topic.class, topicFactory, id, revision, null); } @Override public String getXMLTopicXML(final Integer id) { assert id != null : "The id parameter can not be null"; final RESTTopicV1 entity = getXMLResource(Topic.class, topicFactory, id, null); if (entity.getXmlDoctype() != null) { if (entity.getXmlDoctype() == RESTXMLDoctype.DOCBOOK_45) { return DocBookUtilities.addDocbook45XMLDoctype(entity.getXml(), null, "section"); } else if (entity.getXmlDoctype() == RESTXMLDoctype.DOCBOOK_50) { return DocBookUtilities.addDocbook50XMLDoctype(entity.getXml(), null, "section"); } } return entity.getXml(); } @Override public String updateXMLTopicXML(Integer id, String xml, String message, Integer flag, String userId) { if (xml == null) throw new BadRequestException("The xml parameter can not be null"); if (id == null) throw new BadRequestException("The id parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); // Create the topic data object that will be saved final RESTTopicV1 topic = new RESTTopicV1(); topic.setId(id); topic.explicitSetXml(xml); RESTTopicV1 updatedTopic = updateJSONEntity(Topic.class, topic, topicFactory, "", logDetails); return updatedTopic == null ? null : updatedTopic.getXml(); } @Override public String getXMLTopicRevisionXML(final Integer id, final Integer revision) { assert id != null : "The id parameter can not be null"; assert revision != null : "The revision parameter can not be null"; final RESTTopicV1 entity = getXMLResource(Topic.class, topicFactory, id, revision, null); if (entity.getXmlDoctype() != null) { if (entity.getXmlDoctype() == RESTXMLDoctype.DOCBOOK_45) { return DocBookUtilities.addDocbook45XMLDoctype(entity.getXml(), null, "section"); } else if (entity.getXmlDoctype() == RESTXMLDoctype.DOCBOOK_50) { return DocBookUtilities.addDocbook50XMLDoctype(entity.getXml(), null, "section"); } } return entity.getXml(); } @Override public String getXMLTopicXMLContained(final Integer id, final String containerName) { assert id != null : "The id parameter can not be null"; assert containerName != null : "The containerName parameter can not be null"; return ComponentTopicV1.returnXMLWithNewContainer(getXMLResource(Topic.class, topicFactory, id, null), containerName); } @Override public String getXMLTopicXMLNoContainer(final Integer id, final Boolean includeTitle) { assert id != null : "The id parameter can not be null"; final String retValue = ComponentTopicV1.returnXMLWithNoContainer(getXMLResource(Topic.class, topicFactory, id, null), includeTitle); return retValue; } // CSV TOPIC FUNCTIONS @Override public String getCSVTopics() { final List<Topic> topicList = getAllEntities(Topic.class); response.getOutputHeaders().putSingle("Content-Disposition", "filename=Topics.csv"); return TopicUtilities.getCSVForTopics(entityManager, topicList); } @Override public String getCSVTopicsWithQuery(@PathParam("query") PathSegment query) { final CriteriaQuery<Topic> criteriaQuery = getEntitiesFromQuery(query.getMatrixParameters(), new TopicFilterQueryBuilder(entityManager), new TopicFieldFilter()); final List<Topic> topicList = entityManager.createQuery(criteriaQuery).getResultList(); response.getOutputHeaders().putSingle("Content-Disposition", "filename=Topics.csv"); return TopicUtilities.getCSVForTopics(entityManager, topicList); } // ZIP TOPIC FUNCTIONS @Override public byte[] getZIPTopics() { final List<Topic> topicList = getAllEntities(Topic.class); response.getOutputHeaders().putSingle("Content-Disposition", "filename=XML.zip"); return TopicUtilities.getZIPTopicXMLDump(topicList); } @Override public byte[] getZIPTopicsWithQuery(PathSegment query) { final CriteriaQuery<Topic> criteriaQuery = getEntitiesFromQuery(query.getMatrixParameters(), new TopicFilterQueryBuilder(entityManager), new TopicFieldFilter()); final List<Topic> topicList = entityManager.createQuery(criteriaQuery).getResultList(); response.getOutputHeaders().putSingle("Content-Disposition", "filename=XML.zip"); return TopicUtilities.getZIPTopicXMLDump(topicList); } /* FILTERS FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPFilter(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONFilter(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPFilterRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONFilterRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPFilters(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONFilters(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPFiltersWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONFiltersWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTFilterV1 getJSONFilter(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(Filter.class, filterFactory, id, expand); } @Override public RESTFilterV1 getJSONFilterRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(Filter.class, filterFactory, id, revision, expand); } @Override public RESTFilterCollectionV1 getJSONFilters(final String expand) { return getJSONResources(RESTFilterCollectionV1.class, Filter.class, filterFactory, RESTv1Constants.FILTERS_EXPANSION_NAME, expand); } @Override public RESTFilterCollectionV1 getJSONFiltersWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTFilterCollectionV1.class, query.getMatrixParameters(), FilterFilterQueryBuilder.class, new FilterFieldFilter(), filterFactory, RESTv1Constants.FILTERS_EXPANSION_NAME, expand); } @Override public RESTFilterV1 updateJSONFilter(final String expand, final RESTFilterV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(Filter.class, dataObject, filterFactory, expand, logDetails); } @Override public RESTFilterCollectionV1 updateJSONFilters(final String expand, final RESTFilterCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTFilterCollectionV1.class, Filter.class, dataObjects, filterFactory, RESTv1Constants.FILTERS_EXPANSION_NAME, expand, logDetails); } @Override public RESTFilterV1 createJSONFilter(final String expand, final RESTFilterV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(Filter.class, dataObject, filterFactory, expand, logDetails); } @Override public RESTFilterCollectionV1 createJSONFilters(final String expand, final RESTFilterCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTFilterCollectionV1.class, Filter.class, dataObjects, filterFactory, RESTv1Constants.FILTERS_EXPANSION_NAME, expand, logDetails); } @Override public RESTFilterV1 deleteJSONFilter(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(Filter.class, filterFactory, id, expand, logDetails); } @Override public RESTFilterCollectionV1 deleteJSONFilters(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The ids parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTFilterCollectionV1.class, Filter.class, filterFactory, dbEntityIds, RESTv1Constants.FILTERS_EXPANSION_NAME, expand, logDetails); } /* INTEGERCONSTANT FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPIntegerConstant(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONIntegerConstant(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPIntegerConstantRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONIntegerConstantRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPIntegerConstants(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONIntegerConstants(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPIntegerConstantsWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONIntegerConstantsWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTIntegerConstantV1 getJSONIntegerConstant(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(IntegerConstants.class, integerConstantFactory, id, expand); } @Override public RESTIntegerConstantV1 getJSONIntegerConstantRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(IntegerConstants.class, integerConstantFactory, id, revision, expand); } @Override public RESTIntegerConstantCollectionV1 getJSONIntegerConstants(final String expand) { return getJSONResources(RESTIntegerConstantCollectionV1.class, IntegerConstants.class, integerConstantFactory, RESTv1Constants.INTEGERCONSTANTS_EXPANSION_NAME, expand); } @Override public RESTIntegerConstantCollectionV1 getJSONIntegerConstantsWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTIntegerConstantCollectionV1.class, query.getMatrixParameters(), IntegerConstantFilterQueryBuilder.class, new IntegerConstantFieldFilter(), integerConstantFactory, RESTv1Constants.INTEGERCONSTANTS_EXPANSION_NAME, expand); } @Override public RESTIntegerConstantV1 updateJSONIntegerConstant(final String expand, final RESTIntegerConstantV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(IntegerConstants.class, dataObject, integerConstantFactory, expand, logDetails); } @Override public RESTIntegerConstantCollectionV1 updateJSONIntegerConstants(final String expand, final RESTIntegerConstantCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTIntegerConstantCollectionV1.class, IntegerConstants.class, dataObjects, integerConstantFactory, RESTv1Constants.INTEGERCONSTANTS_EXPANSION_NAME, expand, logDetails); } @Override public RESTIntegerConstantV1 createJSONIntegerConstant(final String expand, final RESTIntegerConstantV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(IntegerConstants.class, dataObject, integerConstantFactory, expand, logDetails); } @Override public RESTIntegerConstantCollectionV1 createJSONIntegerConstants(final String expand, final RESTIntegerConstantCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTIntegerConstantCollectionV1.class, IntegerConstants.class, dataObjects, integerConstantFactory, RESTv1Constants.INTEGERCONSTANTS_EXPANSION_NAME, expand, logDetails); } @Override public RESTIntegerConstantV1 deleteJSONIntegerConstant(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(IntegerConstants.class, integerConstantFactory, id, expand, logDetails); } @Override public RESTIntegerConstantCollectionV1 deleteJSONIntegerConstants(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The ids parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTIntegerConstantCollectionV1.class, IntegerConstants.class, integerConstantFactory, dbEntityIds, RESTv1Constants.INTEGERCONSTANTS_EXPANSION_NAME, expand, logDetails); } /* CONTENT SPEC FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPContentSpec(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONContentSpec(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPContentSpecRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONContentSpecRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPContentSpecs(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONContentSpecs(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPContentSpecsWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONContentSpecsWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTContentSpecV1 getJSONContentSpec(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(ContentSpec.class, contentSpecFactory, id, expand); } @Override public RESTContentSpecV1 getJSONContentSpecRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(ContentSpec.class, contentSpecFactory, id, revision, expand); } @Override public RESTContentSpecCollectionV1 getJSONContentSpecs(final String expand) { return getJSONResources(RESTContentSpecCollectionV1.class, ContentSpec.class, contentSpecFactory, RESTv1Constants.CONTENT_SPEC_EXPANSION_NAME, expand); } @Override public RESTContentSpecCollectionV1 getJSONContentSpecsWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTContentSpecCollectionV1.class, query.getMatrixParameters(), ContentSpecFilterQueryBuilder.class, new ContentSpecFieldFilter(), contentSpecFactory, RESTv1Constants.CONTENT_SPEC_EXPANSION_NAME, expand); } @Override public RESTContentSpecV1 updateJSONContentSpec(final String expand, final RESTContentSpecV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(ContentSpec.class, dataObject, contentSpecFactory, expand, logDetails); } @Override public RESTContentSpecCollectionV1 updateJSONContentSpecs(final String expand, final RESTContentSpecCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTContentSpecCollectionV1.class, ContentSpec.class, dataObjects, contentSpecFactory, RESTv1Constants.CONTENT_SPEC_EXPANSION_NAME, expand, logDetails); } @Override public RESTContentSpecV1 createJSONContentSpec(final String expand, final RESTContentSpecV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(ContentSpec.class, dataObject, contentSpecFactory, expand, logDetails); } @Override public RESTContentSpecCollectionV1 createJSONContentSpecs(final String expand, final RESTContentSpecCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTContentSpecCollectionV1.class, ContentSpec.class, dataObjects, contentSpecFactory, RESTv1Constants.CONTENT_SPEC_EXPANSION_NAME, expand, logDetails); } @Override public RESTContentSpecV1 deleteJSONContentSpec(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(ContentSpec.class, contentSpecFactory, id, expand, logDetails); } @Override public RESTContentSpecCollectionV1 deleteJSONContentSpecs(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The dataObjects parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTContentSpecCollectionV1.class, ContentSpec.class, contentSpecFactory, dbEntityIds, RESTv1Constants.CONTENT_SPEC_EXPANSION_NAME, expand, logDetails); } /* ADDITIONAL CONTENT SPEC FUNCTIONS */ @Override public String getTEXTContentSpec(final Integer id) { if (id == null) throw new BadRequestException("The id parameter can not be null"); try { return ContentSpecUtilities.getContentSpecText(id, entityManager); } catch (Throwable e) { throw processError(null, e); } } @Override public String getTEXTContentSpecRevision(final Integer id, final Integer revision) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); try { return ContentSpecUtilities.getContentSpecText(id, revision, entityManager); } catch (Throwable e) { throw processError(null, e); } } @Override public String updateTEXTContentSpec(final Integer id, final String contentSpec, final Boolean strictTitles, final String message, final Integer flag, final String userId) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (contentSpec == null) throw new BadRequestException("The contentSpec parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateTEXTContentSpecFromString(id, contentSpec, strictTitles, logDetails); } @Override public String createTEXTContentSpec(final String contentSpec, final Boolean strictTitles, final String message, final Integer flag, final String userId) { if (contentSpec == null) throw new BadRequestException("The contentSpec parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createTEXTContentSpecFromString(contentSpec, strictTitles, logDetails); } @Override public RESTTextContentSpecV1 getJSONTextContentSpec(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(ContentSpec.class, textContentSpecFactory, id, expand); } @Override public RESTTextContentSpecV1 getJSONTextContentSpecRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(ContentSpec.class, textContentSpecFactory, id, revision, expand); } @Override public RESTTextContentSpecCollectionV1 getJSONTextContentSpecs(final String expand) { return getJSONResources(RESTTextContentSpecCollectionV1.class, ContentSpec.class, textContentSpecFactory, RESTv1Constants.CONTENT_SPEC_EXPANSION_NAME, expand); } @Override public RESTTextContentSpecCollectionV1 getJSONTextContentSpecsWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTTextContentSpecCollectionV1.class, query.getMatrixParameters(), ContentSpecFilterQueryBuilder.class, new ContentSpecFieldFilter(), textContentSpecFactory, RESTv1Constants.CONTENT_SPEC_EXPANSION_NAME, expand); } @Override public RESTTextContentSpecV1 updateJSONTextContentSpec(final String expand, final RESTTextContentSpecV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONContentSpecFromString(dataObject, logDetails, expand); } @Override public RESTTextContentSpecV1 createJSONTextContentSpec(final String expand, final RESTTextContentSpecV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONContentSpecFromString(dataObject, logDetails, expand); } @Override public byte[] getZIPContentSpecs() { final PathSegment pathSegment = new PathSegmentImpl("query;", false); return getZIPContentSpecsWithQuery(pathSegment); } @Override public byte[] getZIPContentSpecsWithQuery(final PathSegment query) { response.getOutputHeaders().putSingle("Content-Disposition", "filename=ContentSpecs.zip"); final CriteriaQuery<ContentSpec> contentSpecQuery = getEntitiesFromQuery(query.getMatrixParameters(), new ContentSpecFilterQueryBuilder(entityManager), new ContentSpecFieldFilter()); final List<ContentSpec> contentSpecs = entityManager.createQuery(contentSpecQuery).getResultList(); final HashMap<String, byte[]> files = new HashMap<String, byte[]>(); try { for (final ContentSpec entity : contentSpecs) { final String contentSpec = ContentSpecUtilities.getContentSpecText(entity.getId(), null, entityManager); files.put(entity.getId() + ".contentspec", contentSpec.getBytes("UTF-8")); } return ZipUtilities.createZip(files); } catch (Throwable e) { throw processError(null, e); } } /* CONTENT SPEC NODE FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPContentSpecNode(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONContentSpecNode(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPContentSpecNodeRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONContentSpecNodeRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPContentSpecNodes(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONContentSpecNodes(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPContentSpecNodesWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONContentSpecNodesWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTCSNodeV1 getJSONContentSpecNode(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(CSNode.class, csNodeFactory, id, expand); } @Override public RESTCSNodeV1 getJSONContentSpecNodeRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(CSNode.class, csNodeFactory, id, revision, expand); } @Override public RESTCSNodeCollectionV1 getJSONContentSpecNodes(final String expand) { return getJSONResources(RESTCSNodeCollectionV1.class, CSNode.class, csNodeFactory, RESTv1Constants.CONTENT_SPEC_NODE_EXPANSION_NAME, expand); } @Override public RESTCSNodeCollectionV1 getJSONContentSpecNodesWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTCSNodeCollectionV1.class, query.getMatrixParameters(), ContentSpecNodeFilterQueryBuilder.class, new ContentSpecNodeFieldFilter(), csNodeFactory, RESTv1Constants.CONTENT_SPEC_NODE_EXPANSION_NAME, expand); } // @Override // public RESTCSNodeV1 updateJSONContentSpecNode(final String expand, final RESTCSNodeV1 dataObject, final String message, // final Integer flag, final String userId) { // if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); // if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); // // final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); // return updateJSONEntity(CSNode.class, dataObject, csNodeFactory, expand, logDetails); // } // // @Override // public RESTCSNodeCollectionV1 updateJSONContentSpecNodes(final String expand, final RESTCSNodeCollectionV1 dataObjects, // final String message, final Integer flag, final String userId) { // if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); // if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); // // final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); // return updateJSONEntities(RESTCSNodeCollectionV1.class, CSNode.class, dataObjects, csNodeFactory, // RESTv1Constants.CONTENT_SPEC_NODE_EXPANSION_NAME, expand, logDetails); // } // // @Override // public RESTCSNodeV1 createJSONContentSpecNode(final String expand, final RESTCSNodeV1 dataObject, final String message, // final Integer flag, final String userId) { // if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); // // final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); // return createJSONEntity(CSNode.class, dataObject, csNodeFactory, expand, logDetails); // } // // @Override // public RESTCSNodeCollectionV1 createJSONContentSpecNodes(final String expand, final RESTCSNodeCollectionV1 dataObjects, // final String message, final Integer flag, final String userId) { // if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); // if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); // // final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); // return createJSONEntities(RESTCSNodeCollectionV1.class, CSNode.class, dataObjects, csNodeFactory, // RESTv1Constants.CONTENT_SPEC_NODE_EXPANSION_NAME, expand, logDetails); // } // // @Override // public RESTCSNodeV1 deleteJSONContentSpecNode(final Integer id, final String message, final Integer flag, final String userId, // final String expand) { // if (id == null) throw new BadRequestException("The dataObject parameter can not be null"); // // final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); // return deleteJSONEntity(CSNode.class, csNodeFactory, id, expand, logDetails); // } // // @Override // public RESTCSNodeCollectionV1 deleteJSONContentSpecNodes(final PathSegment ids, final String message, final Integer flag, // final String userId, final String expand) { // if (ids == null) throw new BadRequestException("The dataObjects parameter can not be null"); // // final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); // final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); // return deleteJSONEntities(RESTCSNodeCollectionV1.class, CSNode.class, csNodeFactory, dbEntityIds, // RESTv1Constants.CONTENT_SPEC_NODE_EXPANSION_NAME, expand, logDetails); // } /* TRANSLATED CONTENT SPEC FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPTranslatedContentSpec(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedContentSpec(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTranslatedContentSpecRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedContentSpecRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTranslatedContentSpecs(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedContentSpecs(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTranslatedContentSpecsWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedContentSpecsWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTTranslatedContentSpecV1 getJSONTranslatedContentSpec(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(TranslatedContentSpec.class, translatedContentSpecFactory, id, expand); } @Override public RESTTranslatedContentSpecV1 getJSONTranslatedContentSpecRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(TranslatedContentSpec.class, translatedContentSpecFactory, id, revision, expand); } @Override public RESTTranslatedContentSpecCollectionV1 getJSONTranslatedContentSpecs(final String expand) { return getJSONResources(RESTTranslatedContentSpecCollectionV1.class, TranslatedContentSpec.class, translatedContentSpecFactory, RESTv1Constants.TRANSLATED_CONTENT_SPEC_EXPANSION_NAME, expand); } @Override public RESTTranslatedContentSpecCollectionV1 getJSONTranslatedContentSpecsWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTTranslatedContentSpecCollectionV1.class, query.getMatrixParameters(), TranslatedContentSpecFilterQueryBuilder.class, new TranslatedContentSpecFieldFilter(), translatedContentSpecFactory, RESTv1Constants.TRANSLATED_CONTENT_SPEC_EXPANSION_NAME, expand); } @Override public RESTTranslatedContentSpecV1 updateJSONTranslatedContentSpec(final String expand, final RESTTranslatedContentSpecV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(TranslatedContentSpec.class, dataObject, translatedContentSpecFactory, expand, logDetails); } @Override public RESTTranslatedContentSpecCollectionV1 updateJSONTranslatedContentSpecs(final String expand, final RESTTranslatedContentSpecCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTTranslatedContentSpecCollectionV1.class, TranslatedContentSpec.class, dataObjects, translatedContentSpecFactory, RESTv1Constants.TRANSLATED_CONTENT_SPEC_EXPANSION_NAME, expand, logDetails); } @Override public RESTTranslatedContentSpecV1 createJSONTranslatedContentSpec(final String expand, final RESTTranslatedContentSpecV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(TranslatedContentSpec.class, dataObject, translatedContentSpecFactory, expand, logDetails); } @Override public RESTTranslatedContentSpecCollectionV1 createJSONTranslatedContentSpecs(final String expand, final RESTTranslatedContentSpecCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTTranslatedContentSpecCollectionV1.class, TranslatedContentSpec.class, dataObjects, translatedContentSpecFactory, RESTv1Constants.TRANSLATED_CONTENT_SPEC_EXPANSION_NAME, expand, logDetails); } @Override public RESTTranslatedContentSpecV1 deleteJSONTranslatedContentSpec(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(TranslatedContentSpec.class, translatedContentSpecFactory, id, expand, logDetails); } @Override public RESTTranslatedContentSpecCollectionV1 deleteJSONTranslatedContentSpecs(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The dataObjects parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTTranslatedContentSpecCollectionV1.class, TranslatedContentSpec.class, translatedContentSpecFactory, dbEntityIds, RESTv1Constants.TRANSLATED_CONTENT_SPEC_EXPANSION_NAME, expand, logDetails); } /* TRANSLATED CONTENT SPEC NODE FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPTranslatedContentSpecNode(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedContentSpecNode(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTranslatedContentSpecNodeRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedContentSpecNodeRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTranslatedContentSpecNodes(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedContentSpecNodes(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPTranslatedContentSpecNodesWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONTranslatedContentSpecNodesWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTTranslatedCSNodeV1 getJSONTranslatedContentSpecNode(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(TranslatedCSNode.class, translatedCSNodeFactory, id, expand); } @Override public RESTTranslatedCSNodeV1 getJSONTranslatedContentSpecNodeRevision(final Integer id, final Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(TranslatedCSNode.class, translatedCSNodeFactory, id, revision, expand); } @Override public RESTTranslatedCSNodeCollectionV1 getJSONTranslatedContentSpecNodes(final String expand) { return getJSONResources(RESTTranslatedCSNodeCollectionV1.class, TranslatedCSNode.class, translatedCSNodeFactory, RESTv1Constants.CONTENT_SPEC_TRANSLATED_NODE_EXPANSION_NAME, expand); } @Override public RESTTranslatedCSNodeCollectionV1 getJSONTranslatedContentSpecNodesWithQuery(final PathSegment query, final String expand) { return getJSONResourcesFromQuery(RESTTranslatedCSNodeCollectionV1.class, query.getMatrixParameters(), TranslatedContentSpecNodeFilterQueryBuilder.class, new TranslatedContentSpecNodeFieldFilter(), translatedCSNodeFactory, RESTv1Constants.CONTENT_SPEC_TRANSLATED_NODE_EXPANSION_NAME, expand); } @Override public RESTTranslatedCSNodeV1 updateJSONTranslatedContentSpecNode(final String expand, final RESTTranslatedCSNodeV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(TranslatedCSNode.class, dataObject, translatedCSNodeFactory, expand, logDetails); } @Override public RESTTranslatedCSNodeCollectionV1 updateJSONTranslatedContentSpecNodes(final String expand, final RESTTranslatedCSNodeCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTTranslatedCSNodeCollectionV1.class, TranslatedCSNode.class, dataObjects, translatedCSNodeFactory, RESTv1Constants.CONTENT_SPEC_TRANSLATED_NODE_EXPANSION_NAME, expand, logDetails); } @Override public RESTTranslatedCSNodeV1 createJSONTranslatedContentSpecNode(final String expand, final RESTTranslatedCSNodeV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(TranslatedCSNode.class, dataObject, translatedCSNodeFactory, expand, logDetails); } @Override public RESTTranslatedCSNodeCollectionV1 createJSONTranslatedContentSpecNodes(final String expand, final RESTTranslatedCSNodeCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTTranslatedCSNodeCollectionV1.class, TranslatedCSNode.class, dataObjects, translatedCSNodeFactory, RESTv1Constants.CONTENT_SPEC_TRANSLATED_NODE_EXPANSION_NAME, expand, logDetails); } @Override public RESTTranslatedCSNodeV1 deleteJSONTranslatedContentSpecNode(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(TranslatedCSNode.class, translatedCSNodeFactory, id, expand, logDetails); } @Override public RESTTranslatedCSNodeCollectionV1 deleteJSONTranslatedContentSpecNodes(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The dataObjects parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTTranslatedCSNodeCollectionV1.class, TranslatedCSNode.class, translatedCSNodeFactory, dbEntityIds, RESTv1Constants.CONTENT_SPEC_TRANSLATED_NODE_EXPANSION_NAME, expand, logDetails); } /* FILE FUNCTIONS */ /* JSONP FUNCTIONS */ @Override public String getJSONPFile(final Integer id, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONFile(id, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPFileRevision(final Integer id, final Integer revision, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONFileRevision(id, revision, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPFiles(final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONFiles(expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } @Override public String getJSONPFilesWithQuery(final PathSegment query, final String expand, final String callback) { if (callback == null) throw new BadRequestException("The callback parameter can not be null"); try { return wrapJsonInPadding(callback, convertObjectToJSON(getJSONFilesWithQuery(query, expand))); } catch (final Exception ex) { throw new InternalServerErrorException("Could not marshall return value into JSON"); } } /* JSON FUNCTIONS */ @Override public RESTFileV1 getJSONFile(final Integer id, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); return getJSONResource(File.class, fileFactory, id, expand); } @Override public RESTFileV1 getJSONFileRevision(final Integer id, Integer revision, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); return getJSONResource(File.class, fileFactory, id, revision, expand); } @Override public RESTFileCollectionV1 getJSONFiles(final String expand) { return getJSONResources(RESTFileCollectionV1.class, File.class, fileFactory, RESTv1Constants.FILES_EXPANSION_NAME, expand); } @Override public RESTFileCollectionV1 getJSONFilesWithQuery(final PathSegment query, final String expand) { return this.getJSONResourcesFromQuery(RESTFileCollectionV1.class, query.getMatrixParameters(), FileFilterQueryBuilder.class, new FileFieldFilter(), fileFactory, RESTv1Constants.FILES_EXPANSION_NAME, expand); } @Override public RESTFileV1 updateJSONFile(final String expand, final RESTFileV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); if (dataObject.getId() == null) throw new BadRequestException("The dataObject.getId() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntity(File.class, dataObject, fileFactory, expand, logDetails); } @Override public RESTFileCollectionV1 updateJSONFiles(final String expand, final RESTFileCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return updateJSONEntities(RESTFileCollectionV1.class, File.class, dataObjects, fileFactory, RESTv1Constants.FILES_EXPANSION_NAME, expand, logDetails); } @Override public RESTFileV1 createJSONFile(final String expand, final RESTFileV1 dataObject, final String message, final Integer flag, final String userId) { if (dataObject == null) throw new BadRequestException("The dataObject parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntity(File.class, dataObject, fileFactory, expand, logDetails); } @Override public RESTFileCollectionV1 createJSONFiles(final String expand, final RESTFileCollectionV1 dataObjects, final String message, final Integer flag, final String userId) { if (dataObjects == null) throw new BadRequestException("The dataObjects parameter can not be null"); if (dataObjects.getItems() == null) throw new BadRequestException("The dataObjects.getItems() parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return createJSONEntities(RESTFileCollectionV1.class, File.class, dataObjects, fileFactory, RESTv1Constants.FILES_EXPANSION_NAME, expand, logDetails); } @Override public RESTFileV1 deleteJSONFile(final Integer id, final String message, final Integer flag, final String userId, final String expand) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntity(File.class, fileFactory, id, expand, logDetails); } @Override public RESTFileCollectionV1 deleteJSONFiles(final PathSegment ids, final String message, final Integer flag, final String userId, final String expand) { if (ids == null) throw new BadRequestException("The ids parameter can not be null"); final Set<String> dbEntityIds = ids.getMatrixParameters().keySet(); final RESTLogDetailsV1 logDetails = generateLogDetails(message, flag, userId); return deleteJSONEntities(RESTFileCollectionV1.class, File.class, fileFactory, dbEntityIds, RESTv1Constants.FILES_EXPANSION_NAME, expand, logDetails); } @Override public byte[] getRAWFile(@PathParam("id") Integer id, @QueryParam("lang") String locale) { if (id == null) throw new BadRequestException("The id parameter can not be null"); final File entity = getEntity(File.class, id); final String fixedLocale = locale == null ? CommonConstants.DEFAULT_LOCALE : locale; /* Try and find the locale specified first */ for (final LanguageFile languageFile : entity.getLanguageFiles()) { if (fixedLocale.equalsIgnoreCase(languageFile.getLocale())) { response.getOutputHeaders().putSingle("Content-Disposition", "filename=" + entity.getFileName()); return languageFile.getFileData(); } } /* If the specified locale can't be found then use the default */ for (final LanguageFile languageFile : entity.getLanguageFiles()) { if (CommonConstants.DEFAULT_LOCALE.equalsIgnoreCase(languageFile.getLocale())) { response.getOutputHeaders().putSingle("Content-Disposition", "filename=" + entity.getFileName()); return languageFile.getFileData(); } } throw new BadRequestException("No file exists for the " + fixedLocale + " locale."); } @Override public byte[] getRAWFileRevision(@PathParam("id") Integer id, @PathParam("rev") Integer revision, @QueryParam("lang") String locale) { if (id == null) throw new BadRequestException("The id parameter can not be null"); if (revision == null) throw new BadRequestException("The revision parameter can not be null"); final File entity = getEntity(File.class, id, revision); final String fixedLocale = locale == null ? CommonConstants.DEFAULT_LOCALE : locale; /* Try and find the locale specified first */ for (final LanguageFile languageFile : entity.getLanguageFiles()) { if (fixedLocale.equalsIgnoreCase(languageFile.getLocale())) { response.getOutputHeaders().putSingle("Content-Disposition", "filename=" + entity.getFileName()); return languageFile.getFileData(); } } /* If the specified locale can't be found then use the default */ for (final LanguageFile languageFile : entity.getLanguageFiles()) { if (CommonConstants.DEFAULT_LOCALE.equalsIgnoreCase(languageFile.getLocale())) { response.getOutputHeaders().putSingle("Content-Disposition", "filename=" + entity.getFileName()); return languageFile.getFileData(); } } throw new BadRequestException("No file exists for the " + fixedLocale + " locale."); } }
a3e6c16a050a797926eb3fe08277149118ec8ff1
e9dbfc1c9ca628ae3f470038182fdf4335094422
/testing/QuickDBTesting/src/main/java/quickdb/complexmodel/Many1.java
cc7468e319aa88857c58521c7d7937c3ef301d4d
[]
no_license
diegosarmentero/quickdb
8ae6706daf4f40b0ad3be936aa8b949f385c5b14
e98999d7e01cfcd7ff94c6db69da4f1b0c253ff0
refs/heads/master
2021-01-01T17:28:06.498663
2012-12-10T15:21:52
2012-12-10T15:21:52
null
0
0
null
null
null
null
UTF-8
Java
false
false
926
java
package quickdb.complexmodel; import java.util.ArrayList; public class Many1 { private int id; private String description; private ArrayList<Many2> many2; public Many1(){} /** * @return the id */ public int getId() { return id; } /** * @param id the id to set */ public void setId(int id) { this.id = id; } /** * @return the description */ public String getDescription() { return description; } /** * @param description the description to set */ public void setDescription(String description) { this.description = description; } /** * @return the many2 */ public ArrayList<Many2> getMany2() { return many2; } /** * @param many2 the many2 to set */ public void setMany2(ArrayList<Many2> many2) { this.many2 = many2; } }
232253027d108a491b96a1ae05dfefdea3147fa5
3182dd5e2cb4c93c562293816203038d5e4c9708
/src/java/com/github/fge/jsonschema/library/digest/DraftV3DigesterDictionary.java
47a9750dc31aaddd4ce020b8366d1b1f7cdc9440
[]
no_license
mrauer/TAC-Verif
46f1fdc06475fef6d217f48a2ee6a6ffc8ec3e4f
5231854f94008729fb1be67992ffafd2ae8908a3
refs/heads/master
2023-07-16T22:25:33.181442
2021-08-29T16:00:37
2021-08-29T16:00:37
401,082,799
3
0
null
null
null
null
UTF-8
Java
false
false
2,408
java
/* * Decompiled with CFR 0.0. * * Could not load the following classes: * com.github.fge.jsonschema.core.util.Dictionary * com.github.fge.jsonschema.core.util.DictionaryBuilder * com.github.fge.jsonschema.keyword.digest.draftv3.DivisibleByDigester * com.github.fge.jsonschema.keyword.digest.draftv3.DraftV3DependenciesDigester * com.github.fge.jsonschema.keyword.digest.draftv3.DraftV3PropertiesDigester * com.github.fge.jsonschema.keyword.digest.helpers.DraftV3TypeKeywordDigester * com.github.fge.jsonschema.keyword.digest.helpers.NullDigester * java.lang.Object * java.lang.String */ package com.github.fge.jsonschema.library.digest; import com.github.fge.jackson.NodeType; import com.github.fge.jsonschema.core.util.Dictionary; import com.github.fge.jsonschema.core.util.DictionaryBuilder; import com.github.fge.jsonschema.keyword.digest.Digester; import com.github.fge.jsonschema.keyword.digest.draftv3.DivisibleByDigester; import com.github.fge.jsonschema.keyword.digest.draftv3.DraftV3DependenciesDigester; import com.github.fge.jsonschema.keyword.digest.draftv3.DraftV3PropertiesDigester; import com.github.fge.jsonschema.keyword.digest.helpers.DraftV3TypeKeywordDigester; import com.github.fge.jsonschema.keyword.digest.helpers.NullDigester; import com.github.fge.jsonschema.library.digest.CommonDigesterDictionary; public final class DraftV3DigesterDictionary { private static final Dictionary<Digester> DICTIONARY; public static { DictionaryBuilder dictionaryBuilder = Dictionary.newBuilder(); dictionaryBuilder.addAll(CommonDigesterDictionary.get()); dictionaryBuilder.addEntry("divisibleBy", (Object)DivisibleByDigester.getInstance()); dictionaryBuilder.addEntry("properties", (Object)DraftV3PropertiesDigester.getInstance()); dictionaryBuilder.addEntry("dependencies", (Object)DraftV3DependenciesDigester.getInstance()); dictionaryBuilder.addEntry("type", (Object)new DraftV3TypeKeywordDigester("type")); dictionaryBuilder.addEntry("disallow", (Object)new DraftV3TypeKeywordDigester("disallow")); dictionaryBuilder.addEntry("extends", (Object)new NullDigester("extends", NodeType.ARRAY, NodeType.values())); DICTIONARY = dictionaryBuilder.freeze(); } private DraftV3DigesterDictionary() { } public static Dictionary<Digester> get() { return DICTIONARY; } }
0a3749bf5fb6386ca702041545bd43162d829cd6
cf82684a34e0184603298742d214965628dde7e6
/Pythagorean.java
774519de8a831bb9cb9f33c15897fef8d85cc099
[]
no_license
FelixMayer/PythagoreanTheorem
cfa782b11791f8278b6844a5aa01bd8eeedcfc09
b6dda1ce74a4d3a2e85fcd552499ee9fcfcfa65b
refs/heads/main
2023-05-22T19:09:55.561062
2021-06-10T14:55:27
2021-06-10T14:55:27
375,734,379
0
0
null
null
null
null
UTF-8
Java
false
false
187
java
import java.lang.Math; public class Pythagorean { public double calculateHypotenuse(int legA, int legB){ double c = Math.sqrt(Math.pow(legA, 2) + Math.pow(legB, 2)); return c; } }
599995b043beded51d179e194b928940d7e4e1bc
c58a236c73f13f6a59451248f703456c1913334c
/Step02/src/TypeBoolean.java
172993d93220b961b8962f35a4bd0576aa14cfd2
[]
no_license
NamSangKyu/2111JAVA_Sample
0dfce1333dc6a6e9954394de894ed969629853b9
03993582ddde6b222da10138382f80fc610b92e6
refs/heads/main
2023-08-30T16:29:42.308782
2021-11-17T08:31:20
2021-11-17T08:31:20
426,888,657
0
0
null
null
null
null
UTF-8
Java
false
false
314
java
public class TypeBoolean { /* 참 거짓 * boolean : true/false를 저장하는 변수타입 */ public static void main(String[] args) { boolean b1 = true; boolean b2 = false; boolean b3 = 10 > 5; System.out.println(b1); System.out.println(b2); System.out.println(b3); } }
33ad0eaf928ba8dd942c079c09b80ea1dbc9e8aa
7930fdd0a3138e188a220ac740a6b27008d61030
/16_11_15_BooksHibernateCreateDB/src/tel_ran/books/entities/LiterutureBook.java
946c30fef9809ddc963ba0e764b62222a12d7c4b
[]
no_license
liberman-anton/16_11_16_BooksSpringBoot
f5b3c7f828bd158770fa4746da07879f5cfb0a47
2b68f816c8dcadcae21e251edd0ed5f550291eb6
refs/heads/master
2020-07-01T15:01:37.931843
2016-11-21T07:42:39
2016-11-21T07:42:39
74,337,908
0
0
null
null
null
null
UTF-8
Java
false
false
566
java
package tel_ran.books.entities; import javax.persistence.Entity; @Entity public class LiterutureBook extends Book { String genre; public LiterutureBook(long isbn, String title, float price, int publishYear, int pages, String genre) { super(isbn, title, price, publishYear, pages); this.genre = genre; } public LiterutureBook() { super(); } @Override public String toString() { return "LiterutureBook [genre=" + genre + ", toString()=" + super.toString() + "]"; } public String getGenre() { return genre; } }
2cd78f25ebc138149d3c9372d1b55f29cccdb419
52299060edff05e541a9e22f454e13e892bc7ccb
/zuul/src/main/java/com/api/gateway/security/Constants.java
0512ee0d82e14163e5eba6ed415a9b6795da7fd3
[]
no_license
buddhiprab/gateway
cb6beb81aff5d900b724346b73d2343f6bcc483c
78854ea14113ec9fd6e03584a1a5bc66df9bd756
refs/heads/master
2022-09-25T09:53:53.707598
2020-06-02T19:33:24
2020-06-02T19:33:24
268,108,204
0
0
null
null
null
null
UTF-8
Java
false
false
251
java
package com.api.gateway.security; public class Constants { public static final long ACCESS_TOKEN_VALIDITY_SECONDS = 2*60*60; public static final String TOKEN_PREFIX = "Bearer"; public static final String HEADER_STRING = "Authorization"; }
0b2b2ffd13f5dd19a4f134aac082c16702d97d5e
758805e195c1dcc6101032d11e62b2bfcc86cf17
/src/배열정렬/Example5.java
b601fb10fadfeed00ab8af548f16384862025acb
[]
no_license
jodummy/source
55f5db8ef2da9cf25695f9668fad943572b5d516
bf59ffbc09e1bcb0634d4c0e3a3d828798112912
refs/heads/master
2020-04-07T07:00:34.100662
2019-03-25T01:46:51
2019-03-25T01:46:51
157,151,504
0
0
null
null
null
null
UHC
Java
false
false
414
java
package 배열정렬; import java.util.Arrays; public class Example5 { public static void main(String[] args) { Person[] a = new Person[] { new Person("홍길동", 18), new Person("임꺽정", 22), new Person("전우치", 23) }; Arrays.sort(a, new PersonNameComparator()); System.out.println(Arrays.toString(a)); Arrays.sort(a, new PersonNameComparator()); System.out.println(Arrays.toString(a)); } }
654807cfee134e581c9fb3e32efb0430f63013ad
23dc33453b08b776d3cb2dfa9b4dd99c547a1611
/src/main/java/be/beme/schn/vaadin/narrative/presenter/UpDownPresenter.java
bae0c24ee8d6724bba9375ff58a22e260a0835ff
[]
no_license
domessina/SchN
dd9d6e872d2256f4f72e84b49d4cf35df74c353a
d6286560b66e6bca1497fcf12ee67f45952ce9dc
refs/heads/master
2020-04-16T10:55:51.429165
2017-11-24T16:58:08
2017-11-24T16:58:08
54,420,581
0
0
null
null
null
null
UTF-8
Java
false
false
157
java
package be.beme.schn.vaadin.narrative.presenter; /** * Created by Dotista on 21-04-16. */ public interface UpDownPresenter extends NarrativePresenter { }
265e954b378f9f43bca1e7a3352e58101dca472d
8de26957e6f51ac42608a8574c6da2e6ea52e8ab
/src/library/mangement/controller/AllmemberController.java
94b002a187d5b1fddac355847a725785ef64881f
[]
no_license
Deeveo/LibMG
04b69d58726a1b22da005970c0b170463beafc15
77bce9b40cc27e070bfe52dc2f8f21f9aaf3b655
refs/heads/master
2020-03-21T12:15:29.612471
2018-06-25T04:03:16
2018-06-25T04:03:16
138,541,512
0
0
null
null
null
null
UTF-8
Java
false
false
2,364
java
/* * 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 library.mangement.controller; import java.net.URL; import java.sql.SQLException; import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.MenuItem; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.cell.PropertyValueFactory; import library.mangement.Database.Database; import library.mangement.model.Member; import library.mangement.model.MemberDAO; /** * FXML Controller class * * @author JAVA */ public class AllmemberController implements Initializable { @FXML private TableView<Member> tbView; @FXML private TableColumn<?, ?> id; @FXML private TableColumn<?, ?> name; @FXML private TableColumn<?, ?> address; @FXML private TableColumn<?, ?> mobile; @FXML private MenuItem deleteMenu; MemberDAO memberDAO; /** * Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { memberDAO = new MemberDAO(); ObservableList list = null; try { list = memberDAO.showAllMemebr(); } catch (SQLException ex) { Logger.getLogger(AllmemberController.class.getName()).log(Level.SEVERE, null, ex); } id.setCellValueFactory(new PropertyValueFactory<>("id")); name.setCellValueFactory(new PropertyValueFactory<>("name")); address.setCellValueFactory(new PropertyValueFactory<>("address")); mobile.setCellValueFactory(new PropertyValueFactory<>("mobile")); tbView.getItems().addAll(list); } @FXML private void deleteItem(ActionEvent event) throws SQLException { Member member = tbView.getSelectionModel().getSelectedItem(); tbView.getItems().remove(member); memberDAO.removeMember(member.getId()); } }
[ "JAVA@DESKTOP-GIKRNKT" ]
JAVA@DESKTOP-GIKRNKT
003526ca9973f996dc8f942b565a4519309304b6
6c31b838aee5dfc4598f59057a9538adaaab21d3
/LabServlet6.1/src/ie/dit/naylor/mark/UploadServlet.java
a43f1e9903b99c020ef027d2d18e20935203834b
[ "MIT" ]
permissive
naylor0/CloudComputing
9d2c5cab91c757d4521d6a925af3d1df61da8e8b
7b9a5326320de0da330b23a4d247e0c3a42e88ca
refs/heads/master
2020-12-25T22:28:43.352770
2016-04-23T12:42:28
2016-04-23T12:42:28
24,942,471
0
0
null
null
null
null
UTF-8
Java
false
false
977
java
package ie.dit.naylor.mark; import java.io.IOException; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.*; import com.google.appengine.api.blobstore.BlobKey; import com.google.appengine.api.blobstore.BlobstoreServiceFactory; public class UploadServlet extends HttpServlet { private static final long serialVersionUID = 1L; private com.google.appengine.api.blobstore.BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { @SuppressWarnings("deprecation") Map<String, BlobKey> blobs = blobstoreService.getUploadedBlobs(req); BlobKey blobKey = blobs.get("myFile"); if (blobKey == null) { res.sendRedirect("/"); } else { System.out.println("Uploaded a file with blobKey:" + blobKey.getKeyString()); res.sendRedirect("/serve?blob-key=" + blobKey.getKeyString()); } } }
4371ff4b7a6e3cf665cd29d878f3a731b9e7a8f8
c0dbdbe7f9bc2f3786dd838699bc782f83f6f7d0
/src/main/java/design/structure/decorator/ZClient.java
6ad8da07969351c2ec6761b90c4cb63aa582ab8b
[]
no_license
xuanlvry/selfdev
e7dfafdf09dabc339738e310963a1cbbc88749d9
b73dd16e6fcde748fa9f5d06bc4e01ffc4b1ae60
refs/heads/master
2022-12-23T03:07:57.534812
2021-02-08T03:25:41
2021-02-08T03:25:41
91,475,722
0
0
null
2022-12-16T04:28:18
2017-05-16T15:42:23
Java
UTF-8
Java
false
false
464
java
package design.structure.decorator; /** * @author Chengfei.Sun on 2016/10/19. */ public class ZClient { public static void main(String[] args) { SchoolReport schoolReport = new SchoolReportImpl(); schoolReport.report(); schoolReport = new HighScoreDecorator(schoolReport); schoolReport.report(); schoolReport = new SortDecorator(schoolReport); schoolReport.report(); schoolReport.sign("xx"); } }
ba16cd37018fde7d729f45ad1affd4585585cc68
a6ce26b2ecee33819bbd251664be082dd5d1670e
/hr-user/src/main/java/br/com/pierredev/hruser/entities/User.java
4e0749a2387c5e34db3adfb9c0816bcd13b7d315
[]
no_license
pierreEnoc/microservice-payment
ece8058be484bde18f20a9d81ae51624614a72ac
8c2897958ad62a534949a585070a853057ee4fd2
refs/heads/main
2023-03-30T05:00:04.725492
2021-03-15T21:03:43
2021-03-15T21:03:43
342,335,045
0
0
null
null
null
null
UTF-8
Java
false
false
2,326
java
package br.com.pierredev.hruser.entities; import java.io.Serializable; import java.util.HashSet; import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; @Entity @Table(name = "tb_user") public class User implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; @Column(unique = true) private String email; private String password; @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "tb_user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id") ) private Set<Role> roles = new HashSet<>(); public User() { } public User(Long id, String name, String email, String password) { super(); this.id = id; this.name = name; this.email = email; this.password = password; } 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 String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public Set<Role> getRoles() { return roles; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; User other = (User) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; return true; } @Override public String toString() { return "User [id=" + id + ", name=" + name + ", email=" + email + ", password=" + password + "]"; } }
f5c060b5c9ea05cd8e50462d30b024f1c9c2e4a2
f835721271008e3edd514b0b4c8ef90d4db51a43
/jre2/src/cmm04/array/No03_ForLoopArrayDemo.java
4c69ab554be4b616665cd3c1edb9d914f92783c8
[]
no_license
risfot24/JreooPin
aaf8ab3b4e6a68cc5f6172038a2d471d002e5633
33ac5b433f37f11db2e93f8957a8c5f4f86116fe
refs/heads/master
2016-09-05T17:32:34.699864
2015-05-26T12:52:18
2015-05-26T12:52:18
35,945,531
0
0
null
null
null
null
UHC
Java
false
false
512
java
package cmm04.array; import java.util.Scanner; public class No03_ForLoopArrayDemo { public static void main(String[] args) { No03_ForLoopArrayVO fvo = new No03_ForLoopArrayVO(); fvo.input(); //메인 메소드 에 스캐너 장착!! /* * 입력 받은 다섯개의 숫자의 합을 구하세요. * */ No03_ForLoopArrayVO02 fvo2 = new No03_ForLoopArrayVO02(); Scanner scan = new Scanner(System.in); //int arr[] = new int[5]; fvo2.run(); } }
[ "취업반 PM@itbank-PC" ]
취업반 PM@itbank-PC
537d336801791542c70ff13ca069c1db808c9d7e
df81ee92a1995d381bbf2beb2ae0c025c34f82e6
/library/src/main/java/com/fyfeng/android/tools/compress/utils/ServiceLoaderIterator.java
3d5a2b6e43d7180c247ca5215c8927b3d1ef44fc
[]
no_license
yzw1007/ATools
3ee2fb352d14e5c61b9fb975115bb316e8a4cac9
ea8c7863aab6a9c88548cac5bc71cf26d2320726
refs/heads/master
2021-01-21T20:37:57.113334
2019-10-12T08:36:21
2019-10-12T08:36:21
92,257,384
0
0
null
null
null
null
UTF-8
Java
false
false
2,928
java
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package com.fyfeng.android.tools.compress.utils; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; /** * Iterates all services for a given class through the standard * {@link ServiceLoader} mechanism. * * @param <E> * The service to load * @since 1.13 */ public class ServiceLoaderIterator<E> implements Iterator<E> { private E nextServiceLoader; private final Class<E> service; private final Iterator<E> serviceLoaderIterator; public ServiceLoaderIterator(final Class<E> service) { this(service, ClassLoader.getSystemClassLoader()); } public ServiceLoaderIterator(final Class<E> service, final ClassLoader classLoader) { this.service = service; final ServiceLoader<E> serviceLoader = ServiceLoader.load(service, classLoader); serviceLoaderIterator = serviceLoader.iterator(); nextServiceLoader = null; } private boolean getNextServiceLoader() { while (nextServiceLoader == null) { try { if (!serviceLoaderIterator.hasNext()) { return false; } nextServiceLoader = serviceLoaderIterator.next(); } catch (final ServiceConfigurationError e) { if (e.getCause() instanceof SecurityException) { // Ignore security exceptions // TODO Log? continue; } throw e; } } return true; } @Override public boolean hasNext() { return getNextServiceLoader(); } @Override public E next() { if (!getNextServiceLoader()) { throw new NoSuchElementException("No more elements for service " + service.getName()); } final E tempNext = nextServiceLoader; nextServiceLoader = null; return tempNext; } @Override public void remove() { throw new UnsupportedOperationException("service=" + service.getName()); } }
e78b8c61bd5c7cb365daaa3033d99741e7832e25
3be97b269b7c13c8569ce80f84fbb7fc494a17e9
/empwebapp/src/com/ustglobal/empwebapp/servlets/HomeServlet.java
4b4c9b0178fd9d19e668ff6228d2eeebc47f9e80
[]
no_license
megha286/USTGlobal-16Sep19-Megha-Patil
dcb2c41d8c4b729c4336dbd2a6fa66e452ce83fc
fb64652cb42c7c734146b06312771ebcd75ac2ef
refs/heads/master
2023-01-11T18:58:48.540480
2019-11-28T11:20:25
2019-11-28T11:20:25
215,540,531
0
0
null
2023-01-07T16:52:24
2019-10-16T12:16:44
CSS
UTF-8
Java
false
false
1,321
java
package com.ustglobal.empwebapp.servlets; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.ustglobal.empwebapp.dto.EmployeeInfo; @WebServlet("/home") public class HomeServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { HttpSession session=req.getSession(false); if (session!=null) { EmployeeInfo info=(EmployeeInfo)session.getAttribute("info"); PrintWriter out=resp.getWriter(); out.println("<h1>Welcome "+info.getName()); out.println("</h1>"); out.println("<a href='./search.html'>Search</a>"); out.println("<a href='./changepassword.html'>Change Password</a>"); out.println("<a href='./logout'>Logout</a>"); }else { RequestDispatcher dispatcher=req.getRequestDispatcher("/login.html"); dispatcher.forward(req, resp); } } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doGet(req,resp); } }
bf08ad6dc2a005d5d0fb1be86c6f4eae378eb29c
86db07a13949b55e1348913293bdb3f06af70618
/core-app/src/test/java/com/revature/test/StudentAccountTest.java
684d41520854ad2b2990a8c6c78ad0062ad0374f
[]
no_license
AiswaryaRavi/SampleLeaderBoard
632d2e3932d53cd5397f5cbecceaaa3aa088d909
c655a6c7d5a3cea70a077791d1af9d9801a9c6f6
refs/heads/master
2021-01-20T13:03:49.346083
2017-03-14T14:06:43
2017-03-14T14:06:43
82,675,317
0
0
null
null
null
null
UTF-8
Java
false
false
379
java
package com.revature.test; import com.revature.data.exception.DataServiceException; import com.revature.data.impl.StudentAccountDAOImpl; public class StudentAccountTest { public static void main(String[] args) throws DataServiceException { StudentAccountDAOImpl s=new StudentAccountDAOImpl(); System.out.println(s.getId("[email protected]","ais0805")); } }
fe2e1dd353c8f5261332cf541ddbc583be0faa53
14da87432302cd03283200097be8088636af7362
/src/main/java/com/tk/vo/req/RoleReqPageVo.java
978d20e2fefbca4c1fef88efc2e9109693edace7
[]
no_license
qq305563004/xingh
962b5e2e6da3844bdef4cd3834bb8223549687f3
1dc36aefc84887eea6a589ce2e878448daea09eb
refs/heads/master
2022-12-05T17:54:50.314370
2020-09-01T09:04:58
2020-09-01T09:04:58
162,387,261
0
0
null
null
null
null
UTF-8
Java
false
false
261
java
package com.tk.vo.req; import com.tk.dto.PageParam; public class RoleReqPageVo extends PageParam { private String rolename; public String getRolename() { return rolename; } public void setRolename(String rolename) { this.rolename = rolename; } }
a462a15e7f4d8dfd99c0e4ce7b67639a1b8c7cbd
71ea928732731ed86fec90904593226158b5e737
/src/ch03/CustomComponent/src/projavafx/customcomponent/CustomComponent.java
41b5c394505004c63d0bda680590907f15153215
[]
no_license
kindlychung/projavafx8
eda234d4227b52dfbd492e09d6ee89cb852405ca
73ff24fd61882194397fe00853025263490143b9
refs/heads/master
2021-01-10T08:22:09.150884
2016-01-04T12:52:03
2016-01-04T12:52:03
48,996,826
0
0
null
null
null
null
UTF-8
Java
false
false
1,361
java
package projavafx.customcomponent; import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.scene.text.Font; import javafx.stage.Stage; public class CustomComponent extends Application { @Override public void start(Stage primaryStage) throws Exception { VBox vBox = new VBox(10); vBox.setPadding(new Insets(10, 10, 10, 10)); vBox.setAlignment(Pos.BASELINE_CENTER); final Label prodIdLabel = new Label("Enter Product Id:"); final ProdId prodId = new ProdId(); final Label label = new Label(); label.setFont(Font.font(48)); label.textProperty().bind(prodId.prodIdProperty()); HBox hBox = new HBox(10); hBox.setPadding(new Insets(10, 10, 10, 10)); hBox.setAlignment(Pos.BASELINE_LEFT); hBox.getChildren().addAll(prodIdLabel, prodId); vBox.getChildren().addAll(hBox, label); Scene scene = new Scene(vBox); primaryStage.setTitle("Custom Component Example"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
3d7162c97bd3098c95d29b3ad3b4bb017e791605
bca11015f339abbc2f57ff0dc79a0d803289df4f
/SeleniumOnLSK.java
5a3b779855ddb3f8564307041e442ffb005dd947
[]
no_license
amakauskaite/Selenium-examples
19abf17f0fc25c6a5104dfe0941f09b3e5e14e78
9c4d85580acec6104dc122df77c0746612c3e4f0
refs/heads/master
2021-06-25T04:32:36.948742
2017-09-12T12:11:30
2017-09-12T12:11:30
103,265,489
0
0
null
null
null
null
ISO-8859-13
Java
false
false
3,983
java
package tests; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.Select; public class SeleniumOnLSK { private static WebDriver driver; public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", ".\\lib\\chromedriver.exe"); driver = new ChromeDriver(); // Preparing the environment for work driver.manage().window().maximize(); driver.manage().deleteAllCookies(); driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); // Opens lsk main page driver.get("http://www.lsk.flf.vu.lt/lt/"); // Clicks on "Lietuvių kalbos kursai" driver.findElement(By.xpath("//ul[@class='level1']/li[3]")).click(); // Clicks on "Anketa" driver.findElement(By.linkText("Anketa")).click(); fillTheForm(); // driver.quit(); // Uncomment this line when executing if you want to // close the browser after execution } public static void fillTheForm() { // Fills surname driver.findElement(By.id("lib_php_form_standard_1__field_field_1_input_field")).sendKeys("Pavardenis"); // Fills name driver.findElement(By.name("field_2")).sendKeys("Vardenis"); // Fills birth date (in bad format) driver.findElement(By.id("lib_php_form_standard_1__field_field_3_input_field")).sendKeys("2017-09-13"); // Fills nationality driver.findElement(By.id("lib_php_form_standard_1__field_field_4_input_field")).sendKeys("Lietuvis"); // Selects gender (Male) Select genderSelect = new Select(driver.findElement(By.name("field_5"))); genderSelect.selectByValue("Vyras"); // Fills home address driver.findElement(By.id("lib_php_form_standard_1__field_field_6_input_field")).sendKeys("Naugarduko g. 24"); // Fills telephone number driver.findElement(By.name("field_7")).sendKeys("+37061111111"); // Fills fax driver.findElement(By.id("lib_php_form_standard_1__field_field_8_input_field")).sendKeys("Fakso numeris"); // Fills email driver.findElement(By.id("lib_php_form_standard_1__field_field_9_input_field")) .sendKeys("[email protected]"); // Fills current activity driver.findElement(By.name("field_10")).sendKeys("Formos pildymas"); // Fills language driver.findElement(By.name("field_11")).sendKeys("Visas kalbas lietuviškai"); // Selects "Yes" in "Do you know Lithuanian?" Select ltSelect = new Select(driver.findElement(By.name("field_12"))); ltSelect.selectByValue("Taip"); // Selects "Gerai" in "If yes, then how well" Select levelSelect = new Select( driver.findElement(By.id("lib_php_form_standard_1__field_field_13_input_field"))); levelSelect.selectByValue("Gerai"); // Selects some course Select courseSelect = new Select(driver.findElement(By.name("field_14"))); courseSelect.selectByIndex(2); // Selects place to stay Select placeSelect = new Select(driver.findElement(By.name("field_15"))); placeSelect.selectByVisibleText("Bendrabutyje"); // Fills fields about connections driver.findElement(By.name("field_16")).sendKeys("Su mano žmona"); // Fills text box about the course driver.findElement(By.name("field_17")).sendKeys("Ieškojau per google bet kokios anketos"); // Fills text box about the reason of wanting to do this course driver.findElement(By.id("lib_php_form_standard_1__field_field_18_input_field")).sendKeys("Jei praėjo ši anketa, siūlau patikrinti ar teisingai tikrinamas datos formatas"); try { Thread.sleep(30000); // Clicks submit button driver.findElement(By.className("libPhpFormSubmit")).click(); Thread.sleep(20000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
10297d51e03cf48430a00cb72f68a62683aee49d
8594bd923be388eff0f17c5f4e3d1079e1c83599
/web/src/main/java/ar/gaf/mycashflow/web/rest/CentroCostoController.java
015456b0bc25e693a722bf71032e462a6d233993
[]
no_license
gforrade/myNewCashFlow
8efd0df2c43bf3ce592c27cf93ae4fd94b6b3e27
b573ccf85242aa6e336d87bd3708c484d3cbd673
refs/heads/master
2020-03-26T19:35:15.165333
2018-08-19T04:51:34
2018-08-19T04:51:34
145,273,483
0
0
null
null
null
null
UTF-8
Java
false
false
3,865
java
package ar.gaf.mycashflow.web.rest; import ar.gaf.mycashflow.model.entities.CentroCosto; import ar.gaf.mycashflow.model.entities.Grupo; import ar.gaf.mycashflow.service.BusinessService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; /** * Created by gforrade on 2/6/16. * Copyright (c) 2016, DATASTAR S.A. */ @RestController() @RequestMapping(value="/centrosCostos") public class CentroCostoController { @Autowired BusinessService businessService; @RequestMapping(method = RequestMethod.GET) public ResponseEntity<List<CentroCosto>> allCategorias() { Iterable<CentroCosto> centroCostosIterable= businessService.findAllCentrosCosto(); if(centroCostosIterable == null){ return new ResponseEntity<>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND } else { List<CentroCosto> centroCostos = new ArrayList<>(); for (CentroCosto centroCosto: centroCostosIterable) { centroCostos.add(centroCosto); } return new ResponseEntity<>(centroCostos, HttpStatus.OK); } } @RequestMapping(value="/{id}", method= RequestMethod.GET) public ResponseEntity<CentroCosto> getCentroCosto(@PathVariable("id") Long id) { CentroCosto centroCosto = businessService.findCentroCostoById(id); if (centroCosto == null) { return new ResponseEntity<>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND } else { return new ResponseEntity<CentroCosto>(centroCosto,HttpStatus.OK); } } @RequestMapping(value = "", method = RequestMethod.POST) public ResponseEntity<Void> createCentroCosto(@RequestBody CentroCosto centroCosto) { try { System.out.println("centrocosto a crear : "+centroCosto); businessService.saveCentroCosto(centroCosto); return new ResponseEntity<Void>(HttpStatus.CREATED); } catch (Exception ex) { return new ResponseEntity<Void>(HttpStatus.INTERNAL_SERVER_ERROR); } } //------------------- Delete a CentroCosto -------------------------------------------------------- @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public ResponseEntity<CentroCosto> deleteCentroCosto(@PathVariable("id") long id) { System.out.println("Fetching & Deleting CentroCosto with id " + id); CentroCosto centroCosto = businessService.findCentroCostoById(id); if (centroCosto== null) { return new ResponseEntity<CentroCosto>(HttpStatus.NOT_FOUND); } businessService.deleteCentroCostoById(id); return new ResponseEntity<CentroCosto>(HttpStatus.NO_CONTENT); } //------------------- Update a categoria -------------------------------------------------------- @RequestMapping(value = "/{id}", method = RequestMethod.PUT) public ResponseEntity<CentroCosto> updateCentroCosto(@PathVariable("id") long id, @RequestBody CentroCosto centroCosto) { System.out.println("Updating CentroCosto " + id); CentroCosto currentCentroCosto = businessService.findCentroCostoById(id); if (centroCosto==null) { System.out.println("CentroCosto with id " + id + " not found"); return new ResponseEntity<CentroCosto>(HttpStatus.NOT_FOUND); } currentCentroCosto.setNombre(centroCosto.getNombre()); currentCentroCosto.setDescripcion(centroCosto.getDescripcion()); businessService.updateCentroCosto(currentCentroCosto); return new ResponseEntity<CentroCosto>(centroCosto, HttpStatus.OK); } }
911601929fdbd64562497a254770c1c68b8c8a9a
572e77399280551f0119691f7b557a84e072e4eb
/Numbers/app/src/main/java/com/github/veselinazatchepina/numbers/data/local/NumbersDbHelper.java
2b5e26b5d96651ad3f7fc6af652bfe51436d2069
[]
no_license
VeselinaZatchepina/numbers
6ac1fb3af4ed22dcf958298e5997145d1abb49da
db2130f5be3b6467f8671d6fc7efb731a87ba385
refs/heads/master
2021-07-24T11:37:23.238005
2017-11-03T18:10:36
2017-11-03T18:10:36
107,171,868
1
0
null
null
null
null
UTF-8
Java
false
false
2,431
java
package com.github.veselinazatchepina.numbers.data.local; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; public class NumbersDbHelper extends SQLiteOpenHelper { public static final int DATABASE_VERSION = 1; public static final String DATABASE_NAME = "Numbers.db"; private static final String TEXT_TYPE = " TEXT"; private static final String COMMA_SEP = ","; private static final String SQL_CREATE_ENTRIES_HISTORY = "CREATE TABLE " + HistoryNumbersPersistenceContract.NumberEntry.TABLE_NAME + " (" + HistoryNumbersPersistenceContract.NumberEntry.COLUMN_NAME_ENTRY_ID + TEXT_TYPE + " PRIMARY KEY," + HistoryNumbersPersistenceContract.NumberEntry.COLUMN_NAME_NUMBER + TEXT_TYPE + COMMA_SEP + HistoryNumbersPersistenceContract.NumberEntry.COLUMN_NAME_DESCRIPTION + TEXT_TYPE + COMMA_SEP + HistoryNumbersPersistenceContract.NumberEntry.COLUMN_NAME_TYPE + TEXT_TYPE + COMMA_SEP + HistoryNumbersPersistenceContract.NumberEntry.COLUMN_NAME_DATE + TEXT_TYPE + " )"; private static final String SQL_CREATE_ENTRIES_USER = "CREATE TABLE " + UserNumbersPersistenceContract.NumberEntry.TABLE_NAME + " (" + UserNumbersPersistenceContract.NumberEntry.COLUMN_NAME_ENTRY_ID + TEXT_TYPE + " PRIMARY KEY," + UserNumbersPersistenceContract.NumberEntry.COLUMN_NAME_NUMBER + TEXT_TYPE + COMMA_SEP + UserNumbersPersistenceContract.NumberEntry.COLUMN_NAME_DESCRIPTION + TEXT_TYPE + COMMA_SEP + UserNumbersPersistenceContract.NumberEntry.COLUMN_NAME_TYPE + TEXT_TYPE + COMMA_SEP + UserNumbersPersistenceContract.NumberEntry.COLUMN_NAME_DATE + TEXT_TYPE + " )"; public NumbersDbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } public void onCreate(SQLiteDatabase db) { db.execSQL(SQL_CREATE_ENTRIES_HISTORY); db.execSQL(SQL_CREATE_ENTRIES_USER); } public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // Not required as at version 1 } public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { // Not required as at version 1 } }
4048e5d15a0fdd061fcb19f85fa8aeffc2f01c12
834fd9101a08d5818c1686bf0bf97805afd4fd58
/src/main/java/tacos/model/Taco.java
dd1252589aabff63b9d18056bfc6c8668a1f3a52
[]
no_license
styko/SpringInAction5
4d235b2db33a778a7221af971c90a92fad538351
cbded5884800f8c0f3f2162dbda93faf516d7c27
refs/heads/master
2020-03-31T13:26:46.682994
2018-10-23T08:53:12
2018-10-23T08:53:12
152,255,875
0
0
null
null
null
null
UTF-8
Java
false
false
852
java
package tacos.model; import java.util.Date; import java.util.List; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToMany; import javax.persistence.PrePersist; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.Data; @Data @Entity public class Taco { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private Date createdAt; @NotNull @Size(min = 5, message = "Name must be at least 5 characters long") private String name; @Size(min = 1, message = "You must choose at least 1 ingredient") @ManyToMany(targetEntity = Ingredient.class) private List<Ingredient> ingredients; @PrePersist void createdAt() { this.createdAt = new Date(); } }
bf386f96f6b642437b9ae57a61ebc1fe13f0e805
252af24ff1f2efcf836832097d616fa7a62a80b2
/WR/WR/obj/Debug/android/src/md586a62184f138a5ae8634749b9c7d427a/FormEditorActivity.java
8b50029a26813d23cc8bb1f9ba0d016c4cdbfe69
[]
no_license
StasyaZlato/WriteRight
5d0c2dccc05db8853c781714e28501415564d01b
dab91f51d1f402173dce8d73199c3775d2e8aa7b
refs/heads/master
2020-04-26T18:48:34.270051
2019-05-21T19:59:07
2019-05-21T19:59:07
173,755,779
0
0
null
null
null
null
UTF-8
Java
false
false
1,248
java
package md586a62184f138a5ae8634749b9c7d427a; public class FormEditorActivity extends md586a62184f138a5ae8634749b9c7d427a.MainActivity implements mono.android.IGCUserPeer { /** @hide */ public static final String __md_methods; static { __md_methods = "n_onCreate:(Landroid/os/Bundle;)V:GetOnCreate_Landroid_os_Bundle_Handler\n" + "n_onBackPressed:()V:GetOnBackPressedHandler\n" + ""; mono.android.Runtime.register ("WR.Activities.FormEditorActivity, WR", FormEditorActivity.class, __md_methods); } public FormEditorActivity () { super (); if (getClass () == FormEditorActivity.class) mono.android.TypeManager.Activate ("WR.Activities.FormEditorActivity, WR", "", this, new java.lang.Object[] { }); } public void onCreate (android.os.Bundle p0) { n_onCreate (p0); } private native void n_onCreate (android.os.Bundle p0); public void onBackPressed () { n_onBackPressed (); } private native void n_onBackPressed (); private java.util.ArrayList refList; public void monodroidAddReference (java.lang.Object obj) { if (refList == null) refList = new java.util.ArrayList (); refList.add (obj); } public void monodroidClearReferences () { if (refList != null) refList.clear (); } }
f7df696aa02bf520c5560b651e1a1ffd9c4e95c3
7ee5e344026252defd92e0419641be14d5c96060
/src/main/java/pw/servlet/HelloWorldServlet.java
786944f16908ab20aa40c2531fa2bd3f0c8ef0b2
[]
no_license
yrochaa/pw-aula11
f4cdec388d834a4e147f0bcfc0e8cd5247f99573
933850b5bc3acd2d89210575ce3fdf4d4a586a21
refs/heads/master
2020-07-11T11:58:20.506410
2017-06-27T23:49:16
2017-06-27T23:49:16
94,269,809
0
0
null
null
null
null
UTF-8
Java
false
false
781
java
package pw.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(value = "/hello-servlet") public class HelloWorldServlet extends HttpServlet { @Override protected void doGet( HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String html = "<html>"; html += "<head>"; html += "<title>"; html += "Hello"; html += "</title>"; html += "</head>"; html += "<body>"; html += "<h1>"; html += "Hello"; html += "</h1>"; html += "</body>"; html += "</html>"; resp.getOutputStream().print(html); } }
265b006955cad8166fc77fa75182c3270c4b6012
edfffbee3f6307e5814252d92a30f809a4f18bb5
/src/main/java/com/whz/service/UserService.java
794c4a930acd2388037d303ffe6ced685087e566
[]
no_license
CST11021/SpringMVC_Source_3.2.9_Fourm
249009070e247a8f95d1b80b654903e11e72001d
8a87c479607b86338417228e6a8b622b7b361cc4
refs/heads/master
2022-09-16T02:57:57.311437
2018-02-09T10:18:34
2018-02-09T10:18:34
94,592,635
0
1
null
null
null
null
UTF-8
Java
false
false
2,526
java
package com.whz.service; import com.whz.dao.LoginLogDao; import com.whz.dao.UserDao; import com.whz.domain.LoginLog; import com.whz.domain.User; import com.whz.exception.UserExistException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; /** * 用户管理服务器,负责查询用户、注册用户、锁定用户等操作 * */ @Service public class UserService { @Autowired private UserDao userDao; @Autowired private LoginLogDao loginLogDao; // 注册一个新用户,如果用户名已经存在此抛出UserExistException的异常 public void register(User user) throws UserExistException{ User u = this.getUserByUserName(user.getUserName()); if(u != null){ throw new UserExistException("用户名已经存在"); }else{ user.setCredit(100); user.setUserType((byte) 1); userDao.saveEntity(user); } } // 更新用户 public void update(User user){ userDao.updateEntity(user); } // 根据用户名查询 User对象 public User getUserByUserName(String userName){ return userDao.getUserByUserName(userName); } // 根据userId加载User对象 public User getUserById(int userId){ return userDao.getById(userId); } // 将用户锁定,锁定的用户不能够登录 // @param userName 锁定目标用户的用户名 public void lockUser(String userName){ User user = userDao.getUserByUserName(userName); user.setLocked((byte) User.USER_LOCK); userDao.updateEntity(user); } // 解除用户的锁定 // @param userName 解除锁定目标用户的用户名 public void unlockUser(String userName){ User user = userDao.getUserByUserName(userName); user.setLocked((byte) User.USER_UNLOCK); userDao.updateEntity(user); } // 根据用户名为条件,执行模糊查询操作 // @param userName 查询用户名 // @return 所有用户名前导匹配的userName的用户 public List<User> queryUserByUserName(String userName){ return userDao.queryUserByUserName(userName); } // 获取所有用户 public List<User> getAllUsers(){ return userDao.loadAllEntity(); } // 登陆成功 public void loginSuccess(User user) { user.setCredit( 5 + user.getCredit()); LoginLog loginLog = new LoginLog(); loginLog.setUser(user); loginLog.setIp(user.getLastIp()); loginLog.setLoginDate(new Date()); userDao.updateEntity(user); loginLogDao.saveEntity(loginLog); } }
[ "l" ]
l
fe17f4fd8489b389cc719f73469a91c27d4f82cf
feabdf0cfccd28e251e9d30c21a783b2a0b92265
/src/main/java/io/github/jhipster/jhip201802/config/WebConfigurer.java
e13ad8f789b07389087bb0114f5818fb7409a05a
[]
no_license
acpuma/jhip201802
e558d92c1973e542e8d3826c370f27ce1d8d2821
f3429dc26ee69da8f27f50bdf6c3a11c558fdf6c
refs/heads/master
2021-01-24T12:00:16.224935
2018-02-27T10:31:54
2018-02-27T10:31:54
123,113,441
0
0
null
null
null
null
UTF-8
Java
false
false
8,729
java
package io.github.jhipster.jhip201802.config; import io.github.jhipster.config.JHipsterConstants; import io.github.jhipster.config.JHipsterProperties; import io.github.jhipster.web.filter.CachingHttpHeadersFilter; import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.servlet.InstrumentedFilter; import com.codahale.metrics.servlets.MetricsServlet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.embedded.*; import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory; import io.undertow.UndertowOptions; import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; import org.springframework.http.MediaType; import java.io.File; import java.nio.file.Paths; import java.util.*; import javax.servlet.*; /** * Configuration of web application with Servlet 3.0 APIs. */ @Configuration public class WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { private final Logger log = LoggerFactory.getLogger(WebConfigurer.class); private final Environment env; private final JHipsterProperties jHipsterProperties; private MetricRegistry metricRegistry; public WebConfigurer(Environment env, JHipsterProperties jHipsterProperties) { this.env = env; this.jHipsterProperties = jHipsterProperties; } @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); } EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC); initMetrics(servletContext, disps); if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) { initCachingHttpHeadersFilter(servletContext, disps); } if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) { initH2Console(servletContext); } log.info("Web application fully configured"); } /** * Customize the Servlet engine: Mime types, the document root, the cache. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=utf-8"); container.setMimeMappings(mappings); // When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets. setLocationForStaticAssets(container); /* * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288 * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1. * See the JHipsterProperties class and your application-*.yml configuration files * for more information. */ if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) && container instanceof UndertowEmbeddedServletContainerFactory) { ((UndertowEmbeddedServletContainerFactory) container) .addBuilderCustomizers(builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true)); } } private void setLocationForStaticAssets(ConfigurableEmbeddedServletContainer container) { File root; String prefixPath = resolvePathPrefix(); root = new File(prefixPath + "target/www/"); if (root.exists() && root.isDirectory()) { container.setDocumentRoot(root); } } /** * Resolve path prefix to static resources. */ private String resolvePathPrefix() { String fullExecutablePath = this.getClass().getResource("").getPath(); String rootPath = Paths.get(".").toUri().normalize().getPath(); String extractedPath = fullExecutablePath.replace(rootPath, ""); int extractionEndIndex = extractedPath.indexOf("target/"); if (extractionEndIndex <= 0) { return ""; } return extractedPath.substring(0, extractionEndIndex); } /** * Initializes the caching HTTP Headers Filter. */ private void initCachingHttpHeadersFilter(ServletContext servletContext, EnumSet<DispatcherType> disps) { log.debug("Registering Caching HTTP Headers Filter"); FilterRegistration.Dynamic cachingHttpHeadersFilter = servletContext.addFilter("cachingHttpHeadersFilter", new CachingHttpHeadersFilter(jHipsterProperties)); cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*"); cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*"); cachingHttpHeadersFilter.setAsyncSupported(true); } /** * Initializes Metrics. */ private void initMetrics(ServletContext servletContext, EnumSet<DispatcherType> disps) { log.debug("Initializing Metrics registries"); servletContext.setAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE, metricRegistry); servletContext.setAttribute(MetricsServlet.METRICS_REGISTRY, metricRegistry); log.debug("Registering Metrics Filter"); FilterRegistration.Dynamic metricsFilter = servletContext.addFilter("webappMetricsFilter", new InstrumentedFilter()); metricsFilter.addMappingForUrlPatterns(disps, true, "/*"); metricsFilter.setAsyncSupported(true); log.debug("Registering Metrics Servlet"); ServletRegistration.Dynamic metricsAdminServlet = servletContext.addServlet("metricsServlet", new MetricsServlet()); metricsAdminServlet.addMapping("/management/metrics/*"); metricsAdminServlet.setAsyncSupported(true); metricsAdminServlet.setLoadOnStartup(2); } @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = jHipsterProperties.getCors(); if (config.getAllowedOrigins() != null && !config.getAllowedOrigins().isEmpty()) { log.debug("Registering CORS filter"); source.registerCorsConfiguration("/api/**", config); source.registerCorsConfiguration("/management/**", config); source.registerCorsConfiguration("/v2/api-docs", config); } return new CorsFilter(source); } /** * Initializes H2 console. */ private void initH2Console(ServletContext servletContext) { log.debug("Initialize H2 console"); try { // We don't want to include H2 when we are packaging for the "prod" profile and won't // actually need it, so we have to load / invoke things at runtime through reflection. ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?> servletClass = Class.forName("org.h2.server.web.WebServlet", true, loader); Servlet servlet = (Servlet) servletClass.newInstance(); ServletRegistration.Dynamic h2ConsoleServlet = servletContext.addServlet("H2Console", servlet); h2ConsoleServlet.addMapping("/h2-console/*"); h2ConsoleServlet.setInitParameter("-properties", "src/main/resources/"); h2ConsoleServlet.setLoadOnStartup(1); } catch (ClassNotFoundException | LinkageError e) { throw new RuntimeException("Failed to load and initialize org.h2.server.web.WebServlet", e); } catch (IllegalAccessException | InstantiationException e) { throw new RuntimeException("Failed to instantiate org.h2.server.web.WebServlet", e); } } @Autowired(required = false) public void setMetricRegistry(MetricRegistry metricRegistry) { this.metricRegistry = metricRegistry; } }
24b2aa51870357c2f2ec140fdebb7b36c157f06b
ddc9dec03766aa48e5d6f4adb01f643c3a85d68b
/Array/MyArray/RetrieveEvenNumberInArray.java
82dea54e4c1d6e6f77b49d4092a21daf7935b072
[]
no_license
Raushann/Core_Java
319842f148e40aa3b70b73c27063cec4821b9e68
5c08560bd0d84d1250266c0845736aaba223fb45
refs/heads/master
2022-08-24T00:02:22.600051
2020-05-27T17:40:30
2020-05-27T17:40:30
265,676,848
1
0
null
null
null
null
UTF-8
Java
false
false
437
java
package com.Array.MyArray; public class RetrieveEvenNumberInArray { public static void main(String[] args) { int arr[]=new int[10]; int addNumber=0; for (int i = 0; i < arr.length; addNumber++) { arr[i++]=addNumber; } //retrieving from array for (int i = 0; i < arr.length; i++) { if (arr[i]%2==0) { System.out.println("Even Number in the given array is :"+arr[i]); } } } }
5b1ecaf17594d8c1389fb9acd3ebb267a7af3ed3
e9c20f544e893cdcfc1532311e705bf3d40ba953
/src/com/mrkj/ygl/config/SpringWebInitializer.java
1a453d425833d7f4f9ba05b7c42d1a383fabb8e1
[]
no_license
zhangyusong627/mroa
af5000ba54de1ec7dff50f3072fc762ecf9295e1
edf8e75013315b58e1e1844c3b569311d2bfe49f
refs/heads/master
2020-03-28T20:38:32.483450
2018-09-20T13:49:26
2018-09-20T13:49:26
149,089,917
1
1
null
null
null
null
UTF-8
Java
false
false
665
java
package com.mrkj.ygl.config; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; public class SpringWebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class<?>[] getRootConfigClasses() { // TODO Auto-generated method stub return new Class<?>[]{RootConfig.class}; } @Override protected Class<?>[] getServletConfigClasses() { // TODO Auto-generated method stub return new Class<?>[]{WebConfig.class}; } @Override protected String[] getServletMappings() { // TODO Auto-generated method stub return new String[] {"/"}; } }
[ "ASUS@DESKTOP-L3BECP7" ]
ASUS@DESKTOP-L3BECP7
d9f38486b6018f181d6e09aec9fc831b49648fe5
5c9306259667ead4002cdd61d48f9ea32fdcb1e5
/src/main/java/com/ing/modelbank/service/AccountServiceImpl.java
181ea38376a645072c8083da5b3f74dd501eda58
[]
no_license
chandrika782/Modelbank
b3961b62cc484d26aaf69adaf643f74f15c82871
4b3aadaf09bb1484a94d36a741bcba8d19e9749c
refs/heads/master
2020-07-04T16:27:15.865829
2019-08-14T11:51:58
2019-08-14T11:51:58
202,338,879
0
0
null
null
null
null
UTF-8
Java
false
false
1,088
java
package com.ing.modelbank.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ing.modelbank.dto.ResponseAccountDto; import com.ing.modelbank.entity.Account; import com.ing.modelbank.exception.AccountNotFoundException; import com.ing.modelbank.repository.AccountRepository; @Service public class AccountServiceImpl implements AccountService { @Autowired AccountRepository accountRepository; ResponseAccountDto responseAccountDto; @Override public ResponseAccountDto getAccountSummary(Integer accountNumber) { Account account = accountRepository.findByAccountNumber(accountNumber); if (account != null) { responseAccountDto = new ResponseAccountDto(); responseAccountDto.setAccountId(account.getAccountId()); responseAccountDto.setAccountNumber(account.getAccountNumber()); responseAccountDto.setAccountType(account.getAccountType()); responseAccountDto.setBalance(account.getBalance()); return responseAccountDto; } else { throw new AccountNotFoundException(); } } }