id
stringlengths
36
36
text
stringlengths
1
1.25M
9f43f21f-b49a-495f-b794-aafce7ef13ef
public String getApplicationVersion() { return version; }
5e99f08d-9313-4b8c-8ae4-aae3830daf2b
public String getScriptName() { return scriptName; }
0fa27356-1ae5-4f7a-b767-f0662bc1fe16
public String getMainClass() { return mainClass; }
c93291f8-ecee-430e-bbe1-b7d7f1af1bbd
public String getArguments() { return arguments; }
45e452be-8eaa-4515-8421-5537ad73b089
public static InitializationScript createInitializationScript( StringTemplate template, InitializationScriptConfiguration initializationScriptConfiguration) { DaemonConfiguration daemonConfiguration = initializationScriptConfiguration .getDaemonConfiguration(); final ApplicationConfiguration applicationConfiguration = initializationScriptConfiguration .getApplicationConfiguration(); final TargetSystemConfiguration targetSystemConfiguration = initializationScriptConfiguration .getTargetSystemConfiguration(); filterTemplate(template, daemonConfiguration, applicationConfiguration, targetSystemConfiguration, initializationScriptConfiguration.getDaemonJarName()); return new InitializationScript( applicationConfiguration.getScriptName(), template.toString()); }
abd297c5-cb4d-44c6-8545-ec1cabed492f
private static void filterTemplate(StringTemplate template, DaemonConfiguration daemonConfiguration, ApplicationConfiguration applicationConfiguration, TargetSystemConfiguration targetSystemConfiguration, String daemonJarName) { template.setAttribute(InitializationScript.USER, daemonConfiguration.getDaemonUser()); template.setAttribute(InitializationScript.APPLICATION_NAME, applicationConfiguration.getApplicationName()); template.setAttribute(InitializationScript.APPLICATION_VERSION, applicationConfiguration.getApplicationVersion()); template.setAttribute(InitializationScript.APPLICATION_MAIN_CLASS, applicationConfiguration.getMainClass()); template.setAttribute(InitializationScript.APPLICATION_ARGUMENTS, applicationConfiguration.getArguments()); template.setAttribute( InitializationScript.TARGET_SYSTEM_APPLICATION_LOCATION, targetSystemConfiguration.getApplicationJarLocation()); template.setAttribute( InitializationScript.TARGET_SYSTEM_DAEMON_JAR_LOCATION, targetSystemConfiguration.getDaemonJarLocation()); template.setAttribute(InitializationScript.TARGET_SYSTEM_JAVA_HOME, targetSystemConfiguration.getJavaHome()); template.setAttribute(InitializationScript.DAEMON_JAR_NAME, daemonJarName); template.setAttribute(InitializationScript.DELAY, daemonConfiguration.getDelayInMillis()); }
f3684899-c35e-4955-b00a-d2764a41680e
public InitializationScript(String fileName, String contentAsString) { this.fileName = fileName; this.contentAsString = contentAsString; }
4df98ca5-c113-4e39-aa59-1a52d997af12
public String getFileName() { return fileName; }
2c380e64-967a-4998-8dce-07f9ff0d79ec
public String getContentAsString() { return contentAsString; }
96be39b1-cb2f-4f1b-869f-ad211a4fa63f
public InitializationScriptWriter(InitializationScript initializationScript) { this.initializationScript = initializationScript; }
94f3f4d3-0e1e-42f8-9844-53e4a388c730
public void writeToExecutableFile(File outputDirectory) throws IOException { File outputFile = new File(outputDirectory, initializationScript.getFileName()); FileUtils.writeStringToFile(outputFile, initializationScript.getContentAsString()); outputFile.setExecutable(true); outputFile.setReadable(true); }
ee024456-0b36-4df3-bbc5-4f765343c68c
@Before public void setUp() throws Exception { jsvcMojo = new JsvcMojo(); DirectFieldAccessor directFieldAccessor = new DirectFieldAccessor( jsvcMojo); directFieldAccessor.setPropertyValue("mavenProject", mavenProject); directFieldAccessor.setPropertyValue("projectBuildDirectory", temporaryFolder.newFolder("target")); }
8829ffa4-ee67-4e6c-80c5-e74751ce97e1
@Test(expected = MojoExecutionException.class) public void shouldThrowExceptionOnCommonsDaemonArtifactNotFound() throws Exception { given(mavenProject.getArtifactMap()).willReturn( Collections.<String, Artifact> emptyMap()); jsvcMojo.execute(); }
81174b72-1595-448e-bf84-cbe4afac0faa
private void getInstance(){ if(iimc==null) setIimc(Factory.getCalculos()); }
cc40827f-89ca-495f-8307-8bc7af95fefd
public Iimc getIimc() { getInstance(); return iimc; }
2e7450da-7466-4c73-95e0-7161c19d2374
public void setIimc(Iimc iimc) { this.iimc = iimc; }
42ed2b98-45b6-4e11-9f17-5615dc758c00
@GET @Path("/imc/{peso}/{altura}") @Produces(MediaType.TEXT_PLAIN) public String imc(@PathParam("peso") String peso ,@PathParam("altura") String altura) { String resposta=""; if(!new String2DoubleValidator().validar(peso)) resposta="peso informado invalido!"; else if(!new String2DoubleValidator().validar(altura)) resposta="altura informada invalida!"; else resposta= new Double(getIimc().calculaImc(Double.parseDouble(peso), Double.parseDouble(altura))).toString(); return resposta; }
5645c89b-06bd-4f5e-b8ce-15a352109eee
private void getInstance(){ if(idesc==null) setIdesc(Factory.getCalculos()); }
3f71a157-c7a0-4838-93cc-28fb4855627d
public IDesconto getIdesc() { getInstance(); return idesc; }
0bbab3a6-0cd5-4fe7-bd9e-3a3bdc18742a
public void setIdesc(IDesconto idesc) { this.idesc = idesc; }
4c9964c7-c3df-499e-bea0-cc74ab328e6b
@GET @Path("/desconto/{valor}/{percentual}") @Produces(MediaType.TEXT_PLAIN) public String imc(@PathParam("valor") String valor ,@PathParam("percentual") String percentual) { String resposta=""; if(!new String2DoubleValidator().validar(valor)) resposta="valor informado invalido!"; else if(!new String2DoubleValidator().validar(percentual)) resposta="percentual informada invalida!"; else resposta= new Double(getIdesc().calculaDesconto(Double.parseDouble(valor), Double.parseDouble(percentual))).toString(); return resposta; }
7c482e1c-7fcf-470f-a63a-e8a809ed94e3
public static Calculos getCalculos(){ return new Calculos(); }
924719fe-7ce5-4f64-9bb2-3f73a3bdb440
public double getPeso() { return peso; }
2fd6b85b-334c-4ea5-ba26-9d4e10238c4c
public void setPeso(double peso) { this.peso = peso; }
70dc718b-b6c7-47d0-87a3-3ab2adf470d5
public double getAltura() { return altura; }
70956983-0a39-4910-87b7-48afa19e95e3
public void setAltura(double altura) { this.altura = altura; }
d67a3d12-b324-45c6-bbdb-219fe8b03a49
public double getImc() { return imc; }
6300aed3-009e-4b40-82e6-b35804bfcb84
public void setImc(double imc) { this.imc = imc; }
1d7c66cd-3fb0-4d58-84a7-3d0ecbf3d302
public double getValor() { return valor; }
25796c0b-6ced-49d6-9bad-fc2689d69e86
public void setValor(double valor) { this.valor = valor; }
72130915-6797-4c68-ab8a-2aa0d8f9a64b
public double getValor_desconto() { return valor_desconto; }
d67a460c-9241-445b-b932-7934dbe150d1
public void setValor_desconto(double valor_desconto) { this.valor_desconto = valor_desconto; }
2db0ad87-936e-4b3b-99de-4e2bffd695f6
public double getDesconto() { return desconto; }
4a2add8c-9305-438d-ae62-66f7d085a288
public void setDesconto(double desconto) { this.desconto = desconto; }
eeeeb95b-e30a-4893-b7ed-57be0e9b5557
public double getPercentual() { return percentual; }
c4c299eb-d8ba-4cf1-adeb-7e68451fc0fb
public void setPercentual(double percentual) { this.percentual = percentual; }
5279ffdf-2157-4db5-8d13-12b75f0e7640
@Override public boolean validar(Object object) { if(!(object instanceof String)) return false; else return validar((String)object); }
ef3a5a0f-ce7e-4e34-850d-d175f0f81d2b
@SuppressWarnings("finally") private boolean validar(final String param){ boolean isValido =true; try { new Double(param); } catch (NumberFormatException nfe) { isValido=false; } finally{ return isValido; } }
dc97ab5b-664b-4e36-ab7b-04a274ff1f3d
public static boolean valida(Object obj){ Class<?> classe = obj.getClass(); for (Method method : classe.getDeclaredMethods()){ method.setAccessible(true); // if (method.isAnnotationPresent(String2Integer.class)) } return true; }
90321625-b252-482b-ace6-6a79881cbfb7
@Override public boolean validar(Object wrapper) { return false; }
9e5fd82f-c464-43f5-b764-85045d624c25
public abstract boolean validar(Object object);
d6f583c2-7761-458a-8471-03a7eb96b269
@Override public double calculaDesconto(double valor, double percentual) { Preco preco=new Preco(); preco.setValor(valor); preco.setPercentual(percentual); preco.setDesconto( ( preco.getValor()/100 )*preco.getPercentual() ); preco.setValor_desconto( preco.getValor()-preco.getDesconto() ); return preco.getValor_desconto(); }
a38b43a7-df4b-4a30-bf19-873c0d0dcbc2
@Override public double calculaImc(double peso, double altura) { Imc imc =new Imc(); imc.setPeso(peso); imc.setAltura(altura); imc.setImc( imc.getPeso()/( imc.getAltura()*imc.getAltura() ) ); return imc.getImc(); }
a9700343-388d-4c31-96fe-2013844a201a
public abstract double calculaDesconto(double valor,double percentual);
b012f51f-4afa-4aa3-8be2-3bab76c414ab
public abstract double calculaImc(double pelo,double altura);
b507ff2a-3e00-4e97-9775-77231698647d
public double calcularDesconto(double preco,double percentual);
a80f60f7-4aac-4088-9f28-21eb463befbb
@Override public double calcularDesconto(double preco, double percentual) { return ( preco - ( (preco/100) * percentual ) ); }
c35db078-52b1-45ae-91b7-a0b2d04f3aa8
private IDesconto getDesconto() { return getInstance(); }
4cf94f1d-7501-4408-8321-0387f76963fb
private IDesconto getInstance(){ if(desconto==null) return (desconto=DescontoFactory.getDesconto()); else return desconto; }
de4fc058-32ac-48b1-abad-b9e47baf25db
public double calculaDesconto(double preco,double percentual){ return getDesconto().calcularDesconto(preco, percentual); }
f34baf68-549a-4a1e-8313-0ec4424ccdfd
public static Desconto getDesconto(){ return new Desconto(); }
63c8b295-ede8-436c-af9b-36c8f7da3a46
public static void main( String[] args ) { System.out.println( "Hello World!" ); }
0fcc3812-8709-4d7f-a71a-bceec85a93c0
public AppTest( String testName ) { super( testName ); }
06328ad2-2f3c-4064-ab9e-6da85d8822a4
public static Test suite() { return new TestSuite( AppTest.class ); }
04b71aa5-b065-4006-8bef-a73719474807
public void testApp() { assertTrue( true ); }
4cf98886-48d1-4aac-a570-f166f21d5a56
public static void main( String[] args ) { System.out.println( "Hello World!" ); }
43c9734c-9ca2-45ea-aeff-e54aa20b9d81
public AppTest( String testName ) { super( testName ); }
92158fac-298b-4080-9cb3-4583f97b8029
public static Test suite() { return new TestSuite( AppTest.class ); }
0e15caa7-5c38-4522-92f9-86c5a28c6459
public void testApp() { assertTrue( true ); }
cf0cc372-ffe8-4d46-b3be-d916c35e3858
public Human(String name){ this.name=name; }
dc299523-a011-4dfa-bd41-039b4a114774
public Human(String name, int age){ this.name=name; this.age=age; }
abd3d9ef-95a9-446a-924b-35db90c1fa2d
public String GetName(){ return name; }
9a38efb5-105b-47c4-84f9-08932e6d3dc5
protected void Show(){ System.out.println(name+" "); }
bfb790fc-ff50-4323-b505-c8d358d14252
public Jury(String name, int age){ super(name,age); }
8c9b862b-0525-4bca-adbd-16b11df606ad
public Jury(String name){ super(name); }
9331ea4e-8841-4f01-886b-e3ea203c4ebd
public void SetDiscipline(SportDiscipline sport){ this.sport=sport; }
f50cdbc3-d141-4ca8-a3b8-ee13ee32715b
public void StartCompetition(){ sport.Compete(); }
501ab80f-2bb3-49ba-863c-8326e7f595d0
public void TotalCompetition(){ sport.Print(); CmpWR ( ((Sportsman)(sport.GetSportsmen().get(0))).GetResult() ); System.out.println("the main jury member is "+name); }
a1e937ff-aea5-4568-992d-9f7f59394be3
public void CmpWR (double res){ if (res<sport.GetWorldRecord()){ sport.SetWorldRecord(res); System.out.println("New WR is "+res); } }
146affcc-f094-405d-b4cd-53dde69508be
public Sportsman (String name, int age){ super(name,age); }
30e74045-a884-442d-aba4-ce2c8a049799
public Sportsman (String name){ super(name); }
a2af595e-ba4e-4c2c-a863-71b6812544ff
public void SetForces(double force){ forces=force; }
b2796502-4659-4045-8aa4-4b945d7742d8
public void SetPlace(int place){ this.place=place; }
ae60e577-d2bd-4746-a224-de9fcd91a177
public int GetPlace() { return place; }
13f19fc5-7d64-45c4-9a00-c4d8720ae5bd
public abstract void Perform();
0540ddf9-8f7e-4a7d-b672-1b1fb1df7a7a
public double GetResult (){ return result; }
8bbdd85d-4a10-4a0c-b420-14a583b30893
public void Print(){ System.out.println(place+" "+name+" "+result); }
27d42d23-0353-4d72-8a22-6bb08f4e4dd1
public SportsmanShortTrack (String name){ super(name); }
7a97652f-7f8b-4097-8532-42837b4450c7
public void Perform(){ this.time=forces; this.result=forces; }
7efe540f-6143-4556-b5e9-85d71a1aea3a
public double GetResult () { return time; }
73a8588d-55c1-4607-9a47-a27a215919b0
public int compareTo (Object obj){ int res=0; if (time > ( (SportsmanShortTrack) obj).time){ res=1; }else{ if (time < ( (SportsmanShortTrack) obj).time){ res=-1; } } return res; }
392f850f-81dc-45f1-8272-0e496ed1f6ec
public ArrayList GetSportsmen() { return sportsmen; }
1476ff2f-af4f-463e-bc98-e8a8af93b9b0
public void AddSportsmen(Sportsman s){ sportsmen.add(s); }
1b69ff9a-1f63-4ab3-9210-0627f2f857e1
public double GetWorldRecord() { return worldRecord; }
c4578468-9bca-4e8f-b0ee-4d1791b577fb
public void SetWorldRecord(double worldRecord) { this.worldRecord = worldRecord; }
457f0e26-8ddc-4b1b-b88c-38c6de53e4ce
public void Compete(){ int max=sportsmen.size(); for (int i=0; i<max; i++){ ((Sportsman)sportsmen.get(i)).Perform(); } }
35c7544c-9039-4b6f-bb90-4ca80b5e5982
public void Print(){ }
9e798fe3-c3be-4349-a92c-85737966221a
public ShortTrack(int distance, String stage){ //super(); this.distance=distance; this.stage=stage; sportsmen=new ArrayList<Sportsman>(); }
410e28b3-6d74-4ad0-a8f1-52efe8950dec
public void Compete(){ super.Compete(); Collections.sort(sportsmen); int max=sportsmen.size(); for (int i=0; i<max; i++){ ((Sportsman) (sportsmen.get(i))).SetPlace(i+1); } }
54ce6d42-3233-4fad-bf02-6c0183a31c6f
public void Print(){ System.out.println(distance+"m "+stage); int max=sportsmen.size(); for (int i=0; i<max; i++){ ((Sportsman)sportsmen.get(i)).Print(); } }
81a30485-d0cb-43d8-965d-53917c3ee410
public Competition(){ super("Competition"); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { } setSize(400, 250); final JLabel namelabel[] = new JLabel[7]; final JLabel timelabel[] = new JLabel[7]; final JLabel placelabel[] = new JLabel[7]; final SportsmanShortTrack S[]={new SportsmanShortTrack("Vladimir Grigoriev"),new SportsmanShortTrack("Victor An"), new SportsmanShortTrack("Shinke Knegt"), new SportsmanShortTrack("Dazin U"), new SportsmanShortTrack("Davun Sin"),new SportsmanShortTrack("Tyanu Han"), new SportsmanShortTrack("Semen Elistratov")}; S[1].SetForces(1.24102); S[0].SetForces(1.24868); S[2].SetForces(1.25611); S[3].SetForces(1.24239); S[5].SetForces(1.24490); S[6].SetForces(1.24239); S[4].SetForces(1.24215); final Jury J=new Jury("Peter Worte");//final is used inside the inner button listener class ShortTrack ST=new ShortTrack(1000,"final"); ST.SetWorldRecord(1.25); for (int i=0; i<S.length; i++){ ST.AddSportsmen(S[i]); namelabel[i]=new JLabel(S[i].GetName()); /*timelabel[i]=new JLabel(Double.toString(S[i].GetResult())); placelabel[i]=new JLabel(Integer.toString(S[i].GetPlace()));*/ timelabel[i]=new JLabel(Double.toString(0)); placelabel[i]=new JLabel(Integer.toString(0)); } J.SetDiscipline(ST); Container c = getContentPane(); JPanel centerPanel = new JPanel(new GridLayout(1,3)); JPanel panels[]=new JPanel[3]; centerPanel.setBorder(BorderFactory.createEtchedBorder()); c.add(centerPanel, BorderLayout.CENTER); panels[0]=new JPanel(new GridLayout(7,1)); panels[1]=new JPanel(new GridLayout(7,1)); panels[2]=new JPanel(new GridLayout(7,1)); for (int i=0; i<7; i++){ panels[0].add(placelabel[i]); panels[1].add(namelabel[i]); panels[2].add(timelabel[i]); } centerPanel.add(panels[0]); centerPanel.add(panels[1]); centerPanel.add(panels[2]); JButton btn = new JButton("start"); c.add(btn, BorderLayout.SOUTH); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { J.StartCompetition(); J.TotalCompetition(); Arrays.sort(S);//necessary for (int i=0; i<S.length; i++){ namelabel[i].setText(S[i].GetName()); timelabel[i].setText(Double.toString(S[i].GetResult())); placelabel[i].setText(Integer.toString(S[i].GetPlace())); } } }); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
95dc456d-fe15-4818-a0d9-b74e58c788ad
@Override public void actionPerformed(ActionEvent e) { J.StartCompetition(); J.TotalCompetition(); Arrays.sort(S);//necessary for (int i=0; i<S.length; i++){ namelabel[i].setText(S[i].GetName()); timelabel[i].setText(Double.toString(S[i].GetResult())); placelabel[i].setText(Integer.toString(S[i].GetPlace())); } }
204c6073-3423-4967-9817-11ebc89cd7dc
public void windowClosing(WindowEvent e) { System.exit(0); }
37b60323-a1fd-4b73-bc11-c508471f1057
public static void main (String args[]){ new Competition(); }
e7bcaed4-9f76-43e4-af95-afc7677590f2
public void addCustomer();
51fbeaa7-5cd5-44d2-8eb4-c309f316ab06
public String addCustomerReturn(String name);
62390496-910b-4f59-bd31-acd57d3533cf
public void addCustomerAround(String name);
5669bc7f-6836-4da6-ad64-80a184d73d2b
public void addCustomerThrowException() throws Exception;
9c09c54d-40ba-4866-a822-e2de5c0f5dfa
public void addCustomer() { System.out.println("Add customer method is running"); }
d3635aca-a33e-4ccd-9bac-0ed421a94d03
public String addCustomerReturn(String value) { System.out.println("Add customer Return method is running ......"); return value; }