blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
listlengths
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
listlengths
1
1
author_id
stringlengths
0
313
eaf65c86331930110a9345c8dcd3cf142343ca52
5b967962b45d5da00a37e348475ae659e4548d3a
/spring-hibernate-short/src/main/java/com/ozzy/springhibernateshort/exceptions/DataNotFoundException.java
84cc1cb06e85280c79012286aebde277cfa63ab1
[]
no_license
ogcastillo/spring-apps
55b27527ae0822491dd381d862820ab7b6527cda
60a773b2e867c6096f9276ab8621c09bbd61df6a
refs/heads/main
2023-06-27T22:50:00.843923
2021-07-30T16:01:05
2021-07-30T16:01:05
387,634,090
0
0
null
null
null
null
UTF-8
Java
false
false
187
java
package com.ozzy.springhibernateshort.exceptions; public class DataNotFoundException extends RuntimeException{ public DataNotFoundException(String msn){ super(msn); } }
[ "oswaldo.castillo@revature.net" ]
oswaldo.castillo@revature.net
2979fae60b61e7100d952dd70b7c47369e04dd59
be73270af6be0a811bca4f1710dc6a038e4a8fd2
/crash-reproduction-moho/results/XWIKI-13031-1-19-NSGA_II-LineCoverage:ExceptionType:StackTraceSimilarity/org/xwiki/search/solr/internal/reference/SolrEntityReferenceResolver_ESTest.java
2f485f6e792a2b4aafec32f2739d078bd7d1acd1
[]
no_license
STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application
cf118b23ecb87a8bf59643e42f7556b521d1f754
3bb39683f9c343b8ec94890a00b8f260d158dfe3
refs/heads/master
2022-07-29T14:44:00.774547
2020-08-10T15:14:49
2020-08-10T15:14:49
285,804,495
0
0
null
null
null
null
UTF-8
Java
false
false
1,939
java
/* * This file was automatically generated by EvoSuite * Tue Jan 21 17:38:10 UTC 2020 */ package org.xwiki.search.solr.internal.reference; import org.junit.Test; import static org.junit.Assert.*; import static org.evosuite.shaded.org.mockito.Mockito.*; import static org.evosuite.runtime.EvoAssertions.*; import org.apache.solr.common.SolrDocument; import org.evosuite.runtime.EvoRunner; import org.evosuite.runtime.EvoRunnerParameters; import org.evosuite.runtime.ViolatedAssumptionAnswer; import org.evosuite.runtime.javaee.injection.Injector; import org.junit.runner.RunWith; import org.xwiki.model.EntityType; import org.xwiki.model.internal.reference.ExplicitStringEntityReferenceResolver; import org.xwiki.model.reference.EntityReferenceResolver; import org.xwiki.search.solr.internal.reference.SolrEntityReferenceResolver; @RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true) public class SolrEntityReferenceResolver_ESTest extends SolrEntityReferenceResolver_ESTest_scaffolding { @Test(timeout = 4000) public void test0() throws Throwable { SolrEntityReferenceResolver solrEntityReferenceResolver0 = new SolrEntityReferenceResolver(); EntityReferenceResolver<ExplicitStringEntityReferenceResolver> entityReferenceResolver0 = (EntityReferenceResolver<ExplicitStringEntityReferenceResolver>) mock(EntityReferenceResolver.class, new ViolatedAssumptionAnswer()); Injector.inject(solrEntityReferenceResolver0, (Class<?>) SolrEntityReferenceResolver.class, "explicitReferenceEntityReferenceResolver", (Object) entityReferenceResolver0); SolrDocument solrDocument0 = new SolrDocument(); EntityType entityType0 = EntityType.BLOCK; Object[] objectArray0 = new Object[5]; solrDocument0.put("wiki", (Object) solrEntityReferenceResolver0); // Undeclared exception! solrEntityReferenceResolver0.resolve(solrDocument0, entityType0, objectArray0); } }
[ "pouria.derakhshanfar@gmail.com" ]
pouria.derakhshanfar@gmail.com
4f7d027a3c12a57ded89511cef54dffb6988328e
065c1f648e8dd061a20147ff9c0dbb6b5bc8b9be
/ant_cluster/14162/src_3.java
fd8b406524c285d7b7385d5f5c459f7c058a6daf
[]
no_license
martinezmatias/GenPat-data-C3
63cfe27efee2946831139747e6c20cf952f1d6f6
b360265a6aa3bb21bd1d64f1fc43c3b37d0da2a4
refs/heads/master
2022-04-25T17:59:03.905613
2020-04-15T14:41:34
2020-04-15T14:41:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
11,923
java
/* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.tools.ant.types; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.StringTokenizer; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectComponent; /** * Named collection of include/exclude tags. <p> * * Moved out of MatchingTask to make it a standalone object that could be * referenced (by scripts for example). * * @author Arnout J. Kuiper <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a> * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org"> * stefano@apache.org</a> * @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a> * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> */ public class PatternSet extends ProjectComponent { private ArrayList m_includeList = new ArrayList(); private ArrayList m_excludeList = new ArrayList(); private ArrayList m_includesFileList = new ArrayList(); private ArrayList m_excludesFileList = new ArrayList(); public PatternSet() { super(); } /** * Sets the set of exclude patterns. Patterns may be separated by a comma or * a space. * * @param excludes the string containing the exclude patterns */ public void setExcludes( String excludes ) { if( excludes != null && excludes.length() > 0 ) { StringTokenizer tok = new StringTokenizer( excludes, ", ", false ); while( tok.hasMoreTokens() ) { createExclude().setName( tok.nextToken() ); } } } /** * Sets the name of the file containing the excludes patterns. * * @param excludesFile The file to fetch the exclude patterns from. * @exception TaskException Description of Exception */ public void setExcludesfile( File excludesFile ) { createExcludesFile().setName( excludesFile.getAbsolutePath() ); } /** * Sets the set of include patterns. Patterns may be separated by a comma or * a space. * * @param includes the string containing the include patterns */ public void setIncludes( String includes ) { if( includes != null && includes.length() > 0 ) { StringTokenizer tok = new StringTokenizer( includes, ", ", false ); while( tok.hasMoreTokens() ) { createInclude().setName( tok.nextToken() ); } } } /** * Sets the name of the file containing the includes patterns. * * @param includesFile The file to fetch the include patterns from. * @exception TaskException Description of Exception */ public void setIncludesfile( File includesFile ) { createIncludesFile().setName( includesFile.getAbsolutePath() ); } /** * Returns the filtered include patterns. */ public String[] getExcludePatterns( Project p ) throws TaskException { readFiles( p ); return makeArray( m_excludeList ); } /** * Returns the filtered include patterns. * * @param p Description of Parameter * @return The IncludePatterns value */ public String[] getIncludePatterns( Project p ) throws TaskException { readFiles( p ); return makeArray( m_includeList ); } /** * Adds the patterns of the other instance to this set. */ protected void append( PatternSet other ) throws TaskException { String[] incl = other.getIncludePatterns( null ); if( incl != null ) { for( int i = 0; i < incl.length; i++ ) { createInclude().setName( incl[ i ] ); } } String[] excl = other.getExcludePatterns( null ); if( excl != null ) { for( int i = 0; i < excl.length; i++ ) { createExclude().setName( excl[ i ] ); } } } /** * add a name entry on the exclude list * * @return Description of the Returned Value */ public NameEntry createExclude() { return addPatternToList( m_excludeList ); } /** * add a name entry on the exclude files list * * @return Description of the Returned Value */ public NameEntry createExcludesFile() { return addPatternToList( m_excludesFileList ); } /** * add a name entry on the include list */ public NameEntry createInclude() { return addPatternToList( m_includeList ); } /** * add a name entry on the include files list */ public NameEntry createIncludesFile() { return addPatternToList( m_includesFileList ); } public String toString() { return "patternSet{ includes: " + m_includeList + " excludes: " + m_excludeList + " }"; } /** * helper for FileSet. */ boolean hasPatterns() { return m_includesFileList.size() > 0 || m_excludesFileList.size() > 0 || m_includeList.size() > 0 || m_excludeList.size() > 0; } /** * add a name entry to the given list */ private NameEntry addPatternToList( final ArrayList list ) { final NameEntry result = new NameEntry(); list.add( result ); return result; } /** * Convert a vector of NameEntry elements into an array of Strings. */ private String[] makeArray( final ArrayList list ) { if( list.size() == 0 ) { return null; } final ArrayList tmpNames = new ArrayList(); for( Iterator e = list.iterator(); e.hasNext(); ) { final NameEntry ne = (NameEntry)e.next(); final String pattern = ne.evalName( null ); if( pattern != null && pattern.length() > 0 ) { tmpNames.add( pattern ); } } final String[] result = new String[ tmpNames.size() ]; return (String[])tmpNames.toArray( result ); } /** * Read includesfile ot excludesfile if not already done so. */ private void readFiles( Project p ) throws TaskException { if( m_includesFileList.size() > 0 ) { Iterator e = m_includesFileList.iterator(); while( e.hasNext() ) { NameEntry ne = (NameEntry)e.next(); String fileName = ne.evalName( p ); if( fileName != null ) { File inclFile = resolveFile( fileName ); if( !inclFile.exists() ) throw new TaskException( "Includesfile " + inclFile.getAbsolutePath() + " not found." ); readPatterns( inclFile, m_includeList, p ); } } m_includesFileList.clear(); } if( m_excludesFileList.size() > 0 ) { Iterator e = m_excludesFileList.iterator(); while( e.hasNext() ) { NameEntry ne = (NameEntry)e.next(); String fileName = ne.evalName( p ); if( fileName != null ) { File exclFile = resolveFile( fileName ); if( !exclFile.exists() ) throw new TaskException( "Excludesfile " + exclFile.getAbsolutePath() + " not found." ); readPatterns( exclFile, m_excludeList, p ); } } m_excludesFileList.clear(); } } /** * Reads path matching patterns from a file and adds them to the includes or * excludes list (as appropriate). * * @param patternfile Description of Parameter * @param patternlist Description of Parameter * @param p Description of Parameter * @exception TaskException Description of Exception */ private void readPatterns( File patternfile, ArrayList patternlist, Project p ) throws TaskException { BufferedReader patternReader = null; try { // Get a FileReader patternReader = new BufferedReader( new FileReader( patternfile ) ); // Create one NameEntry in the appropriate pattern list for each // line in the file. String line = patternReader.readLine(); while( line != null ) { if( line.length() > 0 ) { line = p.replaceProperties( line ); addPatternToList( patternlist ).setName( line ); } line = patternReader.readLine(); } } catch( IOException ioe ) { String msg = "An error occured while reading from pattern file: " + patternfile; throw new TaskException( msg, ioe ); } finally { if( null != patternReader ) { try { patternReader.close(); } catch( IOException ioe ) { //Ignore exception } } } } /** * inner class to hold a name on list. "If" and "Unless" attributes may be * used to invalidate the entry based on the existence of a property * (typically set thru the use of the Available task). */ public class NameEntry { private String ifCond; private String name; private String unlessCond; public void setIf( String cond ) { ifCond = cond; } public void setName( String name ) { this.name = name; } public void setUnless( String cond ) { unlessCond = cond; } public String getName() { return name; } public String evalName( Project p ) { return valid( p ) ? name : null; } public String toString() { StringBuffer buf = new StringBuffer( name ); if( ( ifCond != null ) || ( unlessCond != null ) ) { buf.append( ":" ); String connector = ""; if( ifCond != null ) { buf.append( "if->" ); buf.append( ifCond ); connector = ";"; } if( unlessCond != null ) { buf.append( connector ); buf.append( "unless->" ); buf.append( unlessCond ); } } return buf.toString(); } private boolean valid( Project p ) { if( ifCond != null && p.getProperty( ifCond ) == null ) { return false; } else if( unlessCond != null && p.getProperty( unlessCond ) != null ) { return false; } return true; } } }
[ "375833274@qq.com" ]
375833274@qq.com
ec035480ad6da4a03a05b5a0e19af12caaadc6d9
d0bc3e382e8c69bfc6bad8f18b7fea8cd0fb16ff
/src/main/java/stackjava.java
e0056afa77433ff7008c4b32acd4755941c5b552
[]
no_license
kannanpvm007/servlet1
1d48b5ab0ab4d7cca58fdfb93d9cce5274efee05
87ab571da8ed96205805050b97a34af51f616fc3
refs/heads/master
2022-07-01T18:38:08.072673
2019-05-29T12:40:36
2019-05-29T12:40:36
188,415,051
0
0
null
2020-10-13T13:26:07
2019-05-24T12:04:50
Java
UTF-8
Java
false
false
4,546
java
import java.io.IOException; import java.sql.Connection; import java.sql.Date; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.text.SimpleDateFormat; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.mysql.fabric.xmlrpc.base.Value; // import com.mysql.jdbc.PreparedStatement; /** * stackjava */ public class stackjava extends HttpServlet { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // super.doPost(req, resp); try { String creat = " CREATE TABLE IF NOT EXISTS Teade(TradeID INTEGER (15),ucccode VARCHAR(12),scrip VARCHAR(10),tradedate VARCHAR(15),tradetype CHAR(1), quantity INTEGER (8),price INTEGER (8)) "; Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/stock", "root", ""); Statement st = con.createStatement(); boolean rs = st.execute(creat); System.out.println("table create"); String TradeIDi = req.getParameter("tradeid"); String ucccode = req.getParameter("ucccode"); String scrip = req.getParameter("scrip"); String tradedated = req.getParameter("tradedate"); String tradetypeC = req.getParameter("tradetype"); String quantityI = req.getParameter("quantity"); String priceI = req.getParameter("price"); // convation int TradeID = Integer.parseInt(TradeIDi); System.out.println(TradeID); // Date tradedate= (Date) new SimpleDateFormat("dd-MM-yyyy").parse(tradedated); // Date tradedate =new SimpleDateFormat("dd/mm/yyy").parse(tradedated); char tradetype = tradetypeC.charAt(0); int quantity = Integer.parseInt(quantityI); int price = Integer.parseInt(priceI); /* System.out.println(TradeID + "," + ucccode + "," + scrip + "," + tradedated + "," + tradetype + "," + quantity + "," + price); String ins="INSERT INTO Teade( TradeID , ucccode , scrip , tradedate , tradetype , quantity , price ) "+"Value(?,?,?,?,?,?,?)"; Connection con3=DriverManager.getConnection("jdbc:mysql://localhost:3306/stock","root","" ); //Statement st= con.createStatement(); //boolean rs=st.execute(ins); PreparedStatement ps= con3.prepareStatement(ins); ps.setInt(1, TradeID); ps.setString(2, ucccode); ps.setString(3, scrip); ps.setString(4, tradedated); //ps.setString(1,c+" ")); ps.setString(5, (Character)tradetype); ps.setInt(6, quantity); ps.setInt(7, price); ps.executeUpdate(); System.out.println("table INSERTed "); */ //String in1= "INSERT INTO teams ( TradeID ,ucccode , scrip , tradedate , tradetype , quantity , price ) VALUES (TradeID + "," + ucccode + "," + scrip + "," + "," + tradedated + "," + tradetype + "," + quantity + "," + price + "," + quantity + "," + price )"; String insertQuery = "INSERT INTO Teade(TradeID, Ucccode, Scrip, tradedate, tradetype, quantity, price) VALUES (" + TradeID + ",'" + ucccode + "'" + ",'" + scrip + "'" + ",'" + tradedated + "'" + ",'" + tradetype + "'," + quantity + "," + price + ")"; String creat1 = "INSERT INTO `teams`(`TradeID`, `ucccode`, `scrip`, `tradedate`, `tradetype`, `quantity`, `price`) VALUES ([value-1],[value-2],[value-3],[value-4],[value-5],[value-6],[value-7]) "; Connection con1 = DriverManager.getConnection("jdbc:mysql://localhost:3306/stock", "root", ""); Statement st1 = con1.createStatement(); boolean rs1 = st1.execute(insertQuery); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } public static void INSERT() throws SQLException { } }
[ "kannan.r@kgisl.com" ]
kannan.r@kgisl.com
3dba2f4f41d944db7c7718feacf34cfb442c590f
9508c3b51682d07935e5c54f4e9680392e6e5d3f
/app/src/main/java/app/zuil/com/glidedemo/PriorityActivity.java
7e3da3bf3e9c25b3b24058d2b9ae9c7570ed0923
[ "Apache-2.0" ]
permissive
zyj1609wz/GlideDemo
1886ece286898c6aea3988acef6427e2c32a2d95
ac99d7475f22c09cf2ba88d84a449109d07034ba
refs/heads/master
2020-04-12T06:40:13.146710
2016-09-01T02:41:43
2016-09-01T02:41:43
60,667,689
6
3
null
null
null
null
UTF-8
Java
false
false
1,223
java
package app.zuil.com.glidedemo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ImageView; import com.bumptech.glide.Glide; import com.bumptech.glide.Priority; public class PriorityActivity extends AppCompatActivity { private ImageView imageView1 , imageView2 , imageView3 ; String url1 = "http://o91woxvtr.bkt.clouddn.com/load3.jpg" ; String url2 = "http://o91woxvtr.bkt.clouddn.com/load2.jpg" ; String url3 = "http://o91woxvtr.bkt.clouddn.com/load1.jpg" ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_priority); imageView1 = (ImageView) findViewById( R.id.image1 ); imageView2 = (ImageView) findViewById( R.id.image2 ); imageView3 = (ImageView) findViewById( R.id.image3 ); Glide.with( this).load( url1).priority(Priority.LOW ).into( imageView1 ) ; Glide.with( this).load( url2).priority(Priority.LOW ).into( imageView2 ) ; Glide.with( this).load( url3).priority(Priority.HIGH ).into( imageView3 ) ; // Glide.with(this).load( url3 ).thumbnail(0.1f).into( imageView3 ); } }
[ "362299465@qq.com" ]
362299465@qq.com
5aa288bdb704a64e9c13755a0601fb2aad56b2cb
51346abc0506e813ee593f013f0999f47341fab9
/app/src/main/java/com/adorkable/acientdict/ui/base/BaseViewActivity.java
5f902e1f034814a5ead6fd0a489432424ceedee6
[]
no_license
qiang/AcientDict
c81924343db0e96a21090a0ff44120248a831493
97b11af2c532b0357c14056470a840bf1f6cb631
refs/heads/master
2022-02-13T20:27:00.999803
2019-08-28T03:04:30
2019-08-28T03:04:30
57,967,603
1
0
null
null
null
null
UTF-8
Java
false
false
769
java
package com.adorkable.acientdict.ui.base; import android.os.Bundle; import com.adorkable.acientdict.mvp.IView; /** * Author: liuqiang * Time: 2018-12-14 11:25 * Description: 既然某个Activity实现了 IView 接口,那么理论来说他肯定有Presenter */ public abstract class BaseViewActivity<P> extends BaseActivity implements IView { protected P mPresenter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPresenter = setPresenter(); } @Override public void showLoading(String msg) { } @Override public void hideLoading() { } @Override public void showError(String msg) { } public abstract P setPresenter(); }
[ "niyingxunzong@gmail.com" ]
niyingxunzong@gmail.com
373a22458503ae2dc6927e089e96a2f1108fcb55
16121f2bffd9c1711941c992f77ae7617dab9e5a
/src/main/java/com/cntv/propertiestest/SpecialProperties.java
32c68b9672ac0b93303099d4c437caa2e535c33f
[]
no_license
757350134/springboot
2b024a961708cafc43d8d3217d8915e917b21833
63e6d785452509bb1055bb332a371eef0790d69e
refs/heads/master
2021-05-01T17:19:27.432899
2017-01-19T08:00:21
2017-01-19T08:00:21
79,425,242
0
0
null
null
null
null
UTF-8
Java
false
false
1,095
java
package com.cntv.propertiestest; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; @Configuration @ConfigurationProperties(locations="classpath:server.properties",prefix = "server.info") public class SpecialProperties { private String address; private String username; private String password; //getter and setter methods public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String toString() { return "SpecialProperties{" + "address='" + address + '\'' + ", username='" + username + '\'' + ", password='" + password + '\'' + '}'; } }
[ "757350134@qq.com" ]
757350134@qq.com
0197468b19bb75929e35a144ab1b7bd958ee58bb
5901ad1f5f419f87ee82be4bdfa1870bc252eb0d
/src/main/java/com/controller/sys/RoleController.java
3d5e19515965c955e584fe069cfb8a90d94317bd
[]
no_license
snowflake09/ncov2019
7fcc438b7f75331140c284b09480d0bf5dbf02fe
9350ae7c99e435dcd952cb415649911f5693a2e3
refs/heads/master
2022-12-25T09:22:52.735305
2020-02-17T01:50:38
2020-02-17T01:50:38
239,510,388
5
0
null
2022-12-16T06:44:59
2020-02-10T12:48:38
JavaScript
UTF-8
Java
false
false
4,339
java
package com.controller.sys; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpSession; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import com.condition.sys.RoleCondition; import com.dto.pagetable.PageModel; import com.dto.sys.RoleDto; import com.dto.sys.RoleResourceDto; import com.service.sys.RoleService; import com.utils.easyui.Json; import com.utils.easyui.Tree; import com.utils.em.CodeType; @Controller @RequestMapping("/sys/role/") public class RoleController { @Resource private RoleService roleService; @RequestMapping("listPage") public ModelAndView listPage(ModelAndView modelAndView){ modelAndView.setViewName("sys/role/roleList"); return modelAndView; } @RequestMapping("addPage") public ModelAndView addPage(ModelAndView modelAndView){ modelAndView.setViewName("sys/role/roleAdd"); return modelAndView; } @RequestMapping("editPage") public ModelAndView editPage(ModelAndView modelAndView,Long id){ RoleDto roleDto = roleService.findById(id); modelAndView.addObject("roleDto", roleDto); modelAndView.setViewName("sys/role/roleEdit"); return modelAndView; } @RequestMapping("grantPage") public ModelAndView grantPage(ModelAndView modelAndView,Long id){ modelAndView.setViewName("sys/role/grantPage"); return modelAndView; } /** * 获取角色列表 * @param pageModel * @param roleDto * @return * @throws Exception * @author LiQiang * @date 2016年11月15日 */ @RequestMapping("/dataGrid") @ResponseBody public PageModel dataGrid(PageModel pageModel,RoleCondition roleCondition){ try { return roleService.dataGrid(roleCondition); } catch (Exception e) { e.printStackTrace(); } return pageModel; } /** * 保存角色 * @param roleDto * @param session * @return * @throws Exception * @author LiQiang * @date 2016年11月15日 */ @RequestMapping("/save") @ResponseBody public Json save(RoleDto roleDto, HttpSession session){ Json j = new Json(); //SessionInfo sessionInfo = (SessionInfo) session.getAttribute(CommonContants.SESSION_INFO); try { //dictionaryDto.setCreateUser(sessionInfo.getUsername()); roleService.save(roleDto); j.setSuccess(true); j.setMsg(CodeType.SUCCESS.getLabel()); } catch (Exception e) { e.printStackTrace(); j.setMsg(CodeType.FAIL.getLabel()); } return j; } /** * 编辑角色 * @param roleDto * @param session * @return * @throws Exception * @author LiQiang * @date 2016年11月15日 */ @RequestMapping("/edit") @ResponseBody public Json edit(RoleDto roleDto, HttpSession session){ Json j = new Json(); //SessionInfo sessionInfo = (SessionInfo) session.getAttribute(CommonContants.SESSION_INFO); try { //dictionaryDto.setUpdateUser(sessionInfo.getUsername()); roleService.update(roleDto); j.setSuccess(true); j.setMsg(CodeType.SUCCESS.getLabel()); } catch (Exception e) { j.setMsg(CodeType.FAIL.getLabel()); } return j; } /** * 删除角色 * @param id * @return * @throws Exception * @author LiQiang * @date 2016年11月15日 */ @RequestMapping("/delete") @ResponseBody public Json delete(Long id){ Json j = new Json(); try { roleService.delete(id); j.setSuccess(true); j.setMsg(CodeType.SUCCESS.getLabel()); } catch (Exception e) { j.setMsg(CodeType.FAIL.getLabel()); } return j; } /** * 获取权限列表 * @param id * @return * @author LiQiang * @date 2016年11月15日 */ @RequestMapping(value="selectPermissionList") @ResponseBody public List<Tree> selectPermissionList(Long id){ return roleService.selectPermissionListByRoleId(id); } /** * 给角色授权 * @param roleResourceDto * @return * @throws Exception * @author LiQiang * @date 2016年11月15日 */ @RequestMapping("/grant") @ResponseBody public Json grant(RoleResourceDto roleResourceDto){ Json j = new Json(); try { roleService.saveGrant(roleResourceDto); j.setSuccess(true); j.setMsg(CodeType.SUCCESS.getLabel()); } catch (Exception e) { e.printStackTrace(); j.setMsg(CodeType.FAIL.getLabel()); } return j; } }
[ "fangqikai@kjmai.cn" ]
fangqikai@kjmai.cn
bb92de86f820a5dc4c9e7144e3d19a0adf03eaa3
2d1f125578ec412defe1a279c5e487b885e685b5
/src/main/java/org/onvif/ver10/schema/IrCutFilterAutoBoundaryType.java
27725a1688b11408968905c0728837ba1175821a
[]
no_license
fengxiaobu/liveclient
3b43ee7b474026c1018a22a6a1be8c89c1c0eb42
a28a0129d244cd49d72b4b781157ac9f964091fa
refs/heads/master
2020-04-11T20:07:15.175695
2018-12-17T01:54:45
2018-12-17T01:54:45
162,060,421
1
1
null
null
null
null
UTF-8
Java
false
false
1,755
java
// // Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5-2 generiert // Siehe <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // �nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. // Generiert: 2014.02.04 um 12:22:03 PM CET // package org.onvif.ver10.schema; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType; /** * <p> * Java-Klasse f�r IrCutFilterAutoBoundaryType. * * <p> * Das folgende Schemafragment gibt den erwarteten Content an, der in dieser Klasse enthalten ist. * <p> * * <pre> * <simpleType name="IrCutFilterAutoBoundaryType"> * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> * <enumeration value="Common"/> * <enumeration value="ToOn"/> * <enumeration value="ToOff"/> * <enumeration value="Extended"/> * </restriction> * </simpleType> * </pre> */ @XmlType(name = "IrCutFilterAutoBoundaryType") @XmlEnum public enum IrCutFilterAutoBoundaryType { @XmlEnumValue("Common") COMMON("Common"), @XmlEnumValue("ToOn") TO_ON("ToOn"), @XmlEnumValue("ToOff") TO_OFF("ToOff"), @XmlEnumValue("Extended") EXTENDED("Extended"); private final String value; IrCutFilterAutoBoundaryType(String v) { value = v; } public static IrCutFilterAutoBoundaryType fromValue(String v) { for (IrCutFilterAutoBoundaryType c : IrCutFilterAutoBoundaryType.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); } public String value() { return value; } }
[ "luopanfeng@benefitech.cn" ]
luopanfeng@benefitech.cn
7a1031817331607dafb41578a7b595cb754b9bf4
7161d1d63364e1aa0524708e1fd50910f4c059f8
/app/src/main/java/com/example/gpy/whiteboard/utils/StoreUtil.java
9199091e8cf38023a00872cdaeb0c59bd072b241
[]
no_license
GitHubSMXY/WhiteBoard
33182c9a24800a65667faf8da287f4f122489444
1facafd5074824c32622c31db5bcf78267d1f0bc
refs/heads/master
2020-08-11T13:00:22.205129
2019-10-12T06:28:21
2019-10-12T06:28:21
214,569,100
0
0
null
2019-10-12T03:13:58
2019-10-12T03:13:58
null
UTF-8
Java
false
false
9,004
java
package com.example.gpy.whiteboard.utils; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.text.TextUtils; import android.util.Log; import com.example.gpy.whiteboard.R; import com.github.guanpy.wblib.bean.DrawPenPoint; import com.github.guanpy.wblib.bean.DrawPenStr; import com.github.guanpy.wblib.bean.DrawPoint; import com.github.guanpy.wblib.bean.Point; import com.github.guanpy.wblib.bean.WhiteBoardPoint; import com.github.guanpy.wblib.bean.WhiteBoardPoints; import com.github.guanpy.wblib.utils.AppContextUtil; import com.github.guanpy.wblib.utils.OperationUtils; import com.google.gson.Gson; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.UUID; /** * 存储空间工具类 * Created by gpy on 2015/8/2. */ public class StoreUtil { private static final String TAG = "StoreUtil"; private static final String CHARSET = "UTF-8"; public static final String CACHE_DIR = "WhiteBoard"; private static final String CACHE_DIR_PHOTO = "photo"; private static final String PHOTO_FORMAT_PNG = ".png"; private static final String CACHE_DIR_WB = "wb"; private static final String WB_FORMAT = ".wb"; /** * 获取保存路径 */ public static String getPhotoSavePath() { return getPhotoPath() + File.separator + UUID.randomUUID().toString() + PHOTO_FORMAT_PNG; } public static String getPhotoPath() { return SdCardStatus.getDefaulstCacheDirInSdCard() + File.separator + CACHE_DIR_PHOTO; } /** * 获取保存路径 */ public static String getWbSavePath() { return getWbPath() + File.separator + UUID.randomUUID().toString() + WB_FORMAT; } public static String getWbPath() { return SdCardStatus.getDefaulstCacheDirInSdCard() + File.separator + CACHE_DIR_WB; } /** * 存储白板集 */ public static void saveWhiteBoardPoints() { WhiteBoardPoints whiteBoardPoints = OperationUtils.getInstance().getWhiteBoardPoints(); if (whiteBoardPoints == null || whiteBoardPoints.getWhiteBoardPoints() == null || whiteBoardPoints.getWhiteBoardPoints().isEmpty()) { return; } for (WhiteBoardPoint whiteBoardPoint : whiteBoardPoints.getWhiteBoardPoints()) {//清除绘画路径,保留字符串形式就行 for (DrawPoint drawPoint : whiteBoardPoint.getSavePoints()) { if (drawPoint.getType() == OperationUtils.DRAW_PEN) { drawPoint.setDrawPen(null); } } } String strJson = new Gson().toJson(whiteBoardPoints); StoreUtil.write(strJson, getWbSavePath()); convertWhiteBoardPoints(whiteBoardPoints); OperationUtils.getInstance().setWhiteBoardPoints(whiteBoardPoints); ToastUtils.showToast(AppContextUtil.getContext(), AppContextUtil.getContext().getString(R.string.white_board_save_sucess)); } /** * 读取白板集 */ public static void readWhiteBoardPoints(String filePath) { String strJson = StoreUtil.read(filePath); if (!TextUtils.isEmpty(strJson)) { WhiteBoardPoints whiteBoardPoints = new Gson().fromJson(strJson, WhiteBoardPoints.class); convertWhiteBoardPoints(whiteBoardPoints); OperationUtils.getInstance().setWhiteBoardPoints(whiteBoardPoints); } } /** * 从json字符中将Path、Paint系统类转换出来 */ public static void convertWhiteBoardPoints(WhiteBoardPoints whiteBoardPoints) { for (WhiteBoardPoint whiteBoardPoint : whiteBoardPoints.getWhiteBoardPoints()) { whiteBoardPoint.getDeletePoints().clear(); for (DrawPoint drawPoint : whiteBoardPoint.getSavePoints()) { if (drawPoint.getType() == OperationUtils.DRAW_PEN) { DrawPenStr drawPenStr = drawPoint.getDrawPenStr(); Paint paint = new Paint(); paint.setAntiAlias(true);//是否使用抗锯齿功能,会消耗较大资源,绘制图形速度会变慢 paint.setDither(true);// 设定是否使用图像抖动处理,会使绘制出来的图片颜色更加平滑和饱满,图像更加清晰 paint.setColor(drawPenStr.getColor());//设置绘制的颜色 paint.setStyle(Paint.Style.STROKE);//设置画笔的样式 paint.setStrokeJoin(Paint.Join.ROUND);//设置绘制时各图形的结合方式,如平滑效果等 paint.setStrokeCap(Paint.Cap.ROUND);//当画笔样式为STROKE或FILL_OR_STROKE时,设置笔刷的图形样式,如圆形样式 Cap.ROUND,或方形样式Cap.SQUARE paint.setStrokeWidth(drawPenStr.getStrokeWidth());//当画笔样式为STROKE或FILL_OR_STROKE时,设置笔刷的粗细度 if (drawPenStr.getIsEraser()) { paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));//擦除模式 } Path path = new Path(); path.moveTo(drawPenStr.getMoveTo().getX(), drawPenStr.getMoveTo().getY()); for (int i = 0; i < drawPenStr.getQuadToA().size(); i++) { Point pointA = drawPenStr.getQuadToA().get(i); Point pointB = drawPenStr.getQuadToB().get(i); path.quadTo(pointA.getX(), pointA.getY(), pointB.getX(), pointB.getY()); } path.lineTo(drawPenStr.getLineTo().getX(), drawPenStr.getLineTo().getY()); path.offset(drawPenStr.getOffset().getX(), drawPenStr.getOffset().getY()); DrawPenPoint drawPenPoint = new DrawPenPoint(); drawPenPoint.setPaint(paint); drawPenPoint.setPath(path); drawPoint.setDrawPen(drawPenPoint); } } } } /** * 保存内容到文件中 */ public static void write(String strWb, String path) { if (TextUtils.isEmpty(strWb) || TextUtils.isEmpty(path)) { Log.d(TAG, "Trying to save null or 0 length strWb or path"); return; } File toFile = new File(path); if (!toFile.getParentFile().exists()) { toFile.getParentFile().mkdirs(); } if (toFile.exists()) { toFile.delete(); } try { toFile.createNewFile(); } catch (IOException e) { Log.e(TAG, "IOException:" + e.getMessage()); toFile = null; } finally { if (null != toFile && null != strWb) { OutputStream outStream = null; try { outStream = new FileOutputStream(toFile); } catch (FileNotFoundException e) { Log.d(TAG, "FileNotFoundException:" + e.getMessage()); outStream = null; } finally { if (null != outStream) { try { outStream.write(strWb.getBytes("utf-8")); outStream.flush(); } catch (IOException e) { Log.e(TAG, "IOException:" + e.getMessage()); } finally { try { if (null != outStream) { outStream.close(); } } catch (IOException e) { Log.d(TAG, "IOException" + e.getMessage()); } } } } } } } /** * 加载文件内容 */ public static String read(String wbPath) { File file = new File(wbPath); if (file.exists()) { FileInputStream fis = null; try { fis = new FileInputStream(file); int len = fis.available(); if (len > 0) { byte[] buf = new byte[len]; fis.read(buf); String string = new String(buf, CHARSET); return string; } } catch (Exception e) { e.printStackTrace(); } catch (OutOfMemoryError e) { e.printStackTrace(); } finally { if (fis != null) try { fis.close(); } catch (IOException e) { e.printStackTrace(); } } } return null; } }
[ "822704186@qq.com" ]
822704186@qq.com
194354bb13a6942bdf1ee61ccd3f1f66ff6d5523
b51cfda37c56844283000b78c00f7eec489d9578
/src/main/java/com/campsite/reservation/model/UpdateReservationDTO.java
fa5d41f1e478df151429512adb8d4731f1f934e6
[]
no_license
akintayo/reservation
d8084800e2fb96564f934b2efca02f45bceb67bb
10301f09f9f8a25a1e9fe3cdabc78df51acf5a67
refs/heads/main
2023-07-18T04:52:41.185831
2021-07-27T16:00:05
2021-07-27T16:00:05
389,649,113
0
0
null
null
null
null
UTF-8
Java
false
false
486
java
package com.campsite.reservation.model; import lombok.Data; import javax.validation.constraints.NotNull; import java.time.LocalDate; /** * POJO for updating a reservation */ @Data public class UpdateReservationDTO { @NotNull(message = "Booking reference cannot be null") private String bookingReferenceId; /** * the new check in date */ private LocalDate checkInDate; /** * the new check out date */ private LocalDate checkoutDate; }
[ "akin.banky@gmail.com" ]
akin.banky@gmail.com
b52cb193d594eeeb2a6bd8d26bbac2a28fa80dd4
179948b1255456be1f8f6bcceae8d5f9ec4ce24e
/teamreignofdke/MapAnalyzer.java
d607b4ddfb5535f9818a514dfb3f29ef4111347e
[ "MIT" ]
permissive
fabian-braun/reignOfDke
3538b3b51eb54c7135155441be687c37ea0d5b36
38202ebed63ac021811214adf7266b15cfc23680
refs/heads/master
2021-04-24T17:49:36.380687
2015-02-03T15:08:39
2015-02-03T15:08:39
29,867,809
2
0
null
null
null
null
UTF-8
Java
false
false
8,043
java
package teamreignofdke; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.PriorityQueue; import battlecode.common.MapLocation; import battlecode.common.RobotController; import battlecode.common.TerrainTile; public class MapAnalyzer { protected RobotController rc; private MapLocation myHq; private MapLocation otherHq; private int height; private int width; private MapLocation bestForPastr; private char[][] mapRepresentation; private double[][] mapCowGrowth; private double[][] mapPastrRating; private int[][] realDistanceFromOpponentHQ; PriorityQueue<MapLocationDistance> queue; private boolean realDistanceReady = false; public MapAnalyzer(RobotController rc, MapLocation myHQ, MapLocation otherHq, int height, int width) { this.rc = rc; this.myHq = myHQ; this.otherHq = otherHq; this.height = height; this.width = width; } /** * generates a map. Each location gets assigned the number of moves * necessary to reach it from the opponent's HQ. (shortest path) Currently * takes about 500 rounds to be executed.. way to expensive. The underlying * algorithm is Dijkstra. */ public void generateRealDistanceMap() { realDistanceFromOpponentHQ = new int[height][width]; for (int[] row : realDistanceFromOpponentHQ) { Arrays.fill(row, Integer.MAX_VALUE - 1); } queue = new PriorityQueue<MapLocationDistance>(); MapLocationDistance source = new MapLocationDistance(otherHq, 0); queue.add(source); while (!queue.isEmpty()) { MapLocationDistance current = queue.poll(); List<MapLocation> neighbours = getNeighbours(current .getMapLocation()); for (MapLocation neighbour : neighbours) { MapLocationDistance n = new MapLocationDistance(neighbour, realDistanceFromOpponentHQ[neighbour.y][neighbour.x]); int distanceOverCurrent = current.getDistance() + 1; if (distanceOverCurrent < n.getDistance()) { queue.remove(n); n.setDistance(distanceOverCurrent); realDistanceFromOpponentHQ[n.getMapLocation().y][n .getMapLocation().x] = distanceOverCurrent; queue.add(n); } n.setDistance(current.getDistance() + 1); } } } private boolean isXonMap(int x) { return x >= 0 && x < width; } private boolean isYonMap(int y) { return y >= 0 && y < height; } /** * returns all neighbours of a location fulfilling the following conditions: * <li>the terrain type is NORMAL or ROAD</li> <li>the location is located * on the map</li><li>the location is not an HQ-location</li> <br> * in short: any location which a soldier can move to</br> * * @param from * @return */ private List<MapLocation> getNeighbours(MapLocation from) { List<MapLocation> neighbours = new ArrayList<MapLocation>(); addNeighbour(neighbours, new MapLocation(from.x - 1, from.y - 1)); addNeighbour(neighbours, new MapLocation(from.x - 1, from.y)); addNeighbour(neighbours, new MapLocation(from.x - 1, from.y + 1)); addNeighbour(neighbours, new MapLocation(from.x, from.y - 1)); addNeighbour(neighbours, new MapLocation(from.x, from.y + 1)); addNeighbour(neighbours, new MapLocation(from.x + 1, from.y - 1)); addNeighbour(neighbours, new MapLocation(from.x + 1, from.y)); addNeighbour(neighbours, new MapLocation(from.x + 1, from.y + 1)); for (int i = neighbours.size() - 1; i >= 0; i--) { MapLocation current = neighbours.get(i); TerrainTile terrain = rc.senseTerrainTile(new MapLocation( current.x, current.y)); if (terrain == TerrainTile.VOID || terrain == TerrainTile.OFF_MAP || current.equals(myHq) || current.equals(otherHq)) { neighbours.remove(i); } } return neighbours; } private void addNeighbour(List<MapLocation> neighbours, MapLocation potentialNeighbour) { if (isXonMap(potentialNeighbour.x) && isYonMap(potentialNeighbour.y)) { neighbours.add(potentialNeighbour); } } public int getRealDistanceToOpponentHq(MapLocation loc) { if (realDistanceReady) return realDistanceFromOpponentHQ[loc.y][loc.x]; else return Integer.MAX_VALUE - 1; } /** * evaluates which location on the map is optimal to construct a pastr.<br/> * This evaluation for each location is based on <li>the cow growth rate</li> * <li>the distance to the opponent's HQ</li><br/> * * In order to keep the performance small, not all tiles are investigated * but only around 24*24. If the map is smaller then all tiles are * investigated. If the real distance has been calculated already it is used * for this method (see {@link #generateRealDistanceMap()}). If not the * direct distance is used instead. * * @return the optimal pastr location */ public MapLocation evaluateBestPastrLoc() { if (bestForPastr != null) { // already found previously return bestForPastr; } mapCowGrowth = rc.senseCowGrowth(); mapPastrRating = new double[height][width]; double currentBestRating = 0; bestForPastr = new MapLocation(0, 0); int xStep = width / 25 + 1; int yStep = height / 25 + 1; for (int y = 2; y < height; y += yStep) { for (int x = 2; x < width; x += xStep) { TerrainTile tile = rc.senseTerrainTile(new MapLocation(x, y)); if (tile != TerrainTile.NORMAL && tile != TerrainTile.ROAD) { continue; } double sumCowGrowth = 0; for (int ylocal = y - 1; ylocal <= y + 1; ylocal++) { for (int xlocal = x - 1; xlocal <= x + 1; xlocal++) { if (ylocal >= 0 && xlocal >= 0 && ylocal < height && xlocal < width) { // mapCowGrowth has x before y.. this is no bug sumCowGrowth += mapCowGrowth[x][y]; } } } int distance = PathFinder.distance(new MapLocation(x, y), otherHq); if (realDistanceReady) { distance = getRealDistanceToOpponentHq(new MapLocation(x, y)); } mapPastrRating[y][x] = distance * sumCowGrowth; if (mapPastrRating[y][x] > currentBestRating) { currentBestRating = mapPastrRating[y][x]; bestForPastr = new MapLocation(x, y); } } } return bestForPastr; } /** * should not be used in competition. Prints out the map terrain */ public void printMap() { mapRepresentation = new char[height][width]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { TerrainTile tile = rc.senseTerrainTile(new MapLocation(x, y)); switch (tile) { case OFF_MAP: mapRepresentation[y][x] = 'X'; break; case ROAD: mapRepresentation[y][x] = '#'; break; case VOID: mapRepresentation[y][x] = 'X'; break; default: if (mapCowGrowth[y][x] > 0) { mapRepresentation[y][x] = (char) (48 + (int) mapCowGrowth[y][x]); } else { mapRepresentation[y][x] = ' '; } } } } mapRepresentation[myHq.y][myHq.x] = 'H'; mapRepresentation[otherHq.y][otherHq.x] = 'E'; System.out.println("map:"); for (int y = 0; y < mapRepresentation.length; y++) { for (int x = 0; x < mapRepresentation[y].length; x++) { System.out.print(mapRepresentation[y][x]); } System.out.println(); } } /** * should not be used in competition. Prints out the pastr rating of the * locations */ public void printMapAnalysis() { System.out.println("map:"); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { System.out.print(String.format("%5.0f", mapPastrRating[y][x])); } System.out.println(); } System.out.println("best Pastr Rating at " + bestForPastr.toString()); System.out.println("other hq is at " + otherHq.toString()); } /** * should not be used in competition. Prints out the distance of each * location to the opponent's HQ */ public void printMapAnalysisDistance() { System.out.println("distance to opponent map:"); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (realDistanceFromOpponentHQ[y][x] > 1000) { System.out.print("XX "); } else { System.out.print(String.format("%02d ", realDistanceFromOpponentHQ[y][x])); } } System.out.println(); } } }
[ "fb.braun@student.maastrichtuniversity.nl" ]
fb.braun@student.maastrichtuniversity.nl
c13ed76b7d56d63bea57cc92a63bfc5be312e5cb
ef247e10cae4535b4cae9109768cb110f03de975
/TheDemoSite/src/main/java/AddUser.java
22fffbd5e0dedd6617fdb1286c826f63a919d419
[]
no_license
brieroth/AutomatedTesting
e48a28f4bfdb0442bf06e4acfd15550787eab3cb
93dc50fa2067324690b1c1c34cb2ba84440366dc
refs/heads/master
2020-03-22T16:14:13.739256
2018-07-13T13:03:04
2018-07-13T13:03:04
140,313,186
0
0
null
null
null
null
UTF-8
Java
false
false
1,029
java
import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import java.awt.*; public class AddUser { @FindBy(xpath = "/html/body/table/tbody/tr/td[1]/form/div/center/table/tbody/tr/td[1]/div/center/table/tbody/tr[1]/td[2]/p/input") private WebElement usrName; @FindBy(xpath = "/html/body/table/tbody/tr/td[1]/form/div/center/table/tbody/tr/td[1]/div/center/table/tbody/tr[2]/td[2]/p/input") private WebElement usrPassword; @FindBy(xpath = "/html/body/table/tbody/tr/td[1]/form/div/center/table/tbody/tr/td[1]/div/center/table/tbody/tr[3]/td[2]/p/input") private WebElement saveButton; @FindBy(xpath = "/html/body/div/center/table/tbody/tr[2]/td/div/center/table/tbody/tr/td[2]/p/small/a[4]") private WebElement logButton; public void addUser(String username, String password) { usrName.sendKeys(username); usrPassword.sendKeys(password); saveButton.submit(); } public void clickLogButton() { logButton.click(); } }
[ "brigitte.roth2018@outlook.com" ]
brigitte.roth2018@outlook.com
ec8bef041c9500057fc7d515db3a8bd0ac1afd29
755da35585bd16e66430289a19eb994d01ed16ef
/src/main/java/ch/ethz/idsc/retina/davis/app/SAEGaussDecayImage.java
4ec0b570ad11167b196ea094f81ba787e4b3baf7
[]
no_license
datahaki/retina
001f0ebe89d23a461ee95c946d93c3ba35bbdf25
b01b72aae54cca859b1f845748f70aa2c765f947
refs/heads/master
2020-09-01T08:32:54.658322
2019-10-27T12:25:36
2019-10-27T12:25:36
103,564,223
1
0
null
2018-10-20T02:02:24
2017-09-14T17:54:32
Matlab
UTF-8
Java
false
false
1,141
java
// code by az package ch.ethz.idsc.retina.davis.app; import ch.ethz.idsc.retina.davis.DavisDevice; import ch.ethz.idsc.retina.davis._240c.DavisDvsEvent; /** surface of active events */ public class SAEGaussDecayImage extends AbstractAccumulatedImage { public static AbstractAccumulatedImage of(DavisDevice davisDevice, int interval_us) { return new SAEGaussDecayImage(davisDevice, interval_us); } // --- /** number of bits to drop */ private static final int DROP = 7; // --- private final GaussDecayLookup gaussP; private final GaussDecayLookup gaussN; private SAEGaussDecayImage(DavisDevice davisDevice, int interval) { super(davisDevice); setInterval(interval); // --- gaussP = new GaussDecayLookup(interval >> DROP, 2.5, +1); gaussN = new GaussDecayLookup(interval >> DROP, 2.5, -1); } @Override // from AbstractAccumulatedImage protected void assign(int delta, DavisDvsEvent dvsDavisEvent) { int index = dvsDavisEvent.x + (dvsDavisEvent.y) * width; bytes[index] = dvsDavisEvent.brightToDark() // ? gaussN.get(delta >> DROP) : gaussP.get(delta >> DROP); } }
[ "jan.hakenberg@gmail.com" ]
jan.hakenberg@gmail.com
9494812a2c04f45177beed8dc046cd0848a9763e
6d4a412f3d0b350ddffcabd213af881c3aea071e
/app/src/main/java/atpl/cc/localisys/fragments/AskQuestionActivity.java
5a7d7095d8a3d0440e3f78061fbbc8e4e334a190
[]
no_license
spacewideweb/localisys
0cedc5cfaa32e13e00615ce3a2a36088af8e1049
0b03ee13392b7d57f9d42504c2cc8cf3d68c41c0
refs/heads/master
2020-04-04T02:42:02.346878
2018-11-01T20:05:34
2018-11-01T20:05:34
155,693,869
0
0
null
null
null
null
UTF-8
Java
false
false
51,945
java
package atpl.cc.localisys.fragments; import android.Manifest; import android.annotation.TargetApi; import android.app.Activity; import android.app.Dialog; import android.app.ProgressDialog; import android.app.TimePickerDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Build; import android.os.Environment; import android.os.ParcelFileDescriptor; import android.os.Parcelable; import android.provider.MediaStore; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v4.content.res.ResourcesCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.StaggeredGridLayoutManager; import android.text.Editable; import android.text.Selection; import android.text.TextUtils; import android.text.TextWatcher; import android.util.Base64; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.Button; import android.widget.EditText; import android.widget.HorizontalScrollView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.TimePicker; import android.widget.Toast; import com.darsh.multipleimageselect.activities.AlbumSelectActivity; import com.darsh.multipleimageselect.models.Image; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesNotAvailableException; import com.google.android.gms.common.GooglePlayServicesRepairableException; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.Status; import com.google.android.gms.location.places.AutocompleteFilter; import com.google.android.gms.location.places.Place; import com.google.android.gms.location.places.Places; import com.google.android.gms.location.places.ui.PlaceAutocomplete; import com.google.android.gms.location.places.ui.PlacePicker; import com.google.android.gms.tasks.OnFailureListener; import com.google.android.gms.tasks.OnSuccessListener; import com.google.firebase.analytics.FirebaseAnalytics; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.storage.FirebaseStorage; import com.google.firebase.storage.StorageReference; import com.google.firebase.storage.UploadTask; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; import atpl.cc.localisys.R; import atpl.cc.localisys.Constants; import atpl.cc.localisys.activities.Localisys_HomeActivity; import atpl.cc.localisys.activities.SelectPlaceActivity; import atpl.cc.localisys.adapter.HorizontalImageAdapter; import atpl.cc.localisys.adapter.MySkillRecyclerAdapter; import atpl.cc.localisys.adapter.TagPeopleAdapter; import atpl.cc.localisys.classes.ExifUtil; import atpl.cc.localisys.classes.PostClass; import atpl.cc.localisys.classes.Price; import atpl.cc.localisys.classes.Timeline; import atpl.cc.localisys.modal.AddService; import de.hdodenhof.circleimageview.CircleImageView; import static android.app.Activity.RESULT_CANCELED; import static android.app.Activity.RESULT_OK; public class AskQuestionActivity extends Fragment implements View.OnClickListener, GoogleApiClient.OnConnectionFailedListener { private static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 12; private static final int PLACE_AUTOCOMPLETE_REQUEST_CODE = 100; private static final int MULTI_CHOICE = 3; TextView tv_title,txt_cancel,tv_notime, tv_hours, tv_days; Button submit ,btn_tag_people,btn_notime,btn_hours,btn_days; ImageView instagram,twitter,facebook; ImageView ques_image_ID; EditText ques_title,ques_description; EditText ques_hashtag; Button ques_valid_time; String image="",title="",desc="",final_price="",pricedollr_left="",pricedollr_right="",user_email="",valid_time="",user_name="",user_image=""; ArrayList<String>img_url=new ArrayList<>(); ProgressDialog pd; SharedPreferences sp; String which=""; File f; String image_upload=""; int REQUEST_CAMERA = 0, SELECT_FILE = 1; String userChoosenTask; private int[] IMAGES = {R.drawable.pic,R.drawable.pic_2,R.drawable.pic_3}; StorageReference mStorageRef; HorizontalImageAdapter mAdapter; FirebaseStorage storage = FirebaseStorage.getInstance(); private static int RESULT_LOAD_IMAGE = 10; ArrayList<String> mArrayData = new ArrayList<>(); private static final int PERMISSION_REQUEST_CODE = 1; private static final int CPERMISSION_REQUEST_CODE = 2; Bitmap mbitmap; Button btn_asktag; boolean status = false; private GoogleApiClient mGoogleApiClient; private int PLACE_PICKER_REQUEST = 113; ArrayList<String> hashtag = new ArrayList<>(); ArrayList<String> arrayList=new ArrayList<>(); ArrayList<String> arrayList_result=new ArrayList(); String twestx = ""; Map<String,Boolean> map = new HashMap<>(); MySkillRecyclerAdapter adapter; ImageView lock; TextView textView; boolean isSecret=false; boolean isPrivate=false; TextView prvtText; ImageView ivMultiple; private FirebaseAnalytics mFirebaseAnalytics; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.activity_ask_question,container,false); mFirebaseAnalytics = FirebaseAnalytics.getInstance(getActivity()); mFirebaseAnalytics.setAnalyticsCollectionEnabled(true); textView=(TextView)view.findViewById(R.id.text_profile); prvtText=(TextView)view.findViewById(R.id.prvtText); lock=(ImageView)view.findViewById(R.id.lock); lock.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isSecret==true){ lock.setImageResource(R.drawable.ask_lock); textView.setText("Your profile is visible."); isSecret=false; } else { lock.setImageResource(R.drawable.ic_lock); textView.setText("No one will see your profile"); isSecret=true; } AddEToFire("tapMakePostSecret"); } }); mStorageRef = storage.getReference(); sp = getActivity().getSharedPreferences("sp", Context.MODE_PRIVATE); user_email = sp.getString("u_email",""); user_name = sp.getString("u_name",""); user_image = sp.getString("u_image",""); try { mGoogleApiClient = new GoogleApiClient .Builder(getActivity()) .addApi(Places.GEO_DATA_API) .addApi(Places.PLACE_DETECTION_API) .enableAutoManage(getActivity(), this) .build(); }catch (Exception e){ e.printStackTrace(); } facebook=(ImageView)view.findViewById(R.id.img_fb); instagram=(ImageView)view.findViewById(R.id.instagram); twitter=(ImageView)view.findViewById(R.id.twitter_light); txt_cancel = (TextView) view.findViewById(R.id.txt_cancel); btn_asktag = (Button)view.findViewById(R.id.btn_asktag); ivMultiple = (ImageView)view.findViewById(R.id.ivMultiple); pd = new ProgressDialog(getActivity(),R.style.MyTheme); pd.setCancelable(false); pd.setProgressStyle(android.R.style.Widget_ProgressBar_Large); pd.setIndeterminateDrawable(ResourcesCompat.getDrawable(getResources(),R.drawable.my_progress_indeterminate,null)); ques_image_ID = (ImageView)view.findViewById(R.id.ques_image_ID); ques_title = (EditText)view.findViewById(R.id.ques_title); ques_description = (EditText)view.findViewById(R.id.ques_description); ques_hashtag = (EditText)view.findViewById(R.id.ques_hashtag); ServiceActivity.places = (TextView) view.findViewById(R.id.ques_location); ques_valid_time = (Button)view.findViewById(R.id.ques_valid_time); facebook.setOnClickListener(this); instagram.setOnClickListener(this); twitter.setOnClickListener(this); ques_valid_time.setOnClickListener(this); ServiceActivity.places.setOnClickListener(this); ques_image_ID.setOnClickListener(this); ServiceActivity.places.setSelected(true); ServiceActivity.places.setEllipsize(TextUtils.TruncateAt.MARQUEE); ServiceActivity.places.setSingleLine(true); ServiceActivity.places.setMarqueeRepeatLimit(1); txt_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().getSupportFragmentManager().popBackStackImmediate(); SharedPreferences.Editor editor=sp.edit(); editor.putString("private_post","no").apply(); AddEToFire("tapCancelCreateQuestion"); } }); submit = (Button) view.findViewById(R.id.btn_quessubmit); submit.setOnClickListener(this); btn_asktag.setOnClickListener(this); arrayList_result.clear(); //ques_hashtag.setText(""); sp = getActivity().getSharedPreferences("sp", Context.MODE_PRIVATE); String private_post=sp.getString("private_post",""); if (private_post.equalsIgnoreCase("yes")){ isPrivate=true; //Private Post. 1 user tagged’ if (sp.getString("nos","0").equalsIgnoreCase("0")){ prvtText.setText("Private post."); }else { if (sp.getString("nos","0").equalsIgnoreCase("1")){ prvtText.setText("Private Post. " + sp.getString("nos", "") + " user tagged."); }else { prvtText.setText("Private Post. " + sp.getString("nos", "") + " users tagged."); } } //private_txt.setText("Private post."); } else { isPrivate=false; if (sp.getString("nos","0").equalsIgnoreCase("0")){ prvtText.setText("Tag people/make post private."); }else { if (sp.getString("nos","0").equalsIgnoreCase("1")) { prvtText.setText(sp.getString("nos", "") + " user tagged."); }else { prvtText.setText(sp.getString("nos", "") + " users tagged."); } } } /* ques_hashtag.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hashtagPopup(); } }); */ ques_hashtag.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { if (b) { if (ques_hashtag.getText().toString().isEmpty()) { ques_hashtag.setText("#"); } } } }); ques_hashtag.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable s) { /* if(!s.toString().contains("#")){ ques_hashtag.setText("#"); Selection.setSelection(ques_hashtag.getText(), ques_hashtag.getText().length()); }else { String result = s.toString().replace(" ", "\t#"); if (!s.toString().equals(result)) { ques_hashtag.setText(result); ques_hashtag.setSelection(result.length()); // alert the user } }*/ if (s.toString().length()>0) { if (!s.toString().contains("#")) { ques_hashtag.setText("#"+s.toString()); Selection.setSelection(ques_hashtag.getText(), ques_hashtag.getText().length()); } else { String result = s.toString().replaceAll(" ", "\t#"); if (!s.toString().equals(result)) { ques_hashtag.setText(result); ques_hashtag.setSelection(result.length()); // alert the user } } }else { } } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } }); return view; } public void AddEToFire(String eName){ Bundle bundle = new Bundle(); mFirebaseAnalytics.logEvent(eName,bundle); } public void getHashtag(){ arrayList_result.clear(); if (!ques_hashtag.getText().toString().equalsIgnoreCase("")){ String[] items = ques_hashtag.getText().toString().replace("\t", "").split("#"); for (String item : items) { Log.d("item = " ,item); if(!item.equalsIgnoreCase("")) { arrayList_result.add(item); } } }else { } } public void showDialog(){ final Dialog dialog = new Dialog(getActivity()); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.submit_dialog); final TextView cancel = (TextView) dialog.findViewById(R.id.cancel); TextView submit = (TextView) dialog.findViewById(R.id.submit); Button choose_provider = (Button) dialog.findViewById(R.id.choose_provider); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); AddQues(); } }); choose_provider.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); //getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.container,new InviteFragment(),null).addToBackStack(null).commit(); } }); dialog.show(); } @Override public void onClick(View v) { if (v==facebook){ Constants.facebook(getActivity()); } if (v==instagram){ Constants.instagram(getActivity()); } if (v==twitter){ Constants.twitter(getActivity()); } if(v==ServiceActivity.places){ /*final AutocompleteFilter typeFilter = new AutocompleteFilter.Builder() .setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES) .build(); try { Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY) .setFilter(typeFilter) .build(getActivity()); startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace(); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace(); }*/ AddEToFire("tapOpenLocationMap"); startActivity(new Intent(getActivity(), SelectPlaceActivity.class)); /*PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); try { startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST); } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) { e.printStackTrace(); }*/ } if (v == submit){ AddEToFire("tapSubmitQuestion"); title = ques_title.getText().toString(); desc = ques_description.getText().toString(); //hashtag = ques_hashtag.getText().toString(); //location = ques_location.getText().toString(); Log.d("title",title); Log.d("desc",desc); Log.d("desc",desc); //Log.d("hashtag",hashtag); Log.d("location",""); if (image.isEmpty()||title.isEmpty()||desc.isEmpty()||SelectPlaceActivity.location==null || ques_hashtag.getText().toString().trim().equalsIgnoreCase("") || ques_hashtag.getText().toString().equalsIgnoreCase("#")){ Constants.Information_Dialog(getActivity(),"All fields are required."); }else if (checkHashtag()){ Constants.Information_Dialog(getActivity(), "Please enter valid Hashtag"); }else { getHashtag(); showDialog(); } } if (v==ques_image_ID){ which = "pic"; onImageClick(); AddEToFire("tapOpenPhotoSelection"); // onImageClick(); } if (v==ques_valid_time){ //show_timeDialog(); valid_Time(); AddEToFire("tapOpenValidTime"); } if (v == btn_asktag){ getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.container,new TagPeople()).addToBackStack(null).commit(); AddEToFire("tapOpenTagPeople"); } } public boolean checkHashtag(){ Log.d("ddddd",ques_hashtag.getText().toString().replace("\t","")); Pattern word = Pattern.compile("##"); return word.matcher(ques_hashtag.getText().toString().replace("\t","")).find(); } public void valid_Time(){ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = LayoutInflater.from(getActivity()).inflate(R.layout.custom_validtime,null); builder.setView(view); final TextView tvDay = (TextView)view.findViewById(R.id.tvDay); final TextView tvWeek = (TextView)view.findViewById(R.id.tvWeek); final TextView tvMonth = (TextView)view.findViewById(R.id.tvMonth); final TextView tvYear = (TextView)view.findViewById(R.id.tvYear); final TextView tvLifetime = (TextView)view.findViewById(R.id.tvLifetime); final AlertDialog alert = builder.create(); alert.getWindow().getDecorView().setBackgroundResource(android.R.color.transparent); tvDay.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { alert.dismiss(); ques_valid_time.setText(tvDay.getText().toString()); valid_time = tvDay.getText().toString().toLowerCase(); } }); tvWeek.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { alert.dismiss(); ques_valid_time.setText(tvWeek.getText().toString()); valid_time = tvWeek.getText().toString().toLowerCase(); } }); tvMonth.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { alert.dismiss(); ques_valid_time.setText(tvMonth.getText().toString()); valid_time = tvMonth.getText().toString().toLowerCase(); } }); tvYear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { alert.dismiss(); ques_valid_time.setText(tvYear.getText().toString()); valid_time = tvYear.getText().toString().toLowerCase(); } }); tvLifetime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { alert.dismiss(); ques_valid_time.setText(tvLifetime.getText().toString()); valid_time = tvLifetime.getText().toString().toLowerCase(); } }); alert.show(); } public void show_timeDialog(){ Calendar mcurrentTime = Calendar.getInstance(); int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY); int minute = mcurrentTime.get(Calendar.MINUTE); TimePickerDialog dialog; dialog = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { Log.d("time",String.format("%02d:%02d", selectedHour, selectedMinute)); ques_valid_time.setText(String.format("%02d:%02d", selectedHour, selectedMinute)); //valid_time = String.format("%02d:%02d", selectedHour, selectedMinute); } },hour, minute, true); dialog.setTitle("Select Time"); dialog.show(); } Price price; Timeline timeline; public void AddQues(){ pd.show(); String currentDateTimeString = String.valueOf(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(new Date())); DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference("Post"); String userId = mDatabase.push().getKey(); price = new Price(0,0,"none"); timeline = new Timeline("none"); //PostClass(Location location, String description, ArrayList<String> hashtags, ArrayList<String> imageURLs, Boolean isPrivate, Boolean isSecret, String postCreatorID, String timestamp, String title, String type, String validTime, Price price, Timeline timeline) PostClass pc = new PostClass(SelectPlaceActivity.location, desc, arrayList_result, img_url, isPrivate, isSecret, Localisys_HomeActivity.user_id, currentDateTimeString, title, "question", valid_time , TagPeopleAdapter.map); //AddService as = new AddService(desc, arrayList_result, img_url, isSecret, isSecret, Localisys_HomeActivity.user_id, "status", currentDateTimeString, title, "Question", valid_time,"","",SelectPlaceActivity.location,"timeline"); //AddService as = new AddService(image,title,desc,hashtag,location,"","",user_email,"ques",valid_time,user_name,user_image); mDatabase.child(userId).setValue(pc, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { pd.dismiss(); if (databaseError == null){ AddUserPostRelation(databaseReference.getKey()); AddPostLocationRelation(databaseReference.getKey(),SelectPlaceActivity.stateStr); mbitmap = null; imageUri = null; Information_Dialog(getActivity(),"Question is added."); if (arrayList_result.size()>0){ for (int i=0;i<arrayList_result.size();i++){ AddPostHashtagRelation(databaseReference.getKey(),arrayList_result.get(i)); } } arrayList_result.clear(); ivMultiple.setVisibility(View.GONE); }else { Constants.Information_Dialog(getActivity(),"error in server."); } } }); } public void AddUserPostRelation(String key){ DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference("PostUserRelation"); Map<String,Object> map = new HashMap<>(); map.put(key,true); mDatabase.child(Localisys_HomeActivity.user_id).updateChildren(map, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { pd.dismiss(); if (databaseError == null) { } else { } } }); } public void AddPostHashtagRelation(String id,String key){ DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference("PostHashtagRelation"); Log.d("dhdhdhd",arrayList_result.size()+""); Map<String,Object> map = new HashMap<>(); map.put(id,true); mDatabase.child(key).updateChildren(map, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { pd.dismiss(); if (databaseError == null) { } else { } } }); } public void AddPostLocationRelation(String id,String key){ DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference("PostLocationRelation"); Log.d("location",SelectPlaceActivity.stateStr+""); Map<String,Object> map = new HashMap<>(); map.put(id,true); mDatabase.child(key).updateChildren(map, new DatabaseReference.CompletionListener() { @Override public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { if (databaseError == null) { } else { } } }); } public void Information_Dialog(Context context,String msg){ android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(context); View view = LayoutInflater.from(context).inflate(R.layout.custom_infodialog,null); TextView tv_Infomsg = (TextView)view.findViewById(R.id.tv_Infomsg); TextView btn_ok = (TextView)view.findViewById(R.id.btn_ok); tv_Infomsg.setText(msg); builder.setView(view); final android.support.v7.app.AlertDialog dialog = builder.create(); dialog.setCancelable(false); dialog.getWindow().getDecorView().setBackgroundResource(android.R.color.transparent); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; btn_ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.container,new AddPostFragment()).commit(); } }); dialog.show(); } public void onImageClick() { final CharSequence[] items = {"Open Camera", "Choose from gallery","Cancel"}; android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity()); builder.setTitle("Select Options"); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { // Do something with the selection switch (item) { case 0: if(checkPermissionForCamera()) { if (checkPermissionForWrite()) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); f = new File(Environment.getExternalStorageDirectory(), "temp.jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); startActivityForResult(intent, 1); } else { requestPermissionForWrite(); } }else { requestPermissionForCamera(); } break; case 1: Intent intent = new Intent(getActivity(), AlbumSelectActivity.class); //set limit on number of images that can be selected, default is 10 intent.putExtra(com.darsh.multipleimageselect.helpers.Constants.INTENT_EXTRA_LIMIT, 3); //intent.putExtra(com.darsh.multipleimageselect.helpers.Constants.INTENT_EXTRA_IMAGES,4); startActivityForResult(intent, 2); /* if(checkPermissionForWrite()) { Intent intent1 = new Intent( Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent1.setType("image*//*"); startActivityForResult( Intent.createChooser(intent1, "Select File"), 2); }else { requestPermissionForWrite(); }*/ break; case 2: dialog.dismiss(); break; } } }); android.app.AlertDialog alert = builder.create(); alert.show(); } @SuppressWarnings("VisibleForTests") public void upload_multiple_image(String imagePath){ pd.show(); final StorageReference childRef = mStorageRef.child("PostImages/question"+System.currentTimeMillis()); //uploading the image InputStream stream = null; try { stream = new FileInputStream(new File(imagePath)); } catch (FileNotFoundException e) { e.printStackTrace(); } UploadTask uploadTask = childRef.putStream(stream); uploadTask.addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { pd.dismiss(); Toast.makeText(getActivity(), "Upload Failed -> " + exception, Toast.LENGTH_SHORT).show(); Log.d("error", exception.toString()); // Handle unsuccessful uploads } }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { pd.dismiss(); childRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() { @Override public void onSuccess(Uri uri) { image = uri.toString(); img_url.add(image); Log.d("downloadUrl",image); Log.d("success", "ff"); } }); } }); } public boolean checkPermissionForCamera() { int result = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA); if (result == PackageManager.PERMISSION_GRANTED) { return true; } else { return false; } } private void requestPermissionForCamera(){ if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.CAMERA)){ Toast.makeText(getActivity(),"write permission allows us to write data. Please allow in App Settings for additional functionality.",Toast.LENGTH_LONG).show(); } else { ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.CAMERA}, CPERMISSION_REQUEST_CODE); } } public boolean checkPermissionForWrite() { int result = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE); if (result == PackageManager.PERMISSION_GRANTED) { return true; } else { return false; } } private void requestPermissionForWrite(){ if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)){ Toast.makeText(getActivity(),"write permission allows us to write data. Please allow in App Settings for additional functionality.", Toast.LENGTH_LONG).show(); } else { ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE); } } @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case PERMISSION_REQUEST_CODE: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Log.d("Permission","Permission granted"); onImageClick(); //Snackbar.make(view,"Permission Granted, Now you can access location data.",Snackbar.LENGTH_LONG).show(); } else { Log.d("Permission","Permission Denied"); //Snackbar.make(view,"Permission Denied, You cannot access location data.",Snackbar.LENGTH_LONG).show(); } break; case CPERMISSION_REQUEST_CODE: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Log.d("Permission","Permission granted"); onImageClick(); //Snackbar.make(view,"Permission Granted, Now you can access location data.",Snackbar.LENGTH_LONG).show(); } else { Log.d("Permission","Permission Denied"); //Snackbar.make(view,"Permission Denied, You cannot access location data.",Snackbar.LENGTH_LONG).show(); } break; } } private void galleryIntent() { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT);// startActivityForResult(Intent.createChooser(intent, "Select File"),SELECT_FILE); } private void cameraIntent() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, REQUEST_CAMERA); } Uri imageUri = null; @Override public void onResume() { super.onResume(); if (mbitmap != null) { ques_image_ID.setImageBitmap(mbitmap); } if (imageUri != null){ ques_image_ID.setImageURI(imageUri); } } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == 1) { File f = new File(Environment.getExternalStorageDirectory().toString()); for (File temp : f.listFiles()) { if (temp.getName().equals("temp.jpg")) { f = temp; break; } } try { Bitmap bitmap; BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); //bitmapOptions.inSampleSize = 8; bitmap = Bitmap.createScaledBitmap(BitmapFactory.decodeFile(f.getAbsolutePath()), 120, 120, true); //bitmap = BitmapFactory.decodeFile(f.getAbsolutePath(), bitmapOptions); Bitmap mbitmap = ExifUtil.rotateBitmap(f.getAbsolutePath(), bitmap); image_upload = f.getAbsolutePath(); mbitmap = mbitmap; ques_image_ID.setImageBitmap(mbitmap); if(!image_upload.equalsIgnoreCase("")){ upload(); } } catch (Exception e) { e.printStackTrace(); } } else if (requestCode == 2) { ArrayList<Image> images = data.getParcelableArrayListExtra(com.darsh.multipleimageselect.helpers.Constants.INTENT_EXTRA_IMAGES); Log.d("numberOfimg",images.size()+""); //ques_image_ID.setImageResource(R.drawable.pruple_hint); //ques_image_ID.setImageURI(Uri.parse(images.get(0).path)); if (!images.isEmpty()){ if (images.size()==1){ ivMultiple.setVisibility(View.GONE); imageUri = Uri.parse(images.get(0).path); ques_image_ID.setImageURI(Uri.parse(images.get(0).path)); upload_multiple_image(images.get(0).path); }else { ivMultiple.setVisibility(View.VISIBLE); imageUri = Uri.parse(images.get(0).path); ques_image_ID.setImageURI(Uri.parse(images.get(0).path)); for (int i = 0; i < images.size(); i++) { upload_multiple_image(images.get(i).path); } } Toast.makeText(getActivity(), images.size()+" Images are uploaded successfully", Toast.LENGTH_SHORT).show(); } /* if (!images.isEmpty()){ for (int i=0;i<images.size();i++){ upload_multiple_image(images.get(i).path); } Toast.makeText(getActivity(), images.size()+" Images are uploaded successfully", Toast.LENGTH_SHORT).show(); }*/ /* Uri selectedImage = data.getData(); String[] filePath = {MediaStore.Images.Media.DATA}; Cursor c = getActivity().getContentResolver().query(selectedImage, filePath, null, null, null); c.moveToFirst(); int columnIndex = c.getColumnIndex(filePath[0]); String picturePath = c.getString(columnIndex); c.close(); Bitmap thumbnail = (BitmapFactory.decodeFile(picturePath)); Bitmap mbitmap = ExifUtil.rotateBitmap(picturePath, thumbnail); image_upload = picturePath; ques_image_ID.setImageBitmap(mbitmap); if(!image_upload.equalsIgnoreCase("")){ upload(); }*/ } } /* if (resultCode == Activity.RESULT_OK) { if (requestCode == SELECT_FILE) { onSelectFromGalleryResult(data); } else if (requestCode == REQUEST_CAMERA) { onCaptureImageResult(data); }*/ if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) { if (resultCode == RESULT_OK) { Place place = PlaceAutocomplete.getPlace(getActivity(), data); Log.i("Place: " ,place.getAddress()+""); //ques_location.setText(place.getAddress()+""); } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) { Status status = PlaceAutocomplete.getStatus(getActivity(), data); // TODO: Handle the error. Log.i("Errr", status.getStatusMessage()); } else if (resultCode == RESULT_CANCELED) { } } /*Parcelable[] parcelableUris = data.getParcelableArrayExtra(ImagePickerActivity.TAG_IMAGE_URI); Uri[] uris = new Uri[parcelableUris.length]; System.arraycopy(parcelableUris, 0, uris, 0, parcelableUris.length); if (requestCode == MULTI_CHOICE) { mArrayData.clear(); for (Uri uri : uris) { File file = new File(uri.getPath()); if (!file.exists()) { return; } mArrayData.add("file:" + file.getAbsolutePath()); mAdapter.notifyDataSetChanged(); } }*/ if (requestCode == PLACE_PICKER_REQUEST) { if (resultCode == RESULT_OK) { Place place = PlacePicker.getPlace(getActivity(), data); StringBuilder stBuilder = new StringBuilder(); String placename = String.format("%s", place.getName()); String latitude = String.valueOf(place.getLatLng().latitude); String longitude = String.valueOf(place.getLatLng().longitude); String address = String.format("%s", place.getAddress()); stBuilder.append("Name: "); stBuilder.append(placename); stBuilder.append("\n"); stBuilder.append("Latitude: "); stBuilder.append(latitude); stBuilder.append("\n"); stBuilder.append("Logitude: "); stBuilder.append(longitude); stBuilder.append("\n"); stBuilder.append("Address: "); stBuilder.append(address); Log.d("selectedplaces", stBuilder.toString()); //ques_location.setText(place.getAddress() + ""); //location=new Location(); //location.setAddressString(address); //location.setLatitude(Double.parseDouble(latitude)); //location.setLongitude(Double.parseDouble(longitude)); //location.setSurroundingDistance(500); //tvPlaceDetails.setText(); } else if (resultCode == PlacePicker.RESULT_ERROR) { /*Status status = PlacePicker.getStatus(getActivity(), data); // TODO: Handle the error. Log.i("PlaceErrr", status.getStatusMessage());*/ } } } private void onCaptureImageResult(Intent data) { Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); thumbnail.compress(Bitmap.CompressFormat.JPEG, 90, bytes); File destination = new File(Environment.getExternalStorageDirectory(), System.currentTimeMillis() + ".jpg"); FileOutputStream fo; try { destination.createNewFile(); fo = new FileOutputStream(destination); fo.write(bytes.toByteArray()); fo.close(); if (which.equalsIgnoreCase("pic")) { image_upload = destination.getAbsolutePath(); Log.d("image_upload", image_upload); ques_image_ID.setImageBitmap(thumbnail); } if(!image_upload.equalsIgnoreCase("")){ upload(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } @SuppressWarnings("VisibleForTests") public void upload(){ pd.show(); final StorageReference childRef = mStorageRef.child("PostImages/questions"+System.currentTimeMillis()); //uploading the image InputStream stream = null; try { stream = new FileInputStream(new File(image_upload)); } catch (FileNotFoundException e) { e.printStackTrace(); } UploadTask uploadTask = childRef.putStream(stream); uploadTask.addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { pd.dismiss(); Toast.makeText(getActivity(), "Upload Failed -> " + exception, Toast.LENGTH_SHORT).show(); Log.d("error", exception.toString()); } }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { pd.dismiss(); childRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() { @Override public void onSuccess(Uri uri) { image = uri.toString(); img_url.add(image); Log.d("downloadUrl",image); Toast.makeText(getActivity(), "Upload successful", Toast.LENGTH_SHORT).show(); // taskSnapshot.getMetadata() contains file metadata such as size, content-type, and download URL. Log.d("success", "ff"); } }); } }); } @SuppressWarnings("deprecation") private void onSelectFromGalleryResult(Intent data) { Bitmap bm; if (data != null) { try { bm = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), data.getData()); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, 90, bytes); File destination = new File(Environment.getExternalStorageDirectory(), System.currentTimeMillis() + ".jpg"); FileOutputStream fo; destination.createNewFile(); fo = new FileOutputStream(destination); fo.write(bytes.toByteArray()); fo.close(); image_upload = destination.getAbsolutePath(); Log.d("image_upload",image_upload); if(!image_upload.equalsIgnoreCase("")){ upload(); } ques_image_ID.setImageBitmap(bm); // status = true; /* if(status == true){ showImageDialog(); }*/ } catch (IOException e) { e.printStackTrace(); } } } public void showImageDialog(){ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View dialog_view = LayoutInflater.from(getActivity()).inflate(R.layout.image_dialog_layout,null); // ViewPager mPager = (ViewPager) dialog_view.findViewById(R.id.pager); TabLayout customtab = (TabLayout) dialog_view.findViewById(R.id.customtab); RecyclerView image_recycler = (RecyclerView) dialog_view.findViewById(R.id.recycler_view); //ImageView cancel_btn = (ImageView) dialog_view.findViewById(R.id.cancel_btn); // Button pickMultiImage = (Button) dialog_view.findViewById(R.id.btn_multi_image); image_recycler.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.HORIZONTAL, false)); mAdapter = new HorizontalImageAdapter(getActivity(), mArrayData); image_recycler.setAdapter(mAdapter); /*pickMultiImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent pickerChooser = new Intent(ImagePickerActivity.ACTION_INTENT); startActivityForResult(pickerChooser, MULTI_CHOICE); } });*/ /* image_recycler.setAdapter(new HorizontalImageAdapter(getActivity(),AskQuestionActivity.this)); image_recycler.setHasFixedSize(true); LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.HORIZONTAL); image_recycler.setLayoutManager(llm);*/ // mPager.setAdapter(new FullScreenImageAdapter(getActivity(), IMAGES)); // customtab.setupWithViewPager(mPager,true); builder.setView(dialog_view); final AlertDialog dialog = builder.create(); dialog.setCancelable(false); dialog.getWindow().getDecorView().setBackgroundResource(android.R.color.transparent); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; /* // cancel_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); // dialog.show();*/ } @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static boolean checkPermission(final Context context) { int currentAPIVersion = Build.VERSION.SDK_INT; if(currentAPIVersion>= Build.VERSION_CODES.M) { if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, Manifest.permission.READ_EXTERNAL_STORAGE)) { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(context); alertBuilder.setCancelable(true); alertBuilder.setTitle("Permission necessary"); alertBuilder.setMessage("External storage permission is necessary"); alertBuilder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void onClick(DialogInterface dialog, int which) { ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); } }); AlertDialog alert = alertBuilder.create(); alert.show(); } else { ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); } return false; } else { return true; } } else { return true; } } @Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) { } }
[ "jelenajekac12@gmail.com" ]
jelenajekac12@gmail.com
e2860802de9470740c7fd139a351ebc78c276880
0b503e488b02b18a619adcdd4d73639dc4c9d67e
/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work/Catalina/localhost/BookStoreWebsite/org/apache/jsp/admin/customer_005flist_jsp.java
710844c15d91c24037e782ec1d181c6c772f9f92
[]
no_license
nilgundagidir/BookStoreProject
ed60a5d1b0d2a33af66641ace2232221e001c6bc
f442d4a6958cd1a7ea09255528dc338ad3273951
refs/heads/main
2023-03-14T15:54:05.101439
2021-04-01T14:05:29
2021-04-01T14:05:29
353,719,850
0
1
null
null
null
null
UTF-8
Java
false
false
22,056
java
/* * Generated by the Jasper component of Apache Tomcat * Version: Apache Tomcat/9.0.34 * Generated at: 2020-06-03 16:19:35 UTC * Note: The last modified time of this file was set to * the last modified time of the source file after * generation to assist with modification tracking. */ package org.apache.jsp.admin; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; public final class customer_005flist_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent, org.apache.jasper.runtime.JspSourceImports { private static final javax.servlet.jsp.JspFactory _jspxFactory = javax.servlet.jsp.JspFactory.getDefaultFactory(); private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants; static { _jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(5); _jspx_dependants.put("/admin/footer.jsp", Long.valueOf(1590060786573L)); _jspx_dependants.put("jar:file:/C:/Users/nilgun/BookStoreProject/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/BookStoreWebsite/WEB-INF/lib/jstl-1.2.jar!/META-INF/fmt.tld", Long.valueOf(1153374282000L)); _jspx_dependants.put("jar:file:/C:/Users/nilgun/BookStoreProject/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/BookStoreWebsite/WEB-INF/lib/jstl-1.2.jar!/META-INF/c.tld", Long.valueOf(1153374282000L)); _jspx_dependants.put("/admin/header.jsp", Long.valueOf(1591130056001L)); _jspx_dependants.put("/WEB-INF/lib/jstl-1.2.jar", Long.valueOf(1589478004305L)); } private static final java.util.Set<java.lang.String> _jspx_imports_packages; private static final java.util.Set<java.lang.String> _jspx_imports_classes; static { _jspx_imports_packages = new java.util.HashSet<>(); _jspx_imports_packages.add("javax.servlet"); _jspx_imports_packages.add("javax.servlet.http"); _jspx_imports_packages.add("javax.servlet.jsp"); _jspx_imports_classes = null; } private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fnobody; private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fc_005fif_0026_005ftest; private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fc_005fforEach_0026_005fvarStatus_005fvar_005fitems; private volatile javax.el.ExpressionFactory _el_expressionfactory; private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager; public java.util.Map<java.lang.String,java.lang.Long> getDependants() { return _jspx_dependants; } public java.util.Set<java.lang.String> getPackageImports() { return _jspx_imports_packages; } public java.util.Set<java.lang.String> getClassImports() { return _jspx_imports_classes; } public javax.el.ExpressionFactory _jsp_getExpressionFactory() { if (_el_expressionfactory == null) { synchronized (this) { if (_el_expressionfactory == null) { _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); } } } return _el_expressionfactory; } public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() { if (_jsp_instancemanager == null) { synchronized (this) { if (_jsp_instancemanager == null) { _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig()); } } } return _jsp_instancemanager; } public void _jspInit() { _005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); _005fjspx_005ftagPool_005fc_005fif_0026_005ftest = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); _005fjspx_005ftagPool_005fc_005fforEach_0026_005fvarStatus_005fvar_005fitems = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); } public void _jspDestroy() { _005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fnobody.release(); _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.release(); _005fjspx_005ftagPool_005fc_005fforEach_0026_005fvarStatus_005fvar_005fitems.release(); } public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException { if (!javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) { final java.lang.String _jspx_method = request.getMethod(); if ("OPTIONS".equals(_jspx_method)) { response.setHeader("Allow","GET, HEAD, POST, OPTIONS"); return; } if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method)) { response.setHeader("Allow","GET, HEAD, POST, OPTIONS"); response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSPs only permit GET, POST or HEAD. Jasper also permits OPTIONS"); return; } } final javax.servlet.jsp.PageContext pageContext; javax.servlet.http.HttpSession session = null; final javax.servlet.ServletContext application; final javax.servlet.ServletConfig config; javax.servlet.jsp.JspWriter out = null; final java.lang.Object page = this; javax.servlet.jsp.JspWriter _jspx_out = null; javax.servlet.jsp.PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("<!DOCTYPE html>\r\n"); out.write("<html>\r\n"); out.write("<head>\r\n"); out.write("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n"); out.write("\t<title>Manage Customers - Cilek Bookstore Administration</title>\r\n"); out.write("\t<link rel=\"stylesheet\" href=\"../css/mycss.css\" >\r\n"); out.write("\t<script type=\"text/javascript\" src=\"../js/jquery-3.3.1.min.js\"></script>\r\n"); out.write("</head>\r\n"); out.write("<body>\r\n"); out.write("\t"); out.write("\r\n"); out.write("<div align=\"center\">\r\n"); out.write("\t<div>\r\n"); out.write("\t\t<a href=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.contextPath}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("/admin/\">\r\n"); out.write("\t\t\t<img src=\"../images/cilek.jpg\" />\r\n"); out.write("\t\t</a>\r\n"); out.write("\t</div>\r\n"); out.write("\t<div>\r\n"); out.write("\t\tWelcome, "); if (_jspx_meth_c_005fout_005f0(_jspx_page_context)) return; out.write(" | <a href=\"logout\">Logout</a>\r\n"); out.write("\t\t<br/><br/>\r\n"); out.write("\t</div>\r\n"); out.write("\t<div id=\"headermenu\">\r\n"); out.write("\t\t<div>\r\n"); out.write("\t\t\t<a href=\"list_users\">\r\n"); out.write("\t\t\t\t<img src=\"../images/users.png\" /><br/>Users\r\n"); out.write("\t\t\t</a>\r\n"); out.write("\t\t</div>\r\n"); out.write("\t\t<div>\r\n"); out.write("\t\t\t<a href=\"list_category\">\r\n"); out.write("\t\t\t\t<img src=\"../images/category.png\" /><br/>Categories\r\n"); out.write("\t\t\t</a>\r\n"); out.write("\t\t</div>\r\n"); out.write("\t\t<div>\r\n"); out.write("\t\t\t<a href=\"list_books\">\r\n"); out.write("\t\t\t\t<img src=\"../images/bookstack.png\" /><br/>Books\r\n"); out.write("\t\t\t</a>\r\n"); out.write("\t\t</div>\r\n"); out.write("\t\t<div>\r\n"); out.write("\t\t\t<a href=\"list_customer\">\r\n"); out.write("\t\t\t\t<img src=\"../images/customer.png\" /><br/>Customers\r\n"); out.write("\t\t\t</a>\r\n"); out.write("\t\t</div>\r\n"); out.write("\t\t<div>\r\n"); out.write("\t\t\t<a href=\"list_review\">\r\n"); out.write("\t\t\t\t<img src=\"../images/review.png\" /><br/>Reviews\r\n"); out.write("\t\t\t</a>\r\n"); out.write("\t\t</div>\r\n"); out.write("\t\t<div>\r\n"); out.write("\t\t\t<a href=\"list_order\"><img src=\"../images/order.png\" /><br/>\r\n"); out.write("\t\t\t\tOrders\r\n"); out.write("\t\t\t</a>\r\n"); out.write("\t\t</div>\r\n"); out.write("\t</div>\r\n"); out.write("</div>"); out.write("\r\n"); out.write("\t\r\n"); out.write("\t<div align=\"center\">\r\n"); out.write("\t\t<h2 class=\"pageheading\">Customers Management</h1>\r\n"); out.write("\t\t<h3><a href=\"customer_form.jsp\">Create New Customer</a></h3>\r\n"); out.write("\t</div>\r\n"); out.write("\t\r\n"); out.write("\t"); if (_jspx_meth_c_005fif_005f0(_jspx_page_context)) return; out.write("\r\n"); out.write("\t\r\n"); out.write("\t<div align=\"center\">\r\n"); out.write("\t\t<table border=\"1\" cellpadding=\"5\">\r\n"); out.write("\t\t\t<tr>\r\n"); out.write("\t\t\t\t<th>Index</th>\r\n"); out.write("\t\t\t\t<th>ID</th>\r\n"); out.write("\t\t\t\t<th>E-mail</th>\r\n"); out.write("\t\t\t\t<th>Full Name</th>\r\n"); out.write("\t\t\t\t<th>City</th>\r\n"); out.write("\t\t\t\t<th>Country</th>\r\n"); out.write("\t\t\t\t<th>Registered Date</th>\r\n"); out.write("\t\t\t\t<th>Actions</th>\r\n"); out.write("\t\t\t</tr>\r\n"); out.write("\t\t\t"); if (_jspx_meth_c_005fforEach_005f0(_jspx_page_context)) return; out.write("\r\n"); out.write("\t\t</table>\r\n"); out.write("\t</div>\r\n"); out.write("\t\r\n"); out.write("\t\r\n"); out.write("\t"); out.write("\r\n"); out.write("<div align=\"center\">\r\n"); out.write("\t<h4>Bookstore Administration</h4>\r\n"); out.write("\t<h3>Copyright(C) 2020 by Cilek Books Co.,Ltd</h3>\r\n"); out.write("</div>"); out.write("\r\n"); out.write("\t\r\n"); out.write("\t<script>\r\n"); out.write("\t\t$(document).ready(function() {\r\n"); out.write("\t\t\t$(\".deleteLink\").each(function() {\r\n"); out.write("\t\t\t\t$(this).on(\"click\", function() {\r\n"); out.write("\t\t\t\t\tcustomerId = $(this).attr(\"id\");\r\n"); out.write("\t\t\t\t\tif (confirm('Are you sure you want to delete the customer with ID ' + customerId + '?')) {\r\n"); out.write("\t\t\t\t\t\twindow.location = 'delete_customer?id=' + customerId;\r\n"); out.write("\t\t\t\t\t}\t\t\t\t\t\r\n"); out.write("\t\t\t\t});\r\n"); out.write("\t\t\t});\r\n"); out.write("\t\t});\r\n"); out.write("\t</script>\r\n"); out.write("</body>\r\n"); out.write("</html>"); } catch (java.lang.Throwable t) { if (!(t instanceof javax.servlet.jsp.SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { if (response.isCommitted()) { out.flush(); } else { out.clearBuffer(); } } catch (java.io.IOException e) {} if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else throw new ServletException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } private boolean _jspx_meth_c_005fout_005f0(javax.servlet.jsp.PageContext _jspx_page_context) throws java.lang.Throwable { javax.servlet.jsp.PageContext pageContext = _jspx_page_context; javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut(); // c:out org.apache.taglibs.standard.tag.rt.core.OutTag _jspx_th_c_005fout_005f0 = (org.apache.taglibs.standard.tag.rt.core.OutTag) _005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fnobody.get(org.apache.taglibs.standard.tag.rt.core.OutTag.class); boolean _jspx_th_c_005fout_005f0_reused = false; try { _jspx_th_c_005fout_005f0.setPageContext(_jspx_page_context); _jspx_th_c_005fout_005f0.setParent(null); // /admin/header.jsp(9,11) name = value type = null reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fout_005f0.setValue((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${sessionScope.useremail}", java.lang.Object.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); int _jspx_eval_c_005fout_005f0 = _jspx_th_c_005fout_005f0.doStartTag(); if (_jspx_th_c_005fout_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { return true; } _005fjspx_005ftagPool_005fc_005fout_0026_005fvalue_005fnobody.reuse(_jspx_th_c_005fout_005f0); _jspx_th_c_005fout_005f0_reused = true; } finally { org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag(_jspx_th_c_005fout_005f0, _jsp_getInstanceManager(), _jspx_th_c_005fout_005f0_reused); } return false; } private boolean _jspx_meth_c_005fif_005f0(javax.servlet.jsp.PageContext _jspx_page_context) throws java.lang.Throwable { javax.servlet.jsp.PageContext pageContext = _jspx_page_context; javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut(); // c:if org.apache.taglibs.standard.tag.rt.core.IfTag _jspx_th_c_005fif_005f0 = (org.apache.taglibs.standard.tag.rt.core.IfTag) _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.get(org.apache.taglibs.standard.tag.rt.core.IfTag.class); boolean _jspx_th_c_005fif_005f0_reused = false; try { _jspx_th_c_005fif_005f0.setPageContext(_jspx_page_context); _jspx_th_c_005fif_005f0.setParent(null); // /admin/customer_list.jsp(21,1) name = test type = boolean reqTime = true required = true fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fif_005f0.setTest(((java.lang.Boolean) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${message != null}", boolean.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)).booleanValue()); int _jspx_eval_c_005fif_005f0 = _jspx_th_c_005fif_005f0.doStartTag(); if (_jspx_eval_c_005fif_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("\r\n"); out.write("\t<div align=\"center\">\r\n"); out.write("\t\t<h4 class=\"message\">"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${message}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("</h4>\r\n"); out.write("\t</div>\r\n"); out.write("\t"); int evalDoAfterBody = _jspx_th_c_005fif_005f0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_c_005fif_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { return true; } _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f0); _jspx_th_c_005fif_005f0_reused = true; } finally { org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag(_jspx_th_c_005fif_005f0, _jsp_getInstanceManager(), _jspx_th_c_005fif_005f0_reused); } return false; } private boolean _jspx_meth_c_005fforEach_005f0(javax.servlet.jsp.PageContext _jspx_page_context) throws java.lang.Throwable { javax.servlet.jsp.PageContext pageContext = _jspx_page_context; javax.servlet.jsp.JspWriter out = _jspx_page_context.getOut(); // c:forEach org.apache.taglibs.standard.tag.rt.core.ForEachTag _jspx_th_c_005fforEach_005f0 = (org.apache.taglibs.standard.tag.rt.core.ForEachTag) _005fjspx_005ftagPool_005fc_005fforEach_0026_005fvarStatus_005fvar_005fitems.get(org.apache.taglibs.standard.tag.rt.core.ForEachTag.class); boolean _jspx_th_c_005fforEach_005f0_reused = false; try { _jspx_th_c_005fforEach_005f0.setPageContext(_jspx_page_context); _jspx_th_c_005fforEach_005f0.setParent(null); // /admin/customer_list.jsp(39,3) name = var type = java.lang.String reqTime = false required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fforEach_005f0.setVar("customer"); // /admin/customer_list.jsp(39,3) name = items type = javax.el.ValueExpression reqTime = true required = false fragment = false deferredValue = true expectedTypeName = java.lang.Object deferredMethod = false methodSignature = null _jspx_th_c_005fforEach_005f0.setItems(new org.apache.jasper.el.JspValueExpression("/admin/customer_list.jsp(39,3) '${listCustomer}'",_jsp_getExpressionFactory().createValueExpression(_jspx_page_context.getELContext(),"${listCustomer}",java.lang.Object.class)).getValue(_jspx_page_context.getELContext())); // /admin/customer_list.jsp(39,3) name = varStatus type = java.lang.String reqTime = false required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null _jspx_th_c_005fforEach_005f0.setVarStatus("status"); int[] _jspx_push_body_count_c_005fforEach_005f0 = new int[] { 0 }; try { int _jspx_eval_c_005fforEach_005f0 = _jspx_th_c_005fforEach_005f0.doStartTag(); if (_jspx_eval_c_005fforEach_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { do { out.write("\r\n"); out.write("\t\t\t<tr>\r\n"); out.write("\t\t\t\t<td>"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${status.index + 1}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("</td>\r\n"); out.write("\t\t\t\t<td>"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${customer.customerId}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("</td>\r\n"); out.write("\t\t\t\t<td>"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${customer.email}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("</td>\r\n"); out.write("\t\t\t\t<td>"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${customer.fullname}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("</td>\r\n"); out.write("\t\t\t\t<td>"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${customer.city}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("</td>\r\n"); out.write("\t\t\t\t<td>"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${customer.country}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("</td>\r\n"); out.write("\t\t\t\t<td>"); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${customer.registerDate}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("</td>\r\n"); out.write("\t\t\t\t<td>\r\n"); out.write("\t\t\t\t\t<a href=\"edit_customer?id="); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${customer.customerId}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("\">Edit</a> &nbsp;\r\n"); out.write("\t\t\t\t\t<a href=\"javascript:void(0);\" class=\"deleteLink\" id=\""); out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${customer.customerId}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null)); out.write("\">Delete</a>\r\n"); out.write("\t\t\t\t</td>\r\n"); out.write("\t\t\t</tr>\r\n"); out.write("\t\t\t"); int evalDoAfterBody = _jspx_th_c_005fforEach_005f0.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); } if (_jspx_th_c_005fforEach_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { return true; } } catch (java.lang.Throwable _jspx_exception) { while (_jspx_push_body_count_c_005fforEach_005f0[0]-- > 0) out = _jspx_page_context.popBody(); _jspx_th_c_005fforEach_005f0.doCatch(_jspx_exception); } finally { _jspx_th_c_005fforEach_005f0.doFinally(); } _005fjspx_005ftagPool_005fc_005fforEach_0026_005fvarStatus_005fvar_005fitems.reuse(_jspx_th_c_005fforEach_005f0); _jspx_th_c_005fforEach_005f0_reused = true; } finally { org.apache.jasper.runtime.JspRuntimeLibrary.releaseTag(_jspx_th_c_005fforEach_005f0, _jsp_getInstanceManager(), _jspx_th_c_005fforEach_005f0_reused); } return false; } }
[ "dagidirnilgun@gmail.com" ]
dagidirnilgun@gmail.com
4fc0387b4ec901e691a8502094887ff1b791886d
b7fb0a7af85f475436ee52c8584b1c4801d65862
/src/Exceptions/Subject1.java
c0e800969d660b65cc4dbf79d878525cfd215191
[]
no_license
spandy021987/Real-time-hospital-handling-systems
b3a7f62f8a432c6ebc332357361b7244ca19079f
16b34e0e6595f1da9bac0336784975da012176e5
refs/heads/master
2020-06-30T17:42:33.095206
2019-08-06T18:06:04
2019-08-06T18:06:04
200,899,905
0
0
null
2019-08-06T18:06:05
2019-08-06T17:57:12
Java
UTF-8
Java
false
false
709
java
package Exceptions; class Subject { void distinction() throws InvalidMarkException { double marks=55.00; if(marks>=85) { System.out.println("Distinction"); } else { throw new InvalidMarkException("Not a distiction"); } } } class InvalidMarkException extends Exception { String msg; InvalidMarkException(String msg) { this.msg=msg; } public String getMessage() { return msg; } } public class Subject1 { public static void main(String[] args) { Subject s1= new Subject(); try { s1.distinction(); } catch(InvalidMarkException i1) { System.out.println(i1.getMessage()); } } }
[ "Spandana@DESKTOP-KTDCJLP" ]
Spandana@DESKTOP-KTDCJLP
84093b94d2fa3d369c9d26120a8bcd7431361c27
2f9bc758ea92fd8c5d91980f85d195f5c06065a1
/src/main/java/seedu/address/logic/commands/ShareCommand.java
cd600834560086ea29fcac26731b2b99a9e7df6b
[ "MIT" ]
permissive
goweiwen/main
3ba193c1a0b68a04de188d76d05b0fb21e6489ec
b3193ccd1cbba7fc0239c49011dfd6b69298ccb2
refs/heads/master
2021-08-11T07:59:39.367935
2017-11-12T09:38:24
2017-11-12T15:29:43
105,434,339
0
0
null
2017-10-01T10:23:26
2017-10-01T10:23:26
null
UTF-8
Java
false
false
4,880
java
package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_SHARE; import java.util.List; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import seedu.address.commons.core.Messages; import seedu.address.commons.core.index.Index; import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.logic.InternetConnectionCheck; import seedu.address.logic.TextToSpeech; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.logic.parser.ParserUtil; import seedu.address.logic.threads.SendEmail; import seedu.address.model.person.ReadOnlyPerson; //@@author hanselblack /** * Emails the list of contact details to the input email address */ public class ShareCommand extends Command { public static final String COMMAND_WORD = "share"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Emails the person's contact details identified by the index number used in the listing.\n" + "Parameters: INDEX (must be a positive integer)\n" + "Example: " + COMMAND_WORD + " 1 " + PREFIX_SHARE + "EMAIL ADDRESS"; public static final String MESSAGE_SUCCESS = "Email Sent!"; public static final String MESSAGE_EMAIL_NOT_VALID = "Email address is not valid!"; public static final String MESSAGE_NO_INTERNET = "Not Connected to the Internet"; public static final String MESSAGE_FAILURE = "Email was not sent!"; private static SendEmail sendEmail; private Index targetIndex; private String[] shareEmailArray; public ShareCommand(Index targetIndex, String[] shareEmailArray) { this.targetIndex = targetIndex; this.shareEmailArray = shareEmailArray; } @Override public CommandResult execute() throws CommandException { requireNonNull(model); requireNonNull(targetIndex); List<ReadOnlyPerson> lastShownList = model.getFilteredPersonList(); if (targetIndex.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } if (InternetConnectionCheck.isConnectedToInternet()) { ReadOnlyPerson person = lastShownList.get(targetIndex.getZeroBased()); String to; for (int index = 0; index < shareEmailArray.length; index++) { to = shareEmailArray[index]; if (isNumeric(to)) { try { Index recipientIndex = ParserUtil.parseIndex(to); if (recipientIndex.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } ReadOnlyPerson personRecipient = lastShownList.get(recipientIndex.getZeroBased()); to = personRecipient.getEmail().toString(); } catch (IllegalValueException ive) { //Text to Speech new TextToSpeech(MESSAGE_FAILURE).speak(); return new CommandResult(MESSAGE_FAILURE); } } if (isValidEmailAddress(to)) { sendEmail = new SendEmail(to, person); sendEmail.start(); } else { //Text to Speech new TextToSpeech(MESSAGE_EMAIL_NOT_VALID).speak();; return new CommandResult(MESSAGE_EMAIL_NOT_VALID); } } //Text to Speech new TextToSpeech(MESSAGE_SUCCESS).speak();; return new CommandResult(MESSAGE_SUCCESS); } else { return new CommandResult(MESSAGE_NO_INTERNET); } } /** * Returns true if string is numeric number. This method is to identify which are * index or email address in the s/ parameter. */ public boolean isNumeric(String s) { return s != null && s.matches("[-+]?\\d*\\.?\\d+"); } @Override public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof ShareCommand // instanceof handles nulls && this.targetIndex.equals(((ShareCommand) other).targetIndex)); // state check } /** * returns true if string is a valid email address */ public static boolean isValidEmailAddress(String email) { boolean result = true; try { InternetAddress emailAddr = new InternetAddress(email); emailAddr.validate(); } catch (AddressException ex) { result = false; } return result; } }
[ "hanselblack@hotmail.com" ]
hanselblack@hotmail.com
6220eb1e8c6c69e6820cb58258f0ce06c6d2a683
f2b60e99f0535278f66d6d2ad7da1614e986594e
/src/main/java/com/example/demo/entity/User.java
e5a87a7785db98c554dc74c684f272e3814863c4
[]
no_license
pedrosbo1/SpringBoot4Sudy
29fa5c07071722fa0296821339a4311769e4e386
1ad84bf7d2724bcd915f48c0b0eccd9d7e784a66
refs/heads/master
2020-04-15T05:34:35.146126
2019-05-16T16:36:26
2019-05-16T16:36:26
164,428,893
0
0
null
2019-05-16T16:36:27
2019-01-07T12:23:25
Java
UTF-8
Java
false
false
509
java
package com.example.demo.entity; import javax.persistence.*; @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long Id; private String name; private int idade; public long getId() { return Id; } public void setId(long id) { Id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getIdade() { return idade; } public void setIdade(int idade) { this.idade = idade; } }
[ "pedro.catalini@hotmail.com" ]
pedro.catalini@hotmail.com
a859808404cea8338f94bd0554d5404b482d3231
78dab9031a874e408304c1611d100e3e38ead289
/src/Main.java
56b44f19ff4cba9d3777206c3331bff541052f73
[]
no_license
ilgar999/B21Project2
5f399a017a4d28a8f273cdee4bc3e7e58d03ba88
decccb58093c1c3a66f334146276bdd2d2fd5dd7
refs/heads/master
2023-01-08T18:05:21.126662
2020-11-10T22:12:22
2020-11-10T22:12:22
311,768,948
1
0
null
2020-11-10T22:12:24
2020-11-10T19:52:42
Java
UTF-8
Java
false
false
136
java
public class Main { public static void main(String[] args) { // write your code here System.out.println("Hello"); } }
[ "ilqar.nureddinoglu@gmail.com" ]
ilqar.nureddinoglu@gmail.com
bbaddfced1d87796bb476a370b6c356916d04284
eadcbb20c31a4dffc8f3896a3a7398d033e1c0a4
/model-generator/src/main/java/com/cyc/model/objects/ControllerObj.java
afd739c6c277553d4752e77d43720e86152874d4
[ "Apache-2.0" ]
permissive
cycorp/model-generator-suite
01bd4d59d75a09a5e433db86e4adf3149fd4f14b
8995984c5dcf668acad813d24e4fe9c544b7aa91
refs/heads/master
2021-01-10T12:44:41.455280
2017-09-01T00:24:51
2017-09-01T00:24:51
45,697,082
4
1
null
null
null
null
UTF-8
Java
false
false
8,107
java
package com.cyc.model.objects; import com.cyc.model.objects.MethodObj.FuncType; @Deprecated public class ControllerObj extends ModelObj { private InterfaceObj primaryImpl; private String controllerVar; public ControllerObj(InterfaceObj io) { this.setPrimaryImpl(io); String controllerNameStr = primaryImpl.getName(); String controllerLCaseStr = Character.toLowerCase(controllerNameStr.charAt(0)) + controllerNameStr.substring(1, controllerNameStr.length()); controllerVar = controllerNameStr.replaceAll("[a-z0-9_]+", "").toLowerCase() + "_var"; } private String generateControllerPre() { String controllerNameStr = primaryImpl.getName(); String controllerLCaseStr = Character.toLowerCase(controllerNameStr.charAt(0)) + controllerNameStr.substring(1, controllerNameStr.length()); String controllerStr = ""; controllerStr = controllerStr + " CycAccess cyc = null;\n"; // controllerStr = controllerStr + " " + controllerNameStr + " " + controllerVar + " = new " + controllerNameStr + "Impl(\"UniversalVocabularyMt\", params.id);\n\n"; controllerStr = controllerStr + " def beforeInterceptor = {\n"; controllerStr = controllerStr + " if (cyc == null){\n"; controllerStr = controllerStr + " cyc = CycAccess.setCurrent(\"legolas.cyc.com\", 3600);\n"; controllerStr = controllerStr + " }\n"; controllerStr = controllerStr + " }\n\n"; controllerStr = controllerStr + " def afterInterceptor = {\n"; controllerStr = controllerStr + " //cyc.clear();\n"; controllerStr = controllerStr + " }\n\n"; // Here we may not get a params.id //controllerStr = controllerStr + "def index() { render \"" + controllerNameStr + "Controller is alive!\"}"; controllerStr = controllerStr + " def delete () {\n"; controllerStr = controllerStr + " a" + controllerNameStr + ".delete();\n"; controllerStr = controllerStr + " }\n\n"; return controllerStr; } public InterfaceObj getPrimaryImpl() { return primaryImpl; } public void setPrimaryImpl(InterfaceObj primaryImpl) { this.primaryImpl = primaryImpl; } public String toString() { String controllerNameStr = primaryImpl.getName(); String controllerLCaseStr = Character.toLowerCase(controllerNameStr.charAt(0)) + controllerNameStr.substring(1, controllerNameStr.length()); String controllerStr = "/**\n" + " * This code was autogenerated by ModelGenerator program. The ModelGenerator\n" + " * creates Java Servlets by introspecting the Cyc Knowledge Base.\n" + " * It is strongly recommended not to make any changes to this file. \n" + " * This will allow regeneration of code when the Cyc KB model changes with fewer\n" + " * downstream changes.\n" + " * \n" + " * The Controller corresponds to " + this.getCycName() + " in the Cyc KB. \n" + " * and to " + this.getPrimaryImpl().getName() + " in the package " + this.getPrimaryImpl().getPackageName() + ". \n" + " * <p>\n" + " * \n" + " * @author ModelGenerator\n" + " * @author Vijay Raj\n" + " * @version \"%I%, %G%\"\n" + " * @since 0.90\n" + " */\n\n"; controllerStr = controllerStr + "class HumanCyclistController {\n"; controllerStr = controllerStr + generateControllerPre(); /*Controller#show - HTTP:GET - CURD:Retrieve*/ controllerStr = controllerStr + " def show() {\n"; controllerStr = controllerStr + " " + controllerNameStr + " " + controllerVar + " = new " + controllerNameStr + "Impl(\"UniversalVocabularyMt\", params.id);\n\n"; controllerStr = controllerStr + " if (0) {\n"; controllerStr = controllerStr + " }\n"; for (MethodObj mo : this.getPrimaryImpl().getMethods()) { if (mo.getfType().equals(FuncType.GET)) { controllerStr = controllerStr + " else if (params.func == \"" + mo.getName() + "\") { \n"; controllerStr = controllerStr + " def context = params.context ?:\"UniversalVocabularyMt\";\n"; controllerStr = controllerStr + " def " + mo.getReturnValue().getName() + " = " + controllerVar + "." + mo.getName() + "(Context.get(context));\n"; controllerStr = controllerStr + " render " + mo.getReturnValue().getName() + ".toString();\n"; controllerStr = controllerStr + " }\n"; } else if (mo.getfType().equals(FuncType.TYPE_GET_LIST)) { controllerStr = controllerStr + " else if (params.func == \"" + mo.getName() + "\") { \n"; controllerStr = controllerStr + " def context = params.context ?:\"UniversalVocabularyMt\";\n"; controllerStr = controllerStr + " def bindingsList = " + controllerVar + "." + mo.getName() + "(Context.get(context));\n"; controllerStr = controllerStr + " render bindingsList.toString();\n"; controllerStr = controllerStr + " }\n"; } } controllerStr = controllerStr + " else if (params.func == \"json\") {\n"; controllerStr = controllerStr + " render " + controllerVar + ".toString();\n"; controllerStr = controllerStr + " }\n"; controllerStr = controllerStr + " }\n\n"; /*Controller#save - HTTP:POST - CURD:Update*/ controllerStr = controllerStr + " def save() {\n"; controllerStr = controllerStr + " " + controllerNameStr + " " + controllerVar + " = new " + controllerNameStr + "Impl(\"UniversalVocabularyMt\", params.id);\n\n"; controllerStr = controllerStr + " if (0) {\n"; controllerStr = controllerStr + " }\n"; for (MethodObj mo : this.getPrimaryImpl().getMethods()) { if (mo.getfType().equals(FuncType.SET)) { controllerStr = controllerStr + " else if (params.func == \"" + mo.getName() + "\") { \n"; controllerStr = controllerStr + " def context = params.context ?:\"UniversalVocabularyMt\";\n"; int count1 = 0; for (ArgumentObj arg : mo.getArguments()) { if (arg.isSObject()) { controllerStr = controllerStr + " " + arg.getType() + " " + arg.getName() + " = new " + arg.getType() + "(params.name);\n"; } else { controllerStr = controllerStr + " " + arg.getType() + " " + arg.getName() + " = new " + arg.getType() + "Impl(params.name)" + ";\n"; } count1++; } controllerStr = controllerStr + " " + controllerVar + "." + mo.getName() + "(Context.get(context), "; int count2 = 0; for (ArgumentObj arg : mo.getArguments()) { if (arg.isSObject()) { controllerStr = controllerStr + arg.getName() + (count2 != mo.getArguments().size() - 1 ? ", " : ""); } else { controllerStr = controllerStr + arg.getName() + ".getInstance()" + (count2 != mo.getArguments().size() - 1 ? ", " : ""); } count2++; } controllerStr = controllerStr + ");\n"; controllerStr = controllerStr + " }\n"; } } controllerStr = controllerStr + " }\n\n"; controllerStr = controllerStr + "}\n\n"; controllerStr = controllerStr + "class UrlMappings {\n\n"; controllerStr = controllerStr + " static mappings = {\n"; controllerStr = controllerStr + " \"/$controller/$action?/$id?\"{\n"; controllerStr = controllerStr + " constraints {\n"; controllerStr = controllerStr + " // apply constraints here\n"; controllerStr = controllerStr + " }\n"; controllerStr = controllerStr + " }\n\n"; controllerStr = controllerStr + " \"/" + controllerNameStr + "/$id/$func?/$context?\"(controller: \"" + controllerNameStr + "\") {\n"; controllerStr = controllerStr + " action = [GET: \"show\", PUT: \"update\", DELETE: \"delete\", POST: \"save\"]\n"; controllerStr = controllerStr + " }\n\n"; controllerStr = controllerStr + " \"/\"(view:\"/index\")\n"; controllerStr = controllerStr + " \"500\"(view:'/error')\n"; controllerStr = controllerStr + " }\n"; controllerStr = controllerStr + "}\n"; return controllerStr; } }
[ "nw@exegetic.net" ]
nw@exegetic.net
d7831935583b5a8349272155f4d4f7ff0fb3b81b
0fef61b3a5fed02e667835a16ff6f7a078f05b92
/Game/src/gfx/Sound.java
29d9eb31dcc17dadb43c457407ef9f9faf533cc0
[]
no_license
dakersnar/Game
0a4884de4bac0cfe6508bcedea56407f812df7c1
156708398cc400d1033acf95923fd3c8efd2d158
refs/heads/master
2021-01-19T23:07:57.914037
2017-05-24T20:27:15
2017-05-24T20:27:15
88,928,897
0
2
null
2017-04-25T16:38:58
2017-04-21T02:05:11
Java
UTF-8
Java
false
false
584
java
package gfx; import java.io.File; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; public class Sound { public static void playSound(String i) { try { AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(i).getAbsoluteFile()); Clip clip = AudioSystem.getClip(); clip.open(audioInputStream); clip.start(); } catch(Exception ex) { System.out.println("Error with playing sound."); ex.printStackTrace(); } } }
[ "dakersnar@10.0.0.5" ]
dakersnar@10.0.0.5
c2f1dd5b18fc1b794e9f7b6526939b052a9679ed
3e4458f0858bc0d9eed2aa69a928dfc801d529a6
/src/main/java/com/anzlee/generalapi/pojo/PathAndParametersEquivalence.java
24d1e93f377eb987b63c51dfe38b27a8fb32ffc5
[]
no_license
AnzLee/general-api
b16d756a9bd803915851613231273e4965a4a243
b76ccf65a27b4ab1ab0a66caee6ea2dc521c6e67
refs/heads/master
2021-09-27T08:35:04.632639
2018-11-07T07:23:32
2018-11-07T07:23:33
115,574,856
0
1
null
null
null
null
UTF-8
Java
false
false
2,077
java
/** * PathAndParametersEquivalence * * @author li.liangzhe * @create 2018-02-01 15:45 **/ package com.anzlee.generalapi.pojo; import com.google.common.base.Equivalence; import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.collect.FluentIterable; import com.google.common.collect.Sets; import springfox.documentation.RequestHandler; import springfox.documentation.service.ResolvedMethodParameter; import java.util.List; import java.util.Set; class PathAndParametersEquivalence extends Equivalence<RequestHandler> { private static final ResolvedMethodParameterEquivalence parameterEquivalence = new ResolvedMethodParameterEquivalence(); @Override protected boolean doEquivalent(RequestHandler a, RequestHandler b) { return a.getPatternsCondition().equals(b.getPatternsCondition()) && !Sets.intersection(a.supportedMethods(), b.supportedMethods()).isEmpty() && a.params().equals(b.params()) && Sets.difference(wrapped(a.getParameters()), wrapped(b.getParameters())).isEmpty(); } private Set<Wrapper<ResolvedMethodParameter>> wrapped(List<ResolvedMethodParameter> parameters) { return FluentIterable.from(parameters) .transform(wrappingFunction()) .toSet(); } private Function<ResolvedMethodParameter, Wrapper<ResolvedMethodParameter>> wrappingFunction() { return new Function<ResolvedMethodParameter, Wrapper<ResolvedMethodParameter>>() { @Override public Wrapper<ResolvedMethodParameter> apply(ResolvedMethodParameter input) { return parameterEquivalence.wrap(input); } }; } @Override protected int doHash(RequestHandler requestHandler) { return Objects.hashCode( requestHandler.getPatternsCondition().getPatterns(), requestHandler.supportedMethods(), requestHandler.params(), wrapped(requestHandler.getParameters())); } }
[ "li.liangzhe@trs.com.cn" ]
li.liangzhe@trs.com.cn
3946cb2e2a3bd4de1d6f5664055e7b4b1f6217e6
dd8e8e1d0bf18abd884261217d431ad0a78a0c00
/src/com/atms391/android/location/GeoLocation.java
67fbb7cd555822796740af0bf8438e6864f87ba2
[]
no_license
btanabe/ATMS391
d907ad3bcbabeff9be3b5d1f6f1fba0ce450fea9
bfb207756b18233d4e55e75fc26fdd05a8c22964
refs/heads/master
2021-01-19T22:13:26.011375
2012-12-06T04:32:42
2012-12-06T04:32:42
null
0
0
null
null
null
null
WINDOWS-1252
Java
false
false
4,275
java
package com.atms391.android.location; import java.util.List; import android.app.Activity; import android.content.Context; import android.location.Address; import android.location.Criteria; import android.location.Geocoder; import android.location.Location; import android.location.LocationManager; import android.widget.Toast; public class GeoLocation { private Activity activity; private LocationManager locationManager; private String bestLocation; private double latitude; private double longitude; /////////////// CONSTRUCTORS: /////////////// public GeoLocation(Activity activity) throws Exception{ this.activity = activity; requestLocationService(); determineBestLocationServiceProvider(); updateLocation(bestLocation); } /////////////// PUBLIC ACCESSORS: /////////////// public void updateLocation() throws Exception{ determineBestLocationServiceProvider(); updateLocation(bestLocation); } public String getLocationString(){ StringBuilder stringBuilder = new StringBuilder(); if(isLocationValid()){ stringBuilder.append("("); stringBuilder.append(getLatitudePrettyPrinted()); stringBuilder.append(", "); stringBuilder.append(getLongitudePrettyPrinted()); stringBuilder.append(")"); } else { stringBuilder.append("LOCATION NOT DETERMINED"); } return stringBuilder.toString(); } public String getLatitudePrettyPrinted(){ StringBuilder stringBuilder = new StringBuilder(); if(latitude > 0){ // In the northern hemisphere stringBuilder.append(latitude); stringBuilder.append("°"); stringBuilder.append("N"); } else if(latitude < 0){ // In the southern hemisphere stringBuilder.append(Math.abs(latitude)); stringBuilder.append("°"); stringBuilder.append("S"); } else { // At the equator stringBuilder.append(latitude); stringBuilder.append("°"); } return stringBuilder.toString(); } public String getLongitudePrettyPrinted(){ StringBuilder stringBuilder = new StringBuilder(); if(longitude > 0){ // In the eastern hemisphere stringBuilder.append(longitude); stringBuilder.append("°"); stringBuilder.append("E"); } else if(longitude < 0){ // In the western hemisphere stringBuilder.append(Math.abs(longitude)); stringBuilder.append("°"); stringBuilder.append("W"); } else { // At the prime meridian stringBuilder.append(longitude); stringBuilder.append("°"); } return stringBuilder.toString(); } /////////////// PRIVATE HELPERS: /////////////// private void requestLocationService(){ locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE); } private void determineBestLocationServiceProvider(){ Criteria criteria = new Criteria(); bestLocation = locationManager.getBestProvider(criteria, false); } private void updateLocation(String bestProvider) throws Exception { Location location = locationManager.getLastKnownLocation(bestProvider); if(location == null){ Toast.makeText(activity, "Location Not Found", Toast.LENGTH_LONG).show(); } else { Geocoder geocoder = new Geocoder(activity); List<Address> user = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1); latitude = (double) user.get(0).getLatitude(); longitude = (double) user.get(0).getLongitude(); } } private boolean isLocationValid(){ boolean isValid = true; if(latitude > 181 || latitude < -181){ isValid = false; } if(longitude > 181 || longitude < -181){ isValid = false; } return isValid; } /////////////// PUBLIC GETTERS: /////////////// public double getLatitude() { return latitude; } public double getLongitude() { return longitude; } public String getBestLocationMethodString(){ return bestLocation; } public boolean usesGps(){ if(bestLocation.equalsIgnoreCase("gps")){ return true; } else { return false; } } public String usesGpsString(){ if(bestLocation.equalsIgnoreCase("gps")){ return "TRUE"; } else { return "FALSE"; } } /////////////// PUBLIC SETTERS: /////////////// public void setLatitude(double latitude) { this.latitude = latitude; } public void setLongitude(double longitude) { this.longitude = longitude; } }
[ "tanabesan4@gmail.com" ]
tanabesan4@gmail.com
f12c424b491cd54490c5de4cb42b79364be843b3
9942e6464d7b86a9fe1516fa5753c30434c77424
/src/main/java/com/baizhi/dao/AdminDao.java
bc6a5945a75791950ba029eff0821bd2123f761a
[]
no_license
wj-Jun/cmfz_star
e8e17ee8176f326af0bd395099fc29828ff167aa
05894935fe578b9ac442b9c92fc0621b6486263d
refs/heads/master
2023-03-05T21:07:36.092270
2019-11-05T11:00:44
2019-11-05T11:00:44
219,709,893
1
0
null
2023-02-22T02:51:50
2019-11-05T09:45:56
JavaScript
UTF-8
Java
false
false
191
java
package com.baizhi.dao; import com.baizhi.entity.Admin; import tk.mybatis.mapper.common.Mapper; //管理员Dao接口 继续通用Mapper public interface AdminDao extends Mapper<Admin> { }
[ "javayiyi9522@163.com" ]
javayiyi9522@163.com
5b5b506ca9d3295e84aa13f81bb871b0a43fb259
65d566974ce06d186b76e773c1af05a3d8c72d42
/cpa/src/main/java/com/taoding/service/voucher/CpaVoucherService.java
c32df3633ed220238e255b199174fa2259c166fe
[]
no_license
ghyaolong/muniubox
c6dc7fde31b4db1720dcdb5f4f36863e45a96948
4fcb01b32174e34103cacd973ea7b27b0f129ff1
refs/heads/master
2021-03-31T01:01:21.040898
2018-03-13T09:07:33
2018-03-13T09:07:33
125,023,825
1
0
null
null
null
null
UTF-8
Java
false
false
3,731
java
package com.taoding.service.voucher; import java.util.List; import java.util.Map; import com.taoding.domain.voucher.CpaVoucher; /** * 凭证 * @author czy * 2017年11月28日 上午11:22:21 */ public interface CpaVoucherService { /** * 为一个客户初始化一张凭证科目表 * @param bookId * @return */ int init(String bookId); /** * 新增凭证及凭证科目 * 2017年11月29日 上午10:00:02 * @param voucher * @return */ public Object insertCpaVoucher(CpaVoucher voucher); /** * 通过Id查询凭证及凭证科目 * 2017年11月29日 上午10:24:37 * @param id * @return */ public CpaVoucher findById(String bookId,String id); /** * 获取下一个记账凭证编号 * 2017年11月29日 下午1:47:42 * @param bookId * @return */ public Object getNextVoucherNo(String bookId); /** * 通过账期+凭证编号查询凭证信息 * 2017年11月29日 下午3:55:19 * @param bookId * @param voucherNo * @param voucherPeriod * @return */ public CpaVoucher findByNoAndPeriod(String bookId,String voucherNo,String voucherPeriod); /** * 修改凭证 * 2017年12月4日 上午10:23:02 * @param voucher * @return */ public Object updateCpaVoucher(CpaVoucher voucher); /** * 根据Id 删除凭证 * 2017年12月4日 下午1:43:40 * @param bookId * @param id * @return */ public Object deleteById(String bookId,String id); /** * 查询当前账期的所有编号 * 2017年12月4日 下午2:32:14 * @param bookId * @param voucherPeriod * @return */ public List<String> findAllNoByPeriod(String bookId,String voucherPeriod); /** * 调整凭证编号(可将编号调整至任意编号前) * 2017年12月4日 下午2:51:01 * @param bookId * @param id * @param voucherNo * @return */ public Object adjustmentVoucherNo(String bookId,String id,String voucherNo); /** * 重新整理凭证编号 * 2017年12月5日 下午1:33:49 * @param lists * @return */ public Object reorganizeVoucherNo(List<CpaVoucher> lists); /** * 批量删除 * 2017年12月6日 上午10:08:24 * @param bookId * @param deleteIds * @return */ public Object batchDelete(String bookId,String [] deleteIds); /** * 查询当前账期所有数据 * 2017年12月6日 上午10:55:14 * @param maps * @return */ public List<CpaVoucher> findAllListByPeriod(Map<String,String> maps); /** * 查询需要合并的凭证基础数据 * 2017年12月6日 上午10:08:24 * @param bookId * @param mergeIds * @return */ public List<CpaVoucher> findMergeVoucherByIds(String bookId,String [] mergeIds); /** * 凭证合并数据 * 2017年12月6日 下午2:00:09 * @param bookId * @param period * @param mergeIds * @return */ public Object mergeVoucherData(String bookId,String [] mergeIds); /** * 凭证合并保存 * 2017年12月6日 下午5:22:08 * @param voucher * @return */ public Object mergeVoucherSave(CpaVoucher voucher); /** * 复制凭证保存 * 2017年12月8日 下午10:15:08 * @param voucher * @return */ public Object pasteVoucherSave(CpaVoucher voucher); /** * * @Description: TODO(凭证汇总表) * @param voucherPeriod 账期 * @param bookId 账薄ID * @param isSum 是否显示统计 * @return Object 返回类型 * @throws * @author lixc * @date 2017年12月19日 */ public Object findVoucherSummaryListAndStatistics(String voucherPeriod,String bookId,boolean isSum); /** * 判断 凭证是否断号 * 2017年12月26日 下午6:13:56 * @param voucherPeriod * @param bookId * @return */ public boolean isFaultVoucherNo(String voucherPeriod,String bookId); }
[ "289911401@qq.com" ]
289911401@qq.com
e669167e91007f990272a311f3a5694af5b4413a
ed3cb95dcc590e98d09117ea0b4768df18e8f99e
/project_1_1/src/e/h/b/Calc_1_1_4716.java
849eafdd1eca3a1c7d844d024366d4dfbdd39a41
[]
no_license
chalstrick/bigRepo1
ac7fd5785d475b3c38f1328e370ba9a85a751cff
dad1852eef66fcec200df10083959c674fdcc55d
refs/heads/master
2016-08-11T17:59:16.079541
2015-12-18T14:26:49
2015-12-18T14:26:49
48,244,030
0
0
null
null
null
null
UTF-8
Java
false
false
131
java
package e.h.b; public class Calc_1_1_4716 { /** @return the sum of a and b */ public int add(int a, int b) { return a+b; } }
[ "christian.halstrick@sap.com" ]
christian.halstrick@sap.com
ac6338a5bfbd92cbf3ee664eb8fac9588f4f3609
40d844c1c780cf3618979626282cf59be833907f
/src/testcases/CWE319_Cleartext_Tx_Sensitive_Info/CWE319_Cleartext_Tx_Sensitive_Info__URLConnection_driverManager_74a.java
5fd97e2953711074807ac9f793abd2bf5513430f
[]
no_license
rubengomez97/juliet
f9566de7be198921113658f904b521b6bca4d262
13debb7a1cc801977b9371b8cc1a313cd1de3a0e
refs/heads/master
2023-06-02T00:37:24.532638
2021-06-23T17:22:22
2021-06-23T17:22:22
379,676,259
1
0
null
null
null
null
UTF-8
Java
false
false
6,959
java
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE319_Cleartext_Tx_Sensitive_Info__URLConnection_driverManager_74a.java Label Definition File: CWE319_Cleartext_Tx_Sensitive_Info.label.xml Template File: sources-sinks-74a.tmpl.java */ /* * @description * CWE: 319 Cleartext Transmission of Sensitive Information * BadSource: URLConnection Read password from a web server with URLConnection * GoodSource: Set password to a hardcoded value (one that was not sent over the network) * Sinks: driverManager * GoodSink: Decrypt the password from the source before using it in database connection * BadSink : Use password directly from source in database connection * Flow Variant: 74 Data flow: data passed in a HashMap from one method to another in different source files in the same package * * */ package testcases.CWE319_Cleartext_Tx_Sensitive_Info; import testcasesupport.*; import java.util.HashMap; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.util.logging.Level; public class CWE319_Cleartext_Tx_Sensitive_Info__URLConnection_driverManager_74a extends AbstractTestCase { public void bad() throws Throwable { String password; password = ""; /* init password */ /* read input from URLConnection */ { URLConnection urlConnection = (new URL("http://www.example.org/")).openConnection(); BufferedReader readerBuffered = null; InputStreamReader readerInputStream = null; try { readerInputStream = new InputStreamReader(urlConnection.getInputStream(), "UTF-8"); readerBuffered = new BufferedReader(readerInputStream); /* POTENTIAL FLAW: Read password from a web server with URLConnection */ /* This will be reading the first "line" of the response body, * which could be very long if there are no newlines in the HTML */ password = readerBuffered.readLine(); } catch (IOException exceptIO) { IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO); } finally { /* clean up stream reading objects */ try { if (readerBuffered != null) { readerBuffered.close(); } } catch (IOException exceptIO) { IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO); } try { if (readerInputStream != null) { readerInputStream.close(); } } catch (IOException exceptIO) { IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO); } } } HashMap<Integer,String> passwordHashMap = new HashMap<Integer,String>(); passwordHashMap.put(0, password); passwordHashMap.put(1, password); passwordHashMap.put(2, password); (new CWE319_Cleartext_Tx_Sensitive_Info__URLConnection_driverManager_74b()).badSink(passwordHashMap ); } public void good() throws Throwable { goodG2B(); goodB2G(); } /* goodG2B() - use GoodSource and BadSink */ private void goodG2B() throws Throwable { String password; /* FIX: Use a hardcoded password as the password (it was not sent over the network) */ /* INCIDENTAL FLAW: CWE-259 Hard Coded Password */ password = "Password1234!"; HashMap<Integer,String> passwordHashMap = new HashMap<Integer,String>(); passwordHashMap.put(0, password); passwordHashMap.put(1, password); passwordHashMap.put(2, password); (new CWE319_Cleartext_Tx_Sensitive_Info__URLConnection_driverManager_74b()).goodG2BSink(passwordHashMap ); } /* goodB2G() - use BadSource and GoodSink */ private void goodB2G() throws Throwable { String password; password = ""; /* init password */ /* read input from URLConnection */ { URLConnection urlConnection = (new URL("http://www.example.org/")).openConnection(); BufferedReader readerBuffered = null; InputStreamReader readerInputStream = null; try { readerInputStream = new InputStreamReader(urlConnection.getInputStream(), "UTF-8"); readerBuffered = new BufferedReader(readerInputStream); /* POTENTIAL FLAW: Read password from a web server with URLConnection */ /* This will be reading the first "line" of the response body, * which could be very long if there are no newlines in the HTML */ password = readerBuffered.readLine(); } catch (IOException exceptIO) { IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO); } finally { /* clean up stream reading objects */ try { if (readerBuffered != null) { readerBuffered.close(); } } catch (IOException exceptIO) { IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO); } try { if (readerInputStream != null) { readerInputStream.close(); } } catch (IOException exceptIO) { IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO); } } } HashMap<Integer,String> passwordHashMap = new HashMap<Integer,String>(); passwordHashMap.put(0, password); passwordHashMap.put(1, password); passwordHashMap.put(2, password); (new CWE319_Cleartext_Tx_Sensitive_Info__URLConnection_driverManager_74b()).goodB2GSink(passwordHashMap ); } /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException { mainFromParent(args); } }
[ "you@example.com" ]
you@example.com
732ecd39352eac5b6f42252ebed9a0e50844849d
8bd7ff85c0fa5f09b5dd3dad8c2ac3f4c09c7913
/app/src/main/java/com/dc/transmission/glCore/MatrixState.java
ae3f41a5c51f3cc7a2b7c8b694802540b6e435d3
[]
no_license
TPEC/Transmission
eea6166b7491636a3a876fa34cc51d2698073cf4
0464cd7a855a57f51d18c25217807714be5ab702
refs/heads/master
2021-01-17T22:00:20.777705
2017-04-10T14:24:38
2017-04-10T14:24:38
84,184,853
0
0
null
null
null
null
UTF-8
Java
false
false
4,168
java
package com.dc.transmission.glCore; import android.opengl.Matrix; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; /** * Created by XIeQian on 2017/3/22. */ public class MatrixState { private static float[] mProjMatrix = new float[16]; private static float[] mVMatrix = new float[16]; private static float[] currMatrix; public static float[] lightLocation=new float[]{0,0,0}; public static FloatBuffer cameraFB; public static FloatBuffer lightPositionFB; static float[][] mStack=new float[10][16]; public static int stackTop=-1; public static void setInitStack() { currMatrix=new float[16]; Matrix.setRotateM(currMatrix, 0, 0, 1, 0, 0); } public static void pushMatrix() { stackTop++; for(int i=0;i<16;i++) { mStack[stackTop][i]=currMatrix[i]; } } public static void popMatrix() { for(int i=0;i<16;i++) { currMatrix[i]=mStack[stackTop][i]; } stackTop--; } public static void translate(float x,float y,float z) { Matrix.translateM(currMatrix, 0, x, y, z); } public static void rotate(float angle,float x,float y,float z) { Matrix.rotateM(currMatrix,0,angle,x,y,z); } public static void scale(float x,float y,float z){ Matrix.scaleM(currMatrix,0, x, y, z); } public static void matrix(float[] self){ float[] result=new float[16]; Matrix.multiplyMM(result,0,currMatrix,0,self,0); currMatrix=result; } static ByteBuffer llbb= ByteBuffer.allocateDirect(3*4); static float[] cameraLocation=new float[3]; public static void setCamera( float cx,float cy,float cz, float tx,float ty,float tz, float upx,float upy,float upz){ Matrix.setLookAtM ( mVMatrix, 0, cx, cy, cz, tx, ty, tz, upx, upy, upz ); cameraLocation[0]=cx; cameraLocation[1]=cy; cameraLocation[2]=cz; llbb.clear(); llbb.order(ByteOrder.nativeOrder()); cameraFB=llbb.asFloatBuffer(); cameraFB.put(cameraLocation); cameraFB.position(0); } public static void setProjectFrustum(float left, float right, float bottom, float top, float near, float far) { Matrix.frustumM(mProjMatrix, 0, left, right, bottom, top, near, far); } public static void setProjectOrtho(float left, float right, float bottom, float top, float near, float far) { Matrix.orthoM(mProjMatrix, 0, left, right, bottom, top, near, far); } private static float[] mVMatrixForSpecFrame = new float[16]; public static void copyMVMatrix() { for(int i=0;i<16;i++) { mVMatrixForSpecFrame[i]=mVMatrix[i]; } } static float[] mMVPMatrix=new float[16]; public static float[] getFinalMatrix() { Matrix.multiplyMM(mMVPMatrix, 0, mVMatrixForSpecFrame, 0, currMatrix, 0); Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mMVPMatrix, 0); return mMVPMatrix; } public static float[] getFinalMatrix(float[] spec) { mMVPMatrix=new float[16]; Matrix.multiplyMM(mMVPMatrix, 0, mVMatrix, 0, spec, 0); Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mMVPMatrix, 0); return mMVPMatrix; } public static float[] getMMatrix() { return currMatrix; } static ByteBuffer llbbL = ByteBuffer.allocateDirect(3*4); public static void setLightLocation(float x,float y,float z) { llbbL.clear(); lightLocation[0]=x; lightLocation[1]=y; lightLocation[2]=z; llbbL.order(ByteOrder.nativeOrder()); lightPositionFB=llbbL.asFloatBuffer(); lightPositionFB.put(lightLocation); lightPositionFB.position(0); } }
[ "489340274@qq.com" ]
489340274@qq.com
a526bff44147a28ac423f22e91149f0a99d415ea
2c0cbe6e538ad1ef391b14a5277f84ee5c2f27e9
/src/main/java/xinghuangxu/codereview/domain/Comment.java
359a81013d6a04a396c08a207e3801004f9192f4
[]
no_license
xinghuangxu/ReviewerRecommenderService
4a631a132c7236ad222bee27ecbe074890569ade
06d732d3aeca347d3a5d8d64a04468c24527799f
refs/heads/master
2021-01-10T01:19:39.065896
2016-03-30T21:54:24
2016-03-30T21:54:24
46,453,805
0
0
null
null
null
null
UTF-8
Java
false
false
975
java
package xinghuangxu.codereview.domain; import javax.persistence.*; import java.util.Date; /** * Created by xinghuangxu on 11/19/15. */ @Entity public class Comment { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; @Column(length=1025) private String message; private Date date; public Date getDate() { return date; } public String getMessage() { return message; } public Comment() { } public Comment(String message, Date date, Review review, Reviewer reviewer) { this.message = message; this.date = date; this.review = review; this.reviewer = reviewer; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "reviewer_id") private Reviewer reviewer; public Reviewer getReviewer(){ return reviewer; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "review_id") private Review review; }
[ "xinghuangxu@gmail.com" ]
xinghuangxu@gmail.com
00724ef038978ee9aa02e1a255e939621a0636aa
2a3282ef62c9d92c9abfe0e1eae170ec2a384555
/src/main/java/com/ledgy98/spring/lesson02/model/UsedGoods.java
8211a69ccd36e75802b94587067149d539ca0d81
[]
no_license
colleenInKorea/WebSpringExample0816
e133a21789e2a533683feca1691c95e8f88e3d69
ed67750f05be4890680f1baddc6df26ebe6209d3
refs/heads/master
2023-08-22T14:56:54.293139
2021-10-14T11:46:39
2021-10-14T11:46:39
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,238
java
package com.ledgy98.spring.lesson02.model; import java.util.Date; public class UsedGoods { private int id; private String title; private int price; private String description; private String picture; private int sellerId; private Date createdAt; private Date updatedAt; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public int getPrice() { return price; } public void setPrice(int price) { this.price = price; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getPicture() { return picture; } public void setPicture(String picture) { this.picture = picture; } public int getSellerId() { return sellerId; } public void setSellerId(int sellerId) { this.sellerId = sellerId; } public Date getCreatedAt() { return createdAt; } public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } public Date getUpdatedAt() { return updatedAt; } public void setUpdatedAt(Date updatedAt) { this.updatedAt = updatedAt; } }
[ "ledgy98@gmail.com" ]
ledgy98@gmail.com
67d408d11a3df551ddf98c7363e81c4519682d60
5aa5e94fc398bed432c81b961ebeb3e78db855b4
/lang/src/test/java/net/sjh/italker/push/lang/ExampleUnitTest.java
323f8b2db1fe041c209bf278fbef6b49d93d64f3
[]
no_license
shijunhong/IM-Android
0e67c8721ff42ecabf3e02750207ecc85d0d08a3
a967b3f7a0505e7be4e52c9c81b69e3ae7011494
refs/heads/master
2020-04-01T10:29:05.348806
2018-11-23T08:36:56
2018-11-23T08:36:56
153,119,526
0
0
null
null
null
null
UTF-8
Java
false
false
386
java
package net.sjh.italker.push.lang; 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); } }
[ "meair@qianyansoft.com" ]
meair@qianyansoft.com
11c18ea0a4e9fdd0c8c78167c5ec1613402cb6a9
80858eb0e9f0bd268292597ce5b1280fcb1f8378
/opensilex-security/src/main/java/org/opensilex/security/authentication/filters/CredentialFilter.java
2383d979e7924b1b5c205d1ba87d20ff3d394691
[]
no_license
Bennio/opensilex
2340b9521992ed0e40a7ffa78bd564b92671b7d0
96e02b315dd33037025e501c16f1fbeb60f30d5b
refs/heads/master
2023-04-23T14:35:54.084951
2021-04-30T07:41:33
2021-04-30T07:41:33
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,819
java
//****************************************************************************** // AuthenticationFilter.java // OpenSILEX - Licence AGPL V3.0 - https://www.gnu.org/licenses/agpl-3.0.en.html // Copyright © INRA 2019 // Contact: vincent.migot@inra.fr, anne.tireau@inra.fr, pascal.neveu@inra.fr //******************************************************************************n the template in the editor. package org.opensilex.security.authentication.filters; import org.opensilex.security.authentication.AuthenticationService; import java.io.IOException; import java.lang.reflect.Method; import java.util.Arrays; import javax.annotation.Priority; import javax.inject.Inject; import javax.ws.rs.Priorities; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerRequestFilter; import javax.ws.rs.container.ResourceInfo; import javax.ws.rs.core.Context; import javax.ws.rs.ext.Provider; import org.opensilex.server.exceptions.ForbiddenException; import org.opensilex.server.exceptions.UnauthorizedException; import org.opensilex.security.authentication.ApiProtected; import org.opensilex.security.authentication.dal.AuthenticationDAO; import org.opensilex.security.user.dal.UserModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * <pre> * Authentication filter * For more information on request filters with Jersey * see: https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/filters-and-interceptors.html * * For any API service call, check if method is annotated with {@code org.opensilex.server.security.ApiProtected} * In that case parse header token to determine current user. * If user as "admin" flag, allow access to protected service. * Otherwise check if current method is in user credentials. * Throw {@code org.opensilex.server.exceptions.UnauthorizedException} if issues occured during token decoding or no token provided * Throw {@code org.opensilex.server.exceptions.ForbiddenException} if user is not found or don't have right credentials * * If user is identified, it can be accessed in the corresponding API method this way: * <code> * ... * * &#64;Inject * private AuthenticationService authentication; * * ... * * &#64;GET * &#64;Path("api-method") ... * &#64;Produces(MediaType.APPLICATION_JSON) public Response apiMethod( * &#64;Context SecurityContext securityContext ) throws Exception { UserModel * currentUser = authentication.getCurrentUser(securityContext); * * ... Do stuff with current user } * * ... * </code> * </pre> * * @author Vincent Migot */ @Provider @Priority(Priorities.AUTHORIZATION) public class CredentialFilter implements ContainerRequestFilter { private static final Logger LOGGER = LoggerFactory.getLogger(CredentialFilter.class); @Context ResourceInfo resourceInfo; @Inject AuthenticationService authentication; @Override public void filter(ContainerRequestContext requestContext) throws IOException { UserModel user = (UserModel) requestContext.getSecurityContext().getUserPrincipal(); Method apiMethod = resourceInfo.getResourceMethod(); if (apiMethod != null) { // Get method ApiProtected annotation ApiProtected securityAnnotation = apiMethod.getAnnotation(ApiProtected.class); if (securityAnnotation != null) { // Throw exception if no token if (user == null || user.isAnonymous()) { throw new UnauthorizedException(); } boolean hasCredential = false; if (user.isAdmin()) { hasCredential = true; } else if (securityAnnotation.adminOnly()) { hasCredential = false; } else { // If user is not an admin check credentials if needed String credentialId = AuthenticationDAO.getCredentialIdFromMethod(apiMethod); if (credentialId != null) { // Get current API service credential // Get user credentials from token String[] accessList = authentication.decodeTokenCredentialsList(user.getToken()); // Check user credential existence hasCredential = Arrays.stream(accessList).anyMatch(credentialId::equals); } else { // If no specific credential, user logged in is sufficient hasCredential = true; } } if (!hasCredential) { throw new ForbiddenException("You don't have credentials to access this API"); } } } } }
[ "vincent.migot@inra.fr" ]
vincent.migot@inra.fr
20a5cef16ac0b45ee2ebea3a9725b243b6654d07
713c675673438a8c44a1c6a67bc5bba9fb4c128e
/src/by/it/markovich/lesson02/TaskB3.java
cd7f71c76cd5ea05691c504227b509f21a4e3e08
[]
no_license
iryna-markovich/cs2018-04-13
e13f8ef3aedc41252c1d2cf2811816616bd190e9
5664518a0992d9e88c6e03733b68624d268cf129
refs/heads/master
2020-03-11T13:37:56.923023
2018-04-26T14:57:29
2018-04-26T14:57:29
130,030,230
0
0
null
2018-04-18T08:31:02
2018-04-18T08:31:02
null
UTF-8
Java
false
false
1,193
java
package by.it.markovich.lesson02; /* Уберите комментарии с части кода, чтобы на экран вывелось сообщение «C Новым Годом». Требования: 1. Программа должна выводить на экран текст. 2. Нужно убрать комментарии в некоторых строках и не менять остальные. 3. В программу нельзя добавлять новые строки или удалять имеющиеся. 4. Выведенный текст должен соответствовать заданию. */ class TaskB3 { public static void main(String[] args) { // String s = "C"; // System.out.println("Новым Годом"); // System.out.println("C Новым"); // System.out.println("Годом"); System.out.print("C Новым"); // System.out.println("Годом"); // System.out.println(s); // System.out.print("C Новым!"); System.out.print(" "); System.out.println("Годом"); } }
[ "irina.markovich13@gmail.com" ]
irina.markovich13@gmail.com
327abda51c83b551cead6f25400481e57258183c
54c8c167565f5b6c0a989f8abe8265674eaac3a9
/src/fr/adrienbrault/idea/symfony2plugin/config/yaml/YamlCompletionContributor.java
925f83d0be8429125e2990def9c0cab9e6acb703
[ "MIT" ]
permissive
Codechanic/idea-php-symfony2-plugin
4cf904edb4dde56ecaba2445437ea578c6af3907
55239d8595e41cf10c2deee0ea95d1b8432bdf19
refs/heads/master
2020-12-27T09:35:08.896485
2016-03-23T12:55:27
2016-03-23T12:55:27
null
0
0
null
null
null
null
UTF-8
Java
false
false
24,917
java
package fr.adrienbrault.idea.symfony2plugin.config.yaml; import com.intellij.codeInsight.completion.*; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.openapi.util.Condition; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileVisitor; import com.intellij.patterns.PlatformPatterns; import com.intellij.patterns.StandardPatterns; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ProcessingContext; import com.jetbrains.php.PhpIndex; import com.jetbrains.php.completion.PhpLookupElement; import com.jetbrains.php.lang.psi.elements.Method; import com.jetbrains.php.lang.psi.elements.PhpClass; import fr.adrienbrault.idea.symfony2plugin.Symfony2Icons; import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent; import fr.adrienbrault.idea.symfony2plugin.config.component.ParameterLookupElement; import fr.adrienbrault.idea.symfony2plugin.config.doctrine.DoctrineStaticTypeLookupBuilder; import fr.adrienbrault.idea.symfony2plugin.config.yaml.completion.ConfigCompletionProvider; import fr.adrienbrault.idea.symfony2plugin.dic.ContainerParameter; import fr.adrienbrault.idea.symfony2plugin.dic.ServiceCompletionProvider; import fr.adrienbrault.idea.symfony2plugin.doctrine.DoctrineYamlAnnotationLookupBuilder; import fr.adrienbrault.idea.symfony2plugin.doctrine.EntityHelper; import fr.adrienbrault.idea.symfony2plugin.doctrine.component.PhpEntityClassCompletionProvider; import fr.adrienbrault.idea.symfony2plugin.doctrine.dict.DoctrineModelField; import fr.adrienbrault.idea.symfony2plugin.doctrine.dict.DoctrineModelFieldLookupElement; import fr.adrienbrault.idea.symfony2plugin.doctrine.metadata.util.DoctrineMetadataUtil; import fr.adrienbrault.idea.symfony2plugin.form.util.FormUtil; import fr.adrienbrault.idea.symfony2plugin.stubs.ContainerCollectionResolver; import fr.adrienbrault.idea.symfony2plugin.util.PhpElementsUtil; import fr.adrienbrault.idea.symfony2plugin.util.PsiElementUtils; import fr.adrienbrault.idea.symfony2plugin.util.SymfonyBundleFileCompletionProvider; import fr.adrienbrault.idea.symfony2plugin.util.completion.EventCompletionProvider; import fr.adrienbrault.idea.symfony2plugin.util.completion.PhpClassAndParameterCompletionProvider; import fr.adrienbrault.idea.symfony2plugin.util.completion.PhpClassCompletionProvider; import fr.adrienbrault.idea.symfony2plugin.util.completion.TagNameCompletionProvider; import fr.adrienbrault.idea.symfony2plugin.util.controller.ControllerCompletionProvider; import fr.adrienbrault.idea.symfony2plugin.util.dict.ServiceUtil; import fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper; import org.apache.commons.lang.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.yaml.psi.YAMLCompoundValue; import org.jetbrains.yaml.psi.YAMLKeyValue; import org.jetbrains.yaml.psi.YAMLSequence; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @author Daniel Espendiller <daniel@espendiller.net> */ public class YamlCompletionContributor extends CompletionContributor { private static final Map<String, String> SERVICE_KEYS = Collections.unmodifiableMap(new HashMap<String, String>() {{ put("class", "(string)"); put("public", "(bool)"); put("tags", null); put("alias", null); put("calls", null); put("arguments", null); put("synchronized", null); put("synthetic", null); put("lazy", "(bool)"); put("abstract", null); put("parent", null); put("scope", "request, prototype"); put("factory", ">= 2.6"); put("factory_class", "<= 2.5"); put("factory_service", "<= 2.5"); put("factory_method", "<= 2.5"); put("autowire", "(bool) >= 2.8"); put("deprecated", "(string) >= 2.8"); put("decorates", null); put("decoration_inner_name", null); put("decoration_priority", "(int) >= 2.8"); }}); public YamlCompletionContributor() { extend( CompletionType.BASIC, YamlElementPatternHelper.getServiceDefinition(), new ServiceCompletionProvider() ); extend( CompletionType.BASIC, YamlElementPatternHelper.getConfigKeyPattern(), new ConfigCompletionProvider() ); extend( CompletionType.BASIC, YamlElementPatternHelper.getAfterCommaPattern(), new FactoryMethodCompletionProvider() ); extend( CompletionType.BASIC, YamlElementPatternHelper.getServiceParameterDefinition(), new CompletionProvider<CompletionParameters>() { public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) { if(!Symfony2ProjectComponent.isEnabled(parameters.getPosition())) { return; } PsiElement element = parameters.getOriginalPosition(); if(element == null) { return; } for(ContainerParameter containerParameter: ContainerCollectionResolver.getParameters(parameters.getPosition().getProject()).values()) { resultSet.addElement(new ParameterLookupElement(containerParameter, ParameterPercentWrapInsertHandler.getInstance(), element.getText())); } } } ); extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmSingleLineScalarKey("unique"), new YamlCompletionProvider(new DoctrineStaticTypeLookupBuilder().getNullAble())); extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmSingleLineScalarKey("nullable"), new YamlCompletionProvider(new DoctrineStaticTypeLookupBuilder().getNullAble())); extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmSingleLineScalarKey("associationKey"), new YamlCompletionProvider(new DoctrineStaticTypeLookupBuilder().getNullAble())); extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmParentLookup("joinColumn"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\JoinColumn")); extend(CompletionType.BASIC, YamlElementPatternHelper.getFilterOnPrevParent("joinColumns"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\JoinColumn")); extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmParentLookup("joinTable"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\JoinTable")); extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmRoot(), new YamlCompletionProvider(new DoctrineStaticTypeLookupBuilder().getRootItems())); extend(CompletionType.BASIC, YamlElementPatternHelper.getFilterOnPrevParent("id"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\Column", "associationKey")); extend(CompletionType.BASIC, YamlElementPatternHelper.getFilterOnPrevParent("fields"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\Column")); extend(CompletionType.BASIC, YamlElementPatternHelper.getFilterOnPrevParent("oneToOne"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\OneToOne")); extend(CompletionType.BASIC, YamlElementPatternHelper.getFilterOnPrevParent("oneToMany"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\OneToMany")); extend(CompletionType.BASIC, YamlElementPatternHelper.getFilterOnPrevParent("manyToOne"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\ManyToOne")); extend(CompletionType.BASIC, YamlElementPatternHelper.getFilterOnPrevParent("manyToMany"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\ManyToMany")); extend(CompletionType.BASIC, YamlElementPatternHelper.getSingleLineScalarKey("class", "factory_class"), new PhpClassAndParameterCompletionProvider()); extend(CompletionType.BASIC, YamlElementPatternHelper.getSingleLineScalarKey("factory_service", "parent"), new ServiceCompletionProvider()); extend(CompletionType.BASIC, YamlElementPatternHelper.getParameterClassPattern(), new PhpClassCompletionProvider()); extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmSingleLineScalarKey("targetEntity", "targetDocument"), new PhpEntityClassCompletionProvider()); extend(CompletionType.BASIC, YamlElementPatternHelper.getSingleLineScalarKey("mappedBy", "inversedBy"), new OrmRelationCompletionProvider()); extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmSingleLineScalarKey("referencedColumnName"), new ReferencedColumnCompletionProvider()); extend(CompletionType.BASIC, YamlElementPatternHelper.getSingleLineScalarKey("_controller"), new ControllerCompletionProvider()); extend(CompletionType.BASIC, YamlElementPatternHelper.getSingleLineScalarKey("resource"), new SymfonyBundleFileCompletionProvider("Resources/config", "Controller")); extend(CompletionType.BASIC, YamlElementPatternHelper.getSingleLineScalarKey("resource"), new DirectoryScopeCompletionProvider()); extend(CompletionType.BASIC, YamlElementPatternHelper.getSuperParentArrayKey("services"), new YamlCompletionProvider(SERVICE_KEYS)); extend(CompletionType.BASIC, YamlElementPatternHelper.getWithFirstRootKey(), new RouteKeyNameYamlCompletionProvider(new String[] {"pattern", "defaults", "path", "requirements", "methods", "condition", "resource", "prefix"})); extend(CompletionType.BASIC, YamlElementPatternHelper.getParentKeyName("requirements"), new RouteRequirementsCompletion()); extend(CompletionType.BASIC, StandardPatterns.and( YamlElementPatternHelper.getInsideKeyValue("tags"), YamlElementPatternHelper.getSingleLineScalarKey("event") ), new EventCompletionProvider()); extend(CompletionType.BASIC, StandardPatterns.and( YamlElementPatternHelper.getInsideKeyValue("tags"), YamlElementPatternHelper.getSingleLineScalarKey("alias") ), new FormAliasCompletionProvider()); extend(CompletionType.BASIC, StandardPatterns.and( YamlElementPatternHelper.getInsideKeyValue("calls") ), new ServiceCallsMethodCompletion()); extend(CompletionType.BASIC, StandardPatterns.and( YamlElementPatternHelper.getInsideKeyValue("tags"), YamlElementPatternHelper.getSingleLineScalarKey("method") ), new ServiceCallsMethodTestCompletion()); extend(CompletionType.BASIC, StandardPatterns.and( YamlElementPatternHelper.getInsideKeyValue("tags"), YamlElementPatternHelper.getSingleLineScalarKey("name") ), new TagNameCompletionProvider()); extend(CompletionType.BASIC, YamlElementPatternHelper.getSingleLineScalarKey("factory_method"), new ServiceClassMethodInsideScalarKeyCompletion("factory_service")); } private static class FactoryMethodCompletionProvider extends CompletionProvider<CompletionParameters> { @Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { PsiElement position = parameters.getPosition(); if(!Symfony2ProjectComponent.isEnabled(position)) { return; } PsiElement prevSiblingOfType = PsiElementUtils.getPrevSiblingOfType(position, YamlElementPatternHelper.getPreviousCommaSibling()); if(prevSiblingOfType == null) { return; } String service = PsiElementUtils.trimQuote(prevSiblingOfType.getText()); if(StringUtils.isBlank(service)) { return; } PhpClass phpClass = ServiceUtil.getServiceClass(prevSiblingOfType.getProject(), service); if(phpClass == null) { return; } for (Method method : phpClass.getMethods()) { if(method.getAccess().isPublic() && !(method.getName().startsWith("__"))) { completionResultSet.addElement(new PhpLookupElement(method)); } } } } public static class DirectoryScopeCompletionProvider extends CompletionProvider<CompletionParameters> { @Override protected void addCompletions(@NotNull CompletionParameters completionParameters, final ProcessingContext processingContext, @NotNull final CompletionResultSet completionResultSet) { PsiFile originalFile = completionParameters.getOriginalFile(); final PsiDirectory containingDirectory = originalFile.getContainingDirectory(); if (containingDirectory == null) { return; } final VirtualFile containingDirectoryFiles = containingDirectory.getVirtualFile(); VfsUtil.visitChildrenRecursively(containingDirectoryFiles, new VirtualFileVisitor() { @Override public boolean visitFile(@NotNull VirtualFile file) { String relativePath = VfsUtil.getRelativePath(file, containingDirectoryFiles, '/'); if (relativePath == null) { return super.visitFile(file); } completionResultSet.addElement(LookupElementBuilder.create(relativePath).withIcon(file.getFileType().getIcon())); return super.visitFile(file); } }); } } private class ServiceCallsMethodTestCompletion extends CompletionProvider<CompletionParameters> { protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } PsiElement psiElement = completionParameters.getPosition(); YAMLCompoundValue yamlCompoundValue = PsiTreeUtil.getParentOfType(psiElement, YAMLCompoundValue.class); if(yamlCompoundValue == null) { return; } yamlCompoundValue = PsiTreeUtil.getParentOfType(yamlCompoundValue, YAMLCompoundValue.class); if(yamlCompoundValue == null) { return; } addYamlClassMethods(yamlCompoundValue, completionResultSet, "class"); } } private class ServiceClassMethodInsideScalarKeyCompletion extends CompletionProvider<CompletionParameters> { private String yamlArrayKeyName; public ServiceClassMethodInsideScalarKeyCompletion(String yamlArrayKeyName) { this.yamlArrayKeyName = yamlArrayKeyName; } protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } PsiElement psiElement = completionParameters.getPosition(); YAMLCompoundValue yamlCompoundValue = PsiTreeUtil.getParentOfType(psiElement, YAMLCompoundValue.class); if(yamlCompoundValue == null) { return; } addYamlClassMethods(yamlCompoundValue, completionResultSet, this.yamlArrayKeyName); } } private class ServiceCallsMethodCompletion extends CompletionProvider<CompletionParameters> { protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } // TODO: move this to pattern; filters match on parameter array // - [ setContainer, [ @service_container ] ] PsiElement psiElement = completionParameters.getPosition(); if(psiElement.getParent() == null || !(psiElement.getParent().getContext() instanceof YAMLSequence)) { return; } YAMLKeyValue callYamlKeyValue = PsiTreeUtil.getParentOfType(psiElement, YAMLKeyValue.class); if(callYamlKeyValue == null) { return; } addYamlClassMethods(callYamlKeyValue.getContext(), completionResultSet, "class"); } } private static void addYamlClassMethods(@Nullable PsiElement psiElement, CompletionResultSet completionResultSet, String classTag) { if(psiElement == null) { return; } YAMLKeyValue classKeyValue = PsiElementUtils.getChildrenOfType(psiElement, PlatformPatterns.psiElement(YAMLKeyValue.class).withName(classTag)); if(classKeyValue == null) { return; } PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), classKeyValue.getValueText()); if(phpClass != null) { PhpElementsUtil.addClassPublicMethodCompletion(completionResultSet, phpClass); } } private static class FormAliasCompletionProvider extends CompletionProvider<CompletionParameters> { @Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) { return; } PsiElement psiElement = completionParameters.getPosition(); YAMLCompoundValue yamlCompoundValue = PsiTreeUtil.getParentOfType(psiElement, YAMLCompoundValue.class); if(yamlCompoundValue == null) { return; } yamlCompoundValue = PsiTreeUtil.getParentOfType(yamlCompoundValue, YAMLCompoundValue.class); if(yamlCompoundValue == null) { return; } String value = YamlHelper.getYamlKeyValueAsString(yamlCompoundValue, "class", true); if(value != null) { PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), value); if(phpClass != null) { FormUtil.attachFormAliasesCompletions(phpClass, completionResultSet); } } } } private static class OrmRelationCompletionProvider extends CompletionProvider<CompletionParameters> { @Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { PsiElement position = completionParameters.getPosition(); if(!Symfony2ProjectComponent.isEnabled(position)) { return; } YAMLCompoundValue yamlCompoundValue = PsiTreeUtil.getParentOfType(position, YAMLCompoundValue.class); if(yamlCompoundValue == null) { return; } String className = YamlHelper.getYamlKeyValueAsString(yamlCompoundValue, "targetEntity", false); if(className == null) { return; } PhpClass phpClass = PhpElementsUtil.getClass(position.getProject(), className); if(phpClass == null) { return; } for(DoctrineModelField field: EntityHelper.getModelFields(phpClass)) { if(field.getRelation() != null) { completionResultSet.addElement(new DoctrineModelFieldLookupElement(field)); } } } } /** * many_to_many: * targetEntity: espend\Doctrine\RelationBundle\Entity\ForeignEntity * joinTable: * name: cms_users_groups * joinColumns: * user_id: * referencedColumnName: id */ private static class ReferencedColumnCompletionProvider extends CompletionProvider<CompletionParameters> { @Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { PsiElement position = completionParameters.getPosition(); if(!Symfony2ProjectComponent.isEnabled(position)) { return; } PsiElement psiElement = PsiTreeUtil.findFirstParent(position, new Condition<PsiElement>() { @Override public boolean value(PsiElement psiElement) { if (psiElement instanceof YAMLKeyValue) { String s = ((YAMLKeyValue) psiElement).getKeyText().toLowerCase(); if ("joinTable".equalsIgnoreCase(s)) { return true; } } return false; } }); if(psiElement == null) { return; } PsiElement yamlCompoundValue = psiElement.getParent(); if(!(yamlCompoundValue instanceof YAMLCompoundValue)) { return; } String className = YamlHelper.getYamlKeyValueAsString((YAMLCompoundValue) yamlCompoundValue, "targetEntity", false); if(className == null) { return; } PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), className); if(phpClass == null) { return; } for(DoctrineModelField field: EntityHelper.getModelFields(phpClass)) { if(field.getRelation() == null) { String columnName = field.getColumn(); if(columnName == null) { completionResultSet.addElement(LookupElementBuilder.create(field.getName()).withIcon(Symfony2Icons.DOCTRINE)); } else { completionResultSet.addElement(LookupElementBuilder.create(columnName).withTypeText(field.getName(), false).withIcon(Symfony2Icons.DOCTRINE)); } } } } } private static class RouteKeyNameYamlCompletionProvider extends YamlCompletionProvider { public RouteKeyNameYamlCompletionProvider(String[] lookups) { super(lookups); } public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) { if(!YamlHelper.isRoutingFile(parameters.getOriginalFile())) { return; } super.addCompletions(parameters, context, resultSet); } } /** * "requirements" on "path/pattern: /hello/{name}" */ private class RouteRequirementsCompletion extends CompletionProvider<CompletionParameters> { @Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { YAMLKeyValue yamlKeyValue = PsiTreeUtil.getParentOfType(completionParameters.getOriginalPosition(), YAMLKeyValue.class); if(yamlKeyValue != null) { PsiElement compoundValue = yamlKeyValue.getParent(); if(compoundValue instanceof YAMLCompoundValue) { // path and pattern are valid String pattern = YamlHelper.getYamlKeyValueAsString((YAMLCompoundValue) compoundValue, "path", false); if(pattern == null) { pattern = YamlHelper.getYamlKeyValueAsString((YAMLCompoundValue) compoundValue, "pattern", false); } if(pattern != null) { Matcher matcher = Pattern.compile("\\{(\\w+)}").matcher(pattern); while(matcher.find()){ completionResultSet.addElement(LookupElementBuilder.create(matcher.group(1))); } } } } } } }
[ "espendiller@gmx.de" ]
espendiller@gmx.de
80ad34c54bc368ddb7e742d762d1cd4a8f47c50c
be5d633ebce2b0030bc38636283c75dac127c82b
/src/ConnectN/client/Client.java
5240db1115d1908b1b70504dafaf751bcdd6df8b
[]
no_license
ilikemyname/connect-n
b52a12e5fb491e4b582a6eb5fa7e1b8eed232bdc
3bb8efbb8e5c775c64f388cea2dc003424602768
refs/heads/master
2021-01-19T00:14:31.442256
2015-02-09T08:53:48
2015-02-09T08:53:48
30,287,234
0
0
null
null
null
null
UTF-8
Java
false
false
316
java
package ConnectN.client; import ConnectN.client.view.components.MetroStyle; import ConnectN.client.view.forms.Dialog_Login; /** * * @author phuy */ public class Client { public static void main(String args[]) { MetroStyle.setLookAndFeel("dark"); new Dialog_Login(); } }
[ "iphathuy@gmail.com" ]
iphathuy@gmail.com
1627a71754c8df380a503c51833b29ea6dc45187
7dabfec176ed563602ee5b59b7339b6367a8f08d
/addressbook-web-tests/src/test/java/ru/stqa/pft/addressbook/appmanager/NavigationHelper.java
635dbd32a8459fc8ce8036af68bc801aa2aa5aa5
[ "Apache-2.0" ]
permissive
ktvgithub/java_ktv
18e48043e5a09e0b3758925c32d0ec26a52378c4
204f00835cfefaa0197c4555147d2a86f4da82ee
refs/heads/master
2020-04-26T13:46:02.125421
2019-05-05T08:03:31
2019-05-05T08:03:31
173,590,027
1
0
null
null
null
null
UTF-8
Java
false
false
910
java
package ru.stqa.pft.addressbook.appmanager; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.Select; public class NavigationHelper extends HelperBase { public NavigationHelper(WebDriver wd) { super(wd); } public void groupPage() { if (isElementPresent(By.tagName("h1")) && wd.findElement(By.tagName("h1")).getText().equals("Group") && isElementPresent(By.name("new"))) { return; } else { click(By.linkText("groups")); } } public void contactPage() { if (isElementPresent(By.id("maintable"))) { return; } else { click(By.linkText("home")); } } public void insideGroup(String groupName) { Select value = new Select(wd.findElement(By.name("group"))); value.selectByVisibleText(groupName); } public void clickLogo() { click(By.id("logo")); } }
[ "ktvbox@mail.ru" ]
ktvbox@mail.ru
940752edb3797e2e7e8084314e9118107fd5b0b6
172268b1e262a0c78a150c91952217f85c174035
/rabbion-hystrix/src/test/java/com/wuhj/RabbionHystrixApplicationTests.java
62be0cacf7e373d8cca14abe53b72be51cbdc139
[]
no_license
whj1121/spring-cloud-test-hystrix
8540e813ce0edacbdfb08958ae83a17f1822e060
5189bfe23e46b26615b9562953bfd0b6498c95f6
refs/heads/master
2020-03-22T21:01:48.914317
2018-07-12T02:36:05
2018-07-12T02:36:05
140,650,624
0
0
null
null
null
null
UTF-8
Java
false
false
333
java
package com.wuhj; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest public class RabbionHystrixApplicationTests { @Test public void contextLoads() { } }
[ "kaitong.com" ]
kaitong.com
cba55f6be0e4bb571566f1b5b1a90e8e4fb9ac79
542ae72ba32980eba2462f8426e81432915cc9b0
/test/src/main/java/bridge/GreenCircle.java
64a687a5cd53fe5fa23f12c5bdfeea67df62698b
[]
no_license
zkning/j2ee
e56591e9cce7dc9e04de5068899c0b6653c5341b
4eb87f778ecc4e31fefd92e63698d38270a7c7e7
refs/heads/master
2021-07-09T00:24:22.147891
2019-10-14T03:41:29
2019-10-14T03:41:29
195,164,156
0
0
null
2020-10-13T15:00:07
2019-07-04T03:41:27
Java
UTF-8
Java
false
false
188
java
package bridge; public class GreenCircle implements DrawApi { @Override public void draw(int x, int y) { System.out.println("画绿色圆:X=" + x + ",y=" + y); } }
[ "ningzuokun@hzed.com" ]
ningzuokun@hzed.com
f9c2a21f52c2a96898ed6afdb2546154d51b032c
09bca85a09a04c7b03393cebdbfed88c6af4b0d2
/src/main/java/com/quest/test/proxy/dynamicPorxy/jdkInvoke/StarAgent.java
016676d2461fa13151a428e3e23c109c14f5edde
[]
no_license
claygan/Tools
7355b6981349422207d6a5427400bf46cb84725a
4f50c89413eb856f545112448b57946dd192405c
refs/heads/master
2021-01-22T05:57:31.905634
2019-04-03T06:59:37
2019-04-03T06:59:37
92,509,372
0
0
null
null
null
null
UTF-8
Java
false
false
311
java
package com.quest.test.proxy.dynamicPorxy.jdkInvoke; import java.lang.reflect.Proxy; public class StarAgent { public static Object proxy(Object target) { return Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), new MyInvocationHandler(target)); } }
[ "gansm@aijk.com" ]
gansm@aijk.com
3cc06cd173acd55ba1758d306a95d4583fd35e78
af5a05ec2ba2dff11e0c3ab311f1472e59310373
/app/src/main/java/com/example/kys_8/easymeetings/ui/activity/ChangePWActivity.java
4f551f551f966ea3f4a622d9601d10d5b2eb8f59
[]
no_license
jianhuidev/EasyMeetings
a515b3a213dfc018e37a4fbea43dc2890f6c9dff
56d8f6fd8c1b492e8bcec9f636d8c940d5279d48
refs/heads/master
2020-04-28T10:30:34.522422
2019-04-21T06:29:24
2019-04-21T06:29:24
175,203,577
0
0
null
null
null
null
UTF-8
Java
false
false
2,801
java
package com.example.kys_8.easymeetings.ui.activity; import android.content.Intent; import android.support.design.widget.TextInputEditText; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.widget.RelativeLayout; import com.example.kys_8.easymeetings.R; import com.example.kys_8.easymeetings.bean.TSVariable; import com.example.kys_8.easymeetings.utils.LogUtil; import com.example.kys_8.easymeetings.utils.ToastUtil; import cn.bmob.v3.exception.BmobException; import cn.bmob.v3.listener.UpdateListener; public class ChangePWActivity extends BaseActivity implements View.OnClickListener{ private TextInputEditText old_password_et,new_password_et; private RelativeLayout affirm_modify; @Override protected int getContentView() { return R.layout.activity_change_pw; } @Override protected void initView() { old_password_et = (TextInputEditText)findViewById(R.id.old_password_change); new_password_et = (TextInputEditText)findViewById(R.id.new_password_change); affirm_modify = (RelativeLayout)findViewById(R.id.affirm_modify_change); } @Override protected void initListener() { affirm_modify.setOnClickListener(this); } @Override protected String getTitleText() { return "修改密码"; } @Override public void onClick(View view) { switch (view.getId()){ case R.id.affirm_modify_change: if (TextUtils.isEmpty(old_password_et.getText().toString().trim()) || TextUtils.isEmpty(new_password_et.getText().toString().trim())){ ToastUtil.showToast(this,"新旧密码不能为空"); return; } if (old_password_et.getText().toString().trim().equals(TSVariable.curUserPassWord)){ TSVariable.userInfo.setValue("password",new_password_et.getText().toString().trim()); TSVariable.userInfo.update(new UpdateListener() { @Override public void done(BmobException e) { if (e == null){ ToastUtil.showToast(ChangePWActivity.this,"修改密码成功"); }else { ToastUtil.showToast(ChangePWActivity.this,"修改密码失败"); LogUtil.e("ChangePWActivity",e.getMessage()); } } }); }else { ToastUtil.showToast(this,"请检查旧密码是否填写正确"); } break; } } }
[ "2366028396@qq.com" ]
2366028396@qq.com
70df34e4cf7950c173a62d6d77d0699dfe4a9178
9760b274e3fa067c154f6b1ac2e58955a4341a65
/src/main/java/com/prac/springboot/config/auth/LoginUser.java
d13dcd8881aa0604835c36480215b1ea923b4724
[]
no_license
xeyong/prac_boot
b8c6bc380fef5792c067269282586c512291e1f3
61f278784ff57c6f0b84f9d2d1303191ea47251e
refs/heads/master
2023-05-02T14:47:25.549436
2021-05-17T11:41:38
2021-05-17T11:41:38
365,110,963
0
0
null
null
null
null
UTF-8
Java
false
false
303
java
package com.prac.springboot.config.auth; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) public @interface LoginUser { }
[ "recruyong@gmail.com" ]
recruyong@gmail.com
db210758b4f87812e37e85e90d7d731bffab9a13
ee5d5de92ac80ff841b9618b23929b99f26a2a52
/core/core-impl/src/main/java/com/minxc/emp/core/impl/executor/ExecutorFactory.java
85e5707ff5de0d0170aa5d15b873d16b048c5377
[]
no_license
liveqmock/iEMPv7.1
827d1aaa714f4feee9ee12ab11f87d8a58563811
ac77fbe3df7835cab7952600e2a045a444846c69
refs/heads/master
2020-03-30T11:53:38.407497
2018-10-01T13:06:30
2018-10-01T13:06:30
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,726
java
package com.minxc.emp.core.impl.executor; import com.google.common.collect.Maps; import com.minxc.emp.core.util.AppContextUtil; import org.minxc.emp.core.api.executor.Executor; import java.util.*; import java.util.Map.Entry; /** * 执行器的服务类 * * @author min.xianchang */ public class ExecutorFactory { private static final Map<Class, Map> sourceMap = Maps.newHashMap(); private ExecutorFactory() { } /** * <pre> * 初始化map方法 * </pre> */ private static <T> Map<String, Executor<T>> executorMap(Class<? extends Executor<T>> cls) { Map<String, Executor<T>> executorMap = sourceMap.get(cls); if (executorMap != null) { return executorMap; } executorMap = new LinkedHashMap<>(); Map<String, ? extends Executor<T>> map = AppContextUtil.getImplInstance(cls); List<Executor<T>> list = new ArrayList<>(); for (Entry<String, ? extends Executor<T>> entry : map.entrySet()) { Executor<T> executor = entry.getValue(); list.add(executor); } Collections.sort(list); for (Executor<T> executor : list) { executorMap.put(executor.getKey(), executor); } //入缓存 sourceMap.put(cls, executorMap); return executorMap; } /** * <pre> * 调用指定插件服务 * </pre> * * @param cls * 要运行的插件类,可以是具体的某个指定插件,也可以是一个抽象的父插件 * @param param * 参数 */ public static <T> void execute(Class<? extends Executor<T>> cls, T param) { for (Entry<String, Executor<T>> entry : executorMap(cls).entrySet()) { Executor<T> executor = entry.getValue(); executor.execute(param); } } }
[ "xianchangmin@126.com" ]
xianchangmin@126.com
e861ae8654b63639e5bee380c5583cd23ba1b5c5
339d7b4f435f477a431757e9f2598b13b45eaca4
/restaurante/src/main/java/com/capgemini/restaurante/service/RestauranteService.java
a81911364a985c1aa3d6a09fe03316a7ddbe3f0d
[]
no_license
polianealmeida/projetoRestaurante
225beb87b39e01c1351f5b1ac1409aa3203faddc
d6a9412efb1abfbed3cfacf9d3359f05e5f78ce2
refs/heads/master
2022-04-17T12:10:56.365939
2020-04-20T12:31:15
2020-04-20T12:31:15
257,255,836
0
0
null
null
null
null
UTF-8
Java
false
false
2,434
java
package com.capgemini.restaurante.service; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.capgemini.restaurante.dto.BuscaGeolocalizacaoDTO; import com.capgemini.restaurante.dto.RestauranteDTO; import com.capgemini.restaurante.dto.TipoComidaDTO; import com.capgemini.restaurante.model.Restaurante; import com.capgemini.restaurante.model.TipoComida; import com.capgemini.restaurante.repository.RestauranteRepository; @Service public class RestauranteService { @Autowired private RestauranteRepository restauranteRepository; public List<RestauranteDTO> buscarRestaruantePorDescricao(String descricao) { List<RestauranteDTO> restaurantes = new ArrayList<>(); restauranteRepository.findByDescricaoLike("%" + descricao + "%").forEach(a -> { restaurantes.add(entityToDTO(a)); }); return restaurantes; } public List<RestauranteDTO> buscarRestaruantePorIdTipoComida(String idTtipoComida) { List<RestauranteDTO> restaurantes = new ArrayList<>(); restauranteRepository.findByIdTipoComida(idTtipoComida).forEach(a -> { restaurantes.add(entityToDTO(a)); }); return restaurantes; } public List<RestauranteDTO> buscarRestaruantePorGeolocalizacao(BuscaGeolocalizacaoDTO buscaGeolocalizacao) { return null; } private RestauranteDTO entityToDTO(Restaurante a) { RestauranteDTO r = new RestauranteDTO(); r.setId(a.getId()); r.setCodigo(a.getCodigo()); r.setDescricao(a.getDescricao()); r.setLatitude(a.getLatitude()); r.setLongitude(a.getLongitude()); r.setEndereco(a.getEndereco()); r.setTipoComida(new TipoComidaDTO(a.getTipoComida().getId(), a.getTipoComida().getCodigo(), a.getTipoComida().getDescricao())); return r; } public void salvarRestaurante(RestauranteDTO restauranteDTO) { Restaurante restaurante = new Restaurante(restauranteDTO.getId()); restaurante.setCodigo(restauranteDTO.getCodigo()); restaurante.setDescricao(restauranteDTO.getDescricao()); restaurante.setEndereco(restauranteDTO.getEndereco()); restaurante.setLatitude(restauranteDTO.getLatitude()); restaurante.setLongitude(restauranteDTO.getLongitude()); restaurante.setTipoComida(new TipoComida(restauranteDTO.getTipoComida().getId())); restauranteRepository.save(restaurante); } }
[ "polianealmeidas@gmail.com" ]
polianealmeidas@gmail.com
e6d94cfeae4edf0039c04389b6823a7db6d69fc2
164e25b4e15c21b36ad3c2fcfc931eaa2dadcda4
/rxsimplify/src/main/java/yun/yalantis/ucrop/util/CubicEasing.java
526e5fed6e462105b82bae10d1f5da288ff39587
[]
no_license
5hmlA/RxSimplify
f596c4aa5a0694b46f2f890e1ac00660bc1c86c0
00cb14721cb0a525835e058236f85f0e43f43754
refs/heads/master
2023-04-03T08:03:40.579230
2017-10-30T16:56:20
2017-10-30T16:56:20
null
0
0
null
null
null
null
UTF-8
Java
false
false
650
java
package yun.yalantis.ucrop.util; public final class CubicEasing { public static float easeOut(float time, float start, float end, float duration) { return end * ((time = time / duration - 1.0f) * time * time + 1.0f) + start; } public static float easeIn(float time, float start, float end, float duration) { return end * (time /= duration) * time * time + start; } public static float easeInOut(float time, float start, float end, float duration) { return (time /= duration / 2.0f) < 1.0f ? end / 2.0f * time * time * time + start : end / 2.0f * ((time -= 2.0f) * time * time + 2.0f) + start; } }
[ "jonas.jzy@gmail.com" ]
jonas.jzy@gmail.com
f1b67aee1af1e9087b7e152c8a658e8398e9b6f1
32868cd5d636f78fd0a061f44cb7e89012779392
/src/main/java/com/maxdavis/cursomc/repositories/EnderecoRepository.java
1eeb1471eea80df53c5501a4936a93c9b6b49621
[]
no_license
maxdavis/cursomc
58187a09f2a61e258cd700c7e8ad5b30de0bc9f0
aee21724ad50d98996d916f88b74b2d70b85e411
refs/heads/master
2020-03-31T15:31:31.537825
2018-10-14T14:29:41
2018-10-14T14:29:41
112,127,192
0
0
null
null
null
null
UTF-8
Java
false
false
304
java
package com.maxdavis.cursomc.repositories; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import com.maxdavis.cursomc.domain.Endereco; @Repository public interface EnderecoRepository extends JpaRepository<Endereco, Integer> { }
[ "maxdavisdesign@gmail.com" ]
maxdavisdesign@gmail.com
ee5785be93460b8cafea73025fee54a5b7743af2
8303133602e4fabc0c6193a2344d1871a45a07c9
/mc/src/main/java/com/moviecentral/mc/entity/PlayHistory.java
1969d1e8228a51a48a32708d30edecd6b1c4c031
[]
no_license
Nayak11/Netflix_TeamProject
03f4b235d389b0f762c20d7d6601443c1490e9e8
8458ed2ee7b3dd7e287c5d32c96d4e9c1ecb14f0
refs/heads/master
2020-04-19T12:44:07.148600
2019-01-29T17:49:58
2019-01-29T17:49:58
168,199,623
1
0
null
null
null
null
UTF-8
Java
false
false
1,068
java
package com.moviecentral.mc.entity; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "playhistory") public class PlayHistory { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer playid; private Integer userid; private Integer movieid; java.sql.Timestamp date; private String type; public Integer getPlayid() { return playid; } public void setPayid(Integer payid) { this.playid = payid; } public Integer getUserid() { return userid; } public void setUserid(Integer userid) { this.userid = userid; } public Integer getMovieid() { return movieid; } public void setMovieid(Integer movieid) { this.movieid = movieid; } public java.sql.Timestamp getDate() { return date; } public void setDate(java.sql.Timestamp date) { this.date = date; } public String getType() { return type; } public void setType(String type) { this.type = type; } }
[ "snsuhasnayak@gmail.com" ]
snsuhasnayak@gmail.com
e8bbcd6f6ceb601cbddf973fa903ba65ce3b5620
b40a0f5ae9330bffe6ebad3303aa8e7ceb827354
/OOP/Homework 2/PART 2/src/SatalliteIterator.java
7538dcdf5b85f41aa8d26a51e530006a9cc3eb35
[]
no_license
celikferhat/ferhat_celik
939be16660911b9cf2667a7ae4f9f8bfe35fe141
30230789ea34f31d3b504f9001d964891f69ab15
refs/heads/master
2021-06-18T01:52:49.681839
2021-03-01T10:24:19
2021-03-01T10:24:19
171,932,788
0
0
null
null
null
null
UTF-8
Java
false
false
2,187
java
import java.util.Iterator; /** * My iterator class */ public class SatalliteIterator implements Iterator { /** * 2d array */ Integer [][] Data ; /** * x and y positions */ int posx,posy = 0; /** * directions */ int [][] dirs = {{1, 0},{0, 1}, {-1, 0}, {0, -1}}; /** * direction position */ int dir = 0; /** * some helper variables */ int ex0 = 0; int ex1 = 0; int ey0 = 0; int ey1 = 0; int hn = 0; /** * * @param data Takes parameter as 2D array */ public SatalliteIterator(Integer[][] data) { Data = data; } /** * Controls there is a next or not * @return if there is next element return true , else false */ @Override public boolean hasNext() { return hn < Data.length * Data[0].length; } /** * * @return Returns next element */ @Override public Object next() { int number = Data[posx][posy]; hn ++; if(hn < Data.length * Data[0].length) { int x = dirs[dir][0]; int y = dirs[dir][1]; while (!check(posx + x, posy + y)) { dir = (dir + 1) % 4; x = dirs[dir][0]; y = dirs[dir][1]; switch (dir) { case 0: ex0++; break; case 1: ey0++; break; case 2: ex1++; break; case 3: ey1++; break; } } posx += dirs[dir][0]; posy += dirs[dir][1]; } return number; } /** * My helper function * @param x x position * @param y y position * @return controls next position is valid , if valid returns true , else returns false */ private boolean check(int x , int y){ return (x < (Data.length - ex1) && x >= (ex0) ) && (y < (Data[0].length - ey1) && y >= ey1); } }
[ "frht5382@gmail.com" ]
frht5382@gmail.com
0159e99e55d164e9525c9f5b82db22af2ce6ba32
2c2b4c033ce6ba330efcc51db0f50d7f43bc3fcb
/entidades/AdicionarProfessorComando.java
9249227d0e0ef26b2668636f2e23013b66db8c7c
[]
no_license
philipedls/Projeto-MPS
c335711a897985382fb89691c271ad6acc0bd475
c30f0a7ea9d66d701364cbd1d83fb3e2520ee817
refs/heads/master
2020-03-25T14:36:10.138008
2018-11-07T22:01:59
2018-11-07T22:01:59
143,863,025
1
0
null
null
null
null
UTF-8
Java
false
false
455
java
package entidades; import controle.Comando; import controle.ProfessorDao; public class AdicionarProfessorComando implements Comando { private ProfessorDao professor; public AdicionarProfessorComando(ProfessorDao professor){ this.professor = professor; } public AdicionarProfessorComando(){ } @Override public Object executar(Object arg) { this.professor.add((Professor) arg); return null; } }
[ "philipe.luna@dce.ufpb.br" ]
philipe.luna@dce.ufpb.br
bb37e191144b48a64f7b1473734a75531f24b417
747003951dbddbaba2feec8827e53079f19bb7a3
/java/bypstest-ser/src-ser-bin/byps/test/api/BSerializer_2053507648.java
5239e57f5b6b343e922b4493bdd1119cce596e98
[ "MIT" ]
permissive
marcarvalho/byps
3718811828388401e25fdd0db56ded16b42efec0
6f4882f8e5abba0dc38f2f41f8b2d4ba8d7dbfef
refs/heads/master
2020-02-26T14:55:18.320194
2015-06-23T08:11:44
2015-06-23T08:11:44
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,589
java
package byps.test.api; /* * Serializer for byps.test.api.prim.PrimitiveTypes[] * * THIS FILE HAS BEEN GENERATED BY class byps.gen.j.GenSerArray DO NOT MODIFY. */ import byps.*; @SuppressWarnings("all") public class BSerializer_2053507648 extends BSerializer { public final static BSerializer instance = new BSerializer_2053507648(); public BSerializer_2053507648() { super(2053507648); } @Override public Object read(final Object obj1, final BInput bin1, final long version) throws BException { final BInputBin bin = (BInputBin)bin1; final BBufferBin bbuf = bin.bbuf; // lengths final int n0 = bbuf.getLength(); // create array final byps.test.api.prim.PrimitiveTypes[] arr = new byps.test.api.prim.PrimitiveTypes[n0]; bin.onObjectCreated(arr); // read final byps.test.api.prim.PrimitiveTypes[] a0 = arr; for (int i0 = 0; i0 < n0; i0++) { a0[i0] = (byps.test.api.prim.PrimitiveTypes)bin.readObj(false, null); } return arr; } @Override public void write(Object obj1, BOutput bout1, final long version) throws BException { final BOutputBin bout = (BOutputBin)bout1; final BBufferBin bbuf = bout.bbuf; final byps.test.api.prim.PrimitiveTypes[] arr = (byps.test.api.prim.PrimitiveTypes[])obj1; // lengths final int n0 = arr.length; bbuf.putLength(n0); // write final byps.test.api.prim.PrimitiveTypes[] a0 = arr; for (int i0 = 0; i0 < n0; i0++) { // checkpoint byps.gen.j.PrintContext:313 bout.writeObj(a0[i0], false, null); } } }
[ "wolfgang.imig@googlemail.com" ]
wolfgang.imig@googlemail.com
2d56b61e6e564db097294c361ee98fa8ed3b3a57
6b465859db51d4d194f452155f46c75d04e5d859
/src/com/company/design/backup/BeanUtils.java
0427a0a06690e35733fe763c904f40ec98ded4b5
[]
no_license
haaphoop/idea-workspace
2753b614ed9f29c427d8eac85b7be8c6e85ad78a
b2c43b71a3c2f859e393cfa3f8e525e06a7a7341
refs/heads/master
2021-05-23T06:02:24.780784
2018-09-03T15:24:37
2018-09-03T15:24:37
94,769,353
0
0
null
null
null
null
UTF-8
Java
false
false
2,307
java
package com.company.design.backup; import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.ObjectInputStream; import java.lang.reflect.Method; import java.util.HashMap; /** * Created by daishuli on 2018/1/23. */ public class BeanUtils { public static HashMap<String, Object> backupProp(Object bean) { HashMap<String, Object> result = new HashMap<String, Object>(); try { // 获得bean描述 BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass()); // 获得属性描述 PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); // 遍历所有属性 for (PropertyDescriptor p : descriptors) { // 属性名称 String fieldName = p.getName(); // 读取属性的方法 Method getter = p.getReadMethod(); // 读取属性值 Object fieldValue = getter.invoke(bean, new Object[]{}); if (!fieldName.equalsIgnoreCase("class")) { result.put(fieldName,fieldValue); } } } catch (Exception e) { e.printStackTrace(); } return result; } // 把hashmap的值返回到bean中 public static void restoreProp(Object bean, HashMap<String, Object> propMap) { try { // 获得bean描述 BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass()); // 获得属性描述 PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); for (PropertyDescriptor propertyDescriptor: descriptors ) { // 属性名称 String fieldName = propertyDescriptor.getName(); // 如果有这个属性 if (propMap.containsKey(fieldName)) { // 写属性的方法 Method setter = propertyDescriptor.getWriteMethod(); setter.invoke(bean, new Object[]{propMap.get(fieldName)}); } } } catch (Exception e){ e.printStackTrace(); } } }
[ "314003129@qq.com" ]
314003129@qq.com
47aeb0321c8aad76f1262fb160dab36d835a7e64
40413c5e5361dfcdbaa6839b6a2120dc142fd494
/core/src/main/java/com/github/mengxianun/core/DataRenderer.java
4d7e461cd614bad1cfbccbca58308aa4cccb0fdc
[ "MIT" ]
permissive
mengxianun/air-data
7f3149f95f015df4defa8ba184f7052790c338ad
f2a193a8e00db70c0cdb1e3c664fdc16c4ebd70d
refs/heads/master
2020-03-27T08:40:58.639436
2019-01-21T03:31:54
2019-01-21T03:31:54
146,277,175
0
0
null
null
null
null
UTF-8
Java
false
false
13,362
java
package com.github.mengxianun.core; import java.math.BigDecimal; import java.util.List; import java.util.UUID; import com.github.mengxianun.core.attributes.AssociationType; import com.github.mengxianun.core.item.ColumnItem; import com.github.mengxianun.core.item.JoinColumnItem; import com.github.mengxianun.core.item.JoinItem; import com.github.mengxianun.core.schema.Column; import com.github.mengxianun.core.schema.Table; import com.google.common.base.Strings; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; /** * 结果数据渲染器 * * @author mengxiangyun * */ public class DataRenderer { /** * 根据数据类型渲染数据. * * @param data * @param action * @return */ public JsonElement render(JsonElement data, Action action) { if (data.isJsonArray()) { return render(data.getAsJsonArray(), action); } else if (data.isJsonObject()) { return render(data.getAsJsonObject(), action); } else { return data; } } public JsonElement render(JsonArray data, Action action) { // 主表唯一记录对象, key 为主表所有列的的值拼接的字符串, value 为主表唯一记录的对象 JsonObject uniqueRecords = new JsonObject(); for (JsonElement jsonElement : data) { JsonObject record = jsonElement.getAsJsonObject(); // 主表的唯一记录对象 JsonObject uniqueRecord; // 主表的唯一记录标识 String uniqueRecordKey = createMainTableUniqueRecordKey(record, action); if (uniqueRecords.has(uniqueRecordKey)) { uniqueRecord = uniqueRecords.getAsJsonObject(uniqueRecordKey); } else { uniqueRecord = new JsonObject(); uniqueRecords.add(uniqueRecordKey, uniqueRecord); } List<JoinItem> joinItems = action.getJoinItems(); // 构建关联信息 if (!joinItems.isEmpty() && action.getGroupItems().isEmpty()) { // 出现过的 join 表的对象, 用于 join 表的列再次获取已经创建的 join 表对象 JsonObject existJoinTables = new JsonObject(); List<ColumnItem> columnItems = action.getColumnItems(); // 当前循环列的表数据对象 JsonObject currentTableObject = uniqueRecord; for (ColumnItem columnItem : columnItems) { if (columnItem instanceof JoinColumnItem) { JoinColumnItem joinColumnItem = (JoinColumnItem) columnItem; Table joinTable = joinColumnItem.getTableItem().getTable(); if (existJoinTables.has(joinTable.getName())) { JsonObject joinTableObject = existJoinTables.getAsJsonObject(joinTable.getName()); addColumnValue(joinTableObject, columnItem, record, action); continue; } List<Table> parentTables = joinColumnItem.getParentTables(); // -- 构建 join 表上层结构 for (int i = 0; i < parentTables.size() - 1; i++) { // 父级表, 第一个元素是主表, 跳过 Table parentTable = parentTables.get(i + 1); // 已经构建了该 join 表的结构, 直接获取 if (uniqueRecord.has(parentTable.getName())) { JsonElement parentElement = uniqueRecord.get(parentTable.getName()); if (parentElement.isJsonArray()) { JsonArray parentArray = parentElement.getAsJsonArray(); // 获取数组关联表的最新的元素, 即当前正在循环的元素 currentTableObject = parentArray.get(parentArray.size() - 1).getAsJsonObject(); } else { currentTableObject = parentElement.getAsJsonObject(); } } else { currentTableObject = createJoinStructure(currentTableObject, parentTables.get(i), parentTables.get(i + 1)); } } // -- 构建 join 表结构 // join 表的父级表 Table parentTable = parentTables.get(parentTables.size() - 1); currentTableObject = createJoinStructure(currentTableObject, parentTable, joinTable); // 记录出现过的 join 表 existJoinTables.add(joinTable.getName(), currentTableObject); addColumnValue(currentTableObject, columnItem, record, action); } else { addColumnValue(currentTableObject, columnItem, record, action); } } } else { if (action.isQueryAllColumns()) { addAllColumnValue(uniqueRecord, record); } else { List<ColumnItem> columnItems = action.getColumnItems(); for (ColumnItem columnItem : columnItems) { addColumnValue(uniqueRecord, columnItem, record, action); } } } } JsonArray renderData = new JsonArray(); for (String uniqueKey : uniqueRecords.keySet()) { renderData.add(uniqueRecords.getAsJsonObject(uniqueKey)); } return renderData; } /** * 生成主表每条记录的唯一标识 * * @param record * @param action * @return */ public String createMainTableUniqueRecordKey(JsonObject record, Action action) { // 单表查询的情况, 每条记录为一条唯一的记录, 所以这里生成了一个唯一ID用于标识每条记录, 以保证唯一 if (!action.isJoin()) { return UUID.randomUUID().toString(); } StringBuilder uniqueKey = new StringBuilder(); List<ColumnItem> columnItems = action.getColumnItems(); for (ColumnItem columnItem : columnItems) { if (!(columnItem instanceof JoinColumnItem)) { // 主表列 Column column = columnItem.getColumn(); // 列名 String columnName = column == null ? columnItem.getExpression() : column.getName(); String columnAlias = columnItem.getAlias(); boolean hasAlias = !Strings.isNullOrEmpty(columnAlias); // 请求列的名称 String columnKey = action.columnAliasEnabled() && hasAlias ? columnAlias : columnName; // 返回结果列的名称 String recordKey = hasAlias ? columnAlias : columnKey; Object value = getValue(record, recordKey, columnName); if (value != null) { uniqueKey.append(value.toString()); } } } return uniqueKey.toString(); } public JsonElement render(JsonObject data, Action action) { JsonObject jsonData = new JsonObject(); List<JoinItem> joinItems = action.getJoinItems(); // 构建关联信息 if (!joinItems.isEmpty() && action.getGroupItems().isEmpty()) { // 出现过的 join 表的对象, 用于 join 表的列再次获取已经创建的 join 表对象 JsonObject existJoinTables = new JsonObject(); List<ColumnItem> columnItems = action.getColumnItems(); // 当前循环列的表数据对象 JsonObject currentTableObject = jsonData; for (ColumnItem columnItem : columnItems) { if (columnItem instanceof JoinColumnItem) { JoinColumnItem joinColumnItem = (JoinColumnItem) columnItem; Table joinTable = joinColumnItem.getTableItem().getTable(); if (existJoinTables.has(joinTable.getName())) { JsonObject joinTableObject = existJoinTables.getAsJsonObject(joinTable.getName()); addColumnValue(joinTableObject, columnItem, data, action); continue; } List<Table> parentTables = joinColumnItem.getParentTables(); // -- 构建 join 表上层结构 for (int i = 0; i < parentTables.size() - 1; i++) { currentTableObject = createJoinStructure(currentTableObject, parentTables.get(i), parentTables.get(i + 1)); } // -- 构建 join 表结构 // join 表的父级表 Table parentTable = parentTables.get(parentTables.size() - 1); currentTableObject = createJoinStructure(currentTableObject, parentTable, joinTable); // 记录出现过的 join 表 existJoinTables.add(joinTable.getName(), currentTableObject); addColumnValue(currentTableObject, columnItem, data, action); } else { addColumnValue(jsonData, columnItem, data, action); } } return jsonData; } List<ColumnItem> columnItems = action.getColumnItems(); if (columnItems.isEmpty()) { return new Gson().toJsonTree(data); } else { columnItems.forEach(e -> addColumnValue(jsonData, e, data, action)); } return jsonData; } /** * 数据渲染后的 value * * @param record * @param columnLabel * @return */ public JsonElement getValue(JsonObject record, String columnLabel, String columnName) { JsonElement value = null; if (record.has(columnLabel)) { value = record.get(columnLabel); } else if (record.has(columnLabel.toUpperCase())) { value = record.get(columnLabel.toUpperCase()); } else if (record.has(columnLabel.toLowerCase())) { value = record.get(columnLabel.toLowerCase()); } else if (record.has(columnName)) { value = record.get(columnName); } return value; } public void addColumnValue(JsonObject record, ColumnItem columnItem, JsonObject originalData, Action action) { Column column = columnItem.getColumn(); // 列名, 在列存在的情况下, 以列名表示, 否则按请求中列的原始内容表示 String columnName = column == null ? columnItem.getExpression() : column.getName(); // 如果请求中指定了列别名, 则返回结果的 key 为指定的列别名, 否则 key 为列名 String columnKey = action.columnAliasEnabled() && columnItem.isCustomAlias() ? columnItem.getAlias() : treatColumn(columnName); // 返回 key(列) 分3种情况 // 1. 指定了列别名的情况下, key 为指定的列别名. 例: column as alias // 2. 只指定了列的情况下的情况下, key 为自动列名. 例: column // 3. 列为表达式, 非具体字段, key 为自动生成的别名. 例: count(*) String recordKey = Strings.isNullOrEmpty(columnItem.getAlias()) ? columnKey : columnItem.getAlias(); JsonElement value = getValue(originalData, recordKey, columnName); addColumnValue(record, column, columnKey, value); } public void addAllColumnValue(JsonObject record, JsonObject originalData) { for (String key : originalData.keySet()) { JsonElement value = originalData.get(key); addColumnValue(record, null, key, value); } } public void addColumnValue(JsonObject record, Column column, String columnKey, JsonElement value) { if (value == null || value.isJsonNull()) { record.addProperty(columnKey, (String) null); } else { JsonPrimitive primitive = value.getAsJsonPrimitive(); if (primitive.isNumber()) { Number number = value.getAsNumber(); if (number instanceof Byte || number instanceof Short || number instanceof Integer || number instanceof Long) { number = value.getAsLong(); } else if (number instanceof Float || number instanceof Double) { number = value.getAsDouble(); } else if (number instanceof BigDecimal) { // if (value.getAsBigDecimal().stripTrailingZeros().scale() <= 0) { // 整数 // number = value.getAsBigDecimal().longValue(); // } else { // number = value.getAsBigDecimal().doubleValue(); // } } record.addProperty(columnKey, render(column, number)); } else if (primitive.isBoolean()) { record.addProperty(columnKey, render(column, primitive.getAsBoolean())); } else if (primitive.isString()) { record.addProperty(columnKey, render(column, primitive.getAsString())); } else { record.addProperty(columnKey, render(column, primitive.getAsString())); } } } /** * 处理返回的列名, 变成小写 * * @param columnName * @return */ public String treatColumn(String columnName) { return columnName.toLowerCase(); } public Number render(Column column, Number value) { if (column == null) { return value; } return value; } public Boolean render(Column column, Boolean value) { if (column == null) { return value; } return value; } public String render(Column column, String value) { if (column == null) { return value; } return value; } public JsonObject createJoinStructure(JsonObject currentTableObject, Table parentTable, Table joinTable) { return createJoinStructure(currentTableObject, joinTable.getName(), parentTable.getAssociationType(joinTable)); } public JsonObject createJoinStructure(JsonObject currentTableObject, String tableName, AssociationType associationType) { switch (associationType) { case ONE_TO_ONE: case MANY_TO_ONE: currentTableObject = createJoinObject(currentTableObject, tableName); break; case ONE_TO_MANY: case MANY_TO_MANY: currentTableObject = createJoinArray(currentTableObject, tableName); break; default: break; } return currentTableObject; } public JsonObject createJoinObject(JsonObject currentTableObject, String tableName) { if (currentTableObject.has(tableName)) { currentTableObject = currentTableObject.getAsJsonObject(tableName); } else { JsonObject tempJsonObject = new JsonObject(); currentTableObject.add(tableName, tempJsonObject); currentTableObject = tempJsonObject; } return currentTableObject; } public JsonObject createJoinArray(JsonObject currentTableObject, String tableName) { if (currentTableObject.has(tableName)) { JsonArray tempJsonArray = currentTableObject.getAsJsonArray(tableName); JsonObject tempJsonObject = new JsonObject(); tempJsonArray.add(tempJsonObject); currentTableObject = tempJsonObject; } else { JsonArray tempJsonArray = new JsonArray(); JsonObject tempJsonObject = new JsonObject(); tempJsonArray.add(tempJsonObject); currentTableObject.add(tableName, tempJsonArray); currentTableObject = tempJsonObject; } return currentTableObject; } }
[ "718517636@qq.com" ]
718517636@qq.com
492adab8a14cbda468ef549a7febb4c3ca4a2881
6c092700939f76b54ffd940630c28454730a9c3f
/baseUserRole/service/impl/BaseUserRoleServiceImpl.java
63b154120226935a8a3abe0ca6f98e679d05a516
[]
no_license
zhudiping2017/Hospital
969dd91c0c2f172f83a7b1dbc63fca901de985a8
e1e375953ccc94a09ec7cd8a9c82489d8dd1d7d3
refs/heads/master
2020-05-23T22:10:04.688122
2019-05-24T02:28:21
2019-05-24T02:28:21
186,968,240
0
0
null
null
null
null
UTF-8
Java
false
false
1,356
java
package com.qhit.baseUserRole.service.impl; import com.qhit.baseUserRole.service.IBaseUserRoleService; import java.util.List; import com.qhit.baseUserRole.dao.IBaseUserRoleDao; import com.qhit.baseUserRole.pojo.BaseUserRole; import org.springframework.stereotype.Service; import javax.annotation.Resource; @Service public class BaseUserRoleServiceImpl implements IBaseUserRoleService { @Resource IBaseUserRoleDao dao; @Override public boolean insert(Object object) { return dao.insert(object); } @Override public boolean update(Object object) { return dao.update(object); } @Override public boolean updateSelective(Object object) { return dao.updateSelective(object); } @Override public boolean delete(Object id) { BaseUserRole baseUserRole = findById(id); return dao.delete(baseUserRole); } @Override public List findAll() { return dao.findAll(); } @Override public BaseUserRole findById(Object id) { List<BaseUserRole> list = dao.findById(id); return list.get(0); } @Override public List<BaseUserRole> search(BaseUserRole baseUserRole) { return dao.search(baseUserRole); } }
[ "noreply@github.com" ]
zhudiping2017.noreply@github.com
a10db45fa1748a065cd263ed3bc0bc4c72ffe556
576b52b1a9b3e181f34a927ddbcd6894ff23c88c
/src/main/java/by/mercom/tradelocal/CreateSQLQuery.java
55d9c5d0a69da13c82bf536be9e8a6d366f267c5
[]
no_license
orsha-mercom/DelUserTradelocal
ceb48156beb653ae326f2347a0fe2b25fc58f049
77ff1d773d5343cc8de088d2190976b5a20a0e89
refs/heads/master
2021-01-20T22:28:19.560878
2014-09-23T13:24:54
2014-09-23T13:24:54
null
0
0
null
null
null
null
UTF-8
Java
false
false
103
java
package by.mercom.tradelocal; /** * Created by dm13y on 9/23/14. */ public class CreateSQLQuery { }
[ "dm13y@admin-PC.MERCOM" ]
dm13y@admin-PC.MERCOM
19babb04570fe06b89d8053487e6125c03d7b938
0af8b92686a58eb0b64e319b22411432aca7a8f3
/large-multiproject/project66/src/test/java/org/gradle/test/performance66_5/Test66_416.java
6dade6f16d1c8611157645dcbdb0364ae183636d
[]
no_license
gradle/performance-comparisons
b0d38db37c326e0ce271abebdb3c91769b860799
e53dc7182fafcf9fedf07920cbbea8b40ee4eef4
refs/heads/master
2023-08-14T19:24:39.164276
2022-11-24T05:18:33
2022-11-24T05:18:33
80,121,268
17
15
null
2022-09-30T08:04:35
2017-01-26T14:25:33
null
UTF-8
Java
false
false
292
java
package org.gradle.test.performance66_5; import static org.junit.Assert.*; public class Test66_416 { private final Production66_416 production = new Production66_416("value"); @org.junit.Test public void test() { assertEquals(production.getProperty(), "value"); } }
[ "cedric.champeau@gmail.com" ]
cedric.champeau@gmail.com
13671436b0225e955c6e7cd0ea1db5a4c07ccb1d
b40a2441d4cf7686d7a864634168e73d84a34bd0
/src/decisiontree/DTNode.java
260486fc816fcb4c86f3cdd5d694b377a7455034
[]
no_license
mcrowder65/478
946225733a7356e92864a4d3df426e2efe7d2e1a
444069e4f8eb8df7e595b4f6a7dd211d748bc6bd
refs/heads/master
2021-03-19T15:52:44.150552
2017-03-30T19:51:01
2017-03-30T19:51:01
79,383,977
0
0
null
null
null
null
UTF-8
Java
false
false
2,813
java
package decisiontree; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import toolkit.Matrix; /** * String value<br> * Map of String, DTNode nodes<br> * Matrix features<br> * Matrix labels<br> * * @author mcrowder65 * */ public class DTNode { private String value; private Map<String, DTNode> nodes; private ObjectMapper mapper; private Matrix features; private Matrix labels; public Matrix getFeatures() { return features; } public void setFeatures(Matrix features) { this.features = features; } public Matrix getLabels() { return labels; } public void setLabels(Matrix labels) { this.labels = labels; } public DTNode(Matrix features, Matrix labels) { setLabels(labels); setFeatures(features); nodes = new HashMap<>(); this.value = null; } public DTNode(DTNode node) { this.value = node.getValue(); this.nodes = node.getNodes(); this.features = node.getFeatures(); this.labels = node.getLabels(); } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public Map<String, DTNode> getNodes() { return nodes; } public void setNodes(Map<String, DTNode> nodes) { for (String key : nodes.keySet()) { this.nodes.put(key, nodes.get(key)); } } public DTNode getNode(String key) { return nodes.get(key); } public void setNode(String key, DTNode value) { nodes.put(key, value); } private ObjectMapper getMapper() { if (mapper == null) { mapper = new ObjectMapper(); } return mapper; } public void deleteNodes() { this.nodes = new HashMap<>(); } public int getNumberOfNodes(DTNode node) { Map<String, DTNode> map = node.getNodes(); int c = 1; if (map.size() == 0) { return 1; } for (String key : map.keySet()) { c += getNumberOfNodes(map.get(key)); } return c; } public int getNumberOfLayers(DTNode node, List<String> keys, int num, DTNode originalNode, ArrayList<Integer> depths) { Map<String, DTNode> map = node.getNodes(); if (map.size() == 0) { return num + 1; } for (String key : map.keySet()) { depths.add(getNumberOfLayers(map.get(key), keys, num + 1, originalNode, depths)); } int greatest = Collections.max(depths); return greatest; } @Override public String toString() { try { return getMapper().writeValueAsString(this); } catch (JsonGenerationException e) { e.printStackTrace(); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } }
[ "mcrowder65@gmail.com" ]
mcrowder65@gmail.com
dab1841601d4a5056a4c75e18d6f020150046942
aa8085ea3aaf4cbbb938fac0ad95477d79c12e64
/archetypes/griffon-javafx-java-archetype/src/main/resources/archetype-resources/src/main/java/ApplicationEventHandler.java
2a3501c166c484c2e056a8531750f6c38da4e6de
[ "Apache-2.0" ]
permissive
griffon/griffon
3197c9ee3a5ee3bcb26418729f5c611f6f49c2d9
de3a5a7807478e750bfa7684f796ced42322f1aa
refs/heads/development
2023-09-04T16:34:08.308818
2021-11-06T23:19:37
2021-11-06T23:19:37
1,889,544
288
96
Apache-2.0
2020-04-30T19:14:02
2011-06-13T15:58:14
Java
UTF-8
Java
false
false
531
java
package ${groupId}; import griffon.core.event.EventHandler; import griffon.core.events.UncaughtExceptionThrownEvent; import griffon.exceptions.GriffonViewInitializationException; import javafx.application.Platform; public class ApplicationEventHandler implements EventHandler { @javax.application.event.EventHandler public void handleUncaughtExceptionThrownEvent(UncaughtExceptionThrownEvent x) { if (x.getThrowable() instanceof GriffonViewInitializationException) { Platform.exit(); } } }
[ "aalmiray@gmail.com" ]
aalmiray@gmail.com
b61dd9bf015980f9b9282028ffc76ebd9104ecca
633c5c649c04cf29236519ed390e955e824f537f
/src/test/java/HotelTest.java
c7c8e11299315c32f1e7d7b28e3049cde3cf7e98
[]
no_license
andrewmorrismacleod/CodeClanTowers
128162028e6b78683b51078607f6a79501212cc0
3e319b1fffd6d3d2d58f2cfed709ec4c3285fc86
refs/heads/master
2020-04-22T17:04:07.584681
2019-02-13T15:10:05
2019-02-13T15:10:05
170,528,436
0
1
null
null
null
null
UTF-8
Java
false
false
3,182
java
import org.junit.Before; import org.junit.Test; import java.util.ArrayList; import static org.junit.Assert.assertEquals; public class HotelTest { private Hotel hotel; private Bedroom bedroom1; private Bedroom bedroom2; private Bedroom bedroom3; private DiningRoom dining; private Conference conference1; private Conference conference2; private Guest guest1; private Guest guest2; private Guest guest3; private Guest guest4; private Guest guest5; private ArrayList<Bedroom> bedrooms; private ArrayList<DiningRoom> dinings; private ArrayList<Conference> conferences; private ArrayList<Guest> guests; @Before public void before(){ bedroom1 = new Bedroom(1, 4, "Double"); bedroom2 = new Bedroom(2, 1, "Single"); bedroom3 = new Bedroom(3, 2, "Twin"); conference1 = new Conference("MacLaren Suite", 40); conference2 = new Conference("Renault Suite", 20); dining = new DiningRoom(60, "Mess Hall"); bedrooms = new ArrayList<>(); dinings = new ArrayList<>(); conferences = new ArrayList<>(); bedrooms.add(bedroom1); bedrooms.add(bedroom2); bedrooms.add(bedroom3); conferences.add(conference1); conferences.add(conference2); dinings.add(dining); hotel = new Hotel(bedrooms, dinings, conferences); guest1 = new Guest(); guest2 = new Guest(); guest3 = new Guest(); guest4 = new Guest(); guest5 = new Guest(); guests = new ArrayList<>(); guests.add(guest1); guests.add(guest2); guests.add(guest3); guests.add(guest4); } @Test public void hotelHasBedrooms(){ assertEquals(3,hotel.getNumberOfVacantBedrooms()); } @Test public void hotelHasConferenceRooms(){ assertEquals(2, hotel.getNumberOfConferenceRooms()); } @Test public void hotelHasDiningRooms(){ assertEquals(1, hotel.getNumberOfDiningRooms()); } // @Test // public void hotelCanCheckInGuests(){ // hotel.checkInGuest(guest1); // assertEquals(1,hotel.getVacantBedrooms().get(0).getNumberOfGuests()); // } @Test public void hotelTotalNumberOfRooms(){ assertEquals(3, hotel.getTotalNumberOfRooms()); } @Test public void hotelCanTakeBooking(){ Booking booking = hotel.bookRoom(2, guests); assertEquals(1, hotel.getNumberOfbookings()); assertEquals(2, hotel.getNumberOfVacantBedrooms()); assertEquals(2, booking.getStayLength()); } @Test public void hotelCanAssignRate(){ hotel.giveRoomsRates(); assertEquals(100, hotel.getVacantBedrooms().get(0).getRate()); } @Test public void hotelHasRoomWithCapactiy__true(){ hotel.bookRoom(3, guests); assertEquals(1, hotel.getNumberOfbookings()); } @Test public void hotelHasRoomWithCapactiy__false(){ guests.add(guest5); Booking booking = hotel.bookRoom(3, guests); assertEquals(0, hotel.getNumberOfbookings()); assertEquals(null, booking); } }
[ "andrewmorrismacleod@googlemail.com" ]
andrewmorrismacleod@googlemail.com
e3bcd861de07c71be1af9de1a8b96e53f0071fc1
9a7e206bb951ad93cf3fa4c95998af9c0fbd0557
/report/src/main/java/com/sdxm/report/service/ReportStatusService.java
99c38495504f07f5d9a31e5b281913d4288adad5
[]
no_license
vtne/spring-cloud
cfdeb556f9da343c97587fed6e5c4a3353fc5ec6
f4f2b0054e1a4d9988331e365601f7fbd0434b05
refs/heads/master
2022-06-21T05:25:12.501373
2019-10-21T05:24:47
2019-10-21T05:24:47
216,482,707
0
0
null
2022-06-17T02:37:44
2019-10-21T05:14:12
Java
UTF-8
Java
false
false
2,285
java
package com.sdxm.report.service; import com.sdxm.report.dao.ReportStatusMapper; import com.sdxm.report.entity.ReportStatus; import com.sdxm.report.entity.ReportStatusExample; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service @Transactional public class ReportStatusService { @Autowired private ReportStatusMapper reportStatusMapper; //增加 public int add(ReportStatus reportStatus) { int i = reportStatusMapper.insert(reportStatus); return i; } //删除 public int delete(Integer id) { int i = reportStatusMapper.deleteByPrimaryKey(id); return i; } //修改 public int update(ReportStatus reportStatus) { //int i = reportStatusMapper.updateByPrimaryKeySelective(reportStatus); ReportStatusExample reportStatusExample = new ReportStatusExample(); reportStatusExample.createCriteria().andIdEqualTo(reportStatus.getId()); return reportStatusMapper.updateByExample(reportStatus, reportStatusExample); } //查询 public List<ReportStatus> query(Integer page,Integer results){ ReportStatusExample reportStatusExample = new ReportStatusExample(); reportStatusExample.setCount(results); reportStatusExample.setLimitStart((page - 1) * results); return reportStatusMapper.selectByExample(reportStatusExample); } //判断是否已经存在 public List<ReportStatus> isThere(ReportStatus reportStatus){ ReportStatusExample reportStatusExample = new ReportStatusExample(); reportStatusExample.createCriteria().andIdEqualTo(reportStatus.getId()); return reportStatusMapper.selectByExample(reportStatusExample); } //查询 public List<ReportStatus> queryByReportId(Integer reportId){ ReportStatusExample reportStatusExample = new ReportStatusExample(); reportStatusExample.createCriteria().andReportIdEqualTo(reportId); reportStatusExample.setOrderByClause("create_time desc"); List<ReportStatus> statuslist = reportStatusMapper.selectByExample(reportStatusExample); return statuslist; } }
[ "690742338@qq.com" ]
690742338@qq.com
a6bc04f4072c89d9e714278168e54cc054f2ae03
70c05563c9031570f03b285a4b8c378295c74060
/samples/kmeans-Ivy-DCran-A/src/cgl/imr/samples/kmeans/ivy/dcran/a/ShuffleVectorData.java
7bfd255c2e03ac2d7ba906526fd73bf586187432
[]
no_license
tfrichard/Twister
55fbfb77ac6136e7c076399a8a4510dcef3be040
af409de804fa74f38f188cdb4a654541a17ca5cd
refs/heads/master
2016-09-05T23:36:33.398239
2013-08-07T02:23:05
2013-08-07T02:23:05
null
0
0
null
null
null
null
UTF-8
Java
false
false
6,787
java
/* * Software License, Version 1.0 * * Copyright 2003 The Trustees of Indiana University. All rights reserved. * * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1) All redistributions of source code must retain the above copyright notice, * the list of authors in the original source code, this list of conditions and * the disclaimer listed in this license; * 2) All redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the disclaimer listed in this license in * the documentation and/or other materials provided with the distribution; * 3) Any documentation included with all redistributions must include the * following acknowledgement: * * "This product includes software developed by the Community Grids Lab. For * further information contact the Community Grids Lab at * http://communitygrids.iu.edu/." * * Alternatively, this acknowledgement may appear in the software itself, and * wherever such third-party acknowledgments normally appear. * * 4) The name Indiana University or Community Grids Lab or Twister, * shall not be used to endorse or promote products derived from this software * without prior written permission from Indiana University. For written * permission, please contact the Advanced Research and Technology Institute * ("ARTI") at 351 West 10th Street, Indianapolis, Indiana 46202. * 5) Products derived from this software may not be called Twister, * nor may Indiana University or Community Grids Lab or Twister appear * in their name, without prior written permission of ARTI. * * * Indiana University provides no reassurances that the source code provided * does not infringe the patent or any other intellectual property rights of * any other entity. Indiana University disclaims any liability to any * recipient for claims brought by any other entity based on infringement of * intellectual property rights or otherwise. * * LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH NO * WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA UNIVERSITY GIVES * NO WARRANTIES AND MAKES NO REPRESENTATION THAT SOFTWARE IS FREE OF * INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR OTHER PROPRIETARY RIGHTS. * INDIANA UNIVERSITY MAKES NO WARRANTIES THAT SOFTWARE IS FREE FROM "BUGS", * "VIRUSES", "TROJAN HORSES", "TRAP DOORS", "WORMS", OR OTHER HARMFUL CODE. * LICENSEE ASSUMES THE ENTIRE RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR * ASSOCIATED MATERIALS, AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION * GENERATED USING SOFTWARE. */ package cgl.imr.samples.kmeans.ivy.dcran.a; import cgl.imr.base.SerializationException; import cgl.imr.base.TwisterMessage; import cgl.imr.base.Value; /** * Intermediate centroids Vector Data * */ public class ShuffleVectorData implements Value { private int numData; private int vecLen; private double totalMinDis; private int rowCount[]; private int data[][]; public ShuffleVectorData() { this.numData = 0; this.vecLen = 0; this.totalMinDis = 0; this.rowCount = null; this.data = null; } public ShuffleVectorData(int numData, int vecLen, double totalMinDis, int rowCount[], int[][] data) { this.numData = numData; this.vecLen = vecLen; this.totalMinDis = totalMinDis; this.rowCount = rowCount; this.data = data; } public void fromTwisterMessage(TwisterMessage message) throws SerializationException { this.numData = message.readInt(); this.vecLen = message.readInt(); this.totalMinDis = message.readDouble(); if (this.numData > 0 && this.vecLen > 0) { this.rowCount = new int[this.numData]; for (int i = 0; i < this.numData; i++) { this.rowCount[i] = message.readInt(); } this.data = new int[this.numData][this.vecLen]; for (int i = 0; i < this.numData; i++) { for (int j = 0; j < this.vecLen; j++) { this.data[i][j] = message.readInt(); } } } else { this.rowCount = null; this.data = null; } } public void toTwisterMessage(TwisterMessage message) throws SerializationException { message.writeInt(this.numData); message.writeInt(this.vecLen); message.writeDouble(this.totalMinDis); if (this.numData > 0 && this.vecLen > 0) { for (int i = 0; i < this.numData; i++) { message.writeInt(this.rowCount[i]); } for (int i = 0; i < this.numData; i++) { for (int j = 0; j < this.vecLen; j++) { message.writeInt(this.data[i][j]); } } } } @Override public void mergeInShuffle(Value val) { if (val.getClass().getName().equals(this.getClass().getName())) { // long start = System.currentTimeMillis(); // merge data ShuffleVectorData newData = (ShuffleVectorData) val; int[][] newdata = newData.getData(); // long end0 = System.currentTimeMillis(); // boolean flag = false; // long lastPause2 = 0; // long pause2 = 0; for (int i = 0; i < this.numData; i++) { // long pause1 = System.currentTimeMillis(); for (int j = 0; j < this.vecLen; j++) { this.data[i][j] = this.data[i][j] + newdata[i][j]; } // lastPause2 = pause2; // pause2 = System.currentTimeMillis(); /* * if ((pause2 - pause1) > 5) { * System.out.println("Merge Operation " + i + " takes " + * (pause2 - pause1)); } */ /* * if ((pause2 - end0) > 100 && !flag) { * System.out.println("Merge Operation from start to " + i + * " takes " + (pause2 - end0) + " " + (lastPause2 - end0)); * flag = true; } */ } // long end1 = System.currentTimeMillis(); // merge row count for (int i = 0; i < this.numData; i++) { this.rowCount[i] = this.rowCount[i] + newData.getRowCount()[i]; } // long end2 = System.currentTimeMillis(); // merge min distance this.totalMinDis = this.getTotalMinDis() + newData.getTotalMinDis(); // long end3 = System.currentTimeMillis(); /* * if ((end3 - start) > 100) { * System.out.println("Merge Operation takes " + (end3 - start) + * " " + (end2 - start) + " " + (end1 - start) + " " + +(end0 - * start) + " " + this.numData + " " + this.vecLen); } */ } else { System.out.println("Merge in shuffle is not allowed."); } } public int getNumData() { return numData; } public int getVecLen() { return vecLen; } public double getTotalMinDis() { return this.totalMinDis; } public int[] getRowCount() { return this.rowCount; } public int[][] getData() { return this.data; } }
[ "tf.richard@gmail.com" ]
tf.richard@gmail.com
cbbcff0656ec271130847c7c9987e0f21f65353b
147bbbb6283f4c562716591000edce278617e710
/src/main/java/com/spring/two/chapterSeven/advancede/customDispatcher/SpittleNotFoundException.java
42ea13485784e136b4084b569d0b4806a05d5de9
[]
no_license
EdwinZhangyc/StudySpring
f05c63b316ab7efba45b7825be250594088b0395
49917189131ae124caaa0b7d01d09b16240ad991
refs/heads/master
2021-04-06T06:33:51.042625
2018-06-12T03:37:56
2018-06-12T03:37:56
null
0
0
null
null
null
null
UTF-8
Java
false
false
419
java
package com.spring.two.chapterSeven.advancede.customDispatcher; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; /** * 程序清单7.8 @ResponseStatus注解:将异常映射为特定的状态码 */ @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Spittle Not Found") public class SpittleNotFoundException extends RuntimeException { }
[ "zyc_wyzh@163.com" ]
zyc_wyzh@163.com
f8389936fd200e71a3006b94e856b9c51103354f
ba5ab9535993a587bc5519668906e92b09c76695
/coursework1/src/coursework1/Cube.java
9c7d3889478bf26153fdba9044170887d8a6bea5
[]
no_license
ayat121998/coursework-1
f65561693fc32bfc68f645bb9e2f61df7f043af4
a3537af2816ca33a7e206d94c79935af28368a76
refs/heads/master
2021-05-15T09:48:04.417535
2017-11-21T10:53:10
2017-11-21T10:53:10
108,109,578
0
0
null
2017-11-21T10:53:11
2017-10-24T10:07:00
Java
UTF-8
Java
false
false
639
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 coursework1; /** * * @author M00557670 */ public class Cube extends ThreeDShape{ public Cube(int numberOfSides, String name) { super(numberOfSides, name); } @Override public double getArea() { double result = 0.0; return result; } @Override public double getPerimeter() { double result = 0.0; return result; } }
[ "M00557670@kvmdxlab110pc24.studentmdx.ac" ]
M00557670@kvmdxlab110pc24.studentmdx.ac
f37edad9212cef6f4622e4482e59fd11db5150a7
dd54232fa06dcd9457f91fe869462ea4d13eb83e
/task9_part2/src/ua/epam/Strategy/Sorting.java
d6cd40bcaa3e24978334268e0c4f33a57f6b21c9
[]
no_license
ipereverzieva/Tasks_Java
e7130d0e3fe4ad69a2096b3b01201c33b674d47f
d662e28c9221df46804e98466a6f28c4d05f75b6
refs/heads/master
2021-06-07T22:35:59.960613
2016-11-04T11:22:42
2016-11-04T11:22:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
134
java
package ua.epam.Strategy; /** * Created by Iryna_Poliakova on 9/26/2016. */ public interface Sorting { void sort(int[] arr); }
[ "Iryna_Poliakova@epam.com" ]
Iryna_Poliakova@epam.com
eff68679e1d4657595726f3c5715f2d56a35bc99
199f789e50f53900e7fcc4339cfd0e8c7abc5536
/FragmentDemp/app/src/main/java/com/example/administrator/fragmentdemp/Fragment2.java
a09763883fd1d5b6194b0f60ce803a20f2e3dc01
[]
no_license
saikrishna133/android5
d46d4deb14035886f11a7ac7a498d06d9a71b8ba
f199157b705e183987edb87a239abfbb5a9dd366
refs/heads/master
2021-01-19T11:38:03.763949
2017-02-20T11:08:08
2017-02-20T11:08:08
82,256,297
0
0
null
null
null
null
UTF-8
Java
false
false
597
java
package com.example.administrator.fragmentdemp; import android.content.Context; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class Fragment2 extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_fragment2, container, false); } }
[ "saikrishna@gleecus.com" ]
saikrishna@gleecus.com
a585eb2464f445d176b76f53708fbdb6a9ecd315
cab07cb930e4c487d12f0197d5818048023fd88c
/data-access-layer/src/main/java/com/knet51/ccweb/jpa/repository/technology/TechnologyRepository.java
3408fbdefeb1a0fc475b8085adc2795c37db96ac
[]
no_license
maidoulubiubiu/RuleIsRule
41cca13108df1986b505d27c39877bb6c024885d
ae4c200bf885e1df1c452fef246981459a17a2a8
refs/heads/master
2021-01-10T07:48:39.337767
2014-10-14T14:22:57
2014-10-14T14:22:57
48,677,619
0
0
null
null
null
null
UTF-8
Java
false
false
1,204
java
package com.knet51.ccweb.jpa.repository.technology; import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import com.knet51.ccweb.jpa.entities.User; import com.knet51.ccweb.jpa.entities.technology.Technology; public interface TechnologyRepository extends JpaRepository<Technology, Long>, JpaSpecificationExecutor<Technology>{ Page<Technology> findAll(Pageable pageable); Page<Technology> findAllByUser(User user, Pageable pageable); Page<Technology> findAllByUserAndStatus(User user,Integer status, Pageable pageable); List<Technology> findAllListByUser(User user); Page<Technology> findAllByStatus(Integer status, Pageable pageable ); List<Technology> findAllListByStatus(Integer status); Page<Technology> findAllByFocusAndStatus(Integer focus,Integer status, Pageable pageable ); List<Technology> findAllListByFocusAndStatus(Integer focus,Integer status, Sort sort); Page<Technology> findAllByFocus(Integer focus, Pageable pageable ); }
[ "971903103@qq.com" ]
971903103@qq.com
9b8b691f16e84f6adf49393a27af56968cc3832e
0cf80bd8ba5494b1eba883f082c9ce7f1672b2df
/src/main/java/io/joshatron/downloader/backend/MovieInfo.java
c59100a71a6bf8f43a23e11fbcb33b943400a6e1
[]
no_license
joshatron/Show-Namer
f5f50781c502f689aed808111b408341db0104d7
6217b9dafd1b49b10c81cb2cc03b6f76dc6650cc
refs/heads/main
2023-05-15T18:30:48.938620
2021-06-16T16:23:08
2021-06-16T16:23:08
258,937,174
0
0
null
2021-06-04T02:36:41
2020-04-26T04:15:33
Java
UTF-8
Java
false
false
406
java
package io.joshatron.downloader.backend; import lombok.AllArgsConstructor; import lombok.Data; @Data @AllArgsConstructor public class MovieInfo { private String movieId; private String movieTitle; private String movieDescription; private int movieYear; public MovieInfo() { movieId = ""; movieTitle = ""; movieDescription = ""; movieYear = 0; } }
[ "legermjoshua@gmail.com" ]
legermjoshua@gmail.com
e45f09891240863986f27edb5427ce29ced87d25
ae7ed2fa7755f15af6971aeed0000dfb4ce6c6b7
/model/src/main/java/org/gluu/oxtrust/model/passport/PassportStrategy.java
966460631356a6c7b4ca37b8c95edbf1dc0f4959
[ "MIT" ]
permissive
GluuFederation/oxTrust
91416b750636f01893beda394bc9cffddff020c2
4f6ab8465829f64f8b810ef57d4689ad871ca461
refs/heads/master
2023-09-01T18:03:40.846414
2023-08-28T07:44:29
2023-08-28T07:44:29
18,222,972
136
78
MIT
2023-09-05T07:09:13
2014-03-28T18:53:26
Java
UTF-8
Java
false
false
470
java
package org.gluu.oxtrust.model.passport; /** * @author Shekhar L. * @version 07/17/2016 */ public class PassportStrategy { private String clientID; private String clientSecret; public String getClientID() { return clientID; } public void setClientID(String clientID) { this.clientID = clientID; } public String getClientSecret() { return clientSecret; } public void setClientSecret(String clientSecret) { this.clientSecret = clientSecret; } }
[ "Yuriy.Movchan@gmail.com" ]
Yuriy.Movchan@gmail.com
6438896b34e7b29f014176357ef289703e4bbe06
fc3dbd3634d7d4ebca018a595f0c11d19e771e82
/operText128/src/operText128/OpTest3.java
cca066f7289f3af11e66807445c5e871d90e62fb
[]
no_license
1109s1/nogihung
ad363382119f680a6421871349a7387d54ade4a0
a7b4a5d96973637d9405f5d3e0a798aeea5f491e
refs/heads/main
2023-02-08T11:40:55.664071
2020-12-10T00:44:53
2020-12-10T00:44:53
316,413,857
0
0
null
null
null
null
UHC
Java
false
false
636
java
package operText128; public class OpTest3 { public static void main(String[] args) { // 논리연산자 // 제어문(if)에서 많이 활용. int num1 = 100, num2 = 200; // ==같다 System.out.println(" == 연산자: " + (num1 == num2 )); // != 다르다 System.out.println("! = 연산자 :" + (num1 != num2)); // >크다 System.out.println("> 연산자 : " + (num1 > num2)); // <작다 System.out.println("< 연산자 : " + (num1 < num2)); // 크거나 같다 System.out.println(">= 연산자 : " + (num1 >= num2)); // 작거나 같다 System.out.println("<= 연산자 : " + (num1 <= num2)); } }
[ "no159753@naver.com" ]
no159753@naver.com
894b9842be68df397f88355e99214d7a488bb212
0a4265a36d7eaf8ff0db67dfd32b81e30f9f9dbe
/P1041_FragmentLifecycle/app/src/main/java/ru/bitreslab/p1041_fragmentlifecycle/Main.java
488f5ae4e3bc4494948f6d348566c0741712eaf9
[]
no_license
bit1394/startandroid
854a7f470056a48308e4af7d0c7deb1e7fb8d046
1734459b7b0b9a5ad0da0ffc8dd9443549fa5da1
refs/heads/master
2020-05-21T12:20:53.631010
2017-06-02T14:29:08
2017-06-02T14:29:08
49,258,645
0
0
null
null
null
null
UTF-8
Java
false
false
916
java
package ru.bitreslab.p1041_fragmentlifecycle; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; public class Main extends AppCompatActivity { final String LT = "myLogs"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.d(LT, "Main onCreate"); } protected void onStart(){ super.onStart(); Log.d(LT, "Main onStart"); } protected void onResume(){ super.onResume(); Log.d(LT, "Main onResume"); } protected void onPause(){ super.onPause(); Log.d(LT, "Main onPause"); } protected void onStop(){ super.onStop(); Log.d(LT, "Main onStop"); } protected void onDestroy(){ super.onDestroy(); Log.d(LT, "Main onDestroy"); } }
[ "it_nv@mail.ru" ]
it_nv@mail.ru
8413c157b5a9dc2611593d8bb52958d1569f22ea
77ca3b271aa6d1a5544392671d0599c4bf941507
/src/main/java/de/cardcontact/opencard/service/smartcardhsm/SmartCardHSMECPrivateKeySpec.java
aa6f6330778a5ad19397e2b87fb7adc843d6c761
[]
no_license
cme813cf/ocf
c66370078c847e0d450c6476e148bc5a760c5e98
5491a5b9fba74f850d3158d1bba2aa53a3557501
refs/heads/development
2023-03-17T10:24:42.764319
2016-09-29T14:25:18
2016-09-29T14:25:18
504,445,890
1
0
null
2022-06-17T08:03:10
2022-06-17T08:03:10
null
UTF-8
Java
false
false
4,975
java
/* * --------- * |.##> <##.| Open Smart Card Development Platform (www.openscdp.org) * |# #| * |# #| Copyright (c) 1999-2012 CardContact Software & System Consulting * |'##> <##'| Andreas Schwier, 32429 Minden, Germany (www.cardcontact.de) * --------- * * This file is part of OpenSCDP. * * OpenSCDP is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * OpenSCDP is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OpenSCDP; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package de.cardcontact.opencard.service.smartcardhsm; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.security.spec.ECField; import java.security.spec.ECFieldFp; import java.security.spec.ECParameterSpec; import java.security.spec.EllipticCurve; import de.cardcontact.tlv.ConstructedTLV; import de.cardcontact.tlv.PrimitiveTLV; import de.cardcontact.tlv.TLVEncodingException; /** * This class contains the data for EC key pair generation. * * @author lew * */ public class SmartCardHSMECPrivateKeySpec extends SmartCardHSMPrivateKeySpec { private ECParameterSpec domainParameter; private EllipticCurve curve; /** * The prime modulus */ private ECFieldFp field; private int keySize; /** * SmartCardHSMECCPrivateKeySpec constructor * * @param car The Certificate Authority Reference * @param chr The Certificate Holder Reference * @param algorithm The key algorithm * @param params The domain parameter */ public SmartCardHSMECPrivateKeySpec(String car, String chr, ECParameterSpec params) { super(car, chr); this.domainParameter = params; this.curve = domainParameter.getCurve(); this.field = (ECFieldFp)curve.getField(); this.keySize = field.getFieldSize(); } /** * @return The domain parameter */ public ECParameterSpec getECParameterSpec() { return this.domainParameter; } /** * @return The key size */ public int getKeySize() { return keySize; } /** * @return The encoded Base Point G * @throws IOException */ public byte[] getBasePointG() throws IOException { ByteArrayOutputStream basePointG = new ByteArrayOutputStream(); basePointG.write(0x04); basePointG.write(unsignedBigIntegerToByteArray(domainParameter.getGenerator().getAffineX(), keySize)); basePointG.write(unsignedBigIntegerToByteArray(domainParameter.getGenerator().getAffineY(), keySize)); return basePointG.toByteArray(); } /** * The command data for EC key pair generation. * @return the tlv encoded c-data */ public byte[] getCData() throws IOException, TLVEncodingException { ConstructedTLV gakpcdata = new ConstructedTLV(0x30); //CPI byte[] cpi = {getCpi()}; gakpcdata.add(new PrimitiveTLV(0x5F29, cpi)); //CAR if (hasCar()) { gakpcdata.add(new PrimitiveTLV(0x42, getCar())); } //Public Key ConstructedTLV puk = new ConstructedTLV(0x7F49); //Public Key Algorithm puk.add(new PrimitiveTLV(0x06, getAlgorithm())); //Prime modulus p ECField field = domainParameter.getCurve().getField(); int keySize = field.getFieldSize(); byte[] v = unsignedBigIntegerToByteArray(((ECFieldFp)field).getP(), keySize); puk.add(new PrimitiveTLV(0x81, v)); //First coefficient a v = unsignedBigIntegerToByteArray(domainParameter.getCurve().getA(), keySize); puk.add(new PrimitiveTLV(0x82, v)); //Second coefficient b v = unsignedBigIntegerToByteArray(domainParameter.getCurve().getB(), keySize); puk.add(new PrimitiveTLV(0x83, v)); //Base point G ByteArrayOutputStream basePointG = new ByteArrayOutputStream(); basePointG.write(0x04); basePointG.write(unsignedBigIntegerToByteArray(domainParameter.getGenerator().getAffineX(), keySize)); basePointG.write(unsignedBigIntegerToByteArray(domainParameter.getGenerator().getAffineY(), keySize)); puk.add(new PrimitiveTLV(0x84, basePointG.toByteArray())); //Order of the base point v = unsignedBigIntegerToByteArray(domainParameter.getOrder(), keySize); puk.add(new PrimitiveTLV(0x85, v)); //Cofactor f byte [] cofactor = {(byte) domainParameter.getCofactor()}; puk.add(new PrimitiveTLV(0x87, cofactor)); gakpcdata.add(puk); //CHR gakpcdata.add(new PrimitiveTLV(0x5F20, getCertificateHolderReference())); //Outer Certificate Authority Reference for authentication signature if P2 != '00' if (hasOuterCar()) { gakpcdata.add(new PrimitiveTLV(0x45, getOuterCar())); } return gakpcdata.getValue(); } }
[ "mflingelli@blackned.de" ]
mflingelli@blackned.de
c04372689878d630adcb11f59df72ce2a3505576
146894d6f6af043b1297362a28d24984108db8f4
/src/main/java/com/insu/house/service/serviceImpl/CommentServiceImpl.java
caf4272ae478f0522fb6c4a881f23e38dbc37604
[]
no_license
shallin-sbj/house
ef1a9cff89b1a9fa05ef6e6870984d575b7fa519
0f033e38c7ee59f18e87426314a846c7c675cea9
refs/heads/master
2020-03-24T23:44:39.386496
2018-08-06T14:42:23
2018-08-06T14:42:23
143,152,591
0
0
null
null
null
null
UTF-8
Java
false
false
2,476
java
package com.insu.house.service.serviceImpl; import com.insu.house.common.constants.CommonConstants; import com.insu.house.common.model.Comment; import com.insu.house.common.model.User; import com.insu.house.common.utils.BeanHelper; import com.insu.house.mapper.CommentMapper; import com.insu.house.service.CommentService; import com.insu.house.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service public class CommentServiceImpl implements CommentService { @Autowired private CommentMapper commentMapper; @Autowired private UserService userService; @Override public void addHouseComment(Long houseId, String content, Long userId) { addComment(houseId,null, content, userId,1); } @Override @Transactional(rollbackFor = Exception.class) public void addComment(Long houseId, Integer blogId, String content, Long userId, int type) { Comment comment = new Comment(); if (type == 1) { comment.setHouseId(houseId); }else { comment.setBlogId(blogId); } comment.setContent(content); comment.setUserId(userId); comment.setType(type); BeanHelper.onInsert(comment); BeanHelper.setDefaultProp(comment, Comment.class); commentMapper.insert(comment); } @Override public void addBlogComment(int blogId, String content, Long userId) { addComment(null,blogId, content, userId, CommonConstants.COMMENT_BLOG_TYPE); } @Override public List<Comment> getHouseComments(long houseId, int size) { List<Comment> comments = commentMapper.selectComments(houseId,size); comments.forEach(comment -> { User user = userService.getUserById(comment.getUserId()); comment.setAvatar(user.getAvatar()); comment.setUserName(user.getName()); }); return comments; } @Override public List<Comment> getBlogComments(long blogId, int size) { List<Comment> comments = commentMapper.selectBlogComments(blogId,size); comments.forEach(comment -> { User user = userService.getUserById(comment.getUserId()); comment.setUserName(user.getName()); comment.setAvatar(user.getAvatar()); }); return comments; } }
[ "sucuilin27@sina.com" ]
sucuilin27@sina.com
1481101cdf8315bbac39ef111ea71bcdbd159fb2
a40797c6b9372d8961884dc24f5dd91115296bbe
/src/alviz/base/graph/BaseGraph.java
c62d72796500e038c151fa6153aaee8d29317b12
[]
no_license
aman935/AI_final
a72075b915752d69e42bc518b514749e30a59d6b
ccd16da2262ab7470f32dae04ca1fe2f8eee853a
refs/heads/master
2021-08-23T03:20:38.572572
2017-12-02T21:07:47
2017-12-02T21:07:47
111,159,504
0
0
null
null
null
null
UTF-8
Java
false
false
18,234
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package alviz.base.graph; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Stroke; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Vector; /** * * @author baskaran */ public abstract class BaseGraph <tNode extends BaseGraph.Node, tEdge extends BaseGraph.Edge> { public List<tNode> moveGen(tNode n) { return n.getChildren(); } public boolean goalTest(tNode n) { return n.isGoalKind(); } // static public double euclideanDistance(Node u, Node v) { // int dx = u.x - v.x; // int dy = u.y - v.y; // return Math.sqrt(dx*dx+dy*dy); // } static public double euclideanDistance(int ux, int uy, int vx, int vy) { int dx = ux - vx; int dy = uy - vy; return Math.sqrt(dx*dx+dy*dy); } private tNode startNode; private List<tNode> goalNodes; private boolean directedGraph=false; public tNode getStartNode() { return startNode; } public List<tNode> getGoalNodes() { return goalNodes; } public void setStartNode(tNode node) { if (node != null) { resetStartNode(); startNode = node; startNode.setStartKind(); } } public void resetStartNode(){ if (startNode != null) { startNode.setDefaultKind(); startNode = null; } } public void setGoalNode(List<tNode> nodes) { if (nodes != null) { resetGoalNodes(); goalNodes = nodes; for (tNode n : goalNodes) { n.setGoalKind(); } } } public void resetGoalNodes(){ if (goalNodes != null) { for (tNode g : goalNodes) { g.setDefaultKind(); } goalNodes = null; } } public tNode getNode(int id) { return nodes.get(id); } private List<tNode> nodes; private List<tEdge> edges; public List<tNode> getNodes() { return nodes; } public List<tEdge> getEdges() { return edges; } private List<tEdge> backPointerEdges; public List<tEdge> getBackPointerEdges() { return backPointerEdges; } private List<tEdge> savedEdges; public List<tEdge> getSavedEdges() { return savedEdges; } public void saveEdge() { if (savedEdges != null) { edges.addAll(savedEdges); } savedEdges = edges; edges = null; } protected BaseGraph() { nodes = null; edges = null; startNode = null; goalNodes = null; } protected BaseGraph(int nodeCount) { this(); nodes = new ArrayList<tNode>(nodeCount); } public int getNodeCount() { if (nodes != null) { return nodes.size(); } return 0; } public int getEdgeCount() { if (edges != null) { return edges.size(); } return 0; } public void resetGraph() { resetNodes(); resetEdges(); } public void destroyEdges(){ if(edges == null) return; Vector<tEdge> edgesCopy = new Vector<tEdge>(); edgesCopy.addAll(edges); for(int i = 0;i < edgesCopy.size();i++) destroyEdge(edgesCopy.get(i)); } public void destroyEdge(tEdge edge) { Node node_1 = edge.node_1; Node node_2 = edge.node_2; node_1.delEdge(edge); node_2.delEdge(edge); node_1.delNeighbor((tNode) node_2); node_2.delNeighbor((tNode) node_1); breakEdge(edge); } private void resetNodes() { if (nodes != null) { for (tNode n : nodes) { n.setDefault(); n.reset_mg_attributes(); } } } private void resetEdges() { if (edges != null) { for (tEdge e : edges) { e.setDefault(); } } } public void setGraphToOld(){ if (nodes != null) { for (tNode n : nodes) { n.setOld(); n.setOldPath(); n.reset_mg_attributes(); } } if (edges != null) { for (tEdge e : edges) { e.setOld(); e.setOldPath(); } } } public void addNode(tNode n) { // lazy initialization of node list if (nodes == null) nodes = new LinkedList<tNode>(); nodes.add(n); } public void addBackPointerEdge(tEdge e) { if (backPointerEdges == null) backPointerEdges = new LinkedList<tEdge>(); backPointerEdges.add(e); } public void addEdge(tEdge e) { // lazy initialization if (edges == null) edges = new LinkedList<tEdge>(); e.node_1.addEdge(e); e.node_2.addEdge(e); e.node_1.addNeighbor(e.node_2); e.node_2.addNeighbor(e.node_1); edges.add(e); } public tEdge insertEdge(tEdge e) { // lazy initialization if (edges == null) edges = new LinkedList<tEdge>(); edges.add(e); return e; } public void breakEdge(tEdge edge) { if(edges == null) return; if(edges.contains(edge)) edges.remove(edge); } static public Object createGraph() { return null; } // { return new BaseGraph<BaseGraph.Node, BaseGraph.Edge>(); } abstract public Object createGraph(int nodeCount); // { return new BaseGraph<BaseGraph.Node, BaseGraph.Edge>(); } abstract public tNode createNode(int x, int y); abstract public tEdge createEdge(tNode n1, tNode n2); protected void createNode(tNode n) { // lazy initialization of node list if (nodes == null) nodes = new LinkedList<tNode>(); nodes.add(n); } protected void createEdge(tEdge e) { // lazy initialization if (edges == null) edges = new LinkedList<tEdge>(); e.node_1.addEdge(e); e.node_2.addEdge(e); e.node_1.addNeighbor(e.node_2); e.node_2.addNeighbor(e.node_1); edges.add(e); } public tEdge makeEdge(tNode node_1, tNode node_2) { tEdge e = createEdge(node_1, node_2); insertEdge(e); return e; } public void openNode(tNode n, tNode parent) { tEdge mgedge = getEdge(n, parent); n.mgParent = parent; n.mgEdge = (tEdge) mgedge; n.setOpen(); if (mgedge != null) mgedge.setOpen(); } public void closeNode(tNode n) { n.setClosed(); if (n.mgEdge != null) n.mgEdge.setClosed(); } public void deleteNode(tNode n) { n.setDefault(); n.mgParent = null; n.mgEdge = null; } public tEdge getEdge(tNode n1, tNode n2) { if (n1 == null || n2 == null) return null; // search the edge list of n1 for (tEdge x : (List<tEdge>) n1.getEdges()) if (x.isEdgeOn(n1, n2)) return x; // else search the edge list of n2 // may not be needed for the current undirected graph implementation... // needed only for finding bugs in the edge assignment... // for (Edge x : n2.edges) if (x.isEdgeOn(n1, n2)) return x; return null; } private int[] tmp_abc=new int[3]; public boolean edgeCrossing(int line[]) { if (edges != null) { computeLineParameters(tmp_abc, line[0], line[1], line[2], line[3]); for (Edge e : edges) { if (edgeCross(tmp_abc, line, e)) { return true; } } } return false; } private boolean edgeCross(int[] abc, int[] line, Edge e) { int dc1 = dC(abc, e.node_1.x, e.node_1.y); int dc2 = dC(abc, e.node_2.x, e.node_2.y); if (dc1 == 0) { if (dc2 == 0) return true; else return false; } else if (dc2 == 0) return false; else if (dc1 > 0 && dc2 > 0) return false; else if (dc1 < 0 && dc2 < 0) return false; dc1 = dC(e.abc, line[0], line[1]); dc2 = dC(e.abc, line[2], line[3]); if (dc1 == 0) { if (dc2 == 0) return true; else return false; } else if (dc2 == 0) return false; else if (dc1 > 0 && dc2 > 0) return false; else if (dc1 < 0 && dc2 < 0) return false; return true; } private int dC(int[] abc, int x, int y) { return abc[0] * x + abc[1] * y - abc[2]; } public enum NodeKind { DEFAULT, START, GOAL /*add algorithm dependent NodeKind here, as per requirement...for example*/ //MAX, //MIN, ; } public enum RuntimeState { /* Needs to be same for all groups*/ DEFAULT(Color.LIGHT_GRAY, null), OPEN(Color.GREEN, new BasicStroke(2f)), CLOSED(Color.RED, new BasicStroke(2f)), BOUNDARY(Color.RED, new BasicStroke(2f)), PATH(Color.BLUE, new BasicStroke(4f)), START(Color.BLUE , null), GOAL(Color.BLUE, null), /*agorithm specific... can use below ones or add more*/ HIGH(Color.BLACK, new BasicStroke(2f)), MEDIUM(Color.CYAN, new BasicStroke(2f)), L0(Color.white, new BasicStroke(2f)), L1(Color.BLUE, new BasicStroke(2f)), L2(Color.CYAN, new BasicStroke(2f)), L3(Color.darkGray, new BasicStroke(2f)), L4(Color.GREEN, new BasicStroke(2f)), L5(Color.MAGENTA, new BasicStroke(3f)), L6(Color.ORANGE, new BasicStroke(3f)), L7(Color.PINK, new BasicStroke(3f)), L8(Color.YELLOW, new BasicStroke(1f)), L9(Color.YELLOW, new BasicStroke(3f)), L10(Color.yellow, new BasicStroke(5f)), RELAY(Color.MAGENTA, null), // modify if required WAITING(Color.MAGENTA, null), // modify if required // old open, closed, rolled-back( reset to default) OLD(Color.DARK_GRAY, new BasicStroke(2f)), OLD_PATH(Color.BLACK, new BasicStroke(4f)), BACKPOINTER_EDGE(Color.BLACK, null), // modify if required // Can use if required //ALPHA_CUT_EDGE(Color.DARK_GRAY, new BasicStroke(2f, BasicStroke.CAP_BUTT , BasicStroke.JOIN_MITER, 1f, new float[] {10.0F, 3.0F, 3.0F, 3.0F},0)), //G1_alphaDashes , 0)), //BETA_CUT_EDGE(Color.GRAY, new BasicStroke(2f, BasicStroke.CAP_BUTT , BasicStroke.JOIN_MITER, 1f, new float[] {2.0F, 3.0F, 2.0F, 4.0F},0)); //G1_betaDashes , 0)); // modify it to purple and dashed line ; final public Color color; final public Stroke stroke; private RuntimeState(Color color, Stroke stroke) { this.color = color; this.stroke = stroke; } public boolean G7_isNotPrint() { return this == L0; } } static private int uidMaxNode=0; static private int getNextNodeId() { return uidMaxNode++; } abstract public class Node { public void setLeaf() { } public boolean isLeaf() { return false; } // begin node data... public int x; public int y; // end node data private int id; public int getId() { return id; } protected String idStr=null; public String getIdString() { if (idStr == null) idStr = String.format("%d:(%d,%d)", id, x, y); return idStr; } protected NodeKind kind; //TODO kind must be private public void setDefaultKind() { kind = NodeKind.DEFAULT; } public void setStartKind() { kind = NodeKind.START; } public void setGoalKind() { kind = NodeKind.GOAL; } public boolean isGoalKind() { return kind == NodeKind.GOAL; } public boolean isStartKind() {return kind == NodeKind.START; } protected RuntimeState state; public RuntimeState getState() { return state; } public void setDefault() { state = RuntimeState.DEFAULT; } public void setStart() { state = RuntimeState.START; } public void setGoal() { state = RuntimeState.GOAL; } public void setOpen() { state = RuntimeState.OPEN; } public void setClosed() { state = RuntimeState.CLOSED; } public void setBoundary() { state = RuntimeState.BOUNDARY; } public void setPath() { state = RuntimeState.PATH; } public boolean isDefault() { return state == RuntimeState.DEFAULT; } public boolean isClosed() { return state == RuntimeState.CLOSED; } public boolean isGoal() { return state == RuntimeState.GOAL; } public boolean isPath() { return state == RuntimeState.PATH; } public boolean isOpen() { return state == RuntimeState.OPEN; } public boolean isCandidate() { switch(state) { case DEFAULT: case OLD: case OLD_PATH: return true; default: return false; } } public void setOld() { switch (state) { case CLOSED: case OPEN: //case ROLLEDBACK: /* use it if define ROLLEDBACK runtimestate*/ state = RuntimeState.OLD; } } public void setOldPath() { switch (state) { case PATH: state = RuntimeState.OLD_PATH; } } List<tEdge> edges; private List<tNode> neighbors; public List<tNode> getChildren() { return neighbors; } public List<tEdge> getEdges() { return edges; } public tNode mgParent; public tEdge mgEdge; public void set_mg_attributes(tNode parent, tEdge edge) { mgParent = parent; mgEdge = edge; } public void reset_mg_attributes() { mgParent = null; mgEdge = null; } public Node(int x, int y) { id = getNextNodeId(); this.x = x; this.y = y; this.kind = NodeKind.DEFAULT; this.state = RuntimeState.DEFAULT; edges = null; neighbors = null; mgParent = null; mgEdge = null; } public void copyData(BaseGraph.Node node) { this.x = node.x; this.y = node.y; this.kind = node.kind; this.state = node.state; } public void addNeighbor(tNode node) { if (neighbors == null) neighbors = new LinkedList<tNode>(); if (!neighbors.contains(node)) neighbors.add(node); } public void addEdge(tEdge edge) { if (edges == null) edges = new LinkedList<tEdge>(); if (!edges.contains(edge)) edges.add(edge); } public boolean isNeighbour(int n_id) { for (Node n : neighbors) { if (n.id == n_id) { return true; } } return false; } public void delNeighbor(tNode node){ if(neighbors.contains(node)) neighbors.remove(node); } public void delEdge(tEdge edge){ if(edges.contains(edge)) edges.remove(edge); } } static private int uidMaxEdge=0; static private int getNextEdgeId() { return ++uidMaxEdge; } abstract public class Edge { private int id; protected String idStr=null; public String getIdString() { return idStr; } protected RuntimeState state; public tNode node_1; public tNode node_2; public double cost; public void setDefault() { state = RuntimeState.DEFAULT; } public void setOpen() { state = RuntimeState.OPEN; } public void setClosed() { state = RuntimeState.CLOSED; } public void setBoundary() { state = RuntimeState.BOUNDARY; } public void setPath() { state = RuntimeState.PATH; } /*public void setOld() { if(state == RuntimeState.CLOSED || state == RuntimeState.OPEN || state == RuntimeState.ROLLEDBACK) state = RuntimeState.OLD; } */ public void setOld() { if(state == RuntimeState.CLOSED || state == RuntimeState.OPEN) state = RuntimeState.OLD; } public void setOldPath() { if(state == RuntimeState.PATH) state = RuntimeState.OLD_PATH; } public Edge(tNode node_1, tNode node_2) { assert node_1 != null; assert node_2 != null; assert node_1 != node_2; // no self loops... id = getNextEdgeId(); this.state = RuntimeState.DEFAULT; this.node_1 = node_1; this.node_2 = node_2; //this.cost = euclideanDistance(node_1, node_2) * (1.0 + Math.random()); this.cost = euclideanDistance(node_1.x, node_1.y, node_2.x, node_2.y) * (1.0 + Math.random()); computeLineParameters(); } public void copyData(BaseGraph.Edge edge) { this.state = edge.state; this.cost = edge.cost; } public boolean isEdgeOn(tNode n1, tNode n2) { if (node_1 == n1 && node_2 == n2) return true; if (node_2 == n1 && node_1 == n2) return true; return false; } // used for edge crossing computation // equation of line in matrix form // a*x + b*y = c // a = -dy, b = dx, c = b*y1 + a*x1 public int[] abc; public void computeLineParameters() { abc = new int[3]; BaseGraph.computeLineParameters(abc, node_1.x, node_1.y, node_2.x, node_2.y); } } static private void computeLineParameters(int[] abc, int x1, int y1, int x2, int y2) { abc[0] = -(y1-y2); abc[1] = x1-x2; abc[2] = abc[1]*y1 + abc[0]*x1; } }
[ "singh.amansingh935@gmail.com" ]
singh.amansingh935@gmail.com
12dd68737397b496a9012b0f7ab921fa888920ed
c3d7e5b407ec414db0327c626251e62472a45fd0
/app/src/main/java/com/think/siet/AboutUsActivity.java
c8d4dcf65f16098c36e77e7efe815538feabb2c3
[]
no_license
shivaprasadks/polyglot
9f7e4b80ff140bdffbc21bc7ec45d44e41741be5
5f7b6f856843f0ab811a99463b3381ab79cdae45
refs/heads/master
2021-06-01T10:20:47.930786
2019-11-21T10:00:54
2019-11-21T10:00:54
56,053,972
1
0
null
2019-11-21T10:00:55
2016-04-12T10:37:05
Java
UTF-8
Java
false
false
334
java
package com.think.siet; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class AboutUsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about_us); } }
[ "shivaprasad.kssp@gmail.com" ]
shivaprasad.kssp@gmail.com
670c06a40b890348e364a8f2a418855f56043481
84ef6299f2745bd8163818a52c2403afcdd75dd6
/src/Sortings/Shell.java
331399ce6052fbcd222dd6cc93a1c74f60a96ad4
[]
no_license
TarnishingColors/AlgorithmsDataStructures
4c3237ec2f9342adf9dbbd434d38b53ebc45d569
9d3cedf1c0dc96a37217059ac2b2a8dce53d21af
refs/heads/master
2022-12-16T22:54:45.875339
2020-09-15T20:29:47
2020-09-15T20:29:47
294,999,842
0
0
null
null
null
null
UTF-8
Java
false
false
820
java
package Sortings; import java.util.ArrayList; import java.util.Scanner; import static Sortings.funcs.*; public class Shell { public static void sort(ArrayList<Integer> a){ int n = a.size(); int h = 1; while (n / 3 > h) h = 3 * h + 1; while (h >= 1) { for (int i = h; i < n; i++) { for (int j = i; j >= h && less(a.get(j), a.get(j - h)); j-=h) { exchange(a, j, j - h); } } h = h / 3; } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); ArrayList<Integer> a = new ArrayList<Integer>(); while (sc.hasNextInt()){ a.add(sc.nextInt()); } sort(a); assert isSorted(a); show(a); } }
[ "aagabitashvili@edu.hse.ru" ]
aagabitashvili@edu.hse.ru
3478db05c7251c68943aaabc09ac7f0228a055c3
104ae031e254737853c6872e0a47644a23a2b208
/src/main/java/com/ewidencja/repo/RecordRepository.java
04a7c9feff3d5e1364ac0a9fd87405a949815a24
[]
no_license
PiotrAnd/SpringEwidencja
cadcfd60ae4cf4f01d07c214b169219a4251f16e
b4b783c98bbe642afe0fbcc41c2408c709564c9c
refs/heads/master
2023-08-09T16:10:28.409568
2020-03-02T12:08:34
2020-03-02T12:08:34
244,359,689
0
0
null
2023-07-23T07:24:59
2020-03-02T11:57:58
HTML
UTF-8
Java
false
false
202
java
package com.ewidencja.repo; import com.ewidencja.model.Record; import org.springframework.data.repository.CrudRepository; public interface RecordRepository extends CrudRepository<Record, Integer> { }
[ "cortezzz2o2.pl" ]
cortezzz2o2.pl
96f5c66f8b7006c2c0afc13eb220f8a1de847bd6
868f92a44d856db827c949a4f61cae9c9ef3db08
/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/EncryptController.java
98b409ecb0d8c2fb78e22948e416bebaed7ec512
[ "Apache-2.0" ]
permissive
QinAyang/apollo
c23687347ef79bf4a5a732dddaa17a5cb27a4f2a
a4e637c30edbc04b9bb5d2c72e4de3e7903ca58c
refs/heads/master
2023-03-29T12:51:41.277687
2021-04-08T07:59:22
2021-04-08T07:59:22
348,908,309
0
0
null
null
null
null
UTF-8
Java
false
false
9,188
java
package com.ctrip.framework.apollo.portal.controller; import com.ctrip.framework.apollo.common.security.EncryptUtil; import com.ctrip.framework.apollo.common.security.RsaKey; import com.ctrip.framework.apollo.common.security.RsaTool; import com.ctrip.framework.apollo.common.utils.Result; import com.ctrip.framework.apollo.portal.entity.bo.KVEntity; import com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO; import com.ctrip.framework.apollo.portal.environment.Env; import com.ctrip.framework.apollo.portal.service.ReleaseService; import org.springframework.beans.factory.annotation.Value; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse; import java.io.OutputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; /** * the controller of Encrypt/Decrypt * <p> * * @author Ning.Zhang(Pegasus) * ***************************************************************** * Name Action Time Description * * Ning.Zhang Initialize 2/14/2021 Initialize * * ***************************************************************** */ @RestController @RequestMapping("/encrypt") public class EncryptController { @Value("${apollo.encrypt.app_id}") private String apolloEncryptAppId; @Value("${apollo.encrypt.private_key_name}") private String apolloEncryptPrivateKeyName; @Value("${apollo.encrypt.public_key_name}") private String apolloEncryptPublicKeyName; private final ReleaseService releaseService; public EncryptController(final ReleaseService releaseService) { this.releaseService = releaseService; } @PostMapping(value = "getKeyAppId") public Result<String> getKeyAppId() { return Result.success(this.apolloEncryptAppId); } @RequestMapping(value = "generateKey") public void generateKey(@RequestParam(value = "appId") final String appId, final HttpServletResponse response) throws Exception { if (!this.apolloEncryptAppId.equals(appId)) { return; } final RsaKey rsaKey = RsaTool.generatorKeyPair(); response.setHeader("content-type", "application/octet-stream"); response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("公钥秘钥.txt", "UTF-8")); final OutputStream outputStream = response.getOutputStream(); final StringBuilder content = new StringBuilder(); content.append("********************************************************************"); content.append("\n"); content.append(String.format("* 公钥Key的名称必须是: %s *", this.apolloEncryptPublicKeyName)); content.append("\n"); content.append(String.format("* 私钥Key的名称必须是: %s *", this.apolloEncryptPrivateKeyName)); content.append("\n"); content.append("* *"); content.append("\n"); content.append("* 例子: *"); content.append("\n"); content.append(String.format("* %s = MIICdgIBADANBg... *", this.apolloEncryptPublicKeyName)); content.append("\n"); content.append(String.format("* %s = MIGfMA0GCSqGSI... *", this.apolloEncryptPrivateKeyName)); content.append("\n"); content.append("* *"); content.append("\n"); content.append(String.format("* 密文必须使用%s%s格式进行包含, 以便区别于明文, 方便解密 *", EncryptUtil.PREFIX, EncryptUtil.SUFFIX)); content.append("\n"); content.append("* 例子: *"); content.append("\n"); content.append(String.format("* %s *", EncryptUtil.addTag("sPpI6Ib9..."))); content.append("\n"); content.append("********************************************************************"); content.append("\n"); content.append("\n"); content.append("公钥:"); content.append("\n"); content.append(rsaKey.getPublicKey()); content.append("\n"); content.append("\n"); content.append("私钥:"); content.append("\n"); content.append(rsaKey.getPrivateKey()); content.append("\n"); outputStream.write(content.toString().trim().getBytes(StandardCharsets.UTF_8)); } @PostMapping(value = "doEncrypt") public Result<EncryptResult> encrypt(@RequestParam(value = "value") final String value, @RequestParam(value = "appId") final String appId, @RequestParam(value = "env") final String env, @RequestParam(value = "cluster") final String cluster, @RequestParam(value = "namespace") final String namespace) { try { final RsaKey rsaKey = getRsaKey(env, cluster, namespace); final EncryptResult encryptResult = new EncryptResult(); final String encrypt = RsaTool.encrypt(value, rsaKey.getPublicKey().trim()); encryptResult.setEncryptValue(encrypt); encryptResult.setEncryptConfigValue(EncryptUtil.addTag(encrypt)); return Result.success(encryptResult); } catch (final Exception exception) { return Result.error(exception.getMessage()); } } @PostMapping(value = "doDecrypt") public Result<String> decrypt(@RequestParam(value = "value") String value, @RequestParam(value = "appId") final String appId, @RequestParam(value = "env") final String env, @RequestParam(value = "cluster") final String cluster, @RequestParam(value = "namespace") final String namespace) { if (!this.apolloEncryptAppId.equals(appId)) { return Result.error("权限不足"); } try { final RsaKey rsaKey = getRsaKey(env, cluster, namespace); final List<Exception> exceptionList = new ArrayList<>(); String result = EncryptUtil.decrypt(value, rsaKey, exceptionList); if(!exceptionList.isEmpty()){ throw exceptionList.get(0); } return Result.success(result); } catch (final Exception exception) { return Result.error(exception.getMessage()); } } private RsaKey getRsaKey(final String env, final String cluster, final String namespace) { RsaKey result = null; final List<ReleaseBO> allReleases = this.releaseService.findAllReleases( this.apolloEncryptAppId, Env.valueOf(env), cluster, namespace, 0, 1); if (null != allReleases && !allReleases.isEmpty()) { result = new RsaKey(); for (final ReleaseBO releaseBO : allReleases) { for (final KVEntity item : releaseBO.getItems()) { if (item.getKey().equals(this.apolloEncryptPrivateKeyName)) { result.setPrivateKey(item.getValue()); } else if (item.getKey().equals(this.apolloEncryptPublicKeyName)) { result.setPublicKey(item.getValue()); } } } } if (null == result || ObjectUtils.isEmpty(result.getPrivateKey()) || ObjectUtils.isEmpty(result.getPublicKey())) { throw new RuntimeException("请先配置公钥和私钥"); } return result; } public static class EncryptResult { private String encryptValue; private String encryptConfigValue; public String getEncryptValue() { return encryptValue; } public void setEncryptValue(final String encryptValue) { this.encryptValue = encryptValue; } public String getEncryptConfigValue() { return encryptConfigValue; } public void setEncryptConfigValue(final String encryptConfigValue) { this.encryptConfigValue = encryptConfigValue; } } }
[ "349409664@qq.com" ]
349409664@qq.com
e1f09a7b3e2dabfc3a9a1e2488b8ed417cdabba4
a7f22825f132def294d627406f4b87ef20e986cc
/hackerrank/SpecialStringAgain.java
ad820dc6a00641a7fb215ecd828b39ade20b1aa7
[]
no_license
mahisandip/java-prep
ebe7e30265910b819b3c2e7716220c61526d4d6e
d983a088ed86f1084fd7ce8efb8a98c2005a9df9
refs/heads/master
2021-07-11T23:08:05.122858
2020-08-05T05:15:09
2020-08-05T05:15:09
186,758,918
0
0
null
2020-07-21T15:31:44
2019-05-15T06:00:28
Java
UTF-8
Java
false
false
1,936
java
package hackerrank; import java.io.UnsupportedEncodingException; public class SpecialStringAgain { // public static long substrCount( String s) { long count = 0; for (int i = 0; i < s.length(); i++) { int innerCounter = 1; int counterDown = 0; int counterUp = 1; while (i - innerCounter >= 0 && i + innerCounter < s.length() && s.charAt(i - innerCounter) == s.charAt(i - 1) && s.charAt(i + innerCounter) == s.charAt(i - 1)) { count++; innerCounter++; } while (i - counterDown >= 0 && i + counterUp < s.length() && s.charAt(i - counterDown) == s.charAt(i) && s.charAt(i + counterUp) == s.charAt(i)) { count++; counterDown++; counterUp++; } } return count + s.length(); } // optimized one from above public static long substrCount(int length, String s) { long counter = 0; for (int i = 0; i < length; i++) { // if the current symbol is in the middle of palindrome, e.g. aba int offset = 1; while (i - offset >= 0 && i + offset < length && s.charAt(i - offset) == s.charAt(i - 1) && s.charAt(i + offset) == s.charAt(i - 1)) { counter++; offset++; } // if this is repeatable characters aa int repeats = 0; while (i + 1 < length && s.charAt(i) == s.charAt(i + 1)) { repeats++; i++; } counter += repeats * (repeats + 1) / 2; } return counter + length; } public static String hexStringToASCII(String sb) throws UnsupportedEncodingException { int countOfHexValues = sb.length() / 2; byte[] bytes = new byte[countOfHexValues]; for (int i = 0; i < countOfHexValues; i++) { int hexValueIndex = i * 2; String hexValue = sb.substring(hexValueIndex, hexValueIndex + 2); bytes[i] = (byte) (Integer.parseInt(hexValue, 16) & 0xFF); } return new String(bytes, "CP1047"); } }
[ "mahisandip2.1@gmail.com" ]
mahisandip2.1@gmail.com
828ca1961d90ffae1b1a5f118066521ff5871b02
ac1fa539b38302b72b53e2252d85ef2a6da8f07f
/UI/UIBackend/src/main/java/com/people10/ws/UIBackenApplication.java
99dae7539e9f981f92572e491463e93408286026
[]
no_license
WuleKop/People10
12e01ef46877a32a61de0509acfb6818943ec0a3
0218a452af7a3a05de896c748f3099e0fc28df7d
refs/heads/master
2023-01-07T17:57:23.964903
2019-09-30T04:43:36
2019-09-30T04:43:36
211,394,323
0
0
null
2023-01-07T10:11:58
2019-09-27T20:10:23
TSQL
UTF-8
Java
false
false
324
java
package com.people10.ws; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class UIBackenApplication { public static void main(String[] args) { SpringApplication.run(UIBackenApplication.class, args); } }
[ "wule2000@gmail.com" ]
wule2000@gmail.com
3430d6f2eebf10b50ef882a1c98aa9e407ed687e
c3d80266b1f35a3e87c72af49f0d8e0c4d2a7ddd
/src/main/java/basics/StdDraw04.java
e1289f076b160823841e8cc8e256d2d02966f0c5
[]
no_license
youdmeng/Algorithms
3f71c561eb2a6e5fc0e48fd3a1e1e8d709e7440c
27bc894490862119ffbe92a0818850480285ebee
refs/heads/master
2022-06-09T11:59:43.986823
2020-05-09T05:05:53
2020-05-09T05:05:53
262,482,548
0
0
null
null
null
null
UTF-8
Java
false
false
1,123
java
package basics; import edu.princeton.cs.introcs.StdDraw; import edu.princeton.cs.introcs.StdRandom; /** * 标准绘图库 * * @author Youdmeng * @date 2018-11-01 */ public class StdDraw04 { public static void main(String[] args) { drawLine(); } /** * 线性函数 */ private static void drawLine() { //函数 int n = 1000; StdDraw.setXscale(0, n); StdDraw.setYscale(0, n * n); StdDraw.setPenRadius(0.01); for (int i = 1; i <= n; i ++) { StdDraw.point(i, i); StdDraw.point(i, i * i); StdDraw.point(i, i * Math.log(i)); } } /** * 随机数 */ private static void drawRandom() { int n = 50; double[] a = new double[n]; for (int i = 0; i < n; i++) { a[i] = StdRandom.random(); } for (int i = 0; i < n; i++) { double x = 1.0 * i / n; double y = a[i] / 2.0; double rw = 0.5 / n; double rh = a[i] /2.0; StdDraw.filledRectangle(x, y, rw, rh); } } }
[ "you.minda@ebiz-fooge.com" ]
you.minda@ebiz-fooge.com
5a095344958d90aad3160f7ef6812f0659e4d320
3c7ea9dfff9790bd88cd08853aa3b273a9bcc309
/phonebook-api/src/main/java/com/telran/phonebookapi/dto/EmailDto.java
71ae7013754a80c51692e01a66030dd7b6711af9
[]
no_license
AR1988/phonebook-m9-1
739b076feb56e4f6cf8e51a04a4a2e19974adf59
26c0735c5ee8702c664fab5e4f04df24e4107594
refs/heads/master
2023-08-31T23:18:02.635910
2021-10-10T15:16:24
2021-10-10T15:16:24
292,912,293
0
0
null
2020-09-04T17:50:25
2020-09-04T17:50:24
null
UTF-8
Java
false
false
276
java
package com.telran.phonebookapi.dto; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.NoArgsConstructor; @Builder @NoArgsConstructor @AllArgsConstructor public class EmailDto { public int id; public String email; public int contactId; }
[ "noreply@github.com" ]
AR1988.noreply@github.com
37a3537095c47f96486fb360f80f4631124a59c7
0529524c95045b3232f6553d18a7fef5a059545e
/app/src/androidTest/java/TestCase_com_android_DroidLiveLite__1342944921.java
c63d62b278fb0ec2af2a982424921e42530dad2b
[]
no_license
sunxiaobiu/BasicUnitAndroidTest
432aa3e10f6a1ef5d674f269db50e2f1faad2096
fed24f163d21408ef88588b8eaf7ce60d1809931
refs/heads/main
2023-02-11T21:02:03.784493
2021-01-03T10:07:07
2021-01-03T10:07:07
322,577,379
0
0
null
null
null
null
UTF-8
Java
false
false
290
java
import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class TestCase_com_android_DroidLiveLite__1342944921 { @Test public void testCase() throws Exception { // $FF: Couldn't be decompiled } }
[ "sunxiaobiu@gmail.com" ]
sunxiaobiu@gmail.com
fc04258ba6f3daef2714dd7e4063133330994e10
b644b1b5fabdf54e32c3c315f9e6025530771ddd
/src/server/Server.java
169274e98171a1f0f95d7235c7febcbceb3e0d64
[]
no_license
jdavidd/ChessGame
bdea091266f48db0259aca2bf7ea09725ce47f81
b4c93921299db8021990c15104184053af377848
refs/heads/master
2020-03-14T17:03:27.793581
2019-09-14T08:47:13
2019-09-14T08:47:13
131,711,159
0
0
null
2018-05-27T12:17:21
2018-05-01T12:35:07
HTML
UTF-8
Java
false
false
22,230
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 server; /* added player and room */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import java.net.SocketException; import java.text.SimpleDateFormat; import java.util.Date; /** * * @author c-tin */ public class Server { /** * @param args the command line arguments * @throws java.io.IOException */ //Aceasta lista contine toti utilizatorii logati in server private static ArrayList <Player> listaUtilizatori; private static ArrayList <room> listaCamere; private static conexiuneBazaUtilizator conexiuneUtilizator; public static void main(String[] args) throws IOException { // TODO code application logic here int clientNumber=0; listaUtilizatori=new ArrayList<>(); listaCamere=new ArrayList(); conexiuneUtilizator=new conexiuneBazaUtilizator(); try(ServerSocket listener = new ServerSocket(9999)) { while(true){ new Player(listener.accept(),clientNumber++).start(); } } } public static class Player extends Thread{ private final int clientNumber; private final Socket socket; private int idUser; private String numeUser; private room cameraJoc; private BufferedReader in; private PrintWriter out; private final Boolean mutex; private ObjectOutputStream outt; private ObjectInputStream inn; public Player(Socket socket,int clientNumber){ idUser=0; numeUser=new String(); this.clientNumber=clientNumber; this.socket=socket; cameraJoc=null; try { in=new BufferedReader(new InputStreamReader(socket.getInputStream())); out=new PrintWriter(socket.getOutputStream(),true); outt = new ObjectOutputStream(socket.getOutputStream()); // Create an input stream from the socket inn = new ObjectInputStream(socket.getInputStream()); } catch (IOException ex) { Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("There is a new connection with client number "+clientNumber); mutex=false; } public static ArrayList<String> getListaUtilizatori() { ArrayList <String> users = new ArrayList<> (); System.out.println(listaUtilizatori.size()); for (int i = 0; i < listaUtilizatori.size(); i++) { users.add(listaUtilizatori.get(i).getNume()); } return users; } public static ArrayList<String> getListaRoom() { ArrayList <String> users = new ArrayList<> (); System.out.println(listaCamere.size()); for (int i = 0; i < listaCamere.size(); i++) { users.add(listaCamere.get(i).getNume()); } return users; } @Override public void run(){ try { conexiuneUtilizator.selectAll(); OUTER: while (true) { String request=in.readLine(); ArrayList<String> cerere=decode(request); int requestType=Integer.parseInt(cerere.get(0)); if(requestType<-1)//Daca s-a facut o cerere cu un cod de identificare nevalid { out.println("0;Cere nerecunoscuta de server, a fost transmis un cod mai mic decat -1"); } else switch (requestType) { //S-a facut o cere de intrerupere a conexiunii case -1: { out.println("0;EXIT_CLIENT"); System.out.println("am inchis clientul"); break OUTER; } //S-a facut o cerere de inregistrare case 1: { ConfirmBox.display("test","singu"); int resultConexiune=conexiuneUtilizator.inregistrare(cerere.get(1),cerere.get(2),cerere.get(3)); switch (resultConexiune) { case -1: { out.println("0;Inregistrare nereusita, au aparut probleme tehnice"); break; } case 0: { out.println("1;Inregistrare Reusita"); break; } case 1: { out.println("0;Adresa de email este folosita deja"); break; } case 2: out.println("0;Username deja folosit"); break; case 3: out.println("0;Inregistrare nereusita, incercati din nou"); break; default: break; } break; } //S-a facut o cere de login case 2: { int resultConexiune=conexiuneUtilizator.login(cerere.get(1),cerere.get(2)); if(resultConexiune>0) { idUser=resultConexiune; numeUser=cerere.get(1); Boolean ok=true; int lungime=listaUtilizatori.size(); for(int i=0;i<lungime;++i) if(idUser==(listaUtilizatori.get(i).getID())) { ok=false; } if(ok==true) { listaUtilizatori.add(this); out.println("1;Login reusit"); } else out.println("0;Exista deja un utilizator logat in acest cont"); } switch (resultConexiune) { case -1: out.println("0;Login nereusit, au aparut probleme tehnice"); break; case -2: out.println("0;Acest Username nu exista"); break; case -3: out.println("0;Parola gresita"); break; default: break; } break; } case 3: { ArrayList <String> numeParolaList=conexiuneUtilizator.getUtilizatorParolaMail(cerere.get(3)); if(numeParolaList.isEmpty()) { out.println("0;Nu exista niciun cont cu aceasta adresa de mail"); } else { if(mailSender.sendMailRecuperareDateCont(cerere.get(3),numeParolaList.get(0),numeParolaList.get(1))==true) out.println("1;Un mail cu datele contului a fost trimis"); else out.println("0;Nu s-a putut trimite mail-ul, a aparut o problema"); } break; } //Cod adaugat !!!!!!!!!!!!!!!!!!!!!!!!!!!! //Cerere pentru creare camera case 4: { System.out.println("creez camera"); String numeCamera=request.substring(2,request.length()); if(cameraJoc!=null) { out.println("-4;Deja faci parte dintr-o camera"); } else { this.createRoom(in,out,numeCamera); } break; } //Cazul in care se face cerere de aderare la o camera de joc case 5: { if(cameraJoc!=null) { out.println("-5;Deja faci parte dintr-o camera"); } else{ String numeCamera=request.substring(2,request.length()); this.enterRoom(in, out, numeCamera); } /*for(int i=0;i<listaCamere.size();++i) if(listaCamere.get(i).black!=null) System.out.println(listaCamere.get(i).getNume()+" "+listaCamere.get(i).white.getNume()+" "+listaCamere.get(i).black.getNume()); else System.out.println(listaCamere.get(i).getNume()+" "+listaCamere.get(i).white.getNume()); System.out.println("\n\n\n");*/ break; } //COD ADAUGAT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! case 6: { // mesajul primit de client va fi de forma 6;nume: mesaj //System.out.println("Hopa mesaj!"); broadcast(cerere.get(1),this.getNume()); break; } //cod 7 send players array case 7: { //System.out.println("AM ajuns player"); ArrayList<String> users = getListaUtilizatori(); outt.writeObject(users); break; } //code 8 send rooms array case 8:{ //System.out.println("AM ajuns room"); ArrayList<String> users = getListaRoom(); outt.writeObject(users); break; } case 9: { //System.out.println("Uraaa! A Ajuns in case 8"); this.cameraJoc.makeMove(Integer.parseInt(request.substring(2,3)),Integer.parseInt(request.substring(3,4)),Integer.parseInt(request.substring(5,6)),Integer.parseInt(request.substring(6,7)), this); break; } default: { //!!!!!!!!!!!!!!!!!!!!!AICICI AI ADAUGAT COD!!!!!!!!!!!!!!!!!!!!!!! out.println("Cod nerecunoscut"); break; } } } } catch (IOException ex) { Logger.getLogger(Server.class.getName()).log(Level.SEVERE, null, ex); } finally{ try{ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!AICICICICI!!!!!!!!!!!!!!!!!!!!! listaUtilizatori.remove(this); socket.close(); } catch(IOException e) { System.out.println("Can't close the socket of client "+clientNumber+" Exceptio: "+e); } } } public int getID() { return idUser; } //AICICI INCEP MODIFICARI!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! public String getNume() { return numeUser; } private synchronized boolean writeMsg(String msg) { if(!socket.isConnected()) { try { socket.close(); } catch(SocketException e){ System.out.println(e.getMessage()); } catch(IOException e){ System.out.println(e.getMessage()); } return false; } out.println(msg); return true; } private static synchronized void broadcast(String message,String nume) { SimpleDateFormat sdf = new SimpleDateFormat(); String time = sdf.format(new Date()); String messageLf = "6;"+time+" "+nume + ": " + message; for(int i = listaUtilizatori.size() - 1; i >= 0; i--) { Player player = listaUtilizatori.get(i); // try to write to the Client if it fails remove it from the list if(!player.writeMsg(messageLf)) { listaUtilizatori.remove(i); System.out.println("Disconnected Client " + player.numeUser + " removed from list."); } } } private synchronized void createRoom(BufferedReader in,PrintWriter out,String numeCamera) { int n=listaCamere.size(); Boolean ok=true; for(int i=0;i<n;++i) if(listaCamere.get(i).getNume().equals(numeCamera)) { ok=false; out.println("-4;Acest nume este deja folosit"); } if(ok==true) try{ room camera=new room(this,numeCamera); cameraJoc=camera; listaCamere.add(camera); out.println("4;Camera creata"); for(int i = listaUtilizatori.size() - 1; i >= 0; i--) { Player player = listaUtilizatori.get(i); // try to write to the Client if it fails remove it from the list if(!player.writeMsg("2;"+numeCamera)) { listaUtilizatori.remove(i); System.out.println("Disconnected Client " + player.numeUser + " removed from list."); } } }catch(Exception e) { out.println("4;Probleme la creare"); } } private synchronized void enterRoom(BufferedReader in,PrintWriter out,String numeCamera) { int n=listaCamere.size(); Boolean found=false; room foundRoom=null; for(int i=0;i<n;++i) if(numeCamera.equals(listaCamere.get(i).getNume())) { found=true; foundRoom=listaCamere.get(i); break; } if(foundRoom==null) { out.println("-5;Camera "+numeCamera+" nu exista"); } else { if(foundRoom.aderare(this).equals(true)) { cameraJoc=foundRoom; out.println("5;Ai intrat in camera"); } else out.println("-5;Nu ai intrat in camera, fie ai fost refuzat, fie camera are deja 2 jucatri"); } } //GATA MODIFICARI!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } private static ArrayList decode(String a) { ArrayList<String> localList=new ArrayList<>(); int n=a.length(); int poz=0; String subExit=a.substring(0,1); switch (subExit) { case "-1": localList.add(subExit); break; case "4": localList.add(subExit); break; case "5": localList.add(subExit); break; case "6": localList.add(subExit); localList.add(a.substring(2)); break; case "7": localList.add(subExit); break; case "8": localList.add(subExit); break; case "9": localList.add(subExit); break; default: if(a.substring(0,2).equals("DA")) { localList.add("99999"); break; } for(int i=0;i<3;++i) { String word=""; while(poz<n) { String sub=a.substring(poz,poz+1); if(sub.equals(";")) break; word = word.concat(sub); ++poz; } ++poz; localList.add(word); } String word=""; String sub=a.substring(poz,n); word=word.concat(sub); localList.add(word); break; } return localList; } private static class room{ private final Player white; public Player black; private Player currentPlayer; private final String nume; Game game; public room(Player X,String NUME ){ white=X; black=null; currentPlayer=white; nume=NUME; game=new Game(); } //COD ADAUGAT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! public synchronized Boolean aderare(Player Y) { if(black!=null) return false; black=Y; return true; } public String getNume() { return nume; } public synchronized boolean makeMove(int linie, int coloana,int linieNoua, int coloanaNoua,Player jucator) { if(jucator!=this.currentPlayer) { jucator.writeMsg("-9;Este randul oponentului"); return false; } else { if(game.move(linie,coloana,linieNoua,coloanaNoua)==true) { // System.out.println("A ajuns aici la game move"); if(currentPlayer==white) currentPlayer=black; else currentPlayer=white; jucator.writeMsg("9;"+linie+coloana+";"+linieNoua+coloanaNoua+";"); currentPlayer.writeMsg("9;"+linie+coloana+";"+linieNoua+coloanaNoua+";"); return true; } else { jucator.writeMsg("-9;Mutare nevalida"); } } //COD ADAUGAT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! return false; } //COD ADAUGAT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } }
[ "noreply@github.com" ]
jdavidd.noreply@github.com
7f24c0598ea231dd91cf276f321ee3146bab5dc2
959614f48776d2487d9e8f7fada1ca36a7c4230f
/src/main/java/entity/Dog.java
f6c9b9be10d7871a19ad90acd6c37ebd4353fe60
[]
no_license
believeWang/mapstruct-demo
92511d3d9d3958a43985f5a83fcfad184a4f47ed
3d12ed6a04f8faacf3d99b3cf24e92a2f076cb8f
refs/heads/master
2023-03-20T11:15:50.704241
2021-03-10T08:47:52
2021-03-10T08:47:52
346,287,174
0
0
null
null
null
null
UTF-8
Java
false
false
151
java
package entity; import lombok.Data; import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) @Data public class Dog extends Animal { }
[ "robertwang@cathayholdings.com.tw" ]
robertwang@cathayholdings.com.tw
2a6b11135933ae853071fae7eb8d542a1f9a371d
79aa80420a40e9dbee790cc62427e1417e8f4793
/app/src/main/java/com/zhny/gr/wisdomcity/bean/DestinationBean.java
f5babd104191c92232fb106429c6ee9b2e75851a
[]
no_license
CzmZomBie/WisdomCity
f49c9d5c1d604bed726d63abf78c29a1889af6c2
304ad2134c61e6bf9353407ba213f09a9dd1448b
refs/heads/master
2021-01-17T18:08:13.178107
2017-06-27T09:28:30
2017-06-27T09:28:30
95,541,574
0
0
null
null
null
null
UTF-8
Java
false
false
8,407
java
package com.zhny.gr.wisdomcity.bean; import java.io.Serializable; /** * Created by czm on 2017/6/12 0012. */ public class DestinationBean implements Serializable { /** * chargeAmount : 0 * recommend : false * downloads : 0 * txt : 走进高增侗寨 高增距离从江县城虽然只有5千米,但交通不太方便。村中依旧保持原始的民风,一座高大的鼓楼矗立在寨子的正中央,寨边则有一座精美的风雨桥。 有六百多年历史的高增侗寨有三座鼓楼,分属上寨、下寨和坝寨三座寨子。其中两座17层,高近30米,另一座13层,高20多米。三座鼓楼都有醒目的攒金宝顶,全部用柱枋凿穿,相互交插而成,不用一钉一铆,工艺精湛之至。 同时,高增侗寨是贵州著名的侗族村寨。素有“美女之乡”的称呼,也是侗族大歌之乡。 凯里19个景点中排名第8 * id : 411 * title : 高增侗寨 * releaseDate : 2017-06-06 11:29:24 * contentImg : * attachmentPaths : * description : 高增距离从江县城虽然只有5千米,但交通不太方便。村中依旧保持原始的民风,一座高大的鼓楼矗立在寨子的正中央,寨边则有一座精美的风雨桥。 * titleImg : * topLevel : 0 * mediaPath : * status : 2 * hasCollect : false * commentCount : 0 * url : http://127.0.0.1:8080/zmmdd/411.jhtml * picPaths : http://127.0.0.1:8080/u/cms/www/201706/06113148ofxj.jpg,http://127.0.0.1:8080/u/cms/www/201706/06113158du72.jpg,http://127.0.0.1:8080/u/cms/www/201706/06113205e48v.jpg,http://127.0.0.1:8080/u/cms/www/201706/061132125pt5.jpg,http://127.0.0.1:8080/u/cms/www/201706/06113216lk6t.jpg * draft : false * charge : false * attachmentNames : * views : 0 * picDescs : ,,,, * downs : 0 * typeImg : * ups : 0 * channel : 醉美目的地 * comments : 0 */ private int chargeAmount; private boolean recommend; private int downloads; private String txt; private int id; private String title; private String releaseDate; private String contentImg; private String attachmentPaths; private String description; private String titleImg; private int topLevel; private String mediaPath; private int status; private boolean hasCollect; private int commentCount; private String url; private String picPaths; private boolean draft; private boolean charge; private String attachmentNames; private int views; private String picDescs; private int downs; private String typeImg; private int ups; private String channel; private int comments; public int getChargeAmount() { return chargeAmount; } public void setChargeAmount(int chargeAmount) { this.chargeAmount = chargeAmount; } public boolean isRecommend() { return recommend; } public void setRecommend(boolean recommend) { this.recommend = recommend; } public int getDownloads() { return downloads; } public void setDownloads(int downloads) { this.downloads = downloads; } public String getTxt() { return txt; } public void setTxt(String txt) { this.txt = txt; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getReleaseDate() { return releaseDate; } public void setReleaseDate(String releaseDate) { this.releaseDate = releaseDate; } public String getContentImg() { return contentImg; } public void setContentImg(String contentImg) { this.contentImg = contentImg; } public String getAttachmentPaths() { return attachmentPaths; } public void setAttachmentPaths(String attachmentPaths) { this.attachmentPaths = attachmentPaths; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getTitleImg() { return titleImg; } public void setTitleImg(String titleImg) { this.titleImg = titleImg; } public int getTopLevel() { return topLevel; } public void setTopLevel(int topLevel) { this.topLevel = topLevel; } public String getMediaPath() { return mediaPath; } public void setMediaPath(String mediaPath) { this.mediaPath = mediaPath; } public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public boolean isHasCollect() { return hasCollect; } public void setHasCollect(boolean hasCollect) { this.hasCollect = hasCollect; } public int getCommentCount() { return commentCount; } public void setCommentCount(int commentCount) { this.commentCount = commentCount; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getPicPaths() { return picPaths; } public void setPicPaths(String picPaths) { this.picPaths = picPaths; } public boolean isDraft() { return draft; } public void setDraft(boolean draft) { this.draft = draft; } public boolean isCharge() { return charge; } public void setCharge(boolean charge) { this.charge = charge; } public String getAttachmentNames() { return attachmentNames; } public void setAttachmentNames(String attachmentNames) { this.attachmentNames = attachmentNames; } public int getViews() { return views; } public void setViews(int views) { this.views = views; } public String getPicDescs() { return picDescs; } public void setPicDescs(String picDescs) { this.picDescs = picDescs; } public int getDowns() { return downs; } public void setDowns(int downs) { this.downs = downs; } public String getTypeImg() { return typeImg; } public void setTypeImg(String typeImg) { this.typeImg = typeImg; } public int getUps() { return ups; } public void setUps(int ups) { this.ups = ups; } public String getChannel() { return channel; } public void setChannel(String channel) { this.channel = channel; } public int getComments() { return comments; } public void setComments(int comments) { this.comments = comments; } @Override public String toString() { return "DestinationBean{" + "chargeAmount=" + chargeAmount + ", recommend=" + recommend + ", downloads=" + downloads + ", txt='" + txt + '\'' + ", id=" + id + ", title='" + title + '\'' + ", releaseDate='" + releaseDate + '\'' + ", contentImg='" + contentImg + '\'' + ", attachmentPaths='" + attachmentPaths + '\'' + ", description='" + description + '\'' + ", titleImg='" + titleImg + '\'' + ", topLevel=" + topLevel + ", mediaPath='" + mediaPath + '\'' + ", status=" + status + ", hasCollect=" + hasCollect + ", commentCount=" + commentCount + ", url='" + url + '\'' + ", picPaths='" + picPaths + '\'' + ", draft=" + draft + ", charge=" + charge + ", attachmentNames='" + attachmentNames + '\'' + ", views=" + views + ", picDescs='" + picDescs + '\'' + ", downs=" + downs + ", typeImg='" + typeImg + '\'' + ", ups=" + ups + ", channel='" + channel + '\'' + ", comments=" + comments + '}'; } }
[ "outmycarry@outlook.com" ]
outmycarry@outlook.com
eee715df1552f52d69022a2401ff394253cef955
f3b9a444d2d513c670d216f7c700131410c47f92
/game_qlz/src/com/gamecenter/common/packets/Txtask_request.java
95940293bc85b4dbfbf00a7275aad53953507cfb
[]
no_license
kuainiao/GameAdminWeb
6a372087380e3c5ad98fc7cf4c8cbf9f01854e5d
f89327374d39c112421606e6a9fe9189b46c1a90
refs/heads/master
2020-06-03T22:15:02.944948
2017-12-22T06:20:38
2017-12-22T06:20:38
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,345
java
package com.gamecenter.common.packets; import java.nio.ByteBuffer; /** * 封号请求 Created by IntelliJ IDEA. User: Administrator Date: 12-9-6 Time: 下午2:22 To change this template use File | Settings | File Templates. */ public class Txtask_request implements PacketBuildUp { private String cmd; private String openid; private String taskid; public ByteBuffer data() { ByteBuffer tempData = ByteBuffer.allocate(200); try { // tempData.putInt(Integer.MIN_VALUE); // tempData.putInt(-1); // tempData.putInt(-1); // tempData.putShort((short) 0x5230); // tempData.putShort((short) JSONObject.fromObject(this).toString().getBytes("UTF-8").length); // tempData.put(JSONObject.fromObject(this).toString().getBytes("UTF-8")); // tempData.putInt(0, (int) (tempData.position() - 4)); // System.out.println("ForbidPassport_request:" + JSONObject.fromObject(this).toString()); tempData.flip(); } catch (Exception e) { e.printStackTrace(); } return tempData; } public String getCmd() { return cmd; } public void setCmd(String cmd) { this.cmd = cmd; } public String getOpenid() { return openid; } public void setOpenid(String openid) { this.openid = openid; } public String getTaskid() { return taskid; } public void setTaskid(String taskid) { this.taskid = taskid; } }
[ "lyh@163.com" ]
lyh@163.com
1e4206e494c1d30dfe4cb95e984553295e8eecdb
56310cbd3d629281a36e32834a9d7799ce494d95
/20190118/custom_function/Main.java
9c4bad79916afd8849206d9e6e6757b87f5ebe95
[]
no_license
tsered/Shiyiyi
dac74d5d23dadd092613b0d28e817e82a908141e
a24d29d0d6b802c11d8d7732cd2af68f68e4cb65
refs/heads/master
2020-04-04T16:24:44.018740
2019-02-12T05:09:01
2019-02-12T05:09:01
156,076,685
6
0
null
null
null
null
UTF-8
Java
false
false
598
java
package custom_function; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int B = 0; while (cin.hasNextInt()) { int count = 0; int A = cin.nextInt(); int L = cin.nextInt(); int R = cin.nextInt(); for (int i = L; i <= R; i++) { if (f(i) * f(i) == f(A * i)) { count++; } } B++; System.out.println("case " + B + ": " + count); } } public static int f(int x) { int s = 0; while (x > 0) { s += x % 10; x /= 10; } return s; } }
[ "Administrator@10.2.233.215" ]
Administrator@10.2.233.215
d09f9a712407b149ee4dd0758fef7c8ebdccbaa8
f7d6b2514f18e7685721165ee5ab97bd896e5ba5
/src/com/soto/study/model/SysUser.java
4c7d40547a2684ba2b092618f34aa4773513a5f1
[]
no_license
sotowang/Mybatis
b9b9c865886029b7b48ead86588b4fe618f23952
97400c8325e7c558b2d51be50198ee6df99543d2
refs/heads/master
2020-03-22T21:44:06.971896
2019-03-11T14:23:49
2019-03-11T14:23:49
140,710,736
1
0
null
null
null
null
UTF-8
Java
false
false
1,349
java
package com.soto.study.model; import java.util.Date; public class SysUser { private Long id; private String userName; private String userPassword; private String userEmail; private String userInfo; private Byte[] headImg; private Date createTime; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getUserPassword() { return userPassword; } public void setUserPassword(String userPassword) { this.userPassword = userPassword; } public String getUserEmail() { return userEmail; } public void setUserEmail(String userEmail) { this.userEmail = userEmail; } public String getUserInfo() { return userInfo; } public void setUserInfo(String userInfo) { this.userInfo = userInfo; } public Byte[] getHeadImg() { return headImg; } public void setHeadImg(Byte[] headImg) { this.headImg = headImg; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } }
[ "sotowang@qq.com" ]
sotowang@qq.com
4ecd8350935fd15da7908b95c46ba4f79c852021
95cfe2239c8fce0cec91d76e0a82f59a9efc4cb8
/sourceCode/CommonsMathMutGenerator/java.lang.ArrayIndexOutOfBoundsException/561_LVR/mut/DSCompiler.java
f1fde78efcadd5858ef2580fd6eeac59fec73523
[]
no_license
Djack1010/BUG_DB
28eff24aece45ed379b49893176383d9260501e7
a4b6e4460a664ce64a474bfd7da635aa7ff62041
refs/heads/master
2022-04-09T01:58:29.736794
2020-03-13T14:15:11
2020-03-13T14:15:11
141,260,015
0
1
null
null
null
null
UTF-8
Java
false
false
78,318
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.analysis.differentiation; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.math3.exception.DimensionMismatchException; import org.apache.commons.math3.exception.MathArithmeticException; import org.apache.commons.math3.exception.MathInternalError; import org.apache.commons.math3.exception.NotPositiveException; import org.apache.commons.math3.exception.NumberIsTooLargeException; import org.apache.commons.math3.util.CombinatoricsUtils; import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.MathArrays; /** Class holding "compiled" computation rules for derivative structures. * <p>This class implements the computation rules described in Dan Kalman's paper <a * href="http://www1.american.edu/cas/mathstat/People/kalman/pdffiles/mmgautodiff.pdf">Doubly * Recursive Multivariate Automatic Differentiation</a>, Mathematics Magazine, vol. 75, * no. 3, June 2002. However, in order to avoid performances bottlenecks, the recursive * rules are "compiled" once in an unfold form. This class does this recursion unrolling * and stores the computation rules as simple loops with pre-computed indirection arrays.</p> * <p> * This class maps all derivative computation into single dimension arrays that hold the * value and partial derivatives. The class does not hold these arrays, which remains under * the responsibility of the caller. For each combination of number of free parameters and * derivation order, only one compiler is necessary, and this compiler will be used to * perform computations on all arrays provided to it, which can represent hundreds or * thousands of different parameters kept together with all theur partial derivatives. * </p> * <p> * The arrays on which compilers operate contain only the partial derivatives together * with the 0<sup>th</sup> derivative, i.e. the value. The partial derivatives are stored in * a compiler-specific order, which can be retrieved using methods {@link * #getPartialDerivativeIndex(int...) getPartialDerivativeIndex} and {@link * #getPartialDerivativeOrders(int)}. The value is guaranteed to be stored as the first element * (i.e. the {@link #getPartialDerivativeIndex(int...) getPartialDerivativeIndex} method returns * 0 when called with 0 for all derivation orders and {@link #getPartialDerivativeOrders(int) * getPartialDerivativeOrders} returns an array filled with 0 when called with 0 as the index). * </p> * <p> * Note that the ordering changes with number of parameters and derivation order. For example * given 2 parameters x and y, df/dy is stored at index 2 when derivation order is set to 1 (in * this case the array has three elements: f, df/dx and df/dy). If derivation order is set to * 2, then df/dy will be stored at index 3 (in this case the array has six elements: f, df/dx, * df/dxdx, df/dy, df/dxdy and df/dydy). * </p> * <p> * Given this structure, users can perform some simple operations like adding, subtracting * or multiplying constants and negating the elements by themselves, knowing if they want to * mutate their array or create a new array. These simple operations are not provided by * the compiler. The compiler provides only the more complex operations between several arrays. * </p> * <p>This class is mainly used as the engine for scalar variable {@link DerivativeStructure}. * It can also be used directly to hold several variables in arrays for more complex data * structures. User can for example store a vector of n variables depending on three x, y * and z free parameters in one array as follows:</p> <pre> * // parameter 0 is x, parameter 1 is y, parameter 2 is z * int parameters = 3; * DSCompiler compiler = DSCompiler.getCompiler(parameters, order); * int size = compiler.getSize(); * * // pack all elements in a single array * double[] array = new double[n * size]; * for (int i = 0; i &lt; n; ++i) { * * // we know value is guaranteed to be the first element * array[i * size] = v[i]; * * // we don't know where first derivatives are stored, so we ask the compiler * array[i * size + compiler.getPartialDerivativeIndex(1, 0, 0) = dvOnDx[i][0]; * array[i * size + compiler.getPartialDerivativeIndex(0, 1, 0) = dvOnDy[i][0]; * array[i * size + compiler.getPartialDerivativeIndex(0, 0, 1) = dvOnDz[i][0]; * * // we let all higher order derivatives set to 0 * * } * </pre> * <p>Then in another function, user can perform some operations on all elements stored * in the single array, such as a simple product of all variables:</p> <pre> * // compute the product of all elements * double[] product = new double[size]; * prod[0] = 1.0; * for (int i = 0; i &lt; n; ++i) { * double[] tmp = product.clone(); * compiler.multiply(tmp, 0, array, i * size, product, 0); * } * * // value * double p = product[0]; * * // first derivatives * double dPdX = product[compiler.getPartialDerivativeIndex(1, 0, 0)]; * double dPdY = product[compiler.getPartialDerivativeIndex(0, 1, 0)]; * double dPdZ = product[compiler.getPartialDerivativeIndex(0, 0, 1)]; * * // cross derivatives (assuming order was at least 2) * double dPdXdX = product[compiler.getPartialDerivativeIndex(2, 0, 0)]; * double dPdXdY = product[compiler.getPartialDerivativeIndex(1, 1, 0)]; * double dPdXdZ = product[compiler.getPartialDerivativeIndex(1, 0, 1)]; * double dPdYdY = product[compiler.getPartialDerivativeIndex(0, 2, 0)]; * double dPdYdZ = product[compiler.getPartialDerivativeIndex(0, 1, 1)]; * double dPdZdZ = product[compiler.getPartialDerivativeIndex(0, 0, 2)]; * </pre> * @see DerivativeStructure * @since 3.1 */ public class DSCompiler { /** Array of all compilers created so far. */ private static AtomicReference<DSCompiler[][]> compilers = new AtomicReference<DSCompiler[][]>(null); /** Number of free parameters. */ private final int parameters; /** Derivation order. */ private final int order; /** Number of partial derivatives (including the single 0 order derivative element). */ private final int[][] sizes; /** Indirection array for partial derivatives. */ private final int[][] derivativesIndirection; /** Indirection array of the lower derivative elements. */ private final int[] lowerIndirection; /** Indirection arrays for multiplication. */ private final int[][][] multIndirection; /** Indirection arrays for function composition. */ private final int[][][] compIndirection; /** Private constructor, reserved for the factory method {@link #getCompiler(int, int)}. * @param parameters number of free parameters * @param order derivation order * @param valueCompiler compiler for the value part * @param derivativeCompiler compiler for the derivative part * @throws NumberIsTooLargeException if order is too large */ private DSCompiler(final int parameters, final int order, final DSCompiler valueCompiler, final DSCompiler derivativeCompiler) throws NumberIsTooLargeException { this.parameters = parameters; this.order = order; this.sizes = compileSizes(parameters, order, valueCompiler); this.derivativesIndirection = compileDerivativesIndirection(parameters, order, valueCompiler, derivativeCompiler); this.lowerIndirection = compileLowerIndirection(parameters, order, valueCompiler, derivativeCompiler); this.multIndirection = compileMultiplicationIndirection(parameters, order, valueCompiler, derivativeCompiler, lowerIndirection); this.compIndirection = compileCompositionIndirection(parameters, order, valueCompiler, derivativeCompiler, sizes, derivativesIndirection); } /** Get the compiler for number of free parameters and order. * @param parameters number of free parameters * @param order derivation order * @return cached rules set * @throws NumberIsTooLargeException if order is too large */ public static DSCompiler getCompiler(int parameters, int order) throws NumberIsTooLargeException { // get the cached compilers final DSCompiler[][] cache = compilers.get(); if (cache != null && cache.length > parameters && cache[parameters].length > order && cache[parameters][order] != null) { // the compiler has already been created return cache[parameters][order]; } // we need to create more compilers final int maxParameters = FastMath.max(parameters, cache == null ? 0 : cache.length); final int maxOrder = FastMath.max(order, cache == null ? 0 : cache[0].length); final DSCompiler[][] newCache = new DSCompiler[maxParameters + 1][maxOrder + 1]; if (cache != null) { // preserve the already created compilers for (int i = 0; i < cache.length; ++i) { System.arraycopy(cache[i], 0, newCache[i], 0, cache[i].length); } } // create the array in increasing diagonal order for (int diag = 0; diag <= parameters + order; ++diag) { for (int o = FastMath.max(0, diag - parameters); o <= FastMath.min(order, diag); ++o) { final int p = diag - o; if (newCache[p][o] == null) { final DSCompiler valueCompiler = (p == 0) ? null : newCache[p - 1][o]; final DSCompiler derivativeCompiler = (o == 0) ? null : newCache[p][o - 1]; newCache[p][o] = new DSCompiler(p, o, valueCompiler, derivativeCompiler); } } } // atomically reset the cached compilers array compilers.compareAndSet(cache, newCache); return newCache[parameters][order]; } /** Compile the sizes array. * @param parameters number of free parameters * @param order derivation order * @param valueCompiler compiler for the value part * @return sizes array */ private static int[][] compileSizes(final int parameters, final int order, final DSCompiler valueCompiler) { final int[][] sizes = new int[parameters + 1][order + 1]; if (parameters == 0) { Arrays.fill(sizes[0], 1); } else { System.arraycopy(valueCompiler.sizes, 0, sizes, 0, parameters); sizes[parameters][0] = 1; for (int i = 0; i < order; ++i) { sizes[parameters][i + 1] = sizes[parameters][i] + sizes[parameters - 1][i + 1]; } } return sizes; } /** Compile the derivatives indirection array. * @param parameters number of free parameters * @param order derivation order * @param valueCompiler compiler for the value part * @param derivativeCompiler compiler for the derivative part * @return derivatives indirection array */ private static int[][] compileDerivativesIndirection(final int parameters, final int order, final DSCompiler valueCompiler, final DSCompiler derivativeCompiler) { if (parameters == 0 || order == 0) { return new int[1][parameters]; } final int vSize = valueCompiler.derivativesIndirection.length; final int dSize = derivativeCompiler.derivativesIndirection.length; final int[][] derivativesIndirection = new int[vSize + dSize][parameters]; // set up the indices for the value part for (int i = 0; i < vSize; ++i) { // copy the first indices, the last one remaining set to 0 System.arraycopy(valueCompiler.derivativesIndirection[i], 0, derivativesIndirection[i], 0, parameters - 1); } // set up the indices for the derivative part for (int i = 0; i < dSize; ++i) { // copy the indices System.arraycopy(derivativeCompiler.derivativesIndirection[i], 0, derivativesIndirection[vSize + i], 0, parameters); // increment the derivation order for the last parameter derivativesIndirection[vSize + i][parameters - 1]++; } return derivativesIndirection; } /** Compile the lower derivatives indirection array. * <p> * This indirection array contains the indices of all elements * except derivatives for last derivation order. * </p> * @param parameters number of free parameters * @param order derivation order * @param valueCompiler compiler for the value part * @param derivativeCompiler compiler for the derivative part * @return lower derivatives indirection array */ private static int[] compileLowerIndirection(final int parameters, final int order, final DSCompiler valueCompiler, final DSCompiler derivativeCompiler) { if (parameters == 0 || order <= 1) { return new int[] { 0 }; } // this is an implementation of definition 6 in Dan Kalman's paper. final int vSize = valueCompiler.lowerIndirection.length; final int dSize = derivativeCompiler.lowerIndirection.length; final int[] lowerIndirection = new int[vSize + dSize]; System.arraycopy(valueCompiler.lowerIndirection, 0, lowerIndirection, 0, vSize); for (int i = 0; i < dSize; ++i) { lowerIndirection[vSize + i] = valueCompiler.getSize() + derivativeCompiler.lowerIndirection[i]; } return lowerIndirection; } /** Compile the multiplication indirection array. * <p> * This indirection array contains the indices of all pairs of elements * involved when computing a multiplication. This allows a straightforward * loop-based multiplication (see {@link #multiply(double[], int, double[], int, double[], int)}). * </p> * @param parameters number of free parameters * @param order derivation order * @param valueCompiler compiler for the value part * @param derivativeCompiler compiler for the derivative part * @param lowerIndirection lower derivatives indirection array * @return multiplication indirection array */ private static int[][][] compileMultiplicationIndirection(final int parameters, final int order, final DSCompiler valueCompiler, final DSCompiler derivativeCompiler, final int[] lowerIndirection) { if ((parameters == 0) || (order == 0)) { return new int[][][] { { { 1, 0, 0 } } }; } // this is an implementation of definition 3 in Dan Kalman's paper. final int vSize = valueCompiler.multIndirection.length; final int dSize = derivativeCompiler.multIndirection.length; final int[][][] multIndirection = new int[vSize + dSize][][]; System.arraycopy(valueCompiler.multIndirection, 0, multIndirection, 0, vSize); for (int i = 0; i < dSize; ++i) { final int[][] dRow = derivativeCompiler.multIndirection[i]; List<int[]> row = new ArrayList<int[]>(dRow.length * 2); for (int j = 0; j < dRow.length; ++j) { row.add(new int[] { dRow[j][0], lowerIndirection[dRow[j][1]], vSize + dRow[j][2] }); row.add(new int[] { dRow[j][0], vSize + dRow[j][1], lowerIndirection[dRow[j][2]] }); } // combine terms with similar derivation orders final List<int[]> combined = new ArrayList<int[]>(row.size()); for (int j = 0; j < row.size(); ++j) { final int[] termJ = row.get(j); if (termJ[0] > 0) { for (int k = j + 1; k < row.size(); ++k) { final int[] termK = row.get(k); if (termJ[1] == termK[1] && termJ[2] == termK[2]) { // combine termJ and termK termJ[0] += termK[0]; // make sure we will skip termK later on in the outer loop termK[0] = 0; } } combined.add(termJ); } } multIndirection[vSize + i] = combined.toArray(new int[combined.size()][]); } return multIndirection; } /** Compile the function composition indirection array. * <p> * This indirection array contains the indices of all sets of elements * involved when computing a composition. This allows a straightforward * loop-based composition (see {@link #compose(double[], int, double[], double[], int)}). * </p> * @param parameters number of free parameters * @param order derivation order * @param valueCompiler compiler for the value part * @param derivativeCompiler compiler for the derivative part * @param sizes sizes array * @param derivativesIndirection derivatives indirection array * @return multiplication indirection array * @throws NumberIsTooLargeException if order is too large */ private static int[][][] compileCompositionIndirection(final int parameters, final int order, final DSCompiler valueCompiler, final DSCompiler derivativeCompiler, final int[][] sizes, final int[][] derivativesIndirection) throws NumberIsTooLargeException { if ((parameters == 0) || (order == 0)) { return new int[][][] { { { 1, 0 } } }; } final int vSize = valueCompiler.compIndirection.length; final int dSize = derivativeCompiler.compIndirection.length; final int[][][] compIndirection = new int[vSize + dSize][][]; // the composition rules from the value part can be reused as is System.arraycopy(valueCompiler.compIndirection, 0, compIndirection, 0, vSize); // the composition rules for the derivative part are deduced by // differentiation the rules from the underlying compiler once // with respect to the parameter this compiler handles and the // underlying one did not handle for (int i = 0; i < dSize; ++i) { List<int[]> row = new ArrayList<int[]>(); for (int[] term : derivativeCompiler.compIndirection[i]) { // handle term p * f_k(g(x)) * g_l1(x) * g_l2(x) * ... * g_lp(x) // derive the first factor in the term: f_k with respect to new parameter int[] derivedTermF = new int[term.length + 1]; derivedTermF[0] = term[0]; // p derivedTermF[1] = term[1] + 1; // f_(k+1) int[] orders = new int[parameters]; orders[parameters - 1] = 1; derivedTermF[term.length] = getPartialDerivativeIndex(parameters, order, sizes, orders); // g_1 for (int j = 2; j < term.length; ++j) { // convert the indices as the mapping for the current order // is different from the mapping with one less order derivedTermF[j] = convertIndex(term[j], parameters, derivativeCompiler.derivativesIndirection, parameters, order, sizes); } Arrays.sort(derivedTermF, 2, derivedTermF.length); row.add(derivedTermF); // derive the various g_l for (int l = 2; l < term.length; ++l) { int[] derivedTermG = new int[term.length]; derivedTermG[0] = term[0]; derivedTermG[1] = term[1]; for (int j = 2; j < term.length; ++j) { // convert the indices as the mapping for the current order // is different from the mapping with one less order derivedTermG[j] = convertIndex(term[j], parameters, derivativeCompiler.derivativesIndirection, parameters, order, sizes); if (j == l) { // derive this term System.arraycopy(derivativesIndirection[derivedTermG[j]], 0, orders, 0, parameters); orders[parameters - 1]++; derivedTermG[j] = getPartialDerivativeIndex(parameters, order, sizes, orders); } } Arrays.sort(derivedTermG, 2, derivedTermG.length); row.add(derivedTermG); } } // combine terms with similar derivation orders final List<int[]> combined = new ArrayList<int[]>(row.size()); for (int j = 0; j < row.size(); ++j) { final int[] termJ = row.get(j); if (termJ[0] > 0) { for (int k = j + 1; k < row.size(); ++k) { final int[] termK = row.get(k); boolean equals = termJ.length == termK.length; for (int l = 1; equals && l < termJ.length; ++l) { equals &= termJ[l] == termK[l]; } if (equals) { // combine termJ and termK termJ[-1] += termK[0]; // make sure we will skip termK later on in the outer loop termK[0] = 0; } } combined.add(termJ); } } compIndirection[vSize + i] = combined.toArray(new int[combined.size()][]); } return compIndirection; } /** Get the index of a partial derivative in the array. * <p> * If all orders are set to 0, then the 0<sup>th</sup> order derivative * is returned, which is the value of the function. * </p> * <p>The indices of derivatives are between 0 and {@link #getSize() getSize()} - 1. * Their specific order is fixed for a given compiler, but otherwise not * publicly specified. There are however some simple cases which have guaranteed * indices: * </p> * <ul> * <li>the index of 0<sup>th</sup> order derivative is always 0</li> * <li>if there is only 1 {@link #getFreeParameters() free parameter}, then the * derivatives are sorted in increasing derivation order (i.e. f at index 0, df/dp * at index 1, d<sup>2</sup>f/dp<sup>2</sup> at index 2 ... * d<sup>k</sup>f/dp<sup>k</sup> at index k),</li> * <li>if the {@link #getOrder() derivation order} is 1, then the derivatives * are sorted in increasing free parameter order (i.e. f at index 0, df/dx<sub>1</sub> * at index 1, df/dx<sub>2</sub> at index 2 ... df/dx<sub>k</sub> at index k),</li> * <li>all other cases are not publicly specified</li> * </ul> * <p> * This method is the inverse of method {@link #getPartialDerivativeOrders(int)} * </p> * @param orders derivation orders with respect to each parameter * @return index of the partial derivative * @exception DimensionMismatchException if the numbers of parameters does not * match the instance * @exception NumberIsTooLargeException if sum of derivation orders is larger * than the instance limits * @see #getPartialDerivativeOrders(int) */ public int getPartialDerivativeIndex(final int ... orders) throws DimensionMismatchException, NumberIsTooLargeException { // safety check if (orders.length != getFreeParameters()) { throw new DimensionMismatchException(orders.length, getFreeParameters()); } return getPartialDerivativeIndex(parameters, order, sizes, orders); } /** Get the index of a partial derivative in an array. * @param parameters number of free parameters * @param order derivation order * @param sizes sizes array * @param orders derivation orders with respect to each parameter * (the lenght of this array must match the number of parameters) * @return index of the partial derivative * @exception NumberIsTooLargeException if sum of derivation orders is larger * than the instance limits */ private static int getPartialDerivativeIndex(final int parameters, final int order, final int[][] sizes, final int ... orders) throws NumberIsTooLargeException { // the value is obtained by diving into the recursive Dan Kalman's structure // this is theorem 2 of his paper, with recursion replaced by iteration int index = 0; int m = order; int ordersSum = 0; for (int i = parameters - 1; i >= 0; --i) { // derivative order for current free parameter int derivativeOrder = orders[i]; // safety check ordersSum += derivativeOrder; if (ordersSum > order) { throw new NumberIsTooLargeException(ordersSum, order, true); } while (derivativeOrder-- > 0) { // as long as we differentiate according to current free parameter, // we have to skip the value part and dive into the derivative part // so we add the size of the value part to the base index index += sizes[i][m--]; } } return index; } /** Convert an index from one (parameters, order) structure to another. * @param index index of a partial derivative in source derivative structure * @param srcP number of free parameters in source derivative structure * @param srcDerivativesIndirection derivatives indirection array for the source * derivative structure * @param destP number of free parameters in destination derivative structure * @param destO derivation order in destination derivative structure * @param destSizes sizes array for the destination derivative structure * @return index of the partial derivative with the <em>same</em> characteristics * in destination derivative structure * @throws NumberIsTooLargeException if order is too large */ private static int convertIndex(final int index, final int srcP, final int[][] srcDerivativesIndirection, final int destP, final int destO, final int[][] destSizes) throws NumberIsTooLargeException { int[] orders = new int[destP]; System.arraycopy(srcDerivativesIndirection[index], 0, orders, 0, FastMath.min(srcP, destP)); return getPartialDerivativeIndex(destP, destO, destSizes, orders); } /** Get the derivation orders for a specific index in the array. * <p> * This method is the inverse of {@link #getPartialDerivativeIndex(int...)}. * </p> * @param index of the partial derivative * @return orders derivation orders with respect to each parameter * @see #getPartialDerivativeIndex(int...) */ public int[] getPartialDerivativeOrders(final int index) { return derivativesIndirection[index]; } /** Get the number of free parameters. * @return number of free parameters */ public int getFreeParameters() { return parameters; } /** Get the derivation order. * @return derivation order */ public int getOrder() { return order; } /** Get the array size required for holding partial derivatives data. * <p> * This number includes the single 0 order derivative element, which is * guaranteed to be stored in the first element of the array. * </p> * @return array size required for holding partial derivatives data */ public int getSize() { return sizes[parameters][order]; } /** Compute linear combination. * The derivative structure built will be a1 * ds1 + a2 * ds2 * @param a1 first scale factor * @param c1 first base (unscaled) component * @param offset1 offset of first operand in its array * @param a2 second scale factor * @param c2 second base (unscaled) component * @param offset2 offset of second operand in its array * @param result array where result must be stored (it may be * one of the input arrays) * @param resultOffset offset of the result in its array */ public void linearCombination(final double a1, final double[] c1, final int offset1, final double a2, final double[] c2, final int offset2, final double[] result, final int resultOffset) { for (int i = 0; i < getSize(); ++i) { result[resultOffset + i] = MathArrays.linearCombination(a1, c1[offset1 + i], a2, c2[offset2 + i]); } } /** Compute linear combination. * The derivative structure built will be a1 * ds1 + a2 * ds2 + a3 * ds3 + a4 * ds4 * @param a1 first scale factor * @param c1 first base (unscaled) component * @param offset1 offset of first operand in its array * @param a2 second scale factor * @param c2 second base (unscaled) component * @param offset2 offset of second operand in its array * @param a3 third scale factor * @param c3 third base (unscaled) component * @param offset3 offset of third operand in its array * @param result array where result must be stored (it may be * one of the input arrays) * @param resultOffset offset of the result in its array */ public void linearCombination(final double a1, final double[] c1, final int offset1, final double a2, final double[] c2, final int offset2, final double a3, final double[] c3, final int offset3, final double[] result, final int resultOffset) { for (int i = 0; i < getSize(); ++i) { result[resultOffset + i] = MathArrays.linearCombination(a1, c1[offset1 + i], a2, c2[offset2 + i], a3, c3[offset3 + i]); } } /** Compute linear combination. * The derivative structure built will be a1 * ds1 + a2 * ds2 + a3 * ds3 + a4 * ds4 * @param a1 first scale factor * @param c1 first base (unscaled) component * @param offset1 offset of first operand in its array * @param a2 second scale factor * @param c2 second base (unscaled) component * @param offset2 offset of second operand in its array * @param a3 third scale factor * @param c3 third base (unscaled) component * @param offset3 offset of third operand in its array * @param a4 fourth scale factor * @param c4 fourth base (unscaled) component * @param offset4 offset of fourth operand in its array * @param result array where result must be stored (it may be * one of the input arrays) * @param resultOffset offset of the result in its array */ public void linearCombination(final double a1, final double[] c1, final int offset1, final double a2, final double[] c2, final int offset2, final double a3, final double[] c3, final int offset3, final double a4, final double[] c4, final int offset4, final double[] result, final int resultOffset) { for (int i = 0; i < getSize(); ++i) { result[resultOffset + i] = MathArrays.linearCombination(a1, c1[offset1 + i], a2, c2[offset2 + i], a3, c3[offset3 + i], a4, c4[offset4 + i]); } } /** Perform addition of two derivative structures. * @param lhs array holding left hand side of addition * @param lhsOffset offset of the left hand side in its array * @param rhs array right hand side of addition * @param rhsOffset offset of the right hand side in its array * @param result array where result must be stored (it may be * one of the input arrays) * @param resultOffset offset of the result in its array */ public void add(final double[] lhs, final int lhsOffset, final double[] rhs, final int rhsOffset, final double[] result, final int resultOffset) { for (int i = 0; i < getSize(); ++i) { result[resultOffset + i] = lhs[lhsOffset + i] + rhs[rhsOffset + i]; } } /** Perform subtraction of two derivative structures. * @param lhs array holding left hand side of subtraction * @param lhsOffset offset of the left hand side in its array * @param rhs array right hand side of subtraction * @param rhsOffset offset of the right hand side in its array * @param result array where result must be stored (it may be * one of the input arrays) * @param resultOffset offset of the result in its array */ public void subtract(final double[] lhs, final int lhsOffset, final double[] rhs, final int rhsOffset, final double[] result, final int resultOffset) { for (int i = 0; i < getSize(); ++i) { result[resultOffset + i] = lhs[lhsOffset + i] - rhs[rhsOffset + i]; } } /** Perform multiplication of two derivative structures. * @param lhs array holding left hand side of multiplication * @param lhsOffset offset of the left hand side in its array * @param rhs array right hand side of multiplication * @param rhsOffset offset of the right hand side in its array * @param result array where result must be stored (for * multiplication the result array <em>cannot</em> be one of * the input arrays) * @param resultOffset offset of the result in its array */ public void multiply(final double[] lhs, final int lhsOffset, final double[] rhs, final int rhsOffset, final double[] result, final int resultOffset) { for (int i = 0; i < multIndirection.length; ++i) { final int[][] mappingI = multIndirection[i]; double r = 0; for (int j = 0; j < mappingI.length; ++j) { r += mappingI[j][0] * lhs[lhsOffset + mappingI[j][1]] * rhs[rhsOffset + mappingI[j][2]]; } result[resultOffset + i] = r; } } /** Perform division of two derivative structures. * @param lhs array holding left hand side of division * @param lhsOffset offset of the left hand side in its array * @param rhs array right hand side of division * @param rhsOffset offset of the right hand side in its array * @param result array where result must be stored (for * division the result array <em>cannot</em> be one of * the input arrays) * @param resultOffset offset of the result in its array */ public void divide(final double[] lhs, final int lhsOffset, final double[] rhs, final int rhsOffset, final double[] result, final int resultOffset) { final double[] reciprocal = new double[getSize()]; pow(rhs, lhsOffset, -1, reciprocal, 0); multiply(lhs, lhsOffset, reciprocal, 0, result, resultOffset); } /** Perform remainder of two derivative structures. * @param lhs array holding left hand side of remainder * @param lhsOffset offset of the left hand side in its array * @param rhs array right hand side of remainder * @param rhsOffset offset of the right hand side in its array * @param result array where result must be stored (it may be * one of the input arrays) * @param resultOffset offset of the result in its array */ public void remainder(final double[] lhs, final int lhsOffset, final double[] rhs, final int rhsOffset, final double[] result, final int resultOffset) { // compute k such that lhs % rhs = lhs - k rhs final double rem = FastMath.IEEEremainder(lhs[lhsOffset], rhs[rhsOffset]); final double k = FastMath.rint((lhs[lhsOffset] - rem) / rhs[rhsOffset]); // set up value result[resultOffset] = rem; // set up partial derivatives for (int i = 1; i < getSize(); ++i) { result[resultOffset + i] = lhs[lhsOffset + i] - k * rhs[rhsOffset + i]; } } /** Compute power of a double to a derivative structure. * @param a number to exponentiate * @param operand array holding the power * @param operandOffset offset of the power in its array * @param result array where result must be stored (for * power the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array * @since 3.3 */ public void pow(final double a, final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives // [a^x, ln(a) a^x, ln(a)^2 a^x,, ln(a)^3 a^x, ... ] final double[] function = new double[1 + order]; if (a == 0) { if (operand[operandOffset] == 0) { function[0] = 1; double infinity = Double.POSITIVE_INFINITY; for (int i = 1; i < function.length; ++i) { infinity = -infinity; function[i] = infinity; } } else if (operand[operandOffset] < 0) { Arrays.fill(function, Double.NaN); } } else { function[0] = FastMath.pow(a, operand[operandOffset]); final double lnA = FastMath.log(a); for (int i = 1; i < function.length; ++i) { function[i] = lnA * function[i - 1]; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute power of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param p power to apply * @param result array where result must be stored (for * power the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void pow(final double[] operand, final int operandOffset, final double p, final double[] result, final int resultOffset) { // create the function value and derivatives // [x^p, px^(p-1), p(p-1)x^(p-2), ... ] double[] function = new double[1 + order]; double xk = FastMath.pow(operand[operandOffset], p - order); for (int i = order; i > 0; --i) { function[i] = xk; xk *= operand[operandOffset]; } function[0] = xk; double coefficient = p; for (int i = 1; i <= order; ++i) { function[i] *= coefficient; coefficient *= p - i; } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute integer power of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param n power to apply * @param result array where result must be stored (for * power the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void pow(final double[] operand, final int operandOffset, final int n, final double[] result, final int resultOffset) { if (n == 0) { // special case, x^0 = 1 for all x result[resultOffset] = 1.0; Arrays.fill(result, resultOffset + 1, resultOffset + getSize(), 0); return; } // create the power function value and derivatives // [x^n, nx^(n-1), n(n-1)x^(n-2), ... ] double[] function = new double[1 + order]; if (n > 0) { // strictly positive power final int maxOrder = FastMath.min(order, n); double xk = FastMath.pow(operand[operandOffset], n - maxOrder); for (int i = maxOrder; i > 0; --i) { function[i] = xk; xk *= operand[operandOffset]; } function[0] = xk; } else { // strictly negative power final double inv = 1.0 / operand[operandOffset]; double xk = FastMath.pow(inv, -n); for (int i = 0; i <= order; ++i) { function[i] = xk; xk *= inv; } } double coefficient = n; for (int i = 1; i <= order; ++i) { function[i] *= coefficient; coefficient *= n - i; } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute power of a derivative structure. * @param x array holding the base * @param xOffset offset of the base in its array * @param y array holding the exponent * @param yOffset offset of the exponent in its array * @param result array where result must be stored (for * power the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void pow(final double[] x, final int xOffset, final double[] y, final int yOffset, final double[] result, final int resultOffset) { final double[] logX = new double[getSize()]; log(x, xOffset, logX, 0); final double[] yLogX = new double[getSize()]; multiply(logX, 0, y, yOffset, yLogX, 0); exp(yLogX, 0, result, resultOffset); } /** Compute n<sup>th</sup> root of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param n order of the root * @param result array where result must be stored (for * n<sup>th</sup> root the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void rootN(final double[] operand, final int operandOffset, final int n, final double[] result, final int resultOffset) { // create the function value and derivatives // [x^(1/n), (1/n)x^((1/n)-1), (1-n)/n^2x^((1/n)-2), ... ] double[] function = new double[1 + order]; double xk; if (n == 2) { function[0] = FastMath.sqrt(operand[operandOffset]); xk = 0.5 / function[0]; } else if (n == 3) { function[0] = FastMath.cbrt(operand[operandOffset]); xk = 1.0 / (3.0 * function[0] * function[0]); } else { function[0] = FastMath.pow(operand[operandOffset], 1.0 / n); xk = 1.0 / (n * FastMath.pow(function[0], n - 1)); } final double nReciprocal = 1.0 / n; final double xReciprocal = 1.0 / operand[operandOffset]; for (int i = 1; i <= order; ++i) { function[i] = xk; xk *= xReciprocal * (nReciprocal - i); } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute exponential of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * exponential the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void exp(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; Arrays.fill(function, FastMath.exp(operand[operandOffset])); // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute exp(x) - 1 of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * exponential the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void expm1(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; function[0] = FastMath.expm1(operand[operandOffset]); Arrays.fill(function, 1, 1 + order, FastMath.exp(operand[operandOffset])); // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute natural logarithm of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * logarithm the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void log(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; function[0] = FastMath.log(operand[operandOffset]); if (order > 0) { double inv = 1.0 / operand[operandOffset]; double xk = inv; for (int i = 1; i <= order; ++i) { function[i] = xk; xk *= -i * inv; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Computes shifted logarithm of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * shifted logarithm the result array <em>cannot</em> be the input array) * @param resultOffset offset of the result in its array */ public void log1p(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; function[0] = FastMath.log1p(operand[operandOffset]); if (order > 0) { double inv = 1.0 / (1.0 + operand[operandOffset]); double xk = inv; for (int i = 1; i <= order; ++i) { function[i] = xk; xk *= -i * inv; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Computes base 10 logarithm of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * base 10 logarithm the result array <em>cannot</em> be the input array) * @param resultOffset offset of the result in its array */ public void log10(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; function[0] = FastMath.log10(operand[operandOffset]); if (order > 0) { double inv = 1.0 / operand[operandOffset]; double xk = inv / FastMath.log(10.0); for (int i = 1; i <= order; ++i) { function[i] = xk; xk *= -i * inv; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute cosine of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * cosine the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void cos(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; function[0] = FastMath.cos(operand[operandOffset]); if (order > 0) { function[1] = -FastMath.sin(operand[operandOffset]); for (int i = 2; i <= order; ++i) { function[i] = -function[i - 2]; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute sine of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * sine the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void sin(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; function[0] = FastMath.sin(operand[operandOffset]); if (order > 0) { function[1] = FastMath.cos(operand[operandOffset]); for (int i = 2; i <= order; ++i) { function[i] = -function[i - 2]; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute tangent of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void tan(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives final double[] function = new double[1 + order]; final double t = FastMath.tan(operand[operandOffset]); function[0] = t; if (order > 0) { // the nth order derivative of tan has the form: // dn(tan(x)/dxn = P_n(tan(x)) // where P_n(t) is a degree n+1 polynomial with same parity as n+1 // P_0(t) = t, P_1(t) = 1 + t^2, P_2(t) = 2 t (1 + t^2) ... // the general recurrence relation for P_n is: // P_n(x) = (1+t^2) P_(n-1)'(t) // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array final double[] p = new double[order + 2]; p[1] = 1; final double t2 = t * t; for (int n = 1; n <= order; ++n) { // update and evaluate polynomial P_n(t) double v = 0; p[n + 1] = n * p[n]; for (int k = n + 1; k >= 0; k -= 2) { v = v * t2 + p[k]; if (k > 2) { p[k - 2] = (k - 1) * p[k - 1] + (k - 3) * p[k - 3]; } else if (k == 2) { p[0] = p[1]; } } if ((n & 0x1) == 0) { v *= t; } function[n] = v; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute arc cosine of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * arc cosine the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void acos(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; final double x = operand[operandOffset]; function[0] = FastMath.acos(x); if (order > 0) { // the nth order derivative of acos has the form: // dn(acos(x)/dxn = P_n(x) / [1 - x^2]^((2n-1)/2) // where P_n(x) is a degree n-1 polynomial with same parity as n-1 // P_1(x) = -1, P_2(x) = -x, P_3(x) = -2x^2 - 1 ... // the general recurrence relation for P_n is: // P_n(x) = (1-x^2) P_(n-1)'(x) + (2n-3) x P_(n-1)(x) // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array final double[] p = new double[order]; p[0] = -1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = FastMath.sqrt(f); function[1] = coeff * p[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial P_n(x) double v = 0; p[n - 1] = (n - 1) * p[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + p[k]; if (k > 2) { p[k - 2] = (k - 1) * p[k - 1] + (2 * n - k) * p[k - 3]; } else if (k == 2) { p[0] = p[1]; } } if ((n & 0x1) == 0) { v *= x; } coeff *= f; function[n] = coeff * v; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute arc sine of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * arc sine the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void asin(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; final double x = operand[operandOffset]; function[0] = FastMath.asin(x); if (order > 0) { // the nth order derivative of asin has the form: // dn(asin(x)/dxn = P_n(x) / [1 - x^2]^((2n-1)/2) // where P_n(x) is a degree n-1 polynomial with same parity as n-1 // P_1(x) = 1, P_2(x) = x, P_3(x) = 2x^2 + 1 ... // the general recurrence relation for P_n is: // P_n(x) = (1-x^2) P_(n-1)'(x) + (2n-3) x P_(n-1)(x) // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array final double[] p = new double[order]; p[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = FastMath.sqrt(f); function[1] = coeff * p[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial P_n(x) double v = 0; p[n - 1] = (n - 1) * p[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + p[k]; if (k > 2) { p[k - 2] = (k - 1) * p[k - 1] + (2 * n - k) * p[k - 3]; } else if (k == 2) { p[0] = p[1]; } } if ((n & 0x1) == 0) { v *= x; } coeff *= f; function[n] = coeff * v; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute arc tangent of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * arc tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void atan(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; final double x = operand[operandOffset]; function[0] = FastMath.atan(x); if (order > 0) { // the nth order derivative of atan has the form: // dn(atan(x)/dxn = Q_n(x) / (1 + x^2)^n // where Q_n(x) is a degree n-1 polynomial with same parity as n-1 // Q_1(x) = 1, Q_2(x) = -2x, Q_3(x) = 6x^2 - 2 ... // the general recurrence relation for Q_n is: // Q_n(x) = (1+x^2) Q_(n-1)'(x) - 2(n-1) x Q_(n-1)(x) // as per polynomial parity, we can store coefficients of both Q_(n-1) and Q_n in the same array final double[] q = new double[order]; q[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 + x2); double coeff = f; function[1] = coeff * q[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial Q_n(x) double v = 0; q[n - 1] = -n * q[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + q[k]; if (k > 2) { q[k - 2] = (k - 1) * q[k - 1] + (k - 1 - 2 * n) * q[k - 3]; } else if (k == 2) { q[0] = q[1]; } } if ((n & 0x1) == 0) { v *= x; } coeff *= f; function[n] = coeff * v; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute two arguments arc tangent of a derivative structure. * @param y array holding the first operand * @param yOffset offset of the first operand in its array * @param x array holding the second operand * @param xOffset offset of the second operand in its array * @param result array where result must be stored (for * two arguments arc tangent the result array <em>cannot</em> * be the input array) * @param resultOffset offset of the result in its array */ public void atan2(final double[] y, final int yOffset, final double[] x, final int xOffset, final double[] result, final int resultOffset) { // compute r = sqrt(x^2+y^2) double[] tmp1 = new double[getSize()]; multiply(x, xOffset, x, xOffset, tmp1, 0); // x^2 double[] tmp2 = new double[getSize()]; multiply(y, yOffset, y, yOffset, tmp2, 0); // y^2 add(tmp1, 0, tmp2, 0, tmp2, 0); // x^2 + y^2 rootN(tmp2, 0, 2, tmp1, 0); // r = sqrt(x^2 + y^2) if (x[xOffset] >= 0) { // compute atan2(y, x) = 2 atan(y / (r + x)) add(tmp1, 0, x, xOffset, tmp2, 0); // r + x divide(y, yOffset, tmp2, 0, tmp1, 0); // y /(r + x) atan(tmp1, 0, tmp2, 0); // atan(y / (r + x)) for (int i = 0; i < tmp2.length; ++i) { result[resultOffset + i] = 2 * tmp2[i]; // 2 * atan(y / (r + x)) } } else { // compute atan2(y, x) = +/- pi - 2 atan(y / (r - x)) subtract(tmp1, 0, x, xOffset, tmp2, 0); // r - x divide(y, yOffset, tmp2, 0, tmp1, 0); // y /(r - x) atan(tmp1, 0, tmp2, 0); // atan(y / (r - x)) result[resultOffset] = ((tmp2[0] <= 0) ? -FastMath.PI : FastMath.PI) - 2 * tmp2[0]; // +/-pi - 2 * atan(y / (r - x)) for (int i = 1; i < tmp2.length; ++i) { result[resultOffset + i] = -2 * tmp2[i]; // +/-pi - 2 * atan(y / (r - x)) } } // fix value to take special cases (+0/+0, +0/-0, -0/+0, -0/-0, +/-infinity) correctly result[resultOffset] = FastMath.atan2(y[yOffset], x[xOffset]); } /** Compute hyperbolic cosine of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * hyperbolic cosine the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void cosh(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; function[0] = FastMath.cosh(operand[operandOffset]); if (order > 0) { function[1] = FastMath.sinh(operand[operandOffset]); for (int i = 2; i <= order; ++i) { function[i] = function[i - 2]; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute hyperbolic sine of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * hyperbolic sine the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void sinh(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; function[0] = FastMath.sinh(operand[operandOffset]); if (order > 0) { function[1] = FastMath.cosh(operand[operandOffset]); for (int i = 2; i <= order; ++i) { function[i] = function[i - 2]; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute hyperbolic tangent of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * hyperbolic tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void tanh(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives final double[] function = new double[1 + order]; final double t = FastMath.tanh(operand[operandOffset]); function[0] = t; if (order > 0) { // the nth order derivative of tanh has the form: // dn(tanh(x)/dxn = P_n(tanh(x)) // where P_n(t) is a degree n+1 polynomial with same parity as n+1 // P_0(t) = t, P_1(t) = 1 - t^2, P_2(t) = -2 t (1 - t^2) ... // the general recurrence relation for P_n is: // P_n(x) = (1-t^2) P_(n-1)'(t) // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array final double[] p = new double[order + 2]; p[1] = 1; final double t2 = t * t; for (int n = 1; n <= order; ++n) { // update and evaluate polynomial P_n(t) double v = 0; p[n + 1] = -n * p[n]; for (int k = n + 1; k >= 0; k -= 2) { v = v * t2 + p[k]; if (k > 2) { p[k - 2] = (k - 1) * p[k - 1] - (k - 3) * p[k - 3]; } else if (k == 2) { p[0] = p[1]; } } if ((n & 0x1) == 0) { v *= t; } function[n] = v; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute inverse hyperbolic cosine of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * inverse hyperbolic cosine the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void acosh(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; final double x = operand[operandOffset]; function[0] = FastMath.acosh(x); if (order > 0) { // the nth order derivative of acosh has the form: // dn(acosh(x)/dxn = P_n(x) / [x^2 - 1]^((2n-1)/2) // where P_n(x) is a degree n-1 polynomial with same parity as n-1 // P_1(x) = 1, P_2(x) = -x, P_3(x) = 2x^2 + 1 ... // the general recurrence relation for P_n is: // P_n(x) = (x^2-1) P_(n-1)'(x) - (2n-3) x P_(n-1)(x) // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array final double[] p = new double[order]; p[0] = 1; final double x2 = x * x; final double f = 1.0 / (x2 - 1); double coeff = FastMath.sqrt(f); function[1] = coeff * p[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial P_n(x) double v = 0; p[n - 1] = (1 - n) * p[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + p[k]; if (k > 2) { p[k - 2] = (1 - k) * p[k - 1] + (k - 2 * n) * p[k - 3]; } else if (k == 2) { p[0] = -p[1]; } } if ((n & 0x1) == 0) { v *= x; } coeff *= f; function[n] = coeff * v; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute inverse hyperbolic sine of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * inverse hyperbolic sine the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void asinh(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; final double x = operand[operandOffset]; function[0] = FastMath.asinh(x); if (order > 0) { // the nth order derivative of asinh has the form: // dn(asinh(x)/dxn = P_n(x) / [x^2 + 1]^((2n-1)/2) // where P_n(x) is a degree n-1 polynomial with same parity as n-1 // P_1(x) = 1, P_2(x) = -x, P_3(x) = 2x^2 - 1 ... // the general recurrence relation for P_n is: // P_n(x) = (x^2+1) P_(n-1)'(x) - (2n-3) x P_(n-1)(x) // as per polynomial parity, we can store coefficients of both P_(n-1) and P_n in the same array final double[] p = new double[order]; p[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 + x2); double coeff = FastMath.sqrt(f); function[1] = coeff * p[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial P_n(x) double v = 0; p[n - 1] = (1 - n) * p[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + p[k]; if (k > 2) { p[k - 2] = (k - 1) * p[k - 1] + (k - 2 * n) * p[k - 3]; } else if (k == 2) { p[0] = p[1]; } } if ((n & 0x1) == 0) { v *= x; } coeff *= f; function[n] = coeff * v; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute inverse hyperbolic tangent of a derivative structure. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param result array where result must be stored (for * inverse hyperbolic tangent the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void atanh(final double[] operand, final int operandOffset, final double[] result, final int resultOffset) { // create the function value and derivatives double[] function = new double[1 + order]; final double x = operand[operandOffset]; function[0] = FastMath.atanh(x); if (order > 0) { // the nth order derivative of atanh has the form: // dn(atanh(x)/dxn = Q_n(x) / (1 - x^2)^n // where Q_n(x) is a degree n-1 polynomial with same parity as n-1 // Q_1(x) = 1, Q_2(x) = 2x, Q_3(x) = 6x^2 + 2 ... // the general recurrence relation for Q_n is: // Q_n(x) = (1-x^2) Q_(n-1)'(x) + 2(n-1) x Q_(n-1)(x) // as per polynomial parity, we can store coefficients of both Q_(n-1) and Q_n in the same array final double[] q = new double[order]; q[0] = 1; final double x2 = x * x; final double f = 1.0 / (1 - x2); double coeff = f; function[1] = coeff * q[0]; for (int n = 2; n <= order; ++n) { // update and evaluate polynomial Q_n(x) double v = 0; q[n - 1] = n * q[n - 2]; for (int k = n - 1; k >= 0; k -= 2) { v = v * x2 + q[k]; if (k > 2) { q[k - 2] = (k - 1) * q[k - 1] + (2 * n - k + 1) * q[k - 3]; } else if (k == 2) { q[0] = q[1]; } } if ((n & 0x1) == 0) { v *= x; } coeff *= f; function[n] = coeff * v; } } // apply function composition compose(operand, operandOffset, function, result, resultOffset); } /** Compute composition of a derivative structure by a function. * @param operand array holding the operand * @param operandOffset offset of the operand in its array * @param f array of value and derivatives of the function at * the current point (i.e. at {@code operand[operandOffset]}). * @param result array where result must be stored (for * composition the result array <em>cannot</em> be the input * array) * @param resultOffset offset of the result in its array */ public void compose(final double[] operand, final int operandOffset, final double[] f, final double[] result, final int resultOffset) { for (int i = 0; i < compIndirection.length; ++i) { final int[][] mappingI = compIndirection[i]; double r = 0; for (int j = 0; j < mappingI.length; ++j) { final int[] mappingIJ = mappingI[j]; double product = mappingIJ[0] * f[mappingIJ[1]]; for (int k = 2; k < mappingIJ.length; ++k) { product *= operand[operandOffset + mappingIJ[k]]; } r += product; } result[resultOffset + i] = r; } } /** Evaluate Taylor expansion of a derivative structure. * @param ds array holding the derivative structure * @param dsOffset offset of the derivative structure in its array * @param delta parameters offsets (&Delta;x, &Delta;y, ...) * @return value of the Taylor expansion at x + &Delta;x, y + &Delta;y, ... * @throws MathArithmeticException if factorials becomes too large */ public double taylor(final double[] ds, final int dsOffset, final double ... delta) throws MathArithmeticException { double value = 0; for (int i = getSize() - 1; i >= 0; --i) { final int[] orders = getPartialDerivativeOrders(i); double term = ds[dsOffset + i]; for (int k = 0; k < orders.length; ++k) { if (orders[k] > 0) { try { term *= FastMath.pow(delta[k], orders[k]) / CombinatoricsUtils.factorial(orders[k]); } catch (NotPositiveException e) { // this cannot happen throw new MathInternalError(e); } } } value += term; } return value; } /** Check rules set compatibility. * @param compiler other compiler to check against instance * @exception DimensionMismatchException if number of free parameters or orders are inconsistent */ public void checkCompatibility(final DSCompiler compiler) throws DimensionMismatchException { if (parameters != compiler.parameters) { throw new DimensionMismatchException(parameters, compiler.parameters); } if (order != compiler.order) { throw new DimensionMismatchException(order, compiler.order); } } }
[ "giachi.iada@gmail.com" ]
giachi.iada@gmail.com
a25421a6e7d153e1cb8b849291366ae56f979a6b
a56254b8f0cd87eefc6bb18fa66da7c11e75447b
/src/test/java/com/web/Blog/controller/HelloControllerTest.java
de3f454385f6e8adddf2cea8ef951676a5ad9756
[]
no_license
Lyh97/blog
7e37a2d9ec5f288b73512db8b1f6d24d501075df
f900af509cec0ef198df61889502a0b556038d14
refs/heads/master
2020-04-14T16:05:18.738312
2019-01-03T08:19:15
2019-01-03T08:19:15
163,943,289
0
0
null
null
null
null
UTF-8
Java
false
false
1,133
java
package com.web.Blog.controller; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import static org.hamcrest.Matchers.equalTo; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc public class HelloControllerTest { @Autowired private MockMvc mockMvc; @Test public void testHello() throws Exception { mockMvc.perform(MockMvcRequestBuilders.get("/hello").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().string(equalTo("Hello world!"))); } }
[ "18524637652@163.com" ]
18524637652@163.com
1e17f56fc607061c7138d8c55952ab1250af5f7f
5fa90bfe3eae44c61dd38449a6105d8da1133ef5
/app/src/main/java/com/example/haipingguo/rxjavademo/test8/CatsHelper.java
1b49cd02898ff1349c172a92dee18393d3380b6a
[]
no_license
guohaiping521/RxJavaDemo
c5a779f090e1630d9f2a750f4184a7fc46d8d938
6298ce266e174e73ec2528b35cc25bc925a4039a
refs/heads/master
2020-04-05T02:24:18.793890
2019-04-26T08:55:43
2019-04-26T08:55:43
156,475,725
0
0
null
null
null
null
UTF-8
Java
false
false
3,393
java
package com.example.haipingguo.rxjavademo.test8; import android.net.Uri; import java.util.ArrayList; import java.util.Collections; import java.util.List; import com.example.haipingguo.rxjavademo.test8.Function; /* import java.util.ArrayList; import io.reactivex.Observable; import io.reactivex.ObservableEmitter; import io.reactivex.ObservableOnSubscribe; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; import io.reactivex.functions.Function;*/ public class CatsHelper { Api mApi = new Api(); public void saveCutestCat(final String query) { new Observable<List<Cat>>() { @Override public void subscribe(Callback<List<Cat>> callback) { List<Cat> catList=new ArrayList<>(); catList.add(new Cat(0)); catList.add(new Cat(1)); catList.add(new Cat(2)); callback.onResult(catList); } }.subscribe(new Callback<List<Cat>>() { @Override public void onResult(List<Cat> result) { } @Override public void onError(Exception e) { } }); /*mApi.queryCats(query).subscribe(new Callback<List<Cat>>() { @Override public void onResult(List<Cat> result) { } @Override public void onError(Exception e) { } });*/ mApi.queryCats(query).map(new Function<List<Cat>, Cat>() { @Override public Cat apply(List<Cat> catList) { return findCutest(catList); } }).flatMap(new Function<Cat, com.example.haipingguo.rxjavademo.test8.Observable<Uri>>() { @Override public com.example.haipingguo.rxjavademo.test8.Observable<Uri> apply(Cat cat) { return mApi.store(cat); } }).subscribe(new Callback<Uri>() { @Override public void onResult(Uri result) { } @Override public void onError(Exception e) { } }); } private void guanfangRxjavaCat(){ /* Observable.create(new ObservableOnSubscribe() { @Override public void subscribe(ObservableEmitter e) throws Exception { List<Cat> catList=new ArrayList<>(); catList.add(new Cat(0)); catList.add(new Cat(1)); catList.add(new Cat(2)); e.onNext(catList); } }).map(new Function<List<Cat>, Cat>() { @Override public Cat apply(List<Cat> cats) { return findCutest(cats); } }).flatMap(new Function<Cat, Uri>() { @Override public Uri apply(Cat cat) throws Exception { return Uri.parse("被保存的url"); } }).subscribe(new Observer<Uri>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(Uri o) { } @Override public void onError(Throwable e) { } @Override public void onComplete() { } });*/ } private Cat findCutest(List<Cat> cats) { return Collections.max(cats); } }
[ "guohaiping@zuoyebang.com" ]
guohaiping@zuoyebang.com
6dbef313a88e63249d295accfa394fd201d1e442
82b3237fb7dc5abaf282242477a0bb15ba36975e
/src/main/java/org/drip/param/period/CompositePeriodSetting.java
21c4764e9d76c14a91d5553a5a1cb34e8ad16514
[ "Apache-2.0" ]
permissive
chengjon/DROP
6d7cbf5fa066d33203e4d9a7dc0c90c9eea1f246
0909c1da1297cc1baac6ea135946afe5b214e47a
refs/heads/master
2023-03-15T07:53:34.940497
2021-03-02T04:36:42
2021-03-02T04:36:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
7,945
java
package org.drip.param.period; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! * Copyright (C) 2020 Lakshmi Krishnamurthy * Copyright (C) 2019 Lakshmi Krishnamurthy * Copyright (C) 2018 Lakshmi Krishnamurthy * Copyright (C) 2017 Lakshmi Krishnamurthy * Copyright (C) 2016 Lakshmi Krishnamurthy * Copyright (C) 2015 Lakshmi Krishnamurthy * Copyright (C) 2014 Lakshmi Krishnamurthy * * This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics, * asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment * analytics, and portfolio construction analytics within and across fixed income, credit, commodity, * equity, FX, and structured products. It also includes auxiliary libraries for algorithm support, * numerical analysis, numerical optimization, spline builder, model validation, statistical learning, * and computational support. * * https://lakshmidrip.github.io/DROP/ * * DROP is composed of three modules: * * - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/ * - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/ * - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/ * * DROP Product Core implements libraries for the following: * - Fixed Income Analytics * - Loan Analytics * - Transaction Cost Analytics * * DROP Portfolio Core implements libraries for the following: * - Asset Allocation Analytics * - Asset Liability Management Analytics * - Capital Estimation Analytics * - Exposure Analytics * - Margin Analytics * - XVA Analytics * * DROP Computational Core implements libraries for the following: * - Algorithm Support * - Computation Support * - Function Analysis * - Model Validation * - Numerical Analysis * - Numerical Optimizer * - Spline Builder * - Statistical Learning * * Documentation for DROP is Spread Over: * * - Main => https://lakshmidrip.github.io/DROP/ * - Wiki => https://github.com/lakshmiDRIP/DROP/wiki * - GitHub => https://github.com/lakshmiDRIP/DROP * - Repo Layout Taxonomy => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md * - Javadoc => https://lakshmidrip.github.io/DROP/Javadoc/index.html * - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal * - Release Versions => https://lakshmidrip.github.io/DROP/version.html * - Community Credits => https://lakshmidrip.github.io/DROP/credits.html * - Issues Catalog => https://github.com/lakshmiDRIP/DROP/issues * - JUnit => https://lakshmidrip.github.io/DROP/junit/index.html * - Jacoco => https://lakshmidrip.github.io/DROP/jacoco/index.html * * 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. */ /** * <i>CompositePeriodSetting</i> implements the custom setting parameters for the composite coupon period. * * <br><br> * <ul> * <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li> * <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li> * <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/param/README.md">Product Cash Flow, Valuation, Market, Pricing, and Quoting Parameters</a></li> * <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/param/period">Composite Composable Period Builder Settings</a></li> * </ul> * * @author Lakshmi Krishnamurthy */ public class CompositePeriodSetting { private int _iFreq = -1; private java.lang.String _strTenor = ""; private java.lang.String _strPayCurrency = ""; private double _dblBaseNotional = java.lang.Double.NaN; private org.drip.numerical.common.Array2D _fsCoupon = null; private org.drip.numerical.common.Array2D _fsNotional = null; private org.drip.state.identifier.EntityCDSLabel _creditLabel = null; private org.drip.param.period.FixingSetting _fxFixingSetting = null; private org.drip.analytics.daycount.DateAdjustParams _dapPay = null; /** * CompositePeriodSetting Constructor * * @param iFreq The Frequency * @param strTenor The Period Tenor * @param strPayCurrency The Pay Currency * @param dapPay Composite Pay Date Adjust Parameters * @param dblBaseNotional The Period Base Notional * @param fsCoupon The Period Coupon Schedule * @param fsNotional The Period Notional Schedule * @param fxFixingSetting The FX Fixing Setting * @param creditLabel The Period Credit Label * * @throws java.lang.Exception Thrown if Inputs are invalid */ public CompositePeriodSetting ( final int iFreq, final java.lang.String strTenor, final java.lang.String strPayCurrency, final org.drip.analytics.daycount.DateAdjustParams dapPay, final double dblBaseNotional, final org.drip.numerical.common.Array2D fsCoupon, final org.drip.numerical.common.Array2D fsNotional, final org.drip.param.period.FixingSetting fxFixingSetting, final org.drip.state.identifier.EntityCDSLabel creditLabel) throws java.lang.Exception { if (0 >= (_iFreq = iFreq) || null == (_strTenor = strTenor) || _strTenor.isEmpty() || null == (_strPayCurrency = strPayCurrency) || _strPayCurrency.isEmpty() || !org.drip.numerical.common.NumberUtil.IsValid (_dblBaseNotional = dblBaseNotional)) throw new java.lang.Exception ("CompositePeriodSetting ctr: Invalid Inputs"); _dapPay = dapPay; _creditLabel = creditLabel; _fxFixingSetting = fxFixingSetting; if (null == (_fsCoupon = fsCoupon)) _fsCoupon = org.drip.numerical.common.Array2D.BulletSchedule(); if (null == (_fsNotional = fsNotional)) _fsNotional = org.drip.numerical.common.Array2D.BulletSchedule(); } /** * Retrieve the Frequency * * @return The Frequency */ public int freq() { return _iFreq; } /** * Retrieve the Tenor * * @return The Tenor */ public java.lang.String tenor() { return _strTenor; } /** * Retrieve the Pay Currency * * @return The Pay Currency */ public java.lang.String payCurrency() { return _strPayCurrency; } /** * Retrieve the Pay DAP * * @return The Pay DAP */ public org.drip.analytics.daycount.DateAdjustParams dapPay() { return _dapPay; } /** * Retrieve the Base Notional * * @return The Base Notional */ public double baseNotional() { return _dblBaseNotional; } /** * Retrieve the Notional Schedule * * @return The Notional Schedule */ public org.drip.numerical.common.Array2D notionalSchedule() { return _fsNotional; } /** * Retrieve the Coupon Schedule * * @return The Coupon Schedule */ public org.drip.numerical.common.Array2D couponSchedule() { return _fsCoupon; } /** * Retrieve the FX Fixing Setting * * @return The FX Fixing Setting */ public org.drip.param.period.FixingSetting fxFixingSetting() { return _fxFixingSetting; } /** * Retrieve the Credit Label * * @return The Credit Label */ public org.drip.state.identifier.EntityCDSLabel creditLabel() { return _creditLabel; } }
[ "lakshmimv7977@gmail.com" ]
lakshmimv7977@gmail.com
96b0fcf2fb60b1ed3e03f27e4b72ec85b1fd6a56
ec2c8ca86112d93095695e7c7cb5df288e4ef31c
/Gameoflife/src/Shell.java
8a9502ea423b3e5bb47998d2b98dad8e57c686be
[]
no_license
Junxi917/Juncode
80d448705bbdc8a7e297b933e0c6eb5a901e8684
244fda6760483aa4f60afaf65f7826bc3c9d0cfc
refs/heads/master
2020-06-07T23:34:02.517925
2019-06-21T16:37:28
2019-06-21T16:37:28
193,115,687
0
0
null
null
null
null
UTF-8
Java
false
false
3,717
java
import java.io.BufferedReader; import java.io.InputStreamReader; import model.Game; import model.Grid; import model.ShapeCollection; public final class Shell { private Shell() { } /** * . compute the game with user. * * @param args array * @throws Exception the fault of the programm */ public static void main(String[] args) throws Exception { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in, "UTF-8")); execute(stdin); } private static void execute(BufferedReader stdin) throws Exception { boolean quit = false; int zahl = 0; Grid t = new Game(); String[] b = null; while (!quit) { System.out.print("gol> "); String input = null; //String input = stdin.readLine(); try { input = stdin.readLine(); } catch (NullPointerException e) { // throw exception } if (input != null) { b = input.trim().split("\\s+"); } else { quit = true; } String[] tokens = b; if (tokens[0].equals("QUIT") || tokens[0].equals("quit")) { quit = true; } else if (tokens[0].equals("HELP")) { System.out.println("NEW x y:beginn a new game"); System.out.println("ALIVE i j:set the position i j live"); System.out.println("DEAD i j:set the position i j die"); System.out.println("GENERATE:compute the next generation in the game"); System.out.println("PRINT:output the game"); System.out.println("CLEAR:set all the live cell die"); System.out.println("RESIZE x y:resize the game"); System.out.println("SHAPE s:output the shape"); System.out.println("QUIT :end the game"); } else if (tokens[0].equals("NEW") || tokens[0].equals("new")) { if (Integer.parseInt(tokens[1]) < 0 || Integer.parseInt(tokens[2]) < 0) { System.out.println("Error! Diese Nummer ist negativ."); } else { Grid a = new Game(Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2])); t = a; zahl = zahl + 1; } } else if (tokens[0].equals("ALIVE") || tokens[0].equals("alive")) { if (tokens.length != 3) { System.out.println("Error! Diese Eingabe ist zu kurz."); } else if (t.getColumns() == 0 || t.getRows() == 0 || Integer.parseInt(tokens[1]) < 0 || Integer.parseInt(tokens[2]) < 0 || Integer.parseInt(tokens[1]) > t.getColumns() - 1 || Integer.parseInt(tokens[2]) > t.getRows() - 1) { System.out.println("Error! Noch kein Spielfeld vorhanden."); } else { t.setAlive(Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]), true); } } else if (tokens[0].equals("DEAD") || tokens[0].equals("dead")) { t.setAlive(Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2]), false); } else if (tokens[0].equals("GENERATE") || tokens[0].equals("generate")) { t.next(); System.out.println("Generation:" + " " + t.getGenerations()); } else if (tokens[0].equals("PRINT") || tokens[0].equals("print")) { if (zahl == 0) { System.out.println("Error! Noch kein Spielfeld vorhanden."); } else { System.out.println(t.toString()); } } else if (tokens[0].equals("CLEAR") || tokens[0].equals("clear")) { t.clear(); } else if (tokens[0].equals("RESIZE") || tokens[0].equals("resize")) { t.resize(Integer.parseInt(tokens[1]), Integer.parseInt(tokens[2])); } else if (tokens[0].equals("SHAPE") || tokens[0].equals("shape")) { t.clear(); ((Game) t).shapeCompute(ShapeCollection.getShapeByName(tokens[1])); } } } }
[ "kejunxi1996@outlook.com" ]
kejunxi1996@outlook.com
c9881359e9302df53a15d424b3f7ad0d5f31c6b0
97afb69a47020edcc47f070835673d2ca179e378
/target/java/org/apache/spark/network/nio/ConnectionManagerId$.java
6c353b5e3f4a22c3c8d7f4cae810c4cd8d7942ba
[]
no_license
tsecret56/spark-core
2aba1d880b683806b259ab851e9f5aa25ada2d87
3967acd9b72980c3d653b1b10fe5fac555829076
refs/heads/master
2021-01-02T09:14:13.709963
2015-08-17T04:42:32
2015-08-17T04:42:32
null
0
0
null
null
null
null
UTF-8
Java
false
false
480
java
package org.apache.spark.network.nio; // no position class ConnectionManagerId$ implements scala.Serializable { /** * Static reference to the singleton instance of this Scala object. */ public static final ConnectionManagerId$ MODULE$ = null; public ConnectionManagerId$ () { throw new RuntimeException(); } public org.apache.spark.network.nio.ConnectionManagerId fromSocketAddress (java.net.InetSocketAddress socketAddress) { throw new RuntimeException(); } }
[ "nyx_m@naver.com" ]
nyx_m@naver.com
d134407492b8576ed7c6f8ae229efd77eed607d7
e05a04dbff4b48d634219099994ce1940fa75a3a
/CuentaTest/ar/edu/unlam/pb2/Cuenta/CuentaTest.java
0e427ca93b6c63d78bad01063040aeab171c7e10
[]
no_license
PerlaMoly/TP2Cuenta
edab2d0d4f3896b1c3aa338171ceedac182e6d71
996456e11a3a77099376c8be5b9c3611f0cde1be
refs/heads/master
2020-05-23T09:33:45.554069
2019-05-15T00:52:41
2019-05-15T00:52:41
186,708,470
0
1
null
2019-05-15T00:52:42
2019-05-14T22:17:49
Java
UTF-8
Java
false
false
200
java
package ar.edu.unlam.pb2.Cuenta; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; class CuentaTest { @Test void test() { fail("Not yet implemented"); } }
[ "pengate@gmail.com" ]
pengate@gmail.com
f0a753a8b07235067efa7343534c8524d8a62b23
1ca656fca1f24e6530acadc16b91189570dbb694
/leetcode/d/Trapping Rain Water.java
d739896d6abfa05ce846dad71ed799cbfcfd25b5
[]
no_license
erliding/deldel
0d5e65949f4dc93d330d91f0c8c7e690cf32b6cd
5837f6ffeae9e4ce4bc67d7fd11f87c85b6c054b
refs/heads/master
2020-03-26T20:41:27.283271
2018-06-12T22:09:27
2018-06-12T22:09:27
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,605
java
/** * Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. * <p> * For example, * Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. **/ // very similar to largest rectangular area, the difference is that no need to consider if stack is not empty after one pass through the data // because heights left in stack are in decreasing order, can not hold water public class Solution { public int trap(int[] height) { Stack<Integer> st = new Stack<>(); int water = 0; for (int i = 0; i < height.length; ) { if (st.isEmpty() || height[st.peek()] >= height[i]) { st.push(i++); } else { int bottom = height[st.pop()]; while (!st.isEmpty() && height[st.peek()] == bottom) st.pop(); int h = st.isEmpty() ? bottom : Math.min(height[i], height[st.peek()]); int left = st.isEmpty() ? 0 : st.peek() + 1; water += (i - left) * (h - bottom); } } return water; } } // another solution can be generalized to 2D version public class Solution { public int trap(int[] height) { int l = 0; int r = height.length - 1; int vol = 0; while (l < r - 1) { if (height[l] <= height[r]) { if (height[l] > height[l + 1]) { vol += height[l] - height[l + 1]; height[l + 1] = height[l]; } l++; } else { if (height[r - 1] < height[r]) { vol += height[r] - height[r- 1]; height[r-1] = height[r]; } r--; } } return vol; } }
[ "erliding@gmail.com" ]
erliding@gmail.com
2792ab13078d1dbf4ebd324b96965cd0f9f7328c
ba25588443e259490e12d25658391cf779d95384
/pattern_searching_usingKMP_algorithm.java
235aae619566ca92177040b12027ae9252321eb5
[]
no_license
gowshikk/string-programs
b71e25a6fea88702cbba6ab813a0534aeda1d772
5a8ca585569b34bd1900039b8200d4057d40dcc5
refs/heads/master
2020-06-10T17:56:10.469800
2019-07-12T14:27:05
2019-07-12T14:27:05
193,699,041
0
0
null
null
null
null
UTF-8
Java
false
false
3,409
java
import java.io.*; class GOWSHIK { void matching_string(String pattern,String text) { int pattern_length=pattern.length(); int text_length= text.length(); // constructing longest prefix suffix int longest_prefix_suffix[]=new int[pattern_length]; compute_longest_prefix_suffix(pattern,longest_prefix_suffix,pattern_length); //after construction longest_prefix_suffix start matching comparison to text int text_index=0, pattern_index=0; int count=0; while(text_index < text_length) { if(text.charAt(text_index) == pattern.charAt(pattern_index)) //if Character at index matches then increment text_index and pattern_index { text_index++; pattern_index++; } if(pattern_index == pattern_length) // this checking gives pattern found as the result { System.out.println("Found at the index---"+(text_index-pattern_index)); count++; pattern_index=longest_prefix_suffix[pattern_index-1]; // this makes the move to next prefix of pattern available } else if(text_index < text_length && text.charAt(text_index)!=pattern.charAt(pattern_index)) { if(pattern_index!=0) { pattern_index = longest_prefix_suffix[pattern_index-1]; // perform this for searching any other pattern index matches with text using longest_prefix_suffix computation } else { text_index++; // increment text index because pattern is not found } } } System.out.println(count); } void compute_longest_prefix_suffix(String pattern,int longest_prefix_suffix[],int pattern_length) { //intialise for 1st Index int len=0,index=1; longest_prefix_suffix[0]=0; //calculating for remaining Characters while(index<pattern_length) { if(pattern.charAt(len)==pattern.charAt(index)) { len++; longest_prefix_suffix[index]=len; index++; } else{ //if len is not 0 if(len!=0) { len=longest_prefix_suffix[len-1]; } else //if len found as 0 then longest_prefix_suffix at that index is also zero { longest_prefix_suffix[index]=0; index++; } } } } public static void main (String[] args) { String text="Writers write descriptive paragraphs because their purpose is to describe something. Their point is that something is beautiful or disgusting or strangely intriguing. Writers write persuasive and argument paragraphs because their purpose is to persuade or convince someone. Their point is that their reader should see things a particular way and possibly take action on that new way of seeing things. Writers write paragraphs of comparison because the comparison will make their point clear to their readers."; String pattern="is"; new GOWSHIK().matching_string(pattern,text); } }
[ "noreply@github.com" ]
gowshikk.noreply@github.com
4b6ba9885352974957bf63be0c945c9f1fe7f131
7c87899e76d41542284e258a5e5b0ea8a7a336e7
/src/main/java/com/tree/www/net/server1/Server.java
45becc596053ec231c322bfd60b37d5dfd24301a
[]
no_license
pengyongshan/study
42ec5bc4417b6be7384ec137b3d10a30bc060e6b
52cf8081fa57e42d9cdb567c0e97924eb537dc87
refs/heads/master
2022-12-23T13:09:00.177350
2022-03-15T07:20:49
2022-03-15T07:20:49
91,772,670
1
0
null
2022-12-16T05:37:50
2017-05-19T06:22:59
Java
UTF-8
Java
false
false
694
java
package com.tree.www.net.server1; import java.io.IOException; import java.io.PrintStream; import java.net.ServerSocket; import java.net.Socket; public class Server { private static final int SERVER_PORT = 30000; public static CrazyMap<String, PrintStream> clients = new CrazyMap<>(); public void init() { try { ServerSocket ss = new ServerSocket(SERVER_PORT); while (true) { Socket socket = ss.accept(); new ServerThread(socket).start(); } } catch (IOException ex) { System.out.println("服务器启动失败,是否端口" + SERVER_PORT + "被占用"); } } public static void main(String[] args) { new Server().init(); } }
[ "pengyongshan@treefinance.com.cn" ]
pengyongshan@treefinance.com.cn
a8314ca3c99d08213ea75e698a6752aa82e9390d
affabd12da6cf9188d1b1135b95a408a58cf139c
/tmp/src/org/celllife/idart/misc/FloatValidator.java
6d9358244f6595cf11132e46afd78d8480046cbf
[]
no_license
iCAPandMSF/iDART-Reprogramming
60a73ea69e2aace752152c1f4d8fdc3b547b1119
c686138a3ae07898798f5539833fd3fe40a05fc4
refs/heads/master
2020-04-09T07:51:55.760481
2015-11-12T23:41:51
2015-11-12T23:41:51
25,474,005
1
2
null
null
null
null
UTF-8
Java
false
false
2,883
java
/** * {iDart - Pharmacy dispensing tool for cronic diseases} * Copyright (C) 2006 Cell-Life * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License version * 2 for more details. * * You should have received a copy of the GNU General Public License version 2 * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA **/ package org.celllife.idart.misc; /** * Created on 10/05/2007 * * Class that checks if text is valid integer. I write this class because the * methods in this class should be used more often to validate user input in the * gui's. For example if the user is expected to give the Quantity of pills * counted, you would only want integer inputs. * */ public class FloatValidator { /** * Default Constructor */ public FloatValidator() { super(); } /** * method to check if String is an integer * * @param theString * the String to check * @return true if the String is an integer else false */ public static boolean isFloat(String theString) { try { // First check if String contains no characters if (theString.length() == 0) return false; // First check for negative number if (theString.charAt(0) == '-') { // First character is a minus sign, we check if the String // contains any more characters. if (theString.length() == 1) return false; // if this statement is executed, it either results in an // exception or the String is parsed to an int Double.parseDouble(theString.substring(1)); } // First character is not a minus sign, so we try to parse it else { Double.parseDouble(theString); } } catch (NumberFormatException nfe) { return false; } return true; } /** * method to check if String is a +ve integer * * @param theString * the String to check * @return true if the String is a +ve integer else false */ public static boolean isPositiveFloat(String theString) { try { if (!isFloat(theString)) return false; else { if ("-".equalsIgnoreCase(theString.substring(0, 1))) return false; else return true; } } catch (NumberFormatException nfe) { return false; } } /** * method to check if String is a -ve integer * * @return true if the String is a -ve integer else false */ public static boolean isNegativeFloat() { try { } catch (NumberFormatException nfe) { return false; } return true; } }
[ "mdfsaraiva@gmail.com" ]
mdfsaraiva@gmail.com
72e0b8619f425798389711c08c70cba176eeab23
4120e073a4b0b2c79870e3ab87b294f98f47d0be
/ride-dispatch/src/test/java/com/rideaustin/dispatch/guards/DispatchNotAcceptedGuardTest.java
265b3ae1581fc6ebd913e6292e05ca957fb78c5b
[ "MIT" ]
permissive
jyt109/server
8933281097303d14b5a329f0c679edea4fcd174b
24354717624c25b5d4faf0b7ea540e2742e8039f
refs/heads/master
2022-03-20T10:36:44.973843
2019-10-03T11:43:07
2019-10-03T11:43:07
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,911
java
package com.rideaustin.dispatch.guards; import static org.junit.Assert.*; import static org.mockito.Mockito.when; import java.util.Collections; import java.util.EnumSet; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.springframework.statemachine.StateMachinePersist; import org.springframework.statemachine.support.DefaultStateMachineContext; import com.rideaustin.StubStateContext.StubExtendedState; import com.rideaustin.application.cache.impl.JedisClient; import com.rideaustin.dispatch.actions.PersistingContextSupport; import com.rideaustin.service.config.RideAcceptanceConfig; import com.rideaustin.service.model.Events; import com.rideaustin.service.model.States; import com.rideaustin.utils.dispatch.StateMachineUtils; import com.tngtech.java.junit.dataprovider.DataProvider; import com.tngtech.java.junit.dataprovider.DataProviderRunner; import com.tngtech.java.junit.dataprovider.UseDataProvider; @RunWith(DataProviderRunner.class) public class DispatchNotAcceptedGuardTest extends PersistingContextSupport { private static final Long RIDE_ID = 1L; @Mock private StateMachinePersist<States, Events, String> access; @Mock private JedisClient jedisClient; @Mock private RideAcceptanceConfig acceptanceConfig; @InjectMocks private DispatchNotAcceptedGuard testedInstance; @DataProvider public static Object[] ineligibleStates() { return EnumSet.complementOf(EnumSet.of(States.DISPATCH_PENDING, States.REQUESTED)).toArray(); } @Before public void setUp() throws Exception { super.setUp(); testedInstance = new DispatchNotAcceptedGuard(); MockitoAnnotations.initMocks(this); context.setSource(States.DISPATCH_PENDING); context.setTarget(States.REQUESTED); requestContext.setRideId(RIDE_ID); StateMachineUtils.updateRequestContext(context, requestContext, persister, environment); } @Test public void testEvaluateFalseWhenRideIsNotFound() { String machineId = StateMachineUtils.getMachineId(environment, RIDE_ID); when(jedisClient.exists(machineId)).thenReturn(false); boolean result = testedInstance.evaluate(context); assertFalse(result); } @Test public void testEvaluateFalseWhenPersistedContextNotFound() throws Exception { String machineId = StateMachineUtils.getMachineId(environment, RIDE_ID); when(jedisClient.exists(machineId)).thenReturn(true); when(access.read(machineId)).thenReturn(null); boolean result = testedInstance.evaluate(context); assertFalse(result); } @Test @UseDataProvider("ineligibleStates") public void testEvaluateFalseWhenWrongState(States state) throws Exception { String machineId = StateMachineUtils.getMachineId(environment, RIDE_ID); when(jedisClient.exists(machineId)).thenReturn(true); DefaultStateMachineContext<States, Events> stateMachineContext = new DefaultStateMachineContext<>(state, null, Collections.emptyMap(), new StubExtendedState()); when(access.read(machineId)).thenReturn(stateMachineContext); boolean result = testedInstance.evaluate(context); assertFalse(result); } @Test public void testEvaluateFalseWhenAccepted() throws Exception { String machineId = StateMachineUtils.getMachineId(environment, RIDE_ID); when(jedisClient.exists(machineId)).thenReturn(true); DefaultStateMachineContext<States, Events> stateMachineContext = new DefaultStateMachineContext<>(States.DISPATCH_PENDING, null, Collections.emptyMap(), new StubExtendedState()); dispatchContext.setAccepted(true); stateMachineContext.getExtendedState().getVariables().put("dispatchContext", dispatchContext); when(access.read(machineId)).thenReturn(stateMachineContext); boolean result = testedInstance.evaluate(context); assertFalse(result); } }
[ "mikhail.chugunov@crossover.com" ]
mikhail.chugunov@crossover.com
03f6cc9a1cd696f4092c2b02d952c7c605dbf7d0
1dd61327f204ec1478ddcc3ccae9114198fb1694
/VS2010/EIAS/EIAS.Android2.0/Code/src/com/yunfang/eias/logic/DatadefinesOperator.java
5422b1cca2d34375c03d35440be286610239a08f
[]
no_license
hui453694187/test
324ed42d69b01834e87109301f9ee864deff2f18
4996f98e4d3456a3b9bd41d1658403679387c056
refs/heads/master
2020-06-03T20:59:41.777593
2015-10-10T10:06:42
2015-10-10T10:06:42
41,663,063
0
0
null
null
null
null
UTF-8
Java
false
false
1,947
java
/** * */ package com.yunfang.eias.logic; import java.util.ArrayList; import java.util.List; import com.yunfang.eias.base.EIASApplication; import com.yunfang.eias.http.task.GetDatadefinesTask; import com.yunfang.eias.model.DataDefine; import com.yunfang.eias.tables.DataDefineWorker; import com.yunfang.framework.model.ResultInfo; import com.yunfang.framework.model.UserInfo; /** * 勘察配置信息数据操作 * @author kevin * */ public class DatadefinesOperator { /*** * 获取最新的勘察配置表信息 * @param userInfo * @return 勘察信息表 */ public static ResultInfo<ArrayList<DataDefine>> getNewestDatadefine(UserInfo userInfo){ ResultInfo<ArrayList<DataDefine>> result=new ResultInfo<ArrayList<DataDefine>>(); try{ if(!EIASApplication.IsOffline){ GetDatadefinesTask getDatadefinesTask=new GetDatadefinesTask(); result=getDatadefinesTask.request(userInfo); ArrayList<DataDefine> motroDefines=(ArrayList<DataDefine>)result.Data; List<String> ddidList=new ArrayList<String>(); //获取本地数据库 勘察表数据 ResultInfo<ArrayList<DataDefine>> localDefines=DataDefineWorker.queryDataDefineByCompanyID(userInfo.CompanyID); for(DataDefine localDefine:localDefines.Data){// 对比本地勘察表, 和远程勘察表 boolean isExist=false; for(DataDefine motroDefine:motroDefines){ if(motroDefine.ID==localDefine.DDID){// 本地的DDID 对应远程服务器的 define 的ID isExist=true; break; } } if(!isExist){// 远程服务器不存这张勘察表 ddidList.add(String.valueOf(localDefine.DDID)); } } if(ddidList.size()>0){// 删除远程不存在的 勘察表 DataDefineWorker.deletDataDefneByDDID(ddidList); } } }catch(Exception e){ result.Success = false; result.Message = result.Message.length() > 0 ? result.Message : e.getMessage(); } return result; } }
[ "hui453694187@163.com" ]
hui453694187@163.com