blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
131 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
32 values
content
stringlengths
3
9.45M
authors
sequencelengths
1
1
author_id
stringlengths
0
313
6e866f77245cac677a010080ba9b3d22074f8d73
acdf45dd3fd141753ad4dc4e0d914c5786394a37
/src/main/java/com/cybozu/kintone/client/model/comment/AddCommentRecordRequest.java
95d7e2d20009cf805522f8aacfc3aae902b7f9f5
[ "MIT" ]
permissive
hokimcuc0202/kintone-java-sdk
e3ea4f7613c41340e2ac25123b033be07b229583
c451f1440201fcdd0339bd041e38a99938749159
refs/heads/master
2020-04-06T22:30:56.869526
2018-11-13T02:43:13
2018-11-13T02:43:13
null
0
0
null
null
null
null
UTF-8
Java
false
false
583
java
/** * MIT License * * Copyright (c) 2018 Cybozu * https://github.com/kintone/kintone-java-sdk/blob/master/LICENSE */ package com.cybozu.kintone.client.model.comment; public class AddCommentRecordRequest { private Integer app; private Integer record; private CommentContent comment; /** * Constructor * @param app * @param record * @param comment */ public AddCommentRecordRequest(Integer app, Integer record, CommentContent comment) { this.app = app; this.record = record; this.comment = comment; } }
843ae61c272c38d828f5cae7e44a1ebb60242459
20a5679d75a4b53666e141149dbf700865487cf8
/java0408/Age.java
6ad30df4e9118e7aade2744297450616231933a7
[]
no_license
XinXin-ru/zhenghou
70a7b6c9151039475460b9af74c3510e39772af0
d627b3b71cc6d55d144a69e292e299beade763fb
refs/heads/master
2023-04-22T11:45:00.823856
2021-05-06T07:52:24
2021-05-06T07:52:24
359,773,528
0
0
null
null
null
null
UTF-8
Java
false
false
389
java
package java0408; public class Age { int age; public void setAge(int age) throws Exception { if (age >= 1 && age <= 100) { this.age = age; // System.out.println("age=" + age); } else { // System.out.println("输入错误"); throw new Exception(); } } public int getAge() { return age; } }
d6440f0115331196a573208552cae8d35ce18372
73267be654cd1fd76cf2cb9ea3a75630d9f58a41
/services/organizations/src/main/java/com/huaweicloud/sdk/organizations/v1/model/DelegatedAdministratorDto.java
b76e6cc21371cea0f3fd16be46168c8f8800aeed
[ "Apache-2.0" ]
permissive
huaweicloud/huaweicloud-sdk-java-v3
51b32a451fac321a0affe2176663fed8a9cd8042
2f8543d0d037b35c2664298ba39a89cc9d8ed9a3
refs/heads/master
2023-08-29T06:50:15.642693
2023-08-24T08:34:48
2023-08-24T08:34:48
262,207,545
91
57
NOASSERTION
2023-09-08T12:24:55
2020-05-08T02:27:00
Java
UTF-8
Java
false
false
5,470
java
package com.huaweicloud.sdk.organizations.v1.model; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import java.time.OffsetDateTime; import java.util.Objects; /** * 包含有关委托管理员的信息。 */ public class DelegatedAdministratorDto { @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty(value = "delegation_enabled_at") private OffsetDateTime delegationEnabledAt; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty(value = "account_id") private String accountId; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty(value = "account_urn") private String accountUrn; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty(value = "join_method") private String joinMethod; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty(value = "joined_at") private OffsetDateTime joinedAt; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty(value = "account_name") private String accountName; public DelegatedAdministratorDto withDelegationEnabledAt(OffsetDateTime delegationEnabledAt) { this.delegationEnabledAt = delegationEnabledAt; return this; } /** * 将帐号设置为委托管理员的日期。 * @return delegationEnabledAt */ public OffsetDateTime getDelegationEnabledAt() { return delegationEnabledAt; } public void setDelegationEnabledAt(OffsetDateTime delegationEnabledAt) { this.delegationEnabledAt = delegationEnabledAt; } public DelegatedAdministratorDto withAccountId(String accountId) { this.accountId = accountId; return this; } /** * 帐号的唯一标识符(ID)。 * @return accountId */ public String getAccountId() { return accountId; } public void setAccountId(String accountId) { this.accountId = accountId; } public DelegatedAdministratorDto withAccountUrn(String accountUrn) { this.accountUrn = accountUrn; return this; } /** * 帐号的统一资源名称。 * @return accountUrn */ public String getAccountUrn() { return accountUrn; } public void setAccountUrn(String accountUrn) { this.accountUrn = accountUrn; } public DelegatedAdministratorDto withJoinMethod(String joinMethod) { this.joinMethod = joinMethod; return this; } /** * 帐号加入组织的方式,invited:邀请加入,created:创建加入。 * @return joinMethod */ public String getJoinMethod() { return joinMethod; } public void setJoinMethod(String joinMethod) { this.joinMethod = joinMethod; } public DelegatedAdministratorDto withJoinedAt(OffsetDateTime joinedAt) { this.joinedAt = joinedAt; return this; } /** * 帐号成为组织一部分的日期。 * @return joinedAt */ public OffsetDateTime getJoinedAt() { return joinedAt; } public void setJoinedAt(OffsetDateTime joinedAt) { this.joinedAt = joinedAt; } public DelegatedAdministratorDto withAccountName(String accountName) { this.accountName = accountName; return this; } /** * 帐号名称。 * @return accountName */ public String getAccountName() { return accountName; } public void setAccountName(String accountName) { this.accountName = accountName; } @Override public boolean equals(java.lang.Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } DelegatedAdministratorDto that = (DelegatedAdministratorDto) obj; return Objects.equals(this.delegationEnabledAt, that.delegationEnabledAt) && Objects.equals(this.accountId, that.accountId) && Objects.equals(this.accountUrn, that.accountUrn) && Objects.equals(this.joinMethod, that.joinMethod) && Objects.equals(this.joinedAt, that.joinedAt) && Objects.equals(this.accountName, that.accountName); } @Override public int hashCode() { return Objects.hash(delegationEnabledAt, accountId, accountUrn, joinMethod, joinedAt, accountName); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DelegatedAdministratorDto {\n"); sb.append(" delegationEnabledAt: ").append(toIndentedString(delegationEnabledAt)).append("\n"); sb.append(" accountId: ").append(toIndentedString(accountId)).append("\n"); sb.append(" accountUrn: ").append(toIndentedString(accountUrn)).append("\n"); sb.append(" joinMethod: ").append(toIndentedString(joinMethod)).append("\n"); sb.append(" joinedAt: ").append(toIndentedString(joinedAt)).append("\n"); sb.append(" accountName: ").append(toIndentedString(accountName)).append("\n"); sb.append("}"); return sb.toString(); } /** * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } return o.toString().replace("\n", "\n "); } }
0417303776205d64ad88299ea4aea81b1f8a249c
ded1d4e9e78a11a3eb2b1cef73f16360866626b1
/VE/TYPES/Triangle.java
61fe08a9b71cc2d256dfa999d49041703418a1fd
[]
no_license
dennisgbrown/capture_the_flag_VR_Java
7701695be022d4b8ed1ebf61d663ca5914ad4fa8
e788a2b0c265d251c1034af1b1552a2efea72682
refs/heads/master
2020-06-30T06:26:28.831593
2019-08-10T13:14:27
2019-08-10T13:14:27
200,755,651
0
0
null
null
null
null
UTF-8
Java
false
false
964
java
// Triangle.java -- Triangle class // // by Dennis Brown for Colab Bus VE Project // // This class implements a triangle object. package ve.types; import ve.types.ThreeVec; import java.io.Serializable; public class Triangle implements Serializable { public int vertices[]; // This is an array of indices into the // vertex array of the PolyObject with // which this triangle is associated public ThreeVec normal; // normal vector // Create a new triangle given the indices of three vertices and normal. public Triangle(int zero, int one, int two, ThreeVec normal) { vertices = new int[3]; vertices[0] = zero; vertices[1] = one; vertices[2] = two; this.normal = normal; } // Create a copy of a triangle. public Triangle(Triangle copyMe) { for(int i = 0; i < 3; i++) vertices[i] = copyMe.vertices[i]; normal = new ThreeVec(copyMe.normal); } }
e828df6413a25b05ef89f4918aeb37f10ec562ff
a5e1131fb13973ca1d612fd915ce900629ea49fc
/client/src/com/ties/InvitedListActivity.java
efb8926e2905c829282baa147d96b20a73feb546
[]
no_license
marni/500ties
e98b7d770eac1e5610c8b7ef30eb9e4af03ebd08
661712c85470260b554fd10acbf2a0eff1e8f557
refs/heads/master
2020-11-26T21:14:55.305521
2012-06-18T21:48:29
2012-06-18T21:48:29
null
0
0
null
null
null
null
UTF-8
Java
false
false
620
java
package com.ties; import android.app.ListActivity; import android.database.Cursor; import android.os.Bundle; import com.ties.utils.Factory; public class InvitedListActivity extends ListActivity { private InvitedCursorAdapter adapter; private Factory factory; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); factory = new Factory(this); Cursor cursor = factory.getInviteDAO().list(); adapter = new InvitedCursorAdapter(this, cursor); //Assign adapter to ListView getListView().setAdapter(adapter); } }
e67c5494d1f7c6b7da0b47806d0b6833c351f402
f6883c66b3bbb2a1c41772fc2de2016db5885a05
/android/app/src/main/java/com/vodafone/MainActivity.java
a40df10ca78779fc895a05aa8ab5f7166df89c44
[]
no_license
xe4me/react-native-vodafone
1da5e3a087c65e6ef2a8f711a7dca0a778922f23
9a304ce3c497356ace02a602f4c71f8dcbf7be6f
refs/heads/master
2023-02-02T19:39:42.143887
2020-04-05T14:06:49
2020-04-05T14:06:49
253,246,851
0
0
null
2023-01-26T18:59:00
2020-04-05T13:54:48
TypeScript
UTF-8
Java
false
false
343
java
package com.vodafone; import com.facebook.react.ReactActivity; public class MainActivity extends ReactActivity { /** * Returns the name of the main component registered from JavaScript. This is used to schedule * rendering of the component. */ @Override protected String getMainComponentName() { return "vodafone"; } }
8982cb794c56ba9874927f93334d21e20c67cd30
370d4a9f019cb0f449191210ae8eaa3ac2f9d4c2
/java/builder/settings/panel/ReplacementsPanel.java
bfd0ddb17e480f70d8da143fb53c22635b341ede
[]
no_license
jaypume/CReST
3090b56393bb80e13980ada0db2a7046a5e2aab9
5726bf2b50d71d8921287f84180567f6d043d9c1
refs/heads/master
2021-01-10T08:59:45.371249
2015-11-19T04:16:22
2015-11-19T04:16:22
46,464,653
0
0
null
null
null
null
UTF-8
Java
false
false
7,808
java
/** * This file is part of CReST: The Cloud Research Simulation Toolkit * Copyright (C) 2011, 2012 John Cartlidge * * For a full list of contributors, refer to file CONTRIBUTORS.txt * * CReST was developed at the University of Bristol, UK, using * financial support from the UK's Engineering and Physical * Sciences Research Council (EPSRC) grant EP/H042644/1 entitled * "Cloud Computing for Large-Scale Complex IT Systems". Refer to * <http://gow.epsrc.ac.uk/NGBOViewGrant.aspx?GrantRef=EP/H042644/1> * * CReST is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/gpl.txt>. * * For further information, contact: * * Dr. John Cartlidge: [email protected] * Department of Computer Science, * University of Bristol, The Merchant Venturers Building, * Woodland Road, Bristol, BS8-1UB, United Kingdom. * */ package builder.settings.panel; import java.awt.Dimension; import java.awt.event.ActionListener; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; import javax.swing.border.EmptyBorder; import sim.module.Module; import sim.module.replacements.configparams.ReplacementModuleConfigParams; import builder.prefs.BuilderPreferences; import builder.settings.SimSettingsView.SaveHandler; import config.SettingsManager; public class ReplacementsPanel extends AbstractSimPanel { protected JCheckBox mChkBoxReplaceInBlocks; protected JCheckBox mChkBoxReplacementFunction; protected JCheckBox mChkBoxPresetServerTypes; protected JSpinner mReplacementThresholdAisle; protected JSpinner mReplacementThresholdContainer; protected JSpinner mReplacementThresholdRack; public ReplacementsPanel(SettingsManager conf, BuilderPreferences prefs) { super(conf, prefs); } @Override public JPanel getPanel(SaveHandler listen, ActionListener fileChooserListener) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Server Replacements"), new EmptyBorder(10, 10, 10, 10))); // Setup controls //Get sim configuration parameters ReplacementModuleConfigParams params = (ReplacementModuleConfigParams) Module.REPLACEMENTS_MODULE.getParams(); // Replace In Blocks JPanel panReplaceInBlocks = new JPanel(); panReplaceInBlocks.setLayout(new BoxLayout(panReplaceInBlocks, BoxLayout.LINE_AXIS)); mChkBoxReplaceInBlocks = new JCheckBox("Block Replacements (Unchecked- Individual Replacements)"); mChkBoxReplaceInBlocks.setSelected(params.isReplacementInBlocks()); mChkBoxReplaceInBlocks.addActionListener(listen); panReplaceInBlocks.add(mChkBoxReplaceInBlocks); panReplaceInBlocks.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); panel.add(panReplaceInBlocks); //panel.add(Box.createVerticalStrut(10)); // Replacement Function JPanel panReplacementFunction = new JPanel(); panReplacementFunction.setLayout(new BoxLayout(panReplacementFunction, BoxLayout.LINE_AXIS)); mChkBoxReplacementFunction = new JCheckBox("Use Replacement Function"); mChkBoxReplacementFunction.setSelected(params.isReplacementViaFunctionTypes()); mChkBoxReplacementFunction.addActionListener(listen); panReplacementFunction.add(mChkBoxReplacementFunction); panReplacementFunction.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); panel.add(panReplacementFunction); //panel.add(Box.createVerticalStrut(10)); // Preset Server Types JPanel panPresetServerTypes = new JPanel(); panPresetServerTypes.setLayout(new BoxLayout(panPresetServerTypes, BoxLayout.LINE_AXIS)); mChkBoxPresetServerTypes = new JCheckBox("Use Preset Server Types"); mChkBoxPresetServerTypes.setSelected(params.isReplacementViaPresetTypes()); mChkBoxPresetServerTypes.addActionListener(listen); panPresetServerTypes.add(mChkBoxPresetServerTypes); panPresetServerTypes.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); panel.add(panPresetServerTypes); panel.add(Box.createVerticalStrut(10)); //Replacement Threshold Aisle JPanel panelReplacementThresholdAisle = new JPanel(); panelReplacementThresholdAisle.setLayout(new BoxLayout(panelReplacementThresholdAisle, BoxLayout.LINE_AXIS)); panelReplacementThresholdAisle.add(new JLabel("Aisle Replacement Threshold")); panelReplacementThresholdAisle.add(Box.createHorizontalStrut(10)); mReplacementThresholdAisle = new JSpinner(new SpinnerNumberModel( params.getReplacementThresholdAisle(), 0, 1, 0.01)); panelReplacementThresholdAisle.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); mReplacementThresholdAisle.addChangeListener(listen); panelReplacementThresholdAisle.add(mReplacementThresholdAisle); panel.add(panelReplacementThresholdAisle); panel.add(Box.createVerticalStrut(10)); //Replacement Threshold Container JPanel panelReplacementThresholdContainer = new JPanel(); panelReplacementThresholdContainer.setLayout(new BoxLayout(panelReplacementThresholdContainer, BoxLayout.LINE_AXIS)); panelReplacementThresholdContainer.add(new JLabel("Container Replacement Threshold")); panelReplacementThresholdContainer.add(Box.createHorizontalStrut(10)); mReplacementThresholdContainer = new JSpinner(new SpinnerNumberModel( params.getReplacementThresholdContainer(), 0, 1, 0.01)); panelReplacementThresholdContainer.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); mReplacementThresholdContainer.addChangeListener(listen); panelReplacementThresholdContainer.add(mReplacementThresholdContainer); panel.add(panelReplacementThresholdContainer); panel.add(Box.createVerticalStrut(10)); //Replacement Threshold Rack JPanel panelReplacementThresholdRack = new JPanel(); panelReplacementThresholdRack.setLayout(new BoxLayout(panelReplacementThresholdRack, BoxLayout.LINE_AXIS)); panelReplacementThresholdRack.add(new JLabel("Rack Replacement Threshold")); panelReplacementThresholdRack.add(Box.createHorizontalStrut(10)); mReplacementThresholdRack = new JSpinner(new SpinnerNumberModel( params.getReplacementThresholdRack(), 0, 1, 0.01)); panelReplacementThresholdRack.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); mReplacementThresholdRack.addChangeListener(listen); panelReplacementThresholdRack.add(mReplacementThresholdRack); panel.add(panelReplacementThresholdRack); return panel; } @Override public void resaveElements() { ReplacementModuleConfigParams params = new ReplacementModuleConfigParams( mChkBoxReplaceInBlocks.isSelected(), mChkBoxPresetServerTypes.isSelected(), mChkBoxReplacementFunction.isSelected(), ((Number) mReplacementThresholdAisle.getValue()).doubleValue(), ((Number) mReplacementThresholdContainer.getValue()).doubleValue(), ((Number) mReplacementThresholdRack.getValue()).doubleValue() ); Module.REPLACEMENTS_MODULE.setParams(params); System.out.println("Resaved: " + Module.REPLACEMENTS_MODULE.getFullDescriptionString()); } }
331f936fa04744b9ac712d674434b2200d68131e
e29aed5297971fbf909530a7d6c7bb942fb63a8a
/src/main/java/com/api/crowdlending/model/FondInvestorModel.java
98562dd4b200841e131cb04707e00eb732ba79e4
[ "Apache-2.0" ]
permissive
magalierambla/App2Java2
c1b588b0a412b312a06fdcad27339f1378f7cd02
5dacff5e3006a3ce3be83564e0d3c70839be7429
refs/heads/main
2023-01-22T05:48:57.806258
2020-10-25T19:46:39
2020-10-25T19:46:39
303,166,807
0
0
null
null
null
null
UTF-8
Java
false
false
1,222
java
package com.api.crowdlending.model; import lombok.Getter; import lombok.Setter; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.Table; import javax.persistence.UniqueConstraint; import javax.persistence.OneToOne; @Entity @Getter @Setter @Table(name = "fonds_investisseurs_paypal",uniqueConstraints={@UniqueConstraint(columnNames ={"token"})}) public class FondInvestorModel implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(nullable = false) private Long amount; @Column(nullable = false) private String token; @Column(nullable = false) private String dateCreated; @Column(nullable = false) private Long timestamp; @OneToOne @JoinColumn(name = "token_investisseur_project", referencedColumnName = "token") private InvestisseursProjectModel _investisseurProject ; @OneToOne @JoinColumn(name = "token_project", referencedColumnName = "token") private Project _project ; }
d11070f43283e498a2b13fcd24dba821785cea12
809b659dc8fddff71ff9752380bce4caca0373b9
/ATSProject1/src/main/java/page/ScreenshotUtils.java
c8f8171e45bce6a994cf9aea3d598b9cc3587305
[]
no_license
lalitapant/ATSSpecProj
8f061a5f4b554b70051a34d81d44309f4fd81509
f2d6489eb026af388c34214e74b326ca7f7e1318
refs/heads/master
2023-05-12T14:25:15.991783
2020-02-03T17:36:00
2020-02-03T17:36:00
238,020,389
0
0
null
2023-05-09T18:45:00
2020-02-03T17:21:27
HTML
UTF-8
Java
false
false
695
java
package page; import java.io.File; import org.apache.commons.io.FileUtils; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; public class ScreenshotUtils { public static void takeSnapShot(WebDriver webdriver,String fileWithPath) throws Exception{ //Convert web driver object to TakeScreenshot TakesScreenshot scrShot =((TakesScreenshot)webdriver); //Call getScreenshotAs method to create image file File SrcFile=scrShot.getScreenshotAs(OutputType.FILE); //Move image file to new destination File DestFile=new File(fileWithPath); //Copy file at destination FileUtils.copyFile(SrcFile, DestFile); } }
4662695b75ca2678db1dd69abeb5db218f4c9b1f
73267be654cd1fd76cf2cb9ea3a75630d9f58a41
/services/gaussdb/src/main/java/com/huaweicloud/sdk/gaussdb/v3/model/ModifyGaussMysqlDnsResponse.java
79cb104a94d45925bf559a3d228fbd5748fd790d
[ "Apache-2.0" ]
permissive
huaweicloud/huaweicloud-sdk-java-v3
51b32a451fac321a0affe2176663fed8a9cd8042
2f8543d0d037b35c2664298ba39a89cc9d8ed9a3
refs/heads/master
2023-08-29T06:50:15.642693
2023-08-24T08:34:48
2023-08-24T08:34:48
262,207,545
91
57
NOASSERTION
2023-09-08T12:24:55
2020-05-08T02:27:00
Java
UTF-8
Java
false
false
1,789
java
package com.huaweicloud.sdk.gaussdb.v3.model; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.huaweicloud.sdk.core.SdkResponse; import java.util.Objects; /** * Response Object */ public class ModifyGaussMysqlDnsResponse extends SdkResponse { @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty(value = "job_id") private String jobId; public ModifyGaussMysqlDnsResponse withJobId(String jobId) { this.jobId = jobId; return this; } /** * 任务ID。 * @return jobId */ public String getJobId() { return jobId; } public void setJobId(String jobId) { this.jobId = jobId; } @Override public boolean equals(java.lang.Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } ModifyGaussMysqlDnsResponse that = (ModifyGaussMysqlDnsResponse) obj; return Objects.equals(this.jobId, that.jobId); } @Override public int hashCode() { return Objects.hash(jobId); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ModifyGaussMysqlDnsResponse {\n"); sb.append(" jobId: ").append(toIndentedString(jobId)).append("\n"); sb.append("}"); return sb.toString(); } /** * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } return o.toString().replace("\n", "\n "); } }
b8d078a390343af242f46ea978f8f23dea0296e6
04d485a7ce12ab5363485641343b181f0318d1e9
/problem9.java
667070e56aedc4e6cff058b95f9f1fa7eb56badb
[]
no_license
MUBEENAUQI/Java_hackerRank
e180c9ed0e8e3c693ea52ea2efca94fda74720d1
a6711f56c6eeafc6fa81972000e8f2211a8eae8d
refs/heads/main
2023-06-01T20:00:25.071001
2021-06-17T23:32:25
2021-06-17T23:32:25
357,323,683
0
2
null
2021-06-17T23:32:25
2021-04-12T20:01:50
Java
UTF-8
Java
false
false
1,680
java
// Static initialization blocks are executed when the class is loaded, and you can initialize static variables in those blocks. // It's time to test your knowledge of Static initialization blocks. You can read about it here. // You are given a class Solution with a main method. Complete the given code so that it outputs the area of a parallelogram with breadth and height . You should read the variables from the standard input. // If or , the output should be "java.lang.Exception: Breadth and height must be positive" without quotes. // Input Format // There are two lines of input. The first line contains : the breadth of the parallelogram. The next line contains : the height of the parallelogram. // Constraints // Output Format // If both values are greater than zero, then the main method must output the area of the parallelogram. Otherwise, print "java.lang.Exception: Breadth and height must be positive" without quotes. // Sample input 1 // 1 // 3 // Sample output 1 // 3 // Sample input 2 // -1 // 2 // Sample output 2 // java.lang.Exception: Breadth and height must be positive import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int B,H; static boolean flag=true; static { Scanner sc = new Scanner(System.in); B = sc.nextInt(); H = sc.nextInt(); if(B<=0 || H<=0){ System.out.println("java.lang.Exception: Breadth and height must be positive"); flag = false; } } public static void main(String[] args){ if(flag){ int area=B*H; System.out.print(area); } }//end of main }//end of class
1e5f703f6d93e0d0f80fc0003cb15662ca173485
17af430ab28d6c466275b9137843bfb7cb8a13a7
/src/main/java/common/Constants.java
29daf5a20ca7a513f179987d3b24ef6bbabbd229
[]
no_license
nuggysantoso/sample-automation-appium
0bf31c025e9511fb5116c22baf9f4a35e55120d7
ce28738b0eaaceab03de84e3b9f88edbef78a111
refs/heads/master
2021-07-12T00:00:52.714745
2017-10-16T07:54:52
2017-10-16T07:54:52
106,267,664
0
0
null
null
null
null
UTF-8
Java
false
false
1,035
java
package common; /** * Created by nugroho_s on 10/5/17. */ public class Constants { /** * Default Constant value for ios and android */ public static final String APPIUM_URL="http://127.0.0.1:4723/wd/hub"; public static final String DEFAULT_APP_PATH= System.getProperty("user.home") + "/Documents/"; /** * Default Constant value for android */ public static final String DEFAULT_ANDROID_PLATFORM_VERSION="5.1.1"; public static final String DEFAULT_ANDROID_DEVICE_NAME="AndroidL"; public static final String DEFAULT_ANDROID_APP_NAME ="Bukalapak.apk"; public static final String DEFAULT_ANDROID_PAKCAGE_NAME ="com.bukalapak.android"; public static final String DEFAULT_ANDROID_ACTIVITY_NAME ="com.bukalapak.android.HomeActivity_"; public static final String DEFAULT_ANDROID_WAIT_ACTIVITY = "com.bukalapak.android.HomeActivity_"; public static final Boolean DEFAULT_ANDROID_FULL_RESET_VALUE = true; public static final int DEFAULT_ANDROID_COMMAND_TIMEOUT = 320000; }
538ba2414d10fe7539a94b0cbe6f2b6192178955
49aa27e9f1bf3efa1f6fdd54556124647fac972c
/src/main/java/com/bailei/study/zookeeper/curator/CuratorAsyncUseSample.java
dd90ffab3c9d5c6a89603b3cd694dc1750fa9061
[ "Apache-2.0" ]
permissive
sonymoon/algorithm
2cd699a61223740200d507edac8bff05b7ab7eb8
cc2a9e0125fc64bdbf6549034bad6482d2027ea2
refs/heads/master
2020-06-11T07:06:32.161489
2019-03-25T03:58:22
2019-03-25T03:58:22
75,738,406
0
0
null
null
null
null
UTF-8
Java
false
false
2,279
java
package com.bailei.study.zookeeper.curator; import com.bailei.study.zookeeper.ZooConfig; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.ExponentialBackoffRetry; import org.apache.zookeeper.CreateMode; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** * Created by bailei on 17/1/14. */ public class CuratorAsyncUseSample { public static final CountDownLatch semaphore = new CountDownLatch(2); public static final ExecutorService tp = Executors.newFixedThreadPool(2); public static void main(String[] args) throws Exception { CuratorFramework client = CuratorFrameworkFactory.builder() .connectString(ZooConfig.SERVER) .sessionTimeoutMs(5000).connectionTimeoutMs(3000) .retryPolicy(new ExponentialBackoffRetry(1000, 3)) .build(); client.start(); System.out.println("New Thread: " + Thread.currentThread().getName()); String path = "/zk-book"; client.create().creatingParentsIfNeeded() .withMode(CreateMode.EPHEMERAL) .inBackground((client1, event) -> { System.out.println("event[code: " + event.getResultCode() + ", type: " + event.getType() + "]"); System.out.println("Thread of processResult: " + Thread.currentThread().getName()); semaphore.countDown(); }, tp) .forPath(path, "init".getBytes()); client.create().creatingParentsIfNeeded() .withMode(CreateMode.EPHEMERAL) .inBackground((client1, event) -> { System.out.println("event[code: " + event.getResultCode() + ", type: " + event.getType() + "]"); System.out.println("Thread of processResult: " + Thread.currentThread().getName()); semaphore.countDown(); }) .forPath(path, "init".getBytes()); semaphore.await(); tp.shutdown(); } }
b9e81f531b5fdd0f474fb3d7db6452e49c942ee3
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/10/10_23b9d5b463a7574373f39f0589116c46ddf4d0dc/ParseEntry/10_23b9d5b463a7574373f39f0589116c46ddf4d0dc_ParseEntry_s.java
8423bb028b73cdee77af4cfde7f9d4803fa65c35
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
7,688
java
/************************************************************************** OmegaT - Computer Assisted Translation (CAT) tool with fuzzy matching, translation memory, keyword search, glossaries, and translation leveraging into updated projects. Copyright (C) 2000-2006 Keith Godfrey and Maxym Mykhalchuk (C) 2005-06 Henry Pijffers (C) 2006 Martin Wunderlich (C) 2006-2007 Didier Briel (C) 2008 Martin Fleurke (C) 2009 Alex Buloichik Home page: http://www.omegat.org/ Support center: http://groups.yahoo.com/group/OmegaT/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA **************************************************************************/ package org.omegat.core.data; import java.util.ArrayList; import java.util.List; import org.omegat.core.segmentation.Rule; import org.omegat.core.segmentation.Segmenter; import org.omegat.filters2.IFilter; import org.omegat.filters2.IParseCallback; import org.omegat.util.Language; import org.omegat.util.StaticUtils; /** * Process one entry on parse source file. * * @author Maxym Mykhalchuk * @author Henry Pijffers * @author Alex Buloichik <[email protected]> */ public abstract class ParseEntry implements IParseCallback { private final ProjectProperties m_config; public ParseEntry(final ProjectProperties m_config) { this.m_config = m_config; } /** * This method is called by filters to add new entry in OmegaT after read it * from source file. * * @param id * ID of entry, if format supports it * @param source * Translatable source string * @param translation * translation of the source string, if format supports it * @param isFuzzy * flag for fuzzy translation. If a translation is fuzzy, it is * not added to the projects TMX, but it is added to the * generated 'reference' TMX, a special TMX that is used as * extra reference during translation. * @param comment * entry's comment, if format supports it * @param filter * filter which produces entry */ public void addEntry(String id, String source, String translation, boolean isFuzzy, String comment, IFilter filter) { ParseEntryResult tmp = new ParseEntryResult(); source = stripSomeChars(source, tmp); if (translation != null) { translation = stripSomeChars(translation, tmp); } String segTranslation = isFuzzy ? null : translation; if (m_config.isSentenceSegmentingEnabled()) { List<StringBuffer> spaces = new ArrayList<StringBuffer>(); List<Rule> brules = new ArrayList<Rule>(); Language sourceLang = m_config.getSourceLanguage(); List<String> segments = Segmenter.segment(sourceLang, source, spaces, brules); if (segments.size() == 1) { addSegment(id, (short) 0, segments.get(0), segTranslation, comment); } else { for (short i = 0; i < segments.size(); i++) { String onesrc = segments.get(i); addSegment(id, i, onesrc, null, comment); } } } else { addSegment(id, (short) 0, source, segTranslation, comment); } if (translation != null) { // Add systematically the TU as a legacy TMX String tmxSource; if (isFuzzy) { tmxSource = "[" + filter.getFuzzyMark() + "] " + source; } else { tmxSource = source; } addFileTMXEntry(tmxSource, translation); } } /** * Adds the source and translation to the generated 'reference TMX', a * special TMX that is used as extra refrence during translation. */ public abstract void addFileTMXEntry(String source, String translation); /** * Adds a segment to the project. If a translation is given, it it added to * the projects TMX. * @param id * ID of entry, if format supports it * @param segmentIndex * Number of the segment-part of the original source string. * @param segmentSource * Translatable source string * @param segmentTranslation * non fuzzy translation of the source string, if format supports it * @param comment * entry's comment, if format supports it */ protected abstract void addSegment(String id, short segmentIndex, String segmentSource, String segmentTranslation, String comment); /** * Strip some chars for represent string in UI. * * @param src * source string to strip chars * @return result */ static String stripSomeChars(final String src, final ParseEntryResult per) { String r = src; /** * AB: we need to find begin/end spaces first, then replace \r,\n chars. * Since \r,\n are spaces, we will not need to store spaces in buffer, * but we can just remember spaces count at the begin and at the end, * then restore spaces from original string. */ /* * Some special space handling: skip leading and trailing whitespace and * non-breaking-space */ int len = r.length(); int b = 0; while (b < len && (Character.isWhitespace(r.charAt(b)) || r.charAt(b) == '\u00A0')) { b++; } per.spacesAtBegin = b; int pos = len - 1; int e = 0; while (pos >= b && (Character.isWhitespace(r.charAt(pos)) || r.charAt(pos) == '\u00A0')) { pos--; e++; } per.spacesAtEnd = e; r = r.substring(b, pos); /* * Replacing all occurrences of single CR (\r) or CRLF (\r\n) by LF * (\n). This is reversed on create translation. (fix for bug 1462566) * We don't need to remember crlf/cr presents on parse, but only on * translate. */ per.crlf = r.indexOf("\r\n") > 0; if (per.crlf) r = r.replace("\\r\\n", "\n"); per.cr = r.indexOf("\r") > 0; if (per.cr) r = r.replace("\\r", "\n"); r = StaticUtils.fixChars(r); return r; } /** * Storage for results of entry parsing, i.e. cr/crlf flags, spaces counts * on the begin and end. */ public static class ParseEntryResult { public boolean crlf, cr; int spacesAtBegin, spacesAtEnd; } }
385f5c10268f81e6c30ea4efff84a685c37fd8d8
be119b303e56e9cec57733b39bfb9a0f86abfdcb
/app/src/androidTest/java/com/fragment/login/musicapp/ApplicationTest.java
655e5bc3a4a29282ed927e3cc0da8bb8cd4fff07
[]
no_license
Nensee/MusicApp
33d81a9ce0a1e622b8932a1b94709e4668a33243
5462e45b657ab3c35477e2e8f48cba188b05f476
refs/heads/master
2021-01-21T07:07:12.252497
2017-02-27T19:57:22
2017-02-27T19:57:22
83,314,469
0
0
null
null
null
null
UTF-8
Java
false
false
358
java
package com.fragment.login.musicapp; import android.app.Application; import android.test.ApplicationTestCase; /** * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> */ public class ApplicationTest extends ApplicationTestCase<Application> { public ApplicationTest() { super(Application.class); } }
ba621fd8705a26606a56fc4b556bed58114a6ec3
89c7d4e98a7767233e7c1f4e4a6cfe241d30b259
/src/MenuPanel.java
56c05d639b5756bd61900949fe0354d8b911759f
[]
no_license
AndreasNbt/Quiz-game
a17be5e287db150f7b1c62aae95dab791d06b3e7
e6fdc2cad0f1a4a22c2c58ac3be0f1935fc3f5f5
refs/heads/master
2023-05-09T10:37:33.017486
2021-06-01T10:48:44
2021-06-01T10:48:44
372,794,159
0
0
null
null
null
null
UTF-8
Java
false
false
6,231
java
import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; import java.io.FileNotFoundException; import java.util.ArrayList; /** * The type Menu panel. */ public class MenuPanel extends JPanel{ JLabel title_label; JPanel menu_panel; JButton play_button; JButton options_button; JButton help_button; JButton quit_button; /** * Instantiates a new MenuPanel. * The MenuPanel gets added to the mainPanel and is shown to the player when he opens the game. * It contains a label named title_label which displays a welcome message to the player. * It also contains four buttons. * The play_button, which begins the game. * The options_button, with which the player can change the number of rounds and the number of questions per round. * The help_button, witch shows the player an info message which explains how the game is played. * The quit_button, with which the player exits the game. * * @param frame the frame * @param gl the Globals object * @param mainPanel the main panel * @param cardLayout the card layout * @param gamePanel the game panel * @param title the title label * @param results the results label */ public MenuPanel(JFrame frame, Globals gl,JPanel mainPanel, CardLayout cardLayout,GamePanel gamePanel,JLabel title,JLabel results) { setBorder(new EmptyBorder(30,10,10,10)); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.anchor = GridBagConstraints.NORTH; title_label = new JLabel("What would you like to do?"); title_label.setSize(new Dimension(200,200)); title_label.setFont(new Font("TimesRoman", Font.ITALIC, 40)); add(title_label,gbc); gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.HORIZONTAL; menu_panel = new JPanel(new GridBagLayout()); play_button = new JButton("Play"); play_button.setSize(new Dimension(200,200)); play_button.setFont(new Font("TimesRoman",Font.BOLD,20)); play_button.addActionListener(e -> { String players = JOptionPane.showInputDialog(frame, "How many players will be playing? ", 1); int i; ArrayList<Player> playerArrayList = new ArrayList<>(); for (i=0;i<Integer.parseInt(players);i++) { String name = JOptionPane.showInputDialog(frame,"Enter the name of player "+(i+1)); playerArrayList.add(new Player(name)); } cardLayout.show(mainPanel, "Game"); try { new GuiGameLogic(frame,playerArrayList,gl,mainPanel,cardLayout,gamePanel,title,results); } catch (FileNotFoundException fileNotFoundException) { fileNotFoundException.printStackTrace(); } }); menu_panel.add(play_button,gbc); options_button = new JButton("Options"); options_button.setSize(new Dimension(200,200)); options_button.setFont(new Font("TimesRoman",Font.BOLD,20)); options_button.addActionListener(e -> { String rounds = JOptionPane.showInputDialog(frame, "How many rounds per game do you want?", gl.getNumberOfRounds()); if(rounds!=null) { gl.setNumberOfRounds(Integer.parseInt(rounds)); } String questions = JOptionPane.showInputDialog(frame, "How many questions per round do you want?", gl.getNumberOfQuestions()); if (questions != null) { gl.setNumberOfQuestions(Integer.parseInt(questions)); }}); menu_panel.add(options_button,gbc); help_button = new JButton("Help"); help_button.setSize(new Dimension(200,200)); help_button.setFont(new Font("TimesRoman",Font.BOLD,20)); help_button.addActionListener(e -> { final String rules = ("There are 5 different round types in Buzz:" + "\n" + "@Right Answer" +"\n" + "@Bet" +"\n" +"@Fast Answer" +"\n" +"@Stop the clock" +"\n" +"@Thermometer" +"\n" + "In Right answer, each player picks the answer he thinks is correct and if he gets it right, he wins 1000 points!"+ "\n" + "In Bet, each player has to bet either 250,500,750 or 1000 points after being shown the type of the next question. If he then chooses the correct answer he wins those points otherwise he loses them( keep in mind that the score can be negative) !"+"\n"+ "In Fast Answer, the player who answers faster wins more points! 1000 points for the player who answers first and 500 for the rest ( if answered correctly of course) !"+"\n"+ "In Stop the clock, all players have to answer before the time runs out. Again the faster player wins more points! He gets one fifth times the time he has left in miliseconds."+"\n"+ "In Thermometer, the first player to answer 5 questions correctly wins 5000 points!")+"\n"+ "To answer, the player uses the keys A,B,C,D on his keyboard to select the answer that he wants. If it is a 2 player game, then the second player uses the keys 1,2,3,4."; JOptionPane.showMessageDialog(frame,rules, "Game rules",JOptionPane.INFORMATION_MESSAGE); }); menu_panel.add(help_button,gbc); quit_button = new JButton("Quit"); quit_button.setSize(new Dimension(200,200)); quit_button.setFont(new Font("TimesRoman",Font.BOLD,20)); quit_button.addActionListener(e -> { String[] options1 = {"Confirm", "Cancel"}; int x = JOptionPane.showOptionDialog(frame, "Are you sure you want to exit the game?", "Buzz", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options1, options1[1]); if (x == 0) { System.exit(0); } }); menu_panel.add(quit_button,gbc); gbc.weighty = 1; add(menu_panel,gbc); mainPanel.add("Menu",this); } }
e402e60c6bfe7042961f86b971af3d77c78da5ed
4a8e887aaf1082443121cc894988469c5c327595
/curso-java-aula-4/src/main/java/com/dextraining/area/CalculadorArea.java
fd7d12852cc4ed8036e2822db55cc388a8684f52
[]
no_license
diegofrsilva/curso_programacao_java_turma_2
2f32bfb3b7809efbd0297a5acfb200fab48921c6
41982a39272b8aa86989e76c3dabb75f358355f7
refs/heads/master
2020-06-10T05:29:52.724035
2017-01-21T19:55:05
2017-01-21T19:55:05
76,072,146
0
0
null
null
null
null
UTF-8
Java
false
false
150
java
package com.dextraining.area; public class CalculadorArea { public static double calcular(AreaCalculavel objeto) { return objeto.getArea(); } }
1159a1956e1b7b7dac450da9a8b79849558699e6
c27f418a440690feb17d1a45fb030a100eb985be
/src/main/java/kurtis/chudasama/controller/CartController.java
119aa992cbaaf2de0724796805d9ca7f14b6e46a
[]
no_license
KurtisChudasama/electronicstore
b9aa6cbb739ac2431769dcc50733c8c360c145e1
c23cd515ef8d4ab8cab4045098b8cb1295408516
refs/heads/master
2020-05-14T17:19:54.444695
2019-04-25T19:42:34
2019-04-25T19:42:34
181,890,817
0
0
null
null
null
null
UTF-8
Java
false
false
3,672
java
package kurtis.chudasama.controller; import kurtis.chudasama.entity.Cart; import kurtis.chudasama.entity.CartItems; import kurtis.chudasama.entity.Item; import kurtis.chudasama.entity.User; import kurtis.chudasama.service.CartItemsService; import kurtis.chudasama.service.CartService; import kurtis.chudasama.service.ItemService; import kurtis.chudasama.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @Controller public class CartController { @Autowired private CartService cartService; @Autowired private UserService userService; @Autowired private ItemService itemService; @Autowired private CartItemsService cartItemsService; @GetMapping("/homepage/addtocart/{id}") public ModelAndView addToCart(@PathVariable("id") int id, @RequestParam(defaultValue = "") String itemName) { ModelAndView model = new ModelAndView(); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); User user = userService.findUserByUsername(auth.getName()); Cart cart = cartService.findByUserId(user.getId()); Item item = itemService.findById(id); ArrayList<CartItems> cart_items = new ArrayList<CartItems>(); cart_items.addAll(cart.getCartItems()); boolean exist = true; for (int i = 0; i < cart_items.size(); i++) { CartItems current = cart_items.get(i); if (current.getItem() == item) { int temp = cart_items.get(i).getQuantity(); cart_items.get(i).setQuantity(temp+1); cartItemsService.saveCartItems(cart_items.get(i)); Set<CartItems> updatedList = new HashSet<>(cart_items); cart.setCartItems(updatedList); exist = false; } } if (exist) { CartItems cartItems = new CartItems(cart, item, 1); cartItemsService.saveCartItems(cartItems); cart_items.add(cartItems); Set<CartItems> updatedList = new HashSet<>(cart_items); cart.setCartItems(updatedList); } cartService.saveCart(cart); String successMessage = ""; model.addObject("successMessage", successMessage); ArrayList<Item> items = itemService.findItemsByName(itemName); model.addObject("items", items); model.setViewName("view_items"); return model; } @GetMapping("/homepage/viewcart") public ModelAndView viewCart() { ModelAndView model = new ModelAndView(); Authentication auth = SecurityContextHolder.getContext().getAuthentication(); User user = userService.findUserByUsername(auth.getName()); Cart cart = cartService.findByUserId(user.getId()); ArrayList<CartItems> cart_items = new ArrayList<CartItems>(); cart_items.addAll(cart.getCartItems()); double total = cart.calculateTotal(); model.addObject("cart", cart); model.addObject("cartitems", cart_items); model.addObject("total", total); model.setViewName("view_cart"); return model; } }
bff471613b55e6bf8e14acd712a1c4f2ace248b6
d4e9ca0fbec211e2d638c4ca6535313e9266ff8a
/src/main/java/com/ml/Application.java
996947ac55e2c1e3b30634edb839007f8b539dbc
[]
no_license
pandahuangwei/ms-spring-boot
4bc078a3c01182dd87981c87e9c6185270db9a12
7af1a3b770d56ba42d13aff17af1737ddc355d29
refs/heads/master
2021-07-14T01:43:09.135722
2017-10-12T15:58:51
2017-10-12T15:58:51
103,121,610
0
0
null
null
null
null
UTF-8
Java
false
false
475
java
package com.ml; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.context.annotation.ComponentScan; @ServletComponentScan @ComponentScan(basePackages={"com.ml"}) @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
b159deccb33845811c9bfc5d59f64ba6e1f826a1
f1f21c83ba7830cd79a369b6685e773b678f542c
/src/br/uff/faleniteroi/tabsfragments/TabRequestFinishedFragment.java
b60c0dd0a60e3f6513a90a68be977801ced5f0f7
[]
no_license
JavierJimenez86/FaleNiteroi
14ee9a40db703443b3f5623d80e3c5210bd65f00
5bff553808962aa687a8d49ef7a6430e0c9468fd
refs/heads/master
2021-05-12T15:24:08.386521
2018-01-10T17:22:45
2018-01-10T17:22:45
116,982,306
0
0
null
null
null
null
ISO-8859-1
Java
false
false
2,181
java
package br.uff.faleniteroi.tabsfragments; import java.util.ArrayList; import br.uff.faleniteroi.R; import br.uff.faleniteroi.RequestDetailActivity; import br.uff.faleniteroi.adapter.RequestClearAdapter; import br.uff.faleniteroi.entity.Request; import br.uff.faleniteroi.sqlite.RequestDAO; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ListView; import android.widget.TextView; import android.widget.AdapterView.OnItemClickListener; public class TabRequestFinishedFragment extends Fragment implements OnItemClickListener { private ListView listView; private RequestClearAdapter requestAdapter; private ArrayList<Request> itens; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tab_fragment_request_latest, container, false); RequestDAO requestDAO = new RequestDAO(view.getContext()); itens = requestDAO.listFinished(); TextView tvRequestInfo = (TextView) view.findViewById(R.id.tvRequestInfo); tvRequestInfo.setVisibility(View.GONE); if (itens.size() == 0) { tvRequestInfo.setVisibility(View.VISIBLE); tvRequestInfo.setText("Nenhuma solicitação finalizada"); } listView = (ListView) view.findViewById(R.id.lvRequests); listView.setOnItemClickListener(this); requestAdapter = new RequestClearAdapter(view.getContext(), itens); listView.setAdapter(requestAdapter); listView.setCacheColorHint(Color.TRANSPARENT); return view; } @Override public void onItemClick(AdapterView<?> arg0, View view, int pos, long arg3) { Request request = (Request) requestAdapter.getItem(pos); Intent intent = new Intent(view.getContext(), RequestDetailActivity.class); intent.putExtra("Request", request); startActivity(intent); } }
2d62875603f29a1c4f95922bab71b8273913ff52
711e906f2b6490ef1e4f1f58ca840fd14b857ce2
/com/google/android/systemui/columbus/gates/VrMode.java
fbd7ad23b42489bd3002c138fdaab0a679b5134f
[]
no_license
dovanduy/SystemUIGoogle
51a29b812000d1857145f429f983e93c02bff14c
cd41959ee1bd39a22d0d4e95dc40cefb72a75ec8
refs/heads/master
2022-07-09T01:48:40.088858
2020-05-16T16:01:21
2020-05-16T16:01:21
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,179
java
// // Decompiled by Procyon v0.5.36 // package com.google.android.systemui.columbus.gates; import android.os.RemoteException; import android.util.Log; import android.service.vr.IVrStateCallbacks; import android.service.vr.IVrManager$Stub; import android.os.ServiceManager; import kotlin.jvm.internal.Intrinsics; import android.content.Context; import android.service.vr.IVrManager; public final class VrMode extends Gate { private boolean inVrMode; private final IVrManager vrManager; private final VrMode$vrStateCallbacks.VrMode$vrStateCallbacks$1 vrStateCallbacks; public VrMode(final Context context) { Intrinsics.checkParameterIsNotNull(context, "context"); super(context); this.vrManager = IVrManager$Stub.asInterface(ServiceManager.getService("vrmanager")); this.vrStateCallbacks = new VrMode$vrStateCallbacks.VrMode$vrStateCallbacks$1(this); } @Override protected boolean isBlocked() { return this.inVrMode; } @Override protected void onActivate() { final IVrManager vrManager = this.vrManager; if (vrManager != null) { try { final boolean vrModeState = vrManager.getVrModeState(); boolean inVrMode = true; if (!vrModeState) { inVrMode = false; } this.inVrMode = inVrMode; vrManager.registerListener((IVrStateCallbacks)this.vrStateCallbacks); } catch (RemoteException ex) { Log.e("Columbus/VrMode", "Could not register IVrManager listener", (Throwable)ex); this.inVrMode = false; } } } @Override protected void onDeactivate() { try { final IVrManager vrManager = this.vrManager; if (vrManager != null) { vrManager.unregisterListener((IVrStateCallbacks)this.vrStateCallbacks); } } catch (RemoteException ex) { Log.e("Columbus/VrMode", "Could not unregister IVrManager listener", (Throwable)ex); this.inVrMode = false; } } }
6cc9f32360265d378de789cd23d435601085a3b5
20eb62855cb3962c2d36fda4377dfd47d82eb777
/IntroClassJava/dataset/grade/95362737dcd262ddd67b0fe1381c25f1e6b885860b4e51efb6f57223dceb77b4c6c7d855e3fe891c10cd51b48c9b052cf2c74f181a28d3020d77a4a2d6e4db18/014/mutations/8/grade_95362737_014.java
5f03b0fba668080c9abf55073bae88dc0944e2ef
[]
no_license
ozzydong/CapGen
356746618848065cce4e253e5d3c381baa85044a
0ba0321b6b1191443276021f1997833342f02515
refs/heads/master
2023-03-18T20:12:02.923428
2020-08-21T03:08:28
2020-08-21T03:08:28
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,501
java
package introclassJava; class IntObj { public int value; public IntObj () { } public IntObj (int i) { value = i; } } class FloatObj { public float value; public FloatObj () { } public FloatObj (float i) { value = i; } } class LongObj { public long value; public LongObj () { } public LongObj (long i) { value = i; } } class DoubleObj { public double value; public DoubleObj () { } public DoubleObj (double i) { value = i; } } class CharObj { public char value; public CharObj () { } public CharObj (char i) { value = i; } } public class grade_95362737_014 { public java.util.Scanner scanner; public String output = ""; public static void main (String[]args) throws Exception { grade_95362737_014 mainClass = new grade_95362737_014 (); String output; if (args.length > 0) { mainClass.scanner = new java.util.Scanner (args[0]); } else { mainClass.scanner = new java.util.Scanner (System.in); } mainClass.exec (); System.out.println (mainClass.output); } public void exec () throws Exception { FloatObj a = new FloatObj (), b = new FloatObj (), c = new FloatObj (), d = new FloatObj (), score = new FloatObj (); output += (String.format ("Enter thresholds for A, B, C, D\nin that order, decreasing percentages > ")); a.value = scanner.nextFloat (); b.value = scanner.nextFloat (); c.value = scanner.nextFloat (); d.value = scanner.nextFloat (); output += (String.format ("Thank you. Now enter student score (percent) >")); score.value = scanner.nextFloat (); if (score.value >= a.value) { output += (String.format ("Student has a A grade\n")); } if (score.value >= b.value && score.value < a.value) { output += (String.format ("Student has a B grade\n")); } if (score.value >= c.value && score.value < b.value) { output += (String.format ("Student has a C grade\n")); } if (score.value >= d.value && score.value < c.value) { output += (String.format ("Student has a D grade\n")); } if (score.value < a.value) { output += (String.format ("Student has failed the course\n")); } if (true) return;; } }
fc93770b75014e189c77d5187abead0c7e0d7083
c1b25858868550f657a43f05b684ad4fff5efbfc
/src/main/java/com/gitlab/martinpiz097/htmlbuilder/html/types/HTMLContentElement.java
924172e3cf86fc8af7ae2c7689337ce6663a4abd
[ "Apache-2.0" ]
permissive
martinpiz097/htmlbuilder
83eaa58f4836c6d1abe8cdd316bf6aa8f80618bf
e45417613fb3942b25eae58ed5865180491f2762
refs/heads/master
2020-04-05T22:35:28.682453
2018-11-03T17:30:57
2018-11-03T17:30:57
157,261,582
0
0
null
null
null
null
UTF-8
Java
false
false
1,419
java
package com.gitlab.martinpiz097.htmlbuilder.html.types; import com.gitlab.martinpiz097.htmlbuilder.html.interfaces.HtmlDrawable; import java.util.ArrayList; public class HTMLContentElement extends HTMLElement { protected String content; public HTMLContentElement(String name) { this(name, null, null); } public HTMLContentElement(String name, HTMLElement parent, String content) { super(name, parent); this.content = content; } public HTMLContentElement(String name, String content) { this(name, null, content); } public boolean hasContent() { return content != null; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } @Override public String draw() { StringBuilder sbHtml = new StringBuilder(); sbHtml.append('<').append(name); appendAttributes(sbHtml); sbHtml.append(">"); if (content != null) sbHtml.append('\n').append(content).append('\n'); else if (listChilds.size() > 0) { sbHtml.append('\n'); for (int i = 0; i < listChilds.size(); i++) sbHtml.append(listChilds.get(i).draw()); sbHtml.append('\n'); } sbHtml.append("</").append(name).append(">\n"); return sbHtml.toString(); } }
1a27b388a78d198c97724b58cd4923ad6661e1af
d6657c06cc07322407395a973d4d2e4164d2ef97
/StartSpringBootWithThemleaf/src/main/java/springboot/demo/service/AccountService.java
b08e4cc7f9fedaefbfb42ef9613a91a3ad8a8bc4
[]
no_license
HongTQ/SpringBoot
dbbc902b3777d5d81af48861b829bfa2cd4ad908
2981213b56a1400da1ef1256ff56039864748477
refs/heads/master
2020-12-06T20:12:59.906211
2020-01-10T11:41:32
2020-01-10T11:41:32
232,542,719
0
0
null
2020-01-08T11:09:46
2020-01-08T10:55:53
Java
UTF-8
Java
false
false
434
java
package springboot.demo.service; import java.util.List; import java.util.Optional; import springboot.demo.entity.Account; public interface AccountService { public List<Account> findAll(); Optional<Account> findById(int id); Account addAccount(Account account); void deleteAccount(int id); Account loadAccountByName(String accountName); Boolean checkLogin(Account account); Account updateAccount(int id, Account account); }
d5b804069b949b777879a3ea3d0ee6d30628640c
28242589932d730d7bec680a900842370f23c3ce
/app/src/main/java/com/example/constanza/tingoidapp/api/model/PromoDetalleBody.java
857fc5938b4201cec2941152ae3d37fac4ba157c
[]
no_license
cperezadasme/TingoID
0b4aa026dc8a361ee8f177dffd57688d5acefbf4
9bb89920008ee78f90cd6d88e53becc5f14ee067
refs/heads/master
2021-01-01T18:31:15.780918
2017-11-08T19:33:04
2017-11-08T19:33:48
98,353,587
0
0
null
null
null
null
UTF-8
Java
false
false
304
java
package com.example.constanza.tingoidapp.api.model; public class PromoDetalleBody { private String id_avance; private String id_promocion; public PromoDetalleBody(String id_avance, String id_promocion) { this.id_avance = id_avance; this.id_promocion = id_promocion; } }
549266648dfb989c70fa177109bd205091ec55d8
01f1b51b236363bbe1538affb91a741a00de8df9
/src/main/java/am/itspace/springdemo/service/BookService.java
469f30a5bde5149fdd689f84bfe90ecd39657c52
[]
no_license
mrkaren/spring-demo
8a68265232fa3a358fbdaff099718577a2bcac64
0e51506ba34655fff6087039df5f3847e1b55544
refs/heads/master
2022-11-30T10:48:37.223681
2020-08-12T19:13:56
2020-08-12T19:13:56
278,937,562
0
0
null
2020-07-22T19:15:34
2020-07-11T20:33:54
Java
UTF-8
Java
false
false
620
java
package am.itspace.springdemo.service; import am.itspace.springdemo.model.Book; import am.itspace.springdemo.repository.BookRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.util.Optional; @Service @RequiredArgsConstructor public class BookService { private final BookRepository bookRepository; public void save(Book book) { bookRepository.save(book); } public Optional<Book> findOne(int id) { return bookRepository.findById(id); } public void deleteById(int id) { bookRepository.deleteById(id); } }
290ee09d020b7449eee61e40bfe5da19d555533b
7b82d70ba5fef677d83879dfeab859d17f4809aa
/_part2/durcframework-core.demo/src/main/java/durcframework/test/student/controller/StringController.java
d13a9cbbefd02987cac8c054776b916533be5b24
[]
no_license
apollowesley/jun_test
fb962a28b6384c4097c7a8087a53878188db2ebc
c7a4600c3f0e1b045280eaf3464b64e908d2f0a2
refs/heads/main
2022-12-30T20:47:36.637165
2020-10-13T18:10:46
2020-10-13T18:10:46
null
0
0
null
null
null
null
UTF-8
Java
false
false
404
java
package durcframework.test.student.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class StringController { @RequestMapping(value="listString",produces="text/plain") public @ResponseBody String listString() { return "hello,世界"; } }
5281382ef6af962aca23f878a32b09b9fc0eb85d
9f44158dcca8578d7cf49d0ad5f100e7d69dad6a
/src/main/java/com/pree/dao/SugarLevelDao.java
6828c68edd6c2bcd70c3d880b28be2f2c079b2e7
[]
no_license
preenair86/BloodSugarSimulator
07047dc087cecef90271ad68f3c2971b4dc4f0bc
894ab6f6cf3295a676c30ffa3ca8a7af2ea374f4
refs/heads/master
2021-01-22T23:15:58.833101
2015-06-29T17:36:23
2015-06-29T17:36:23
38,127,189
0
0
null
2015-07-14T05:29:51
2015-06-26T18:31:02
Java
UTF-8
Java
false
false
3,965
java
package com.pree.dao; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVRecord; import org.joda.time.LocalTime; import com.pree.service.SugarLevelFactor; public class SugarLevelDao { private static final String FOOD_DB="FoodDB.csv"; private static final String EXERCISE_DB="ExerciseDB.csv"; private LocalTime startTime; private LocalTime endTime; private float listTimeStep; private float displayTimeStep; private List<SugarLevelFactor> foodDB; private List<SugarLevelFactor> exerciseDB; public SugarLevelDao() { startTime = new LocalTime(7, 0); endTime = new LocalTime(22, 0); // In minutes listTimeStep = 30.0f; displayTimeStep = 1.0f; loadFoodDB(); loadExerciseDB(); } private void loadFoodDB() { foodDB = new ArrayList<SugarLevelFactor>(); Reader in = null; Iterable<CSVRecord> records = null; try { ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource(FOOD_DB).getFile()); in = new FileReader(file); } catch (FileNotFoundException e) { e.printStackTrace(); } try { records = CSVFormat.EXCEL.withHeader().parse(in); } catch (IOException e) { e.printStackTrace(); } for (CSVRecord record : records) { SugarLevelFactor currentFactor = new SugarLevelFactor(); currentFactor.setName(record.get("Name")); currentFactor.setRate(Integer.parseInt(record.get("Glycemic Index"))); currentFactor.setDoesIncrease(true); currentFactor.setDuration(120.0f); foodDB.add(currentFactor); } } private void loadExerciseDB() { exerciseDB = new ArrayList<SugarLevelFactor>(); Reader in = null; Iterable<CSVRecord> records = null; try { ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource(EXERCISE_DB).getFile()); in = new FileReader(file); } catch (FileNotFoundException e) { e.printStackTrace(); } try { records = CSVFormat.EXCEL.withHeader().parse(in); } catch (IOException e) { e.printStackTrace(); } for (CSVRecord record : records) { SugarLevelFactor currentFactor = new SugarLevelFactor(); currentFactor.setName(record.get("Exercise")); currentFactor.setRate(Integer.parseInt(record.get("Exercise Index"))); currentFactor.setDoesIncrease(false); currentFactor.setDuration(60.0f); exerciseDB.add(currentFactor); } } // TODO(preenair): Move this logic to service layer. public List<String> getFoodList() { List<String> output = new ArrayList<String>(); for(SugarLevelFactor f : foodDB) { output.add(f.getName()); } return output; } public List<String> getExerciseList() { List<String> output = new ArrayList<String>(); for(SugarLevelFactor f : exerciseDB) { output.add(f.getName()); } return output; } public Map<String, SugarLevelFactor> getNameToFactor() { Map<String, SugarLevelFactor> nameToFactor = new HashMap<String, SugarLevelFactor>(); for(SugarLevelFactor f : foodDB) { nameToFactor.put(f.getName(), f); } for(SugarLevelFactor f : exerciseDB) { nameToFactor.put(f.getName(), f); } return nameToFactor; } public float getListTimeStep() { return listTimeStep; } public void setListTimeStep(float listTimeStep) { this.listTimeStep = listTimeStep; } public float getDisplayTimeStep() { return displayTimeStep; } public void setDisplayTimeStep(float displayTimeStep) { this.displayTimeStep = displayTimeStep; } public LocalTime getStartTime() { return startTime; } public void setStartTime(LocalTime startTime) { this.startTime = startTime; } public LocalTime getEndTime() { return endTime; } public void setEndTime(LocalTime endTime) { this.endTime = endTime; } }
021a5304063ad80232741892b5690a009a612b14
c7f8221de49bfc2b6c28fcd34c833f96658e9a0b
/src/main/java/rustichromia/block/BlockSnakeFluid.java
c72b725d8e4c6dd92619d19aa85f6a7f45c499eb
[ "MIT" ]
permissive
DaedalusGame/Heterorustichromia
9276330ce3e35a787a0a489207e6512f51c29162
f32893b1a7fc7a4b0116e4dbbd5d165663299d02
refs/heads/master
2021-07-14T21:23:28.470907
2020-07-11T11:13:44
2020-07-11T11:13:44
185,208,292
1
2
MIT
2020-07-11T11:13:45
2019-05-06T14:01:49
Java
UTF-8
Java
false
false
9,915
java
package rustichromia.block; import net.minecraft.block.Block; import net.minecraft.block.material.EnumPushReaction; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import rustichromia.handler.PistonHandler; import rustichromia.util.DimensionPos; import rustichromia.util.SnakeFluidHelper; import javax.annotation.Nullable; import java.util.*; public abstract class BlockSnakeFluid extends Block { private static final int MOVE = 1; private static final int DELETED = 2; protected ThreadLocal<Boolean> harvesting = ThreadLocal.withInitial(() -> false); private Map<DimensionPos, Integer> checkSet = new HashMap<>(); private List<SnakeFluidHelper> runningHelpers = new ArrayList<>(); private static Material material = new Material(MapColor.WHITE_STAINED_HARDENED_CLAY) { @Override public EnumPushReaction getMobilityFlag() { return EnumPushReaction.DESTROY; } @Override public boolean isLiquid() { return true; } }; public static final PropertyInteger TRAIL = PropertyInteger.create("trail", 0, 15); public boolean isHead(IBlockState state) { return state.getValue(TRAIL) == 0; } public boolean isTail(IBlockState state) { return state.getValue(TRAIL) > 0; } public BlockSnakeFluid(MapColor blockMapColorIn) { super(material, blockMapColorIn); setDefaultState(getDefaultState().withProperty(TRAIL, 0)); setTickRandomly(true); MinecraftForge.EVENT_BUS.register(this); } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public boolean isFullCube(IBlockState state) { return false; } @Nullable @Override public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { return NULL_AABB; } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, TRAIL); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(TRAIL); } @Override public int tickRate(World worldIn) { return getDecayTime(); } public int getDecayTime() { return 1; } public int getTrailLength() { return 15; } @Override public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(TRAIL, meta); } @Override public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) { return isTail(worldIn.getBlockState(pos)); } public abstract boolean canFlowInto(World world, BlockPos pos, IBlockState state, EnumFacing direction); public abstract boolean canPushInto(World world, BlockPos pos, IBlockState state, EnumFacing direction); public boolean couldFlowInto(World world, BlockPos pos, IBlockState state, EnumFacing direction) { return canFlowInto(world, pos, state, direction) || state.getBlock() == this; } @Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) worldIn.scheduleUpdate(pos, this, isHead(state) ? 1 : getDecayTime()); //worldIn.updateBlockTick(pos,this, isHead(state) ? 1 : 10,0); } @Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { if (!worldIn.isRemote) worldIn.scheduleUpdate(pos, this, isHead(state) ? 1 : getDecayTime()); } @Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (isHead(state)) tryFlow(worldIn, pos); else { int trailCount = state.getValue(TRAIL) + 1; if (trailCount > getTrailLength()) worldIn.setBlockToAir(pos); else worldIn.setBlockState(pos, state.withProperty(TRAIL, trailCount)); } } private void tryFlow(World world, BlockPos pos) { BlockPos downPos = pos.down(); IBlockState downState = world.getBlockState(downPos); if (canFlowInto(world, downPos, downState, EnumFacing.DOWN)) { flow(world, pos, downPos, EnumFacing.DOWN); } else if (!world.isRemote) { checkSet.put(new DimensionPos(pos, world.provider.getDimension()), MOVE); } } public boolean flow(World world, BlockPos from, BlockPos to, EnumFacing direction) { IBlockState fromState = world.getBlockState(from); world.setBlockState(to, fromState); world.setBlockState(from, fromState.withProperty(TRAIL, 1)); world.scheduleUpdate(from, this, getDecayTime()); return true; } public boolean push(World world, BlockPos from, BlockPos to, EnumFacing direction) { world.setBlockState(to, getDefaultState()); return true; } public abstract void settle(World world, BlockPos pos); public abstract void explode(World world, BlockPos pos, EnumFacing pushFacing); public int getMaxDistance() { return 128; } @Override public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) { if (isHead(state) && !worldIn.isRemote) checkSet.put(new DimensionPos(pos, worldIn.provider.getDimension()), DELETED); } @Override public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) { harvesting.set(true); super.harvestBlock(worldIn, player, pos, state, te, stack); harvesting.set(false); } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { //if(isHead(state)) // checkSet.put(new DimensionPos(pos,worldIn.provider.getDimension()),DELETED); } @SubscribeEvent public void onTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.END) { int cost = 0; for (Map.Entry<DimensionPos, Integer> entry : checkSet.entrySet()) { BlockPos pos = entry.getKey().getPos(); int dimension = entry.getKey().getDimension(); int type = entry.getValue(); switch (type) { case MOVE: runningHelpers.add(new SnakeFluidHelper(entry.getKey(), this)); break; case DELETED: EnumFacing pushFacing = PistonHandler.getPushDirection(entry.getKey()); cost += tryPush(pos, dimension, pushFacing); break; } } checkSet.clear(); HashSet<DimensionPos> helperPositions = new HashSet<>(); Iterator<SnakeFluidHelper> iterator = runningHelpers.iterator(); while (iterator.hasNext() && cost < 10000) { SnakeFluidHelper helper = iterator.next(); if (helperPositions.contains(helper)) { iterator.remove(); break; } helperPositions.add(helper.getPos()); cost += helper.calculate(); if (helper.isDone()) { helper.solve(); iterator.remove(); } } } } private int tryPush(BlockPos pos, int dimension, EnumFacing pushFacing) { World world = DimensionManager.getWorld(dimension); if (pushFacing != null && canPushInto(world, pos.offset(pushFacing), world.getBlockState(pos.offset(pushFacing)), pushFacing)) { push(world, pos, pos.offset(pushFacing), pushFacing); //world.setBlockState(pos.offset(pushFacing),getDefaultState()); return 1; } else { boolean done = false; if (canPushInto(world, pos.down(), world.getBlockState(pos.down()), EnumFacing.DOWN)) { push(world, pos, pos.down(), EnumFacing.DOWN); done = true; } if (!done) for (EnumFacing facing : EnumFacing.HORIZONTALS) { if (canPushInto(world, pos.offset(facing), world.getBlockState(pos.offset(facing)), facing)) { push(world, pos, pos.offset(facing), facing); done = true; break; } } if (!done && canPushInto(world, pos.up(), world.getBlockState(pos.up()), EnumFacing.UP)) { push(world, pos, pos.up(), EnumFacing.UP); done = true; } if (!done) { //Explode explode(world, pos, pushFacing); } return 10; } } @Override public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { return BlockFaceShape.UNDEFINED; } }
e48e06fb3a8858cee95123050b27add2667c17bb
9a58308f6f2bbddf34da16de7c48002b78a1edf2
/wmxfx/src/com/darna/wmxfx/utils/FragmentTabHost.java
159f09758b0e4791af2448f66b161ebfe0e46904
[]
no_license
PiemonJ/Baelish
a384ebba381b0c73589c6b8da3d5fed986564673
05d4246a422d236fde50dd742b8aa402f604cbfc
refs/heads/master
2021-01-12T05:18:16.240372
2016-07-26T01:26:58
2016-07-26T01:26:58
null
0
0
null
null
null
null
UTF-8
Java
false
false
11,841
java
package com.darna.wmxfx.utils; import java.util.ArrayList; import android.content.Context; import android.content.res.TypedArray; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TabHost; import android.widget.TabWidget; /** * Special TabHost that allows the use of {@link Fragment} objects for * its tab content. When placing this in a view hierarchy, after inflating * the hierarchy you must call {@link #setup(Context, FragmentManager, int)} * to complete the initialization of the tab host. * * <p>Here is a simple example of using a FragmentTabHost in an Activity: * * {@sample development/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.java * complete} * * <p>This can also be used inside of a fragment through fragment nesting: * * {@sample development/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabsFragmentSupport.java * complete} */ public class FragmentTabHost extends TabHost implements TabHost.OnTabChangeListener { private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); private FrameLayout mRealTabContent; private Context mContext; private FragmentManager mFragmentManager; private int mContainerId; private TabHost.OnTabChangeListener mOnTabChangeListener; private TabInfo mLastTab; private boolean mAttached; static final class TabInfo { private final String tag; private final Class<?> clss; private final Bundle args; private Fragment fragment; TabInfo(String _tag, Class<?> _class, Bundle _args) { tag = _tag; clss = _class; args = _args; } } static class DummyTabFactory implements TabHost.TabContentFactory { private final Context mContext; public DummyTabFactory(Context context) { mContext = context; } @Override public View createTabContent(String tag) { View v = new View(mContext); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; } } static class SavedState extends BaseSavedState { String curTab; SavedState(Parcelable superState) { super(superState); } private SavedState(Parcel in) { super(in); curTab = in.readString(); } @Override public void writeToParcel(Parcel out, int flags) { super.writeToParcel(out, flags); out.writeString(curTab); } @Override public String toString() { return "FragmentTabHost.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " curTab=" + curTab + "}"; } public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() { public SavedState createFromParcel(Parcel in) { return new SavedState(in); } public SavedState[] newArray(int size) { return new SavedState[size]; } }; } public FragmentTabHost(Context context) { // Note that we call through to the version that takes an AttributeSet, // because the simple Context construct can result in a broken object! super(context, null); initFragmentTabHost(context, null); } public FragmentTabHost(Context context, AttributeSet attrs) { super(context, attrs); initFragmentTabHost(context, attrs); } private void initFragmentTabHost(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0); mContainerId = a.getResourceId(0, 0); a.recycle(); super.setOnTabChangedListener(this); } private void ensureHierarchy(Context context) { // If owner hasn't made its own view hierarchy, then as a convenience // we will construct a standard one here. if (findViewById(android.R.id.tabs) == null) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); addView(ll, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); TabWidget tw = new TabWidget(context); tw.setId(android.R.id.tabs); tw.setOrientation(TabWidget.HORIZONTAL); ll.addView(tw, new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0)); FrameLayout fl = new FrameLayout(context); fl.setId(android.R.id.tabcontent); ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0)); mRealTabContent = fl = new FrameLayout(context); mRealTabContent.setId(mContainerId); ll.addView(fl, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, 0, 1)); } } /** * @deprecated Don't call the original TabHost setup, you must instead * call {@link #setup(Context, FragmentManager)} or * {@link #setup(Context, FragmentManager, int)}. */ @Override @Deprecated public void setup() { throw new IllegalStateException( "Must call setup() that takes a Context and FragmentManager"); } public void setup(Context context, FragmentManager manager) { ensureHierarchy(context); // Ensure views required by super.setup() super.setup(); mContext = context; mFragmentManager = manager; ensureContent(); } public void setup(Context context, FragmentManager manager, int containerId) { ensureHierarchy(context); // Ensure views required by super.setup() super.setup(); mContext = context; mFragmentManager = manager; mContainerId = containerId; ensureContent(); mRealTabContent.setId(containerId); // We must have an ID to be able to save/restore our state. If // the owner hasn't set one at this point, we will set it ourself. if (getId() == View.NO_ID) { setId(android.R.id.tabhost); } } private void ensureContent() { if (mRealTabContent == null) { mRealTabContent = (FrameLayout)findViewById(mContainerId); if (mRealTabContent == null) { throw new IllegalStateException( "No tab content FrameLayout found for id " + mContainerId); } } } @Override public void setOnTabChangedListener(OnTabChangeListener l) { mOnTabChangeListener = l; } public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) { tabSpec.setContent(new DummyTabFactory(mContext)); String tag = tabSpec.getTag(); TabInfo info = new TabInfo(tag, clss, args); if (mAttached) { // If we are already attached to the window, then check to make // sure this tab's fragment is inactive if it exists. This shouldn't // normally happen. info.fragment = mFragmentManager.findFragmentByTag(tag); if (info.fragment != null && !info.fragment.isDetached()) { FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.detach(info.fragment); ft.commit(); } } mTabs.add(info); addTab(tabSpec); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); String currentTab = getCurrentTabTag(); // Go through all tabs and make sure their fragments match // the correct state. FragmentTransaction ft = null; for (int i=0; i<mTabs.size(); i++) { TabInfo tab = mTabs.get(i); tab.fragment = mFragmentManager.findFragmentByTag(tab.tag); if (tab.fragment != null && !tab.fragment.isDetached()) { if (tab.tag.equals(currentTab)) { // The fragment for this tab is already there and // active, and it is what we really want to have // as the current tab. Nothing to do. mLastTab = tab; } else { // This fragment was restored in the active state, // but is not the current tab. Deactivate it. if (ft == null) { ft = mFragmentManager.beginTransaction(); } ft.detach(tab.fragment); } } } // We are now ready to go. Make sure we are switched to the // correct tab. mAttached = true; ft = doTabChanged(currentTab, ft); if (ft != null) { ft.commit(); mFragmentManager.executePendingTransactions(); } } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mAttached = false; } @Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); ss.curTab = getCurrentTabTag(); return ss; } @Override protected void onRestoreInstanceState(Parcelable state) { SavedState ss = (SavedState)state; super.onRestoreInstanceState(ss.getSuperState()); setCurrentTabByTag(ss.curTab); } @Override public void onTabChanged(String tabId) { if (mAttached) { FragmentTransaction ft = doTabChanged(tabId, null); if (ft != null) { ft.commit(); } } if (mOnTabChangeListener != null) { mOnTabChangeListener.onTabChanged(tabId); } } private FragmentTransaction doTabChanged(String tabId, FragmentTransaction ft) { TabInfo newTab = null; for (int i=0; i<mTabs.size(); i++) { TabInfo tab = mTabs.get(i); if (tab.tag.equals(tabId)) { newTab = tab; } } if (newTab == null) { throw new IllegalStateException("No tab known for tag " + tabId); } if (mLastTab != newTab) { if (ft == null) { ft = mFragmentManager.beginTransaction(); } if (mLastTab != null) { if (mLastTab.fragment != null) { //将detach替换为hide,隐藏Fragment ft.detach(mLastTab.fragment); //ft.hide(mLastTab.fragment); } } if (newTab != null) { if (newTab.fragment == null) { newTab.fragment = Fragment.instantiate(mContext, newTab.clss.getName(), newTab.args); ft.add(mContainerId, newTab.fragment, newTab.tag); } else { //将attach替换为show,显示Fragment ft.attach(newTab.fragment); //ft.show(newTab.fragment); } } mLastTab = newTab; } return ft; } }
434b18ba3e9f7627f2f12a7e03c2667d92e8356e
50425d18343509b2fe08ec6c6500855b4bcc46be
/flink-statebackend-heap-spillable/src/main/java/org/apache/flink/runtime/state/heap/estimate/ValueStateMemoryEstimator.java
fa051eaa47c845308cc9cca2886f2a9a3a44b281
[ "Apache-2.0" ]
permissive
mathwyz/flink-spillable-statebackend
8d8ad4012decaf02cbebf61462fcece216fc47e3
cbe0bc08d1f3dc8d5d764517d5cc07fcf1c16559
refs/heads/master
2022-06-06T03:22:00.047402
2020-04-30T16:19:06
2020-04-30T16:20:36
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,731
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.flink.runtime.state.heap.estimate; import org.apache.flink.api.common.state.ValueState; import org.apache.flink.api.common.typeutils.TypeSerializer; /** * Estimates memory usage of {@link ValueState}. * * @param <K> type of key * @param <N> type of namespace * @param <V> type of state */ public class ValueStateMemoryEstimator<K, N, V> extends AbstractStateMemoryEstimator<K, N, V> { private boolean isStateFix; private long stateSize; public ValueStateMemoryEstimator( TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer, TypeSerializer<V> valueSerializer) { super(keySerializer, namespaceSerializer); this.isStateFix = valueSerializer.getLength() != -1; this.stateSize = -1; } @Override protected long getStateSize(V state) { if (stateSize == -1 || !isStateFix) { this.stateSize = RamUsageEstimator.sizeOf(state); } return this.stateSize; } }
9f8cca5b325f7fa409a62a42e0daf0de75abc807
fdf26ac89756de1c5ea0fae05b149d4be3281a92
/osiris-faces/src/main/java/com/osiris/component/bootstrap/menu/UISubMenu.java
ad2e769155e5363b359bbbc6c33b15dff75a5212
[ "Apache-2.0" ]
permissive
ocrisurbainski/osiris-faces
ebf862541b3655bfcbc61d9761bb16999470211d
a05d634b07fb9c81506cf287e1a13683e8399dcc
refs/heads/master
2022-06-21T18:24:55.532198
2014-01-12T11:51:38
2014-01-12T11:51:38
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,535
java
package com.osiris.component.bootstrap.menu; import java.util.ArrayList; import java.util.List; import javax.el.ValueExpression; import javax.faces.application.ResourceDependencies; import javax.faces.application.ResourceDependency; import javax.faces.component.FacesComponent; import javax.faces.component.UIPanel; /** * * Classe que representa um component de sub-menu. * * @author Cristian Urbainski<[email protected]> * @since 13/07/2013 * @version 1.0 * */ @ResourceDependencies({ @ResourceDependency(library = "javax.faces", name = "jsf.js"), @ResourceDependency(library = "primefaces", name = "jquery/jquery.js"), @ResourceDependency(library = "primefaces", name = "primefaces.js"), @ResourceDependency(library = "js", name = "bootstrap.min.js"), @ResourceDependency(library = "modal", name = "modal.js"), @ResourceDependency(library = "css", name = "bootstrap.min.css"), @ResourceDependency(library = "css", name = "menu.css") }) @FacesComponent(value = UISubMenu.COMPONENT_TYPE) public class UISubMenu extends UIPanel { /** * Tipo do componente. */ public static final String COMPONENT_TYPE = "com.osiris.component.bootstrap.SubMenu"; /** * Familia do componente. */ public static final String COMPONENT_FAMILY = "com.osiris.component.bootstrap"; /** * Renderizador padrão do componente. */ private static final String DEFAULT_RENDERER = "com.osiris.component.bootstrap.SubMenuRenderer"; /** * Pacote otimizado do componente. */ private static final String OPTIMIZED_PACKAGE = "com.osiris.component.bootstrap."; /** * Classe interna para definição dos parametros da classe. * * @author Cristian Urbainski * @since 18/07/2013 * @version 1.0 * */ protected enum PropertyKeys { /** * label que sera mostrado. */ label, /** * Estilo css no componente. */ style, /** * Classe de estilo do componente. */ styleClass; /** * Valor que será retornado. */ private String toString; /** * Construtor default do componente. * @param toString valor da string */ PropertyKeys(String toString) { this.toString = toString; } /** * Construtor default do componente. */ PropertyKeys() { } /** * Método que retorna o toString da string interna. * @return toString da string interna */ public String toString() { return ((this.toString != null) ? this.toString : super.toString()); } } /** * Construtor padrão do compoente. */ public UISubMenu() { setRendererType(DEFAULT_RENDERER); } public String getFamily() { return COMPONENT_FAMILY; } /** * Set do label. * @param label */ public void setLabel(java.lang.String label) { getStateHelper().put(PropertyKeys.label, label); handleAttribute("label", label); } public java.lang.String getLabel() { return (java.lang.String) getStateHelper().eval(PropertyKeys.label, null); } public java.lang.String getStyle() { return (java.lang.String) getStateHelper().eval(PropertyKeys.style, null); } /** * Set do style. * @param style */ public void setStyle(java.lang.String style) { getStateHelper().put(PropertyKeys.style, style); handleAttribute("style", style); } public java.lang.String getStyleClass() { return (java.lang.String) getStateHelper().eval(PropertyKeys.styleClass, null); } /** * Set do styleClass. * @param styleClass */ public void setStyleClass(java.lang.String styleClass) { getStateHelper().put(PropertyKeys.styleClass, styleClass); handleAttribute("styleClass", styleClass); } /** * Método hanfleAttributes copiado do primefaces. * * @param name nome * @param value objeto */ @SuppressWarnings("unchecked") public void handleAttribute(String name, Object value) { List<String> setAttributes = (List<String>) this.getAttributes().get("javax.faces.component.UIComponentBase.attributesThatAreSet"); if (setAttributes == null) { String cname = this.getClass().getName(); if (cname != null && cname.startsWith(OPTIMIZED_PACKAGE)) { setAttributes = new ArrayList<String>(Integer.parseInt("6")); this.getAttributes().put("javax.faces.component.UIComponentBase.attributesThatAreSet", setAttributes); } } if (setAttributes != null) { if (value == null) { ValueExpression ve = getValueExpression(name); if (ve == null) { setAttributes.remove(name); } else if (!setAttributes.contains(name)) { setAttributes.add(name); } } } } }
cc7a1bef7c3cf5117814c4cbadb70dd579a128a8
8b0aa83e66987385fc85dff9d37b5ad37e4a677a
/src/lesson11/exceptions/exceptions/io/IOExample.java
b3797fbce145ba850aea074cadcb22724c614a86
[]
no_license
vsPoputnikov/lessons
dd92d8eeb502d534ea958bd359efc35d7b430c49
04968735070c10d2ee6f5f1d7651a794140b9cb7
refs/heads/master
2020-04-27T10:06:48.707523
2019-05-09T12:00:40
2019-05-09T12:00:40
174,240,583
2
0
null
null
null
null
UTF-8
Java
false
false
4,325
java
package lesson11.exceptions.exceptions.io; import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils; import java.io.*; import java.nio.charset.Charset; import java.util.Arrays; public class IOExample { /* try{ } */ // IO| NIO // IO API public static void main(String[] args) { // Работают с байтами // InputStream // OutputStream // Работают с char // Reader // Writer File file = new File("src/file.txt"); try { readByte(file); } catch (IOException e){ e.printStackTrace(); } /*try { long l = readByte(file); } catch (IOException e){ e.printStackTrace(); } try { writeToFile("src/file.txt", true, Charset.forName("UTF-8")); } catch (IOException e){ e.printStackTrace(); }*/ } public static long readByte(File file)throws IOException{ //FileInputStream long summ=0; try(FileInputStream inputStream = new FileInputStream(file)){ System.out.println(inputStream.available()); while(inputStream.available()>0){ int data = inputStream.read(); summ+=data; System.out.println((char)data); } System.out.println(summ); return summ; } } public static void writeToFile(String fileName, boolean append, Charset charset) throws IOException { // FileOutputStream Нужно закрывать либо в try() try (FileOutputStream outputStream = new FileOutputStream(fileName, append)) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 6; i++) { sb.append("line ").append(i).append("\n"); } byte[] bytes = sb.toString().getBytes(charset); outputStream.write(bytes); } } public static void readByteArray(File file, Charset charset) throws IOException { try(FileInputStream fileInputStream = new FileInputStream(file); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream() ){ byte[] buff = new byte[10]; int len; while ((len = fileInputStream.read(buff))>0){ System.out.println(Arrays.toString(buff)); byteArrayOutputStream.write(buff,0,len); } System.out.println(Arrays.toString(byteArrayOutputStream.toByteArray())); System.out.println(new String(byteArrayOutputStream.toByteArray(),charset)); } } public static void writeWithBuffer(File file)throws IOException{ // Декоратор try (FileOutputStream fileOutputStream = new FileOutputStream(file); BufferedOutputStream outputStream = new BufferedOutputStream(fileOutputStream) ){ StringBuilder sb = new StringBuilder(); for (int i = 0; i < 6; i++) { sb.append("line ").append(i).append("\n"); } byte[] buffer = sb.toString().getBytes(); outputStream.write(buffer,0, buffer.length); } } public static void readFromSeveralFiles(File[] files, Charset charset)throws IOException{ try ( FileInputStream inputStream1 = new FileInputStream(files[0]); FileInputStream inputStream2 = new FileInputStream(files[1]); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream() ){ SequenceInputStream sequenceInputStream = new SequenceInputStream(inputStream1,inputStream2); byte[] buf = new byte[1024]; int len; while((len = sequenceInputStream.read(buf))>0){ byteArrayOutputStream.write(buf,0,len); } } } public static String readChar(InputStream in, Charset charset)throws IOException{ InputStreamReader reader = new InputStreamReader(in); char[] buf = new char[128]; int len = buf.length; StringBuilder sb = new StringBuilder(); while ((len - reader.read(buf))>0){ sb.append(buf,0,len); } return sb.toString(); } }
e50e88c8729c24419f1f73b54a5261dc7af5fe73
dcaed125dddbff8c6465e651961af846a8160381
/app/src/main/java/com/jk/jkproject/net/im/info/PushGame.java
c50821d32a378d786f2ad4791ab455ef5833a248
[]
no_license
guoshilun/live
7bc582c99775b3a1a3570fb04a6b5228606a2864
f8dbb9458792e1727dee4f8ecf3661b1ec58391b
refs/heads/main
2023-02-24T10:51:06.311063
2021-01-28T03:36:14
2021-01-28T03:36:14
null
0
0
null
null
null
null
UTF-8
Java
false
true
22,101
java
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: PushGame.proto package com.jk.jkproject.net.im.info; public final class PushGame { private PushGame() {} public static void registerAllExtensions( com.google.protobuf.ExtensionRegistryLite registry) { } public static void registerAllExtensions( com.google.protobuf.ExtensionRegistry registry) { registerAllExtensions( (com.google.protobuf.ExtensionRegistryLite) registry); } public interface PushGameMessageOrBuilder extends // @@protoc_insertion_point(interface_extends:proto.PushGameMessage) com.google.protobuf.MessageOrBuilder { /** * <pre> *正面压注总数量 * </pre> * * <code>optional int32 front = 2;</code> */ int getFront(); /** * <pre> *反面压注总数量 * </pre> * * <code>optional int32 contrary = 3;</code> */ int getContrary(); /** * <pre> *最大竞猜数量 * </pre> * * <code>optional int32 maxBet = 4;</code> */ int getMaxBet(); /** * <pre> * 当前倒计时时间 * </pre> * * <code>optional int32 time = 8;</code> */ int getTime(); } /** * Protobuf type {@code proto.PushGameMessage} */ public static final class PushGameMessage extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:proto.PushGameMessage) PushGameMessageOrBuilder { // Use PushGameMessage.newBuilder() to construct. private PushGameMessage(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { super(builder); } private PushGameMessage() { front_ = 0; contrary_ = 0; maxBet_ = 0; time_ = 0; } @Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } private PushGameMessage( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { this(); int mutable_bitField0_ = 0; try { boolean done = false; while (!done) { int tag = input.readTag(); switch (tag) { case 0: done = true; break; default: { if (!input.skipField(tag)) { done = true; } break; } case 16: { front_ = input.readInt32(); break; } case 24: { contrary_ = input.readInt32(); break; } case 32: { maxBet_ = input.readInt32(); break; } case 64: { time_ = input.readInt32(); break; } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(this); } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException( e).setUnfinishedMessage(this); } finally { makeExtensionsImmutable(); } } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return PushGame.internal_static_proto_PushGameMessage_descriptor; } protected FieldAccessorTable internalGetFieldAccessorTable() { return PushGame.internal_static_proto_PushGameMessage_fieldAccessorTable .ensureFieldAccessorsInitialized( PushGame.PushGameMessage.class, PushGame.PushGameMessage.Builder.class); } public static final int FRONT_FIELD_NUMBER = 2; private int front_; /** * <pre> *正面压注总数量 * </pre> * * <code>optional int32 front = 2;</code> */ public int getFront() { return front_; } public static final int CONTRARY_FIELD_NUMBER = 3; private int contrary_; /** * <pre> *反面压注总数量 * </pre> * * <code>optional int32 contrary = 3;</code> */ public int getContrary() { return contrary_; } public static final int MAXBET_FIELD_NUMBER = 4; private int maxBet_; /** * <pre> *最大竞猜数量 * </pre> * * <code>optional int32 maxBet = 4;</code> */ public int getMaxBet() { return maxBet_; } public static final int TIME_FIELD_NUMBER = 8; private int time_; /** * <pre> * 当前倒计时时间 * </pre> * * <code>optional int32 time = 8;</code> */ public int getTime() { return time_; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; } public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (front_ != 0) { output.writeInt32(2, front_); } if (contrary_ != 0) { output.writeInt32(3, contrary_); } if (maxBet_ != 0) { output.writeInt32(4, maxBet_); } if (time_ != 0) { output.writeInt32(8, time_); } } public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (front_ != 0) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(2, front_); } if (contrary_ != 0) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(3, contrary_); } if (maxBet_ != 0) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(4, maxBet_); } if (time_ != 0) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(8, time_); } memoizedSize = size; return size; } private static final long serialVersionUID = 0L; @Override public boolean equals(final Object obj) { if (obj == this) { return true; } if (!(obj instanceof PushGame.PushGameMessage)) { return super.equals(obj); } PushGame.PushGameMessage other = (PushGame.PushGameMessage) obj; boolean result = true; result = result && (getFront() == other.getFront()); result = result && (getContrary() == other.getContrary()); result = result && (getMaxBet() == other.getMaxBet()); result = result && (getTime() == other.getTime()); return result; } @Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); hash = (37 * hash) + FRONT_FIELD_NUMBER; hash = (53 * hash) + getFront(); hash = (37 * hash) + CONTRARY_FIELD_NUMBER; hash = (53 * hash) + getContrary(); hash = (37 * hash) + MAXBET_FIELD_NUMBER; hash = (53 * hash) + getMaxBet(); hash = (37 * hash) + TIME_FIELD_NUMBER; hash = (53 * hash) + getTime(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; } public static PushGame.PushGameMessage parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static PushGame.PushGameMessage parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static PushGame.PushGameMessage parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static PushGame.PushGameMessage parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static PushGame.PushGameMessage parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } public static PushGame.PushGameMessage parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input, extensionRegistry); } public static PushGame.PushGameMessage parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input); } public static PushGame.PushGameMessage parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static PushGame.PushGameMessage parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } public static PushGame.PushGameMessage parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input, extensionRegistry); } public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } public static Builder newBuilder(PushGame.PushGameMessage prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } public Builder toBuilder() { return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); } @Override protected Builder newBuilderForType( BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /** * Protobuf type {@code proto.PushGameMessage} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements // @@protoc_insertion_point(builder_implements:proto.PushGameMessage) PushGame.PushGameMessageOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return PushGame.internal_static_proto_PushGameMessage_descriptor; } protected FieldAccessorTable internalGetFieldAccessorTable() { return PushGame.internal_static_proto_PushGameMessage_fieldAccessorTable .ensureFieldAccessorsInitialized( PushGame.PushGameMessage.class, PushGame.PushGameMessage.Builder.class); } // Construct using PushGame.PushGameMessage.newBuilder() private Builder() { maybeForceBuilderInitialization(); } private Builder( BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); } private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessageV3 .alwaysUseFieldBuilders) { } } public Builder clear() { super.clear(); front_ = 0; contrary_ = 0; maxBet_ = 0; time_ = 0; return this; } public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return PushGame.internal_static_proto_PushGameMessage_descriptor; } public PushGame.PushGameMessage getDefaultInstanceForType() { return PushGame.PushGameMessage.getDefaultInstance(); } public PushGame.PushGameMessage build() { PushGame.PushGameMessage result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } public PushGame.PushGameMessage buildPartial() { PushGame.PushGameMessage result = new PushGame.PushGameMessage(this); result.front_ = front_; result.contrary_ = contrary_; result.maxBet_ = maxBet_; result.time_ = time_; onBuilt(); return result; } public Builder clone() { return (Builder) super.clone(); } public Builder setField( com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { return (Builder) super.setField(field, value); } public Builder clearField( com.google.protobuf.Descriptors.FieldDescriptor field) { return (Builder) super.clearField(field); } public Builder clearOneof( com.google.protobuf.Descriptors.OneofDescriptor oneof) { return (Builder) super.clearOneof(oneof); } public Builder setRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, int index, Object value) { return (Builder) super.setRepeatedField(field, index, value); } public Builder addRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, Object value) { return (Builder) super.addRepeatedField(field, value); } public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof PushGame.PushGameMessage) { return mergeFrom((PushGame.PushGameMessage)other); } else { super.mergeFrom(other); return this; } } public Builder mergeFrom(PushGame.PushGameMessage other) { if (other == PushGame.PushGameMessage.getDefaultInstance()) return this; if (other.getFront() != 0) { setFront(other.getFront()); } if (other.getContrary() != 0) { setContrary(other.getContrary()); } if (other.getMaxBet() != 0) { setMaxBet(other.getMaxBet()); } if (other.getTime() != 0) { setTime(other.getTime()); } onChanged(); return this; } public final boolean isInitialized() { return true; } public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { PushGame.PushGameMessage parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (PushGame.PushGameMessage) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; } private int front_ ; /** * <pre> *正面压注总数量 * </pre> * * <code>optional int32 front = 2;</code> */ public int getFront() { return front_; } /** * <pre> *正面压注总数量 * </pre> * * <code>optional int32 front = 2;</code> */ public Builder setFront(int value) { front_ = value; onChanged(); return this; } /** * <pre> *正面压注总数量 * </pre> * * <code>optional int32 front = 2;</code> */ public Builder clearFront() { front_ = 0; onChanged(); return this; } private int contrary_ ; /** * <pre> *反面压注总数量 * </pre> * * <code>optional int32 contrary = 3;</code> */ public int getContrary() { return contrary_; } /** * <pre> *反面压注总数量 * </pre> * * <code>optional int32 contrary = 3;</code> */ public Builder setContrary(int value) { contrary_ = value; onChanged(); return this; } /** * <pre> *反面压注总数量 * </pre> * * <code>optional int32 contrary = 3;</code> */ public Builder clearContrary() { contrary_ = 0; onChanged(); return this; } private int maxBet_ ; /** * <pre> *最大竞猜数量 * </pre> * * <code>optional int32 maxBet = 4;</code> */ public int getMaxBet() { return maxBet_; } /** * <pre> *最大竞猜数量 * </pre> * * <code>optional int32 maxBet = 4;</code> */ public Builder setMaxBet(int value) { maxBet_ = value; onChanged(); return this; } /** * <pre> *最大竞猜数量 * </pre> * * <code>optional int32 maxBet = 4;</code> */ public Builder clearMaxBet() { maxBet_ = 0; onChanged(); return this; } private int time_ ; /** * <pre> * 当前倒计时时间 * </pre> * * <code>optional int32 time = 8;</code> */ public int getTime() { return time_; } /** * <pre> * 当前倒计时时间 * </pre> * * <code>optional int32 time = 8;</code> */ public Builder setTime(int value) { time_ = value; onChanged(); return this; } /** * <pre> * 当前倒计时时间 * </pre> * * <code>optional int32 time = 8;</code> */ public Builder clearTime() { time_ = 0; onChanged(); return this; } public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return this; } public final Builder mergeUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return this; } // @@protoc_insertion_point(builder_scope:proto.PushGameMessage) } // @@protoc_insertion_point(class_scope:proto.PushGameMessage) private static final PushGame.PushGameMessage DEFAULT_INSTANCE; static { DEFAULT_INSTANCE = new PushGame.PushGameMessage(); } public static PushGame.PushGameMessage getDefaultInstance() { return DEFAULT_INSTANCE; } private static final com.google.protobuf.Parser<PushGameMessage> PARSER = new com.google.protobuf.AbstractParser<PushGameMessage>() { public PushGameMessage parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return new PushGameMessage(input, extensionRegistry); } }; public static com.google.protobuf.Parser<PushGameMessage> parser() { return PARSER; } @Override public com.google.protobuf.Parser<PushGameMessage> getParserForType() { return PARSER; } public PushGame.PushGameMessage getDefaultInstanceForType() { return DEFAULT_INSTANCE; } } private static final com.google.protobuf.Descriptors.Descriptor internal_static_proto_PushGameMessage_descriptor; private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_proto_PushGameMessage_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; } private static com.google.protobuf.Descriptors.FileDescriptor descriptor; static { String[] descriptorData = { "\n\016PushGame.proto\022\005proto\032\014Entity.proto\"P\n" + "\017PushGameMessage\022\r\n\005front\030\002 \001(\005\022\020\n\010contr" + "ary\030\003 \001(\005\022\016\n\006maxBet\030\004 \001(\005\022\014\n\004time\030\010 \001(\005B" + " \n\036com.sencorsta.ids.common.protob\006proto" + "3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { public com.google.protobuf.ExtensionRegistry assignDescriptors( com.google.protobuf.Descriptors.FileDescriptor root) { descriptor = root; return null; } }; com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { Entity.getDescriptor(), }, assigner); internal_static_proto_PushGameMessage_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_proto_PushGameMessage_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_proto_PushGameMessage_descriptor, new String[] { "Front", "Contrary", "MaxBet", "Time", }); Entity.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) }
29012e582c4a7b812be29b52132d09c5ec91915f
beb4ea93e0279a02f1af9b78450b5f9b3bcc4595
/lesson5bai2.java
e5ed4287f8e0afe9eb71ead5ab5a0d6cb49e9f61
[]
no_license
datnt0801/BTVNlesson5
a1dc2cfb57323fe19d93bc88588e40ad5cf7ffed
a2bccd07b4c90742b33c0e7c1d616346b7836961
refs/heads/main
2023-05-09T23:00:18.166048
2021-05-30T09:03:19
2021-05-30T09:03:19
372,168,377
0
0
null
null
null
null
UTF-8
Java
false
false
1,109
java
public class lesson5bai2 { public static void main(String[] args) { System.out.println(thor(12)); System.out.println(Fibo(6)); } public static void swap(int a, int b) { a = a + b; b = a - b; a = a - b; } public static int thor(int n) { int de = 0; int hold = 0; int tholon = 0; int thocon = 1; for (int i = 0; i < n - 1; i++) { int decu = de; int holdcu = hold; int tholoncu = tholon; int thoconcu = thocon; hold = tholoncu + decu; tholon = thoconcu; de = holdcu; thocon = decu; System.out.println(de); System.out.println(hold); System.out.println(tholon); System.out.println(thocon); System.out.println("vong thu " + i); } return de + tholon + thocon + hold; } public static int Fibo(int n) { if (n == 1 || n == 2) return 1; return Fibo(n - 1) + Fibo(n - 2); } }
7683711afd12b7f41f8a73f006662135315c07a2
e77593485fac0daee74c25c668d97424b8dd1f8b
/MatchingPro/src/main/java/com/project/MatchingPro/test/ResponseDto.java
17cfc77c3d8000905a4f8115c4ea38c1e44ddf77
[]
no_license
myeongsu-ko/MatchingProject2
de9ec487a7c238b04658555a12b3d86051b0b3df
71b7480989f921d5e5d4caf9f0ccfe66fc706b08
refs/heads/main
2023-01-02T00:00:24.089985
2020-10-26T02:16:05
2020-10-26T02:16:05
307,241,586
0
0
null
2020-10-26T02:29:36
2020-10-26T02:29:36
null
UTF-8
Java
false
false
308
java
package com.project.MatchingPro.test; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @Data @Builder @NoArgsConstructor @AllArgsConstructor public class ResponseDto { private String errorCode; private String errorMsg; private Object data; }
e26bab09e0cab22c143135653b6fe43be8cd076c
b564793ea33b9d8d9abf2908adb3acb745e69373
/src/main/java/com/company/bpmdemor1/BpmStudioDemoR1Application.java
e029fe3f916a5f00b4c9e2f5390a5800f25128c6
[]
no_license
jmix-projects/bpm-studio-demo-r1
1a729ec2f678141ccf611531bc1a8cac2d7783ba
ab725f6a3b200ec039c91c028b65177f7b240c7c
refs/heads/main
2023-06-08T01:51:31.853084
2021-07-02T13:45:03
2021-07-02T13:45:03
378,841,349
0
0
null
null
null
null
UTF-8
Java
false
false
1,672
java
package com.company.bpmdemor1; import com.google.common.base.Strings; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.event.ApplicationStartedEvent; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.context.event.EventListener; import org.springframework.core.env.Environment; import javax.sql.DataSource; @SpringBootApplication public class BpmStudioDemoR1Application { @Autowired private Environment environment; public static void main(String[] args) { SpringApplication.run(BpmStudioDemoR1Application.class, args); } @Bean @Primary @ConfigurationProperties("main.datasource") DataSourceProperties dataSourceProperties() { return new DataSourceProperties(); } @Bean @Primary @ConfigurationProperties("main.datasource.hikari") DataSource dataSource(DataSourceProperties dataSourceProperties) { return dataSourceProperties.initializeDataSourceBuilder().build(); } @EventListener public void printApplicationUrl(ApplicationStartedEvent event) { LoggerFactory.getLogger(BpmStudioDemoR1Application.class).info("Application started at " + "http://localhost:" + environment.getProperty("local.server.port") + Strings.nullToEmpty(environment.getProperty("server.servlet.context-path"))); } }
8c8ff0be6b44ce198df44b55bb0dbfa01f1fd339
bf9651c5a24035b21d4656d673a7abebed8bfad9
/sms_admin/src/main/java/com/stxy/smsadmin/service/demoservice/DemoService.java
5496d3e83a2690de143a1cbb51ebfe22dcf54ec6
[]
no_license
caoxiaowei414/parent_project
6443c2ad727acb7e464320f2ce20d5a25d04611e
687a0d5d213fc50da1ce69b08e01b1b59c81892f
refs/heads/master
2020-04-03T12:15:00.558459
2018-10-30T00:27:04
2018-10-30T00:27:04
155,246,053
0
0
null
null
null
null
UTF-8
Java
false
false
104
java
package com.stxy.smsadmin.service.demoservice; public interface DemoService { Object demoGet(); }
b6866be7396ea553f33465b3497959c8e9b9ac5b
87d0c7488d275326869e41a3695562d859bfd502
/src/com/william/demo/jdon/jserver/application/Connection.java
202761a44600c94f78c72d89a0f77a3ea0b5cb4c
[]
no_license
javazoom/WilliamDemo
a6a2d16b2a6c1a928c4611821927a65074de1209
00083b9f630f8bb2aa728dd311dbf0132d3982fc
refs/heads/master
2021-01-23T13:17:43.908289
2013-06-09T07:09:28
2013-06-09T07:09:28
7,778,362
0
1
null
null
null
null
UTF-8
Java
false
false
3,829
java
package com.william.demo.jdon.jserver.application; import com.william.demo.jdon.jserver.connector.queue.MessageQueue; import com.william.demo.jdon.jserver.connector.data.*; import com.william.demo.jdon.jserver.application.connection.ConnectionFactory; import com.william.demo.jdon.util.Debug; /** * 连接接口,需要发送和接受数据时,使用本类。 * 从ConnectionFactory获得本类实例。 * <p>Copyright: Jdon.com Copyright (c) 2003</p> * <p>Company: 上海解道计算机技术有限公司</p> * @author banq * @version 1.0 */ public abstract class Connection { private final static String module = Connection.class.getName(); /** * 连接Queue */ protected MessageQueue queue = null; /** * 服务器端还是客户端连接模式 */ protected int CSType; /** * 写入Object * @param obj * @throws Exception */ public void writeObject(Object obj) throws Exception { if (!isConnect()) throw new Exception("not connected"); try { QueueWorker worker = new QueueAddWorker(queue); ObjectType ot = new ObjectType(getWriteMsgType()); ot.setContent(obj); ot.accpet(worker); } catch (Exception ex) { Debug.logError("TcpConnection writeObject error:" + ex, module); throw new Exception(ex); } } /** * 读取Object * @return Object * @throws Exception */ public Object readObject() throws Exception { if (!isConnect()) throw new Exception("not connected"); try { QueueWorker worker = new QueueTakeWorker(queue); ObjectType ot = new ObjectType(getReadMsgType()); ot.accpet(worker); return ot.getContent(); } catch (Exception ex) { Debug.logError("TcpConnection writeObject error:" + ex, module); throw new Exception(ex); } } /** * 写入字符串 * @param msg * @throws Exception */ public void writeString(String msg) throws Exception { if (!isConnect()) throw new Exception("not connected"); try { QueueWorker worker = new QueueAddWorker(queue); StringType st = new StringType(getWriteMsgType()); st.setContent(msg); st.accpet(worker); } catch (Exception ex) { Debug.logError("TcpConnection writeString error:" + ex, module); throw new Exception(ex); } } /** * 读取字符串 * @return String * @throws Exception */ public String readString() throws Exception { if (!isConnect()) throw new Exception("not connected"); try { QueueWorker worker = new QueueTakeWorker(queue); StringType st = new StringType(getReadMsgType()); st.accpet(worker); return st.getContent(); } catch (Exception ex) { Debug.logError("TcpConnection writeObject error:" + ex, module); throw new Exception(ex); } } /** * 根据是服务器应用还是客户端应用,设置写入Queue中的信息类型 * 是request 还是response * @return */ public int getWriteMsgType() { if (CSType == ConnectionFactory.CLIENT) return QueueWorker.REQUEST; else return QueueWorker.RESPONSE; } /** * 根据是服务器应用还是客户端应用,设置从Queue中读取的信息类型 * 是request 还是response * @return */ public int getReadMsgType() { if (CSType == ConnectionFactory.CLIENT) return QueueWorker.RESPONSE; else return QueueWorker.REQUEST; } /** * 打开连接 * @param url * @param port * @throws Exception */ public abstract void open(String url, int port) throws Exception; /** * 关闭连接 * @throws Exception */ public abstract void close() throws Exception; /** * 是否连接 * @return * @throws Exception */ public abstract boolean isConnect() throws Exception; }
eac2b87747309803d648e488fa89d42b23953aba
5a8440c04879543f75bec7dd0f689aa88c5daae1
/src/main/java/com/cu/service/impl/ResultServiceImpl.java
6c5b00aa0308bbfa158035c45f5458a2f296732b
[]
no_license
yangjzh888/development
6411bd08dd74feb3084838f36978df3e6cc2d173
fd662cf387a62c0fe5081979a248486e317f39cc
refs/heads/master
2021-08-30T19:04:15.800690
2017-12-18T03:14:28
2017-12-18T03:14:28
114,712,484
0
0
null
2017-12-19T03:02:11
2017-12-19T03:02:11
null
UTF-8
Java
false
false
11,493
java
package com.cu.service.impl; import com.cu.dao.ContentKeyDao; import com.cu.dao.ProblemDao; import com.cu.dao.ProcessKeyDao; import com.cu.dao.ResultDao; import com.cu.model.*; import com.cu.service.ResultService; import org.apache.poi.hssf.usermodel.*; import org.apache.poi.ss.usermodel.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * 结果表业务逻辑实现类 * * @authur Zyq * @create 2017/9/27. */ @Service public class ResultServiceImpl implements ResultService { @Autowired private ResultDao resultDao; @Autowired private ContentKeyDao contentKeyDao; @Autowired private ProblemDao problemDao; @Autowired private ProcessKeyDao processKeyDao; @Override public List<Result> setResult(List<BalkBasic> balkList,int year,int month) { List<Result> resultList = new ArrayList<>(16); for (int i = 0; i < balkList.size(); i++) { BalkBasic balkBasic = balkList.get(i); Result result = new Result(); StringBuffer introTemp = new StringBuffer();//用于整合一个受理单下所有工单的处理过程 result.setUser_id(0);//todo: 缺少动态获取userid的session方法,待添加 result.setType("受理单");//todo 还未知受理单类型如何查询,待添加 result.setBalk_no(balkBasic.getBalk_no()); //受理单号 result.setBalk_content(balkBasic.getBalk_content()); //申告内容 result.setWrite_dept_name("网管中心.交换中心"); //填写部门 result.setWrite_time(Integer.toString(year)+"-"+(month<10?"0"+Integer.toString(month):Integer.toString(month))); for (int j = 0; j < balkBasic.getSheetProcList().size(); j++) { SheetProc sheetProc = balkBasic.getSheetProcList().get(j); introTemp.append(sheetProc.getIntro()); introTemp.append(" "); } String intro = introTemp.toString(); result.setIntro(intro); resultList.add(result); } return resultList; } @Override public List<Result> setResult(List<BalkBasic> balkList, String search_time) { List<Result> resultList = new ArrayList<>(16); for (int i = 0; i < balkList.size(); i++) { BalkBasic balkBasic = balkList.get(i); List<SheetProc> sheetProcList = balkBasic.getSheetProcList(); for (int j = 0; j < sheetProcList.size(); j++) { Result result = new Result(); //将查询结果存入实例中 result.setUser_id(0);//todo: 缺少动态获取userid的session方法,待添加 result.setType("受理单");//todo 还未知受理单类型如何查询,待添加 result.setBalk_no(balkBasic.getBalk_no()); //受理单号 result.setBalk_content(balkBasic.getBalk_content()); //申告内容 result.setContent_key(balkBasic.getContent_key()); //申告内容关键字 result.setProc_key(balkBasic.getProc_key()); //处理过程关键字 result.setWrite_dept_name("网管中心.交换中心"); //填写部门 result.setIntro(sheetProcList.get(j).getIntro()); resultList.add(result); } } return resultList; } @Override public void insertResult(List<Result> resultList) { resultDao.insertResult(resultList); } @Override public List<String> searchTimeList() { return resultDao.searchTimeList(); } @Override public List<Result> queryBySearchTime(String search_time) { return resultDao.queryBySearchTime(search_time); } @Override public List<Result> queryByProblem(String[] problems) { return resultDao.queryByProblem(problems); } @Override public List<Result> queryByContentKey(String content_key) { return resultDao.queryByContentKey(content_key); } @Override public List<Result> queryByWriteTime(String write_time) { return resultDao.queryByWriteTime(write_time); } @Override public HSSFWorkbook writeResultExcel(List<Result> resultList) { String[] header = {"序号", "类型", "受理单号", "申告内容", "填写部门", "填写内容", "申告内容关键字", "处理过程关键字", "故障现象", "故障原因"}; //创建workbook (excel) HSSFWorkbook wb = new HSSFWorkbook(); //首先创建字体样式 HSSFFont font1 = wb.createFont();//创建header字体样式 font1.setFontName("微软雅黑");//使用宋体 font1.setFontHeightInPoints((short) 10);//字体大小 font1.setBold(true);//加粗 HSSFFont font2 = wb.createFont();//创建数据行字体样式 font2.setFontName("宋体"); font2.setFontHeightInPoints((short) 10); //设置header单元格样式 HSSFCellStyle style1 = wb.createCellStyle(); style1.setFont(font1);//将字体注入 //style1.setWrapText(true);// 自动换行 style1.setAlignment(HorizontalAlignment.CENTER);//居中 style1.setVerticalAlignment(VerticalAlignment.CENTER);// 水平居中 style1.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.index);// 设置单元格的背景颜色(亮黄色) style1.setFillPattern(FillPatternType.SOLID_FOREGROUND); style1.setBorderTop(BorderStyle.THIN);// 边框的大小 style1.setBorderBottom(BorderStyle.THIN); style1.setBorderLeft(BorderStyle.THIN); style1.setBorderRight(BorderStyle.THIN); //设置数据单元格样式 HSSFCellStyle style2 = wb.createCellStyle(); style2.setFont(font2); //style2.setWrapText(true);//自动换行 style2.setAlignment(HorizontalAlignment.LEFT);//居左 style2.setVerticalAlignment(VerticalAlignment.CENTER);//水平居中 style2.setFillForegroundColor(IndexedColors.WHITE.index);//背景色(白色) style2.setFillPattern(FillPatternType.SOLID_FOREGROUND); style2.setBorderTop(BorderStyle.THIN);// 边框的大小 style2.setBorderBottom(BorderStyle.THIN); style2.setBorderLeft(BorderStyle.THIN); style2.setBorderRight(BorderStyle.THIN); //创建excel的sheet HSSFSheet sheet = wb.createSheet(); //设置列的默认宽度 sheet.setDefaultColumnWidth(15); //设置header内容 HSSFRow row = sheet.createRow(0); for (int i = 0; i < header.length; i++) { HSSFCell cell = row.createCell(i); cell.setCellStyle(style1); HSSFRichTextString text = new HSSFRichTextString(header[i]); cell.setCellValue(text); } //遍历resultList存入excel int rownum = 1;//数据行从第二行开始 for (Result result : resultList) { row = sheet.createRow(rownum); List<String> rs = new ArrayList<>(); rs.add(String.valueOf(rownum));//序号 rs.add(result.getType());//类型 rs.add(result.getBalk_no());//受理单号 rs.add(result.getBalk_content());//申告内容 rs.add(result.getWrite_dept_name());//填写部门 rs.add(result.getIntro());//填写内容(处理过程) rs.add(result.getContent_key());//申告内容关键字 rs.add(result.getProc_key());//处理过程关键字 rs.add(result.getProblem());//故障现象 rs.add(result.getReason());//故障原因 for (int i = 0; i < rs.size(); i++) { HSSFCell cell = row.createCell(i); cell.setCellStyle(style2); HSSFRichTextString richTextString = new HSSFRichTextString(rs.get(i)); cell.setCellValue(richTextString); } rownum++; } return wb; } @Override public void tagResult() { //1.给resultList打申告内容关键字和故障现象的标签 List<ContentKey> contentKeyList = contentKeyDao.queryAllOrderByPriority(); for (ContentKey aContentKeyList : contentKeyList) { //为result从高到低的优先级打标签 String contentKey = aContentKeyList.getContent_key(); //contentKeyTemp:经过处理后的申告内容关键字 String contentKeyTemp = contentKey.replaceAll("&", "%' )AND( balk_content LIKE '%"); contentKeyTemp = contentKeyTemp.replaceAll("或", "%' OR balk_content LIKE '%"); List<Result> resultList = resultDao.queryByContentKey(contentKeyTemp); //查找含有contentkey的受理单 //problemId:故障现象id 用于标记故障现象 int problemId = aContentKeyList.getProblem_id(); Problem problem = problemDao.queryById(problemId); //根据contentKey对应的problemid 查找对应的故障现象 //contentkeyid:用于查询对应的处理过程 List<String> balkNoListForContent = new ArrayList<>(16); if (resultList == null || resultList.size() == 0) { continue; } for (Result result : resultList) { //为contentkey和problem字段为空的行打上标签 if ((result.getContent_key() == null || result.getContent_key().equals("")) && (result.getProblem() == null || result.getProblem().equals(""))) { //result.setContent_key(contentKey); balkNoListForContent.add(result.getBalk_no()); } } if (balkNoListForContent.size() != 0 && problem !=null) { resultDao.updateContentKeyAndProblem(contentKey, problem.getProblem(), balkNoListForContent); } else { continue; } //2.给resultList打处理过程关键字和故障原因标签 int contentKeyId = aContentKeyList.getContent_key_id(); List<ProcessKey> processKeyList = processKeyDao.queryAllByPriority(contentKeyId); for (ProcessKey aProcessKeyList : processKeyList) { String reason = aProcessKeyList.getReason(); String processKey = aProcessKeyList.getProcess_key(); String processKeyTemp = processKey.replaceAll("&", "%' )AND( intro LIKE '%"); processKeyTemp = processKeyTemp.replaceAll("或", "%' OR intro LIKE '%"); List<Result> resultList1 = resultDao.queryByProcessKey(balkNoListForContent, processKeyTemp); List<String> balkNoListForProcess = new ArrayList<>(16); if (resultList1 == null || resultList1.size() == 0) { continue; } for (Result result : resultList1) { if ((result.getProc_key() == null || result.getProc_key().equals("")) && (result.getReason() == null || result.getReason().equals(""))) { balkNoListForProcess.add(result.getBalk_no()); } } if (balkNoListForProcess.size() != 0 && reason !=null) { resultDao.updateProcessKeyAndReason(processKey, reason, balkNoListForProcess); } } } //todo null-->other } }
2bebcc112393fa94eb5c12edc9320e45a0a34f1b
7b341143a6c93d983d355f921e23c17ec23dd080
/src/main/java/com/kh/dok/movie/model/vo/CancelData.java
606067df982af30df3ceea465a39271ac58b4526
[]
no_license
ijoo3419/dok_GV
5720b5b86703675eeeb1a2a42e6b072a4f3d5d0a
ee642179c9d24ac08c68f1c9391d07fd6571ff97
refs/heads/master
2020-03-29T01:21:26.748962
2018-12-26T02:19:04
2018-12-26T02:19:04
149,385,037
0
0
null
2018-12-26T02:19:05
2018-09-19T03:08:40
Java
UTF-8
Java
false
false
1,216
java
package com.kh.dok.movie.model.vo; import java.math.BigDecimal; import com.google.gson.annotations.SerializedName; public class CancelData { @SerializedName("imp_uid") private String imp_uid; @SerializedName("merchant_uid") private String merchant_uid; @SerializedName("amount") private BigDecimal amount; @SerializedName("reason") private String reason; @SerializedName("refund_holder") private String refund_holder; @SerializedName("refund_bank") private String refund_bank; @SerializedName("refund_account") private String refund_account; public CancelData(String uid, boolean imp_uid_or_not) { if ( imp_uid_or_not ) { this.imp_uid = uid; } else { this.merchant_uid = uid; } } public CancelData(String uid, boolean imp_uid_or_not, BigDecimal amount) { this(uid, imp_uid_or_not); this.amount = amount; } public void setReason(String reason) { this.reason = reason; } public void setRefund_holder(String refund_holder) { this.refund_holder = refund_holder; } public void setRefund_bank(String refund_bank) { this.refund_bank = refund_bank; } public void setRefund_account(String refund_account) { this.refund_account = refund_account; } }
[ "Park@DESKTOP-TMP4IH6" ]
Park@DESKTOP-TMP4IH6
90fe028826782b3cdd5f1e6f5a968026df1269f9
a6e2cd9ea01bdc5cfe58acce25627786fdfe76e9
/src/main/java/com/alipay/api/domain/KoubeiCraftsmanDataProviderBatchqueryModel.java
db22f577175f9473e85cfff998209e0ffbcc906e
[ "Apache-2.0" ]
permissive
cc-shifo/alipay-sdk-java-all
38b23cf946b73768981fdeee792e3dae568da48c
938d6850e63160e867d35317a4a00ed7ba078257
refs/heads/master
2022-12-22T14:06:26.961978
2020-09-23T04:00:10
2020-09-23T04:00:10
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,230
java
package com.alipay.api.domain; import java.util.List; import com.alipay.api.AlipayObject; import com.alipay.api.internal.mapping.ApiField; import com.alipay.api.internal.mapping.ApiListField; /** * 手艺人信息批量查询接口 * * @author auto create * @since 1.0, 2020-06-18 11:57:42 */ public class KoubeiCraftsmanDataProviderBatchqueryModel extends AlipayObject { private static final long serialVersionUID = 2547391661343818125L; /** * 服务商、服务商员工、商户、商户员工等口碑角色操作时必填,对应为 koubei.member.data.oauth.query 中的 auth_code,默认有效期24小时;ISV自身角色操作的时候,无需传该参数 */ @ApiField("auth_code") private String authCode; /** * 手艺人id (如果传入craftsman_ids,会忽略其他参数:注意,不能与shop_id同时为空),以数组方式传值 */ @ApiListField("craftsman_ids") @ApiField("string") private List<String> craftsmanIds; /** * 手艺人外部id(如果没有传craftsman_ids,传了craftsman_external_ids,会忽略其他参数,注意,不能与shop_id 同时为空) */ @ApiListField("out_craftsman_ids") @ApiField("string") private List<String> outCraftsmanIds; /** * 页码,大于0,最大为int的最大值 */ @ApiField("page_no") private String pageNo; /** * 每页的条数,大于0,最大不超过100条 */ @ApiField("page_size") private String pageSize; /** * 手艺人码对应的门店,只有指定了码门店字段,才会返回手艺人码信息 */ @ApiField("qr_code_shop_id") private String qrCodeShopId; /** * 是否推荐 (true 返回在c端展示的手艺人,false 返回c端隐藏的手艺人,不传表示不过滤) */ @ApiField("recommend") private Boolean recommend; /** * 口碑门店id(不能与craftsman_ids和out_craftsman_ids同时为空) */ @ApiField("shop_id") private String shopId; public String getAuthCode() { return this.authCode; } public void setAuthCode(String authCode) { this.authCode = authCode; } public List<String> getCraftsmanIds() { return this.craftsmanIds; } public void setCraftsmanIds(List<String> craftsmanIds) { this.craftsmanIds = craftsmanIds; } public List<String> getOutCraftsmanIds() { return this.outCraftsmanIds; } public void setOutCraftsmanIds(List<String> outCraftsmanIds) { this.outCraftsmanIds = outCraftsmanIds; } public String getPageNo() { return this.pageNo; } public void setPageNo(String pageNo) { this.pageNo = pageNo; } public String getPageSize() { return this.pageSize; } public void setPageSize(String pageSize) { this.pageSize = pageSize; } public String getQrCodeShopId() { return this.qrCodeShopId; } public void setQrCodeShopId(String qrCodeShopId) { this.qrCodeShopId = qrCodeShopId; } public Boolean getRecommend() { return this.recommend; } public void setRecommend(Boolean recommend) { this.recommend = recommend; } public String getShopId() { return this.shopId; } public void setShopId(String shopId) { this.shopId = shopId; } }
5762e268090140aef9d17e6c13896caee11261ae
4741e849359e6e1b3350c2f7e4f1c1358860b61c
/Server/src/main/java/org/openas2/cmd/CommandRegistry.java
e2c3ca95f1ee7f9e768d2a0445b23814ba5bc682
[ "BSD-2-Clause" ]
permissive
OpenAS2/OpenAs2App
ce489278f492107bb5dd5b80663cdbd091cb1438
f9bc602382467d3f88d619f0ed4a8efaed974913
refs/heads/master
2023-08-17T12:04:57.187007
2023-08-15T09:57:27
2023-08-15T09:57:27
39,078,691
163
154
BSD-2-Clause
2023-09-12T18:48:07
2015-07-14T14:12:02
Java
UTF-8
Java
false
false
171
java
package org.openas2.cmd; import org.openas2.Component; import java.util.List; public interface CommandRegistry extends Component { List<Command> getCommands(); }
fdae4ec166154f9c9994fce4d82d640f19782204
415160260b0c6519ec4938a2219af621b51f956d
/app/src/main/java/com/example/lgw/mqtt1/adapter/MyRecyclerViewAdapter.java
8ee33911276dfe4109df367be3d8e618850f6e22
[]
no_license
liubryant/mqtt1
4e915a94ca4d6b3ea4c58f663c11ad212dce2162
d622d191dce90e3717f3725723d7943d0d6082d9
refs/heads/master
2022-06-24T06:06:45.450110
2020-05-01T15:42:42
2020-05-01T15:42:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,243
java
package com.example.lgw.mqtt1.adapter; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.example.lgw.mqtt1.R; import java.util.ArrayList; //设置RecyclerView的适配器 public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewAdapter.MyViewHolder> { private final Context context; private ArrayList<String> datas; public MyRecyclerViewAdapter(Context context, ArrayList<String> datas) { this.context=context; this.datas=datas; } /** * 相当于getView方法中创建View和ViewHolder * @param parent * @param viewType * @return */ @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView=View.inflate(context, R.layout.item_brand,null); return new MyViewHolder(itemView); } /** * 相当于getView方法中的绑定 * view的绑定 * @param holder * @param position */ @Override public void onBindViewHolder(MyViewHolder holder, int position) { //根据位置得到对应数据 String data=datas.get(position); holder.tv_brand.setText(data); } /** * 得到总条数 * @return */ @Override public int getItemCount() { return datas.size(); } // /** // * 添加数据 // * @param position // * @param data // */ // public void addData(int position, String data) { // datas.add(position,data); // /** // * 刷新适配器 // */ // notifyItemInserted(position); // } // // public void removeData(int position) { // datas.remove(position); // /** // * 刷新适配器 // */ // notifyItemRemoved(position); // } class MyViewHolder extends RecyclerView.ViewHolder{ private TextView tv_brand; public MyViewHolder(View itemView) { super(itemView); tv_brand=(TextView) itemView.findViewById(R.id.tv_brand); itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Toast.makeText(context, "data=="+datas.get(getLayoutPosition()), Toast.LENGTH_SHORT).show(); if (onItemClickListener!=null){ onItemClickListener.OnItemClick(view,datas.get(getLayoutPosition())); } } }); } } /** * 点击RecyclerView的某条的监听 */ public interface OnItemClickListener{ /** * 当RecyclerView某个被点击的时候回调 * @param view 点击item的视图 * @param data 点击得到的数据 */ public void OnItemClick(View view, String data); } public OnItemClickListener onItemClickListener; /** * 设置RecyclerView某个的监听 * @param onItemClickListener */ public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } }
96ddeb2f568cfa3ead6f0635c0941aa59579740a
65ec9467b9c0c53a69f5066ed898d7e725313e0e
/src/main/java/com/switchfully/eurder/service/ItemService.java
43814a6234d8e2ffc75bcd618f201273526066a4
[]
no_license
pelinyvg/eurder
4bcdec7493ef8985e962aa879b4559de69343129
c7e8594df96a7efec732811d8debf8b2e1f082c3
refs/heads/master
2023-03-29T15:17:18.993888
2021-04-08T07:02:57
2021-04-08T07:02:57
352,912,002
0
0
null
null
null
null
UTF-8
Java
false
false
1,030
java
package com.switchfully.eurder.service; import com.switchfully.eurder.domain.items.Item; import com.switchfully.eurder.domain.items.ItemRepository; import com.switchfully.eurder.infrastructure.util.ValidationUtil; import org.springframework.stereotype.Service; import java.util.List; import java.util.UUID; @Service public class ItemService { private final ItemRepository repository; public ItemService(ItemRepository repository) { this.repository = repository; } public void createItem(Item item) { repository.saveItem(item); } public Item getItemById(UUID id) { Item item = repository.getItemById(id); if (ValidationUtil.isNull(item)) { throw new IllegalArgumentException("No item found!"); } return item; } public void updateItem(UUID id, Item item) { repository.updateItem(id, item); } public List<Item> getOverviewItems(Integer filter) { return repository.getItemsByStockAvailability(filter); } }
4eb9590fa313eb84712675469f4b5fa75d503b1e
e8ad23168e4e04f4a494887dde16e3ec0225c897
/src/main/java/redis/clients/redisson/eviction/EvictionScheduler.java
d95feb80320b932e505a5293807694eee5e67137
[ "Apache-2.0" ]
permissive
qq1588518/JRediClients
4f057fcbf06ddfa19f840dc909e120dabd46580a
ef6fa0ab7c9d061cd234f882d88bafb223f3ac42
refs/heads/master
2021-07-15T09:46:41.250818
2017-10-18T01:58:59
2017-10-18T01:58:59
107,071,247
5
1
null
null
null
null
UTF-8
Java
false
false
2,707
java
/** * Copyright 2016 Nikita Koksharov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package redis.clients.redisson.eviction; import java.util.concurrent.ConcurrentMap; import redis.clients.redisson.command.CommandAsyncExecutor; import io.netty.util.internal.PlatformDependent; /** * Eviction scheduler. * Deletes expired entries in time interval between 5 seconds to 2 hours. * It analyzes deleted amount of expired keys * and 'tune' next execution delay depending on it. * * @author Nikita Koksharov * */ public class EvictionScheduler { private final ConcurrentMap<String, EvictionTask> tasks = PlatformDependent.newConcurrentHashMap(); private final CommandAsyncExecutor executor; public EvictionScheduler(CommandAsyncExecutor executor) { this.executor = executor; } public void scheduleCleanMultimap(String name, String timeoutSetName) { EvictionTask task = new MultimapEvictionTask(name, timeoutSetName, executor); EvictionTask prevTask = tasks.putIfAbsent(name, task); if (prevTask == null) { task.schedule(); } } public void scheduleJCache(String name, String timeoutSetName, String expiredChannelName) { EvictionTask task = new JCacheEvictionTask(name, timeoutSetName, expiredChannelName, executor); EvictionTask prevTask = tasks.putIfAbsent(name, task); if (prevTask == null) { task.schedule(); } } public void schedule(String name, long shiftInMilliseconds) { EvictionTask task = new ScoredSetEvictionTask(name, executor, shiftInMilliseconds); EvictionTask prevTask = tasks.putIfAbsent(name, task); if (prevTask == null) { task.schedule(); } } public void schedule(String name, String timeoutSetName, String maxIdleSetName, String expiredChannelName, String lastAccessTimeSetName) { EvictionTask task = new MapCacheEvictionTask(name, timeoutSetName, maxIdleSetName, expiredChannelName, lastAccessTimeSetName, executor); EvictionTask prevTask = tasks.putIfAbsent(name, task); if (prevTask == null) { task.schedule(); } } }
448f885209816ec9211f114793298524d2f77e38
307e601e13338e29e03ccbd0f7d9c61670cae695
/msql-compiler/src/main/java/com/app/aptprocessor/processor/SQLTable.java
f6b506bdfd910297ac1608c0a981f4b8a3a8bbc4
[]
no_license
fengxiaocan/MinorSQL
c2b310445ba817ea731a5388729f808d7f966170
8bfc254e8ea7f638d1bba40bb49eda61f6909bcf
refs/heads/master
2023-02-01T10:45:57.042428
2020-12-11T11:10:14
2020-12-11T11:10:14
316,465,536
0
0
null
null
null
null
UTF-8
Java
false
false
257
java
package com.app.aptprocessor.processor; public class SQLTable { public String name; public String table; public SQLTable() { } public SQLTable(String name, String table) { this.name = name; this.table = table; } }
2c9617e46ecaa956583ac9da178860703adae864
f6beb7535dd2843dece84854c4cd354f782987d2
/accounts/src/main/java/pl/wipek/accounts/bonuses/families/moneyback/BusinessMoneyBackBonus.java
80361e16cc20b2d07efd732d6fe21eed7ec1f6fd
[]
no_license
WiPeK/JavaEE-Bank
b86f85e1e93371d8f9aa292746f0cec6bcc82378
5446e1c0fc87b7d4ef28e89bd3c5542de62ecaa7
refs/heads/master
2021-09-05T14:36:55.765139
2018-01-28T12:58:47
2018-01-28T12:58:47
110,385,594
0
2
null
null
null
null
UTF-8
Java
false
false
1,075
java
package pl.wipek.accounts.bonuses.families.moneyback; public class BusinessMoneyBackBonus extends MoneyBackBonus { private static int MIN_MOBILE_LOGGINS_NUMBERS = 1; private static int MIN_BLIK_USE_NUMBERS = 1; private static Double MIN_SUM_PAYMENTS_TO_ACCOUNT = 2000.0; private static Double MIN_MONEY_SPENT_FOR_FUEL = 300.0; private static Double BONUS = 100.0; private Double moneySpentForFuel; @Override public void addBonus() { if(isConditionsChecked()) { setGrantedBonus(BONUS * (getSumPaymentToAccount() / 10000)); setGranted(true); } } public void setMoneySpentForFuel(Double moneySpentForFuel) { this.moneySpentForFuel = moneySpentForFuel; } private boolean isConditionsChecked() { return getMobileLoggingNumbers() >= MIN_MOBILE_LOGGINS_NUMBERS && getBlikUseNumbers() >= MIN_BLIK_USE_NUMBERS && getSumPaymentToAccount() >= MIN_SUM_PAYMENTS_TO_ACCOUNT && moneySpentForFuel >= MIN_MONEY_SPENT_FOR_FUEL; } }
23594c04a1ef685b25ab71887190d9fff47c5bd7
83c6b17a3e8e282a4f11141d32f4f1c21d0b09fe
/archive/java/resonantinduction/old/client/model/ModelConstructionPump.java
665bf336e54a32afe3985f06ce1cf8640fa34c5d
[]
no_license
tgame14/Resonant-Induction
65c40197df0c6cdf5be4388ef8b6729d5df1ba77
60839ccf4354ceaac0931d74c33648e88d36e1e5
refs/heads/master
2020-12-25T04:10:48.645921
2014-06-17T20:30:46
2014-06-17T20:30:46
21,034,495
2
3
null
null
null
null
UTF-8
Java
false
false
2,458
java
// Date: 4/15/2013 6:17:44 AM // Template version 1.1 // Java generated by Techne // Keep in mind that you still need to fill in some blanks // - ZeuX package resonantinduction.old.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; public class ModelConstructionPump extends ModelBase { // fields ModelRenderer Side3; ModelRenderer Motor2; ModelRenderer Motor; ModelRenderer side; ModelRenderer base; ModelRenderer side2; ModelRenderer side4; public ModelConstructionPump() { textureWidth = 128; textureHeight = 128; Side3 = new ModelRenderer(this, 46, 37); Side3.addBox(-5F, 0F, -3F, 10, 11, 5); Side3.setRotationPoint(0F, 10F, -4F); Side3.setTextureSize(64, 32); Side3.mirror = true; setRotation(Side3, 0F, 0F, 0F); Motor2 = new ModelRenderer(this, 10, 23); Motor2.addBox(-4F, -4F, 0F, 8, 8, 4); Motor2.setRotationPoint(0F, 15F, -2F); Motor2.setTextureSize(64, 32); Motor2.mirror = true; setRotation(Motor2, 0F, 0F, 0F); Motor = new ModelRenderer(this, 10, 23); Motor.addBox(-4F, -4F, 0F, 8, 8, 4); Motor.setRotationPoint(0F, 15F, -2F); Motor.setTextureSize(64, 32); Motor.mirror = true; setRotation(Motor, 0F, 0F, 0.7853982F); side = new ModelRenderer(this, 15, 37); side.addBox(-5F, 0F, -3F, 10, 11, 5); side.setRotationPoint(0F, 10F, 5F); side.setTextureSize(64, 32); side.mirror = true; setRotation(side, 0F, 0F, 0F); base = new ModelRenderer(this, 16, 54); base.addBox(-7F, 0F, -8F, 14, 3, 16); base.setRotationPoint(0F, 21F, 0F); base.setTextureSize(64, 32); base.mirror = true; setRotation(base, 0F, 0F, 0F); side2 = new ModelRenderer(this, 0, 37); side2.addBox(-3F, 0F, 2F, 6, 10, 1); side2.setRotationPoint(0F, 11F, 5F); side2.setTextureSize(64, 32); side2.mirror = true; setRotation(side2, 0F, 0F, 0F); side4 = new ModelRenderer(this, 77, 37); side4.addBox(-3F, 0F, -3F, 6, 10, 1); side4.setRotationPoint(0F, 11F, -5F); side4.setTextureSize(64, 32); side4.mirror = true; setRotation(side4, 0F, 0F, 0F); } public void render(float f5) { Side3.render(f5); side.render(f5); base.render(f5); side2.render(f5); side4.render(f5); } public void renderMotor(float f5) { Motor2.render(f5); Motor.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } }
e8e811bd7fb199de244922aed4dd7fec3e6ac089
c0bfa317d27128479a13f0ea30b60ef9f756bde6
/P11-Api/src/napisy/Immutable.java
c24d0e504df919fbb4139f8192545c5b3b78cf58
[]
no_license
LukaszSajenko/exercises
b6910c0afa341ed9395e88fd430f44d4298f914f
89c1b903d80fc800b6c4885cb6318ce1e8378c9c
refs/heads/master
2021-05-14T10:46:01.521673
2018-01-05T08:42:16
2018-01-05T08:42:16
116,361,933
0
0
null
null
null
null
UTF-8
Java
false
false
527
java
package napisy; public class Immutable { static void metoda(String s) { s += " ma psa"; System.out.println(" w metodzie s: "+ s); } public static void main(String[] args) { String a = "Ala"; String b = a; a += " ma kota"; System.out.println(a); System.out.println(b); int x = 100; int y = x; x += 13; System.out.println(x); System.out.println(y); System.out.println(); System.out.println("przed metodą b: " + b); metoda(b); System.out.println(" po metodzie b: " + b); } }
3afbe4e33ecf1dbeef5f54bf515ac3b63f6d03bc
fc2d0b7b287da0af7e6bb72489676532309e462a
/junjie/develop/proj/modules/ic/src/public/nc/ui/ic/md/dialog/MDUtils.java
75415ec659480c9e3f467976045d2193c6ac2c5d
[]
no_license
jiangsongHB/nc56_junjie
b46fb1a38877d4fb3ed884852d8d4711e0fd52c5
4504a08b055cd7d3c9e5c6460213d3bfdc39848d
refs/heads/master
2020-09-09T12:25:01.084199
2015-12-09T12:51:56
2015-12-09T12:51:56
null
0
0
null
null
null
null
GB18030
Java
false
false
8,719
java
package nc.ui.ic.md.dialog; import java.util.HashMap; import nc.bs.framework.common.NCLocator; import nc.itf.uap.IUAPQueryBS; import nc.jdbc.framework.processor.ColumnProcessor; import nc.ui.pub.beans.UIButton; import nc.vo.ic.md.MdcrkVO; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDouble; /** * 码单入库单基本属性及常量字段 * * @author zhoujie * @since 2010-09-04 15:57:47 */ public class MDUtils { public final static String SAVE_BUTTON = "保存"; public final static String EDIT_BUTTON = "编辑"; public final static String ADDLINE_BUTTON = "增行"; public final static String DELLINE_BUTTON = "删行"; public final static String CALC_BUTTON = "计算"; public final static String CANCEL_BUTTON = "取消"; public final static String MDINFO_BUTTON = "码单维护"; public final static String MBJS_BUTTON = "毛边计算"; public final static UIButton BLANK_BUTTON = new UIButton(); /** * 入库 */ public final static int KC_IN = 0; /** * 出库 */ public final static int KC_OUT = 1; /** * 初始状态 */ public final static int INIT = 0x1; /** * 初始化后,可以编辑状态 */ public final static int INIT_CANEDIT = 0x2; /** * 编辑ing 状态 */ public final static int EDITING = 0x4; private static HashMap<String, String> billname; /** * 取得按钮名字的列表 * @return 按钮名称的列表 * @see #EDIT_BUTTON * @see #ADDLINE_BUTTON * @see #DELLINE_BUTTON * @see #CALC_BUTTON * @see #SAVE_BUTTON * @see #CANCEL_BUTTON */ public static final String[] getButtons(){ return new String[]{EDIT_BUTTON,ADDLINE_BUTTON,DELLINE_BUTTON,CALC_BUTTON,SAVE_BUTTON,CANCEL_BUTTON}; } public static final String[] getEdgeButtons(){ return new String[]{CALC_BUTTON,SAVE_BUTTON,CANCEL_BUTTON}; } public static String getBillNameByBilltype(String billtype){ if(billname==null){ billname= new HashMap<String, String>(); billname.put("45","采购入库单"); billname.put("4A","其他入库单"); // billname.put("4E","调拨入库单"); billname.put("4I","其他出库单"); billname.put("4C","销售出库单"); // billname.put("4Y","调拨出库单"); } return billname.get(billtype); } /** * 磅计的算法, * * @param vos * @param sszl * @return * @throws BusinessException */ public static MdcrkVO[] mdBJ(MdcrkVO[] vos,UFDouble sszl) throws BusinessException{ sszl = sszl.abs();//出库单此处的值是负的,所以取绝对值 if(sszl==null||sszl.doubleValue()<=0){ throw new BusinessException("实收重量不能小于0"); } boolean isCG = false; if(vos[0].getMd_meter()!=null){ isCG = true; } UFDouble count_LW = new UFDouble(0);// 米数*件数和 /长*宽*米数和 UFDouble count_ZL = new UFDouble(0);// 所有分摊重量和 for (int i=0 ;i<vos.length;i++) { MdcrkVO vo = vos[i]; UFDouble lenth = vo.getMd_length();// 长 UFDouble width = vo.getMd_width( );//宽 UFDouble meter = vo.getMd_meter();//米数 UFDouble zs = vo.getSrkzs(); if (zs==null||zs.doubleValue()<=0) { throw new BusinessException("第"+(i+1)+"行,件数不能小于0"); } if(isCG){ if (meter==null||meter.doubleValue()<=0) { throw new BusinessException("第"+(i+1)+"行,米数不能小于0"); } count_LW = count_LW.add(meter.multiply(zs)); }else{ if (lenth==null||lenth.doubleValue()<=0) { throw new BusinessException("第"+(i+1)+"行,长不能小于0"); } if (width==null||width.doubleValue()<=0) { throw new BusinessException("第"+(i+1)+"行,宽不能小于0"); } count_LW = count_LW.add(lenth.multiply(width).multiply(zs)); } } for (int i=0 ;i<vos.length;i++) { MdcrkVO vo = vos[i]; UFDouble lenth = vo.getMd_length();// 长 UFDouble width = vo.getMd_width( );//宽 UFDouble meter = vo.getMd_meter();//米数 UFDouble zs = vo.getSrkzs(); if(i == vos.length-1){ vo.setSrkzl(sszl.sub(count_ZL)); }else{ UFDouble vga = UFDouble.ZERO_DBL; if(isCG){ vga = sszl.multiply(meter).multiply(zs).div(count_LW); }else{ vga = sszl.multiply(width).multiply(lenth).multiply(zs).div(count_LW); } vga = vga.setScale(4,UFDouble.ROUND_HALF_UP); vo.setSrkzl(vga); count_ZL = count_ZL.add(vga); } // System.out.println("########"+vo.getSrkzl()); } return vos; } /** * 码单理计算法 * @param vos * @return * @throws BusinessException */ public static MdcrkVO[] mdLJ(MdcrkVO[] vos) throws BusinessException{ boolean isCG = false;// 是否为槽钢 if(vos[0].getMd_meter()!=null){ isCG = true; }else if(vos[0].getMd_length()==null||vos[0].getMd_width()==null){ throw new BusinessException("第1行,长度/宽度/米数不能同时为空."); } UFDouble fjm = getFJM(vos[0]); UFDouble lsxs = getLSXS(vos[0]); for (int i=0 ;i<vos.length;i++) { MdcrkVO vo = vos[i]; UFDouble lenth = vo.getMd_length();// 长 UFDouble width = vo.getMd_width( );//宽 UFDouble meter = vo.getMd_meter();//米数 String guige = vo.getDef6(); UFDouble zs = vo.getSrkzs(); if (zs==null||zs.doubleValue()<=0) { throw new BusinessException("第"+(i+1)+"行,支数不能小于0"); } if(isCG){ if (meter==null||meter.doubleValue()<=0) { throw new BusinessException("第"+(i+1)+"行,米数不能小于0"); } // 米数*支数*理算系数/1000 vo.setSrkzl(lsxs.multiply(zs).multiply(meter).div(1000)); }else{ if(guige==null||guige.trim().equals("")){ throw new BusinessException("第"+(i+1)+"行,系统认为该存货为 锅炉板,但其规格不合标准"); } if (lenth==null||lenth.doubleValue()<=0) { throw new BusinessException("第"+(i+1)+"行,长度不能小于0"); } if (width==null||width.doubleValue()<=0) { throw new BusinessException("第"+(i+1)+"行,宽度不能小于0"); } UFDouble gui = new UFDouble(guige); //(厚+附加值)*宽*长*支数*7.85 /1000000000 vo.setSrkzl((gui.add(fjm)).multiply(width).multiply(lenth).multiply(zs).multiply(7.85).div(1000000000)); } } return vos; } /** * 付加码 * @param vo * @return */ static UFDouble getFJM(MdcrkVO vo){ String pk_invbasid = getInvBasidByMDVO(vo); if(pk_invbasid==null){ return UFDouble.ZERO_DBL; } // FIXME 与佛山代码整合后,需要更改此处代码 // IJJUAPService js = NCLocator.getInstance().lookup(IJJUAPService.class); // js.queryAdditionalvalue(pk_invbasid); // queryAdditionalvalue(String pk_invbasdoc) 根据存货基本档案查出附加值 return UFDouble.ZERO_DBL; } static String getInvBasidByMDVO(MdcrkVO vo){ IUAPQueryBS bs = NCLocator.getInstance().lookup(IUAPQueryBS.class); Object obj = null; try { obj = bs.executeQuery("select cinvbasid from ic_general_b where cgeneralbid = '"+vo.getCgeneralbid()+"' ", new ColumnProcessor()); } catch (BusinessException e) { e.printStackTrace(); } if(obj==null){ System.out.println(" 查询不到存货基本档案PK "); return null; }else return obj.toString(); } /** * 理算系数 * @param vo * @return */ static UFDouble getLSXS(MdcrkVO vo){ String pk_invbasid = getInvBasidByMDVO(vo); if(pk_invbasid==null){ return new UFDouble(1); } //FIXME 与佛山代码整合后,需要更改此处代码 // IJJUAPService js = NCLocator.getInstance().lookup(IJJUAPService.class); // js.queryAdjustmentcoefficient(pk_invbasid); // queryAdditionalvalue(String pk_invbasdoc) 根据存货基本档案查出附加值 // // // queryAdjustmentcoefficient(String pk_invbasdoc) 根据存货基本档案查出理算系数 return new UFDouble(1); } /** * 毛边系数 * @param cinvbasid 存货基本档案 * @param pk_cubasdoc 客商基本档案 * @param pk_invcl 存货分类 * @param hd 厚度 * @return */ public static UFDouble getMBXS(String cinvbasid,String pk_cubasdoc,UFDouble hd){ // FIXME 与佛山代码整合后,需要更改此处代码 IUAPQueryBS bs = NCLocator.getInstance().lookup(IUAPQueryBS.class); Object obj = null; try { obj = bs.executeQuery("select pk_invcl from bd_invbasdoc where pk_invbasdoc = '"+cinvbasid+"' ", new ColumnProcessor()); } catch (BusinessException e) { e.printStackTrace(); } return new UFDouble(0.5); } }
[ "heyiqiu@d7022953-1ca3-a944-a70e-6a56d19ef69b" ]
heyiqiu@d7022953-1ca3-a944-a70e-6a56d19ef69b
83e64ebf1764810cb484500b4e64fcb612b2c6fb
95e944448000c08dd3d6915abb468767c9f29d3c
/sources/com/p280ss/android/vesdk/VEAudioEffectBean.java
e1991cb9191f485b9fc40cfe723a078dc2288a31
[]
no_license
xrealm/tiktok-src
261b1faaf7b39d64bb7cb4106dc1a35963bd6868
90f305b5f981d39cfb313d75ab231326c9fca597
refs/heads/master
2022-11-12T06:43:07.401661
2020-07-04T20:21:12
2020-07-04T20:21:12
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,131
java
package com.p280ss.android.vesdk; /* renamed from: com.ss.android.vesdk.VEAudioEffectBean */ public class VEAudioEffectBean { public int blockSize; public float centtone; public boolean formatShiftOn; public float octative; public int phaseAdjustMethod; public int phaseResetMode; public int pitchTunerMode; public int processChMode; public float semiton; public boolean smoothOn; public float speedRatio; public int transientDetectMode; public int type; public int windowMode; public VEAudioEffectBean(int i, boolean z, boolean z2, int i2, int i3, int i4, int i5, int i6, int i7, int i8, float f, float f2, float f3, float f4) { this.type = i; this.formatShiftOn = z; this.smoothOn = z2; this.processChMode = i2; this.transientDetectMode = i3; this.phaseResetMode = i4; this.phaseAdjustMethod = i5; this.windowMode = i6; this.pitchTunerMode = i7; this.blockSize = i8; this.centtone = f; this.semiton = f2; this.octative = f3; this.speedRatio = f4; } }
04cfb148a838835f93966faa5a020dafadaf03fe
66399c0df6465bdf256d3f0a285d0e571d792fc8
/src/main/java/exprest/doc/swagger/SwaggerView.java
3cd956fdcde5b0d73a5774cbe82265823ff4860f
[ "Apache-2.0" ]
permissive
jrolfe777/exprest
29147926cbf64155783d412be2f534ebfb1d1d33
379acfa3069cd3caaa6a5e65beda5fed2e3af759
refs/heads/master
2020-05-18T08:37:29.265994
2015-02-12T12:20:35
2015-02-12T12:20:35
30,506,701
2
0
null
null
null
null
UTF-8
Java
false
false
311
java
package exprest.doc.swagger; import io.dropwizard.views.View; import com.google.common.base.Charsets; public class SwaggerView extends View { public SwaggerView() { super("/index.ftl", Charsets.UTF_8); } public String getSwaggerStaticPath() { return SwaggerBundle.PATH; } }
cf58003d1c33be90a19a0836459cc554daf2f2ef
1162ac3491e88f5300649e7d8d17e13fc5381c88
/prospectCRMEJB/ejbModule/cl/prospect/crm/dao/EstadoDao.java
6eadcad756dce9ca65a5c89edc38e1e78d34f37c
[]
no_license
claudiocastillor/prospect
78d3fcf32424757ed3ee73726f1b843ecb982f5d
9bb461f8b6a1d2f34a7d4f8f8298f81563505ef9
refs/heads/master
2020-04-10T08:11:21.360178
2013-06-15T00:19:20
2013-06-15T00:19:20
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,642
java
package cl.prospect.crm.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.ResourceBundle; import com.mysql.jdbc.Statement; import cl.prospect.crm.conexion.Conexion; import cl.prospect.crm.dao.interfaces.IEstadoDao; import cl.prospect.crm.to.EstadoTo; public class EstadoDao implements IEstadoDao{ private static Conexion con = new Conexion(); PreparedStatement stmtSelect = null; Connection conn = null; String sqlString = null; private ResourceBundle sql = null; @Override public EstadoTo getById(Long id) throws SQLException { this.conn = this.con.connect("jndi_crm"); ResultSet rs = null; EstadoTo estado = null; try{ this.stmtSelect = this.conn.prepareStatement(this.sql.getString("SELECT_ESTADO_BY_ID")); this.stmtSelect.setLong(1, id); rs = this.stmtSelect.executeQuery(); while (rs.next()){ estado = new EstadoTo(); estado.setId(rs.getLong("id")); estado.setNombre(rs.getString("nombre")); } }catch(SQLException e){ e.printStackTrace(); }finally{ if(rs != null){ rs.close(); } this.stmtSelect.close(); this.conn.close(); } return estado; } @Override public List<EstadoTo> getAll() throws SQLException { this.conn = this.con.connect("jndi_crm"); ResultSet rs = null; List<EstadoTo> lstEstados = new ArrayList<EstadoTo>(); try{ this.stmtSelect = this.conn.prepareStatement(this.sql.getString("SELECT_ESTADO_GET_ALL")); rs = this.stmtSelect.executeQuery(); while (rs.next()){ lstEstados.add(this.getById(rs.getLong("id"))); } }catch(SQLException e){ e.printStackTrace(); }finally{ if(rs != null){ rs.close(); } this.conn.close(); } return lstEstados; } @Override public List<EstadoTo> getByParameters(String parameter, String value) throws SQLException { this.conn = this.con.connect("jndi_crm"); ResultSet rs = null; List<EstadoTo> lstEstados = new ArrayList<EstadoTo>(); this.sqlString = "SELECT id FROM estados WHERE " + parameter + " = ?"; try{ this.stmtSelect = this.conn.prepareStatement(this.sqlString); this.stmtSelect.setString(1, value); rs = this.stmtSelect.executeQuery(); while (rs.next()){ lstEstados.add(this.getById(rs.getLong("id"))); } }catch(SQLException e){ e.printStackTrace(); }finally{ if(rs != null){ rs.close(); } this.conn.close(); } return lstEstados; } @Override public Long save(EstadoTo p) throws SQLException { this.conn = this.con.connect("jndi_crm"); Long id = 0L; try { if(p.getId() == 0){ this.stmtSelect = this.conn.prepareStatement(this.sql.getString("SELECT_ESTADO_GRABAR"), Statement.RETURN_GENERATED_KEYS); this.stmtSelect.setLong(1, p.getId()); this.stmtSelect.setString(2, p.getNombre()); this.stmtSelect.executeUpdate(); ResultSet keys = this.stmtSelect.getGeneratedKeys(); keys.next(); id = keys.getLong(1); keys.close(); }else{ this.stmtSelect = this.conn.prepareStatement(this.sql.getString("SELECT_ESTADO_UPDATE")); this.stmtSelect.setString(1, p.getNombre()); this.stmtSelect.setLong(2, p.getId()); this.stmtSelect.executeUpdate(); } } catch (Exception e) { // TODO: handle exception } return id; } }
5b57a4d758617c22e098261bc29842ea0b603854
49595f93e7694540104729115ab593138f6d61a6
/Caso 1/RedSocial/src/redsocial/RedSocial.java
01478ad71194b82f5d04baac4d4bedfe20e7d347
[]
no_license
josepa333/Casos-Dise-o
b1e1d6988c0fb523a3bb89566d87fb95ee96f9f8
baf10b7dc8f1a5f6948891d7bc7e225be9aec82b
refs/heads/master
2020-05-22T08:52:40.032879
2019-05-23T08:31:14
2019-05-23T08:31:14
186,287,440
0
0
null
null
null
null
UTF-8
Java
false
false
482
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 redsocial; import redsocial.controller.InicioController; /** * * @author Angelo PC */ public class RedSocial{ /** * @param args the command line arguments */ public static void main(String[] args) { InicioController lcc = new InicioController(); } }
f39e0ef7c2cfacbccb3baf6bf399bef5f323d41e
e8fc983e973af70b1888820aec632c4bb0a36b0c
/src/test/java/com/adaptris/core/es5/CsvBuilderCase.java
d47e7d02adc7b835b63d2aca75b7d6d0fac4d5f7
[ "Apache-2.0" ]
permissive
adaptris/interlok-es5
f14e2e1ec5aec05d647739c196a67f7e718b732e
1aa4e8d74acd90c0b2cb5a84a6db2af0ba1f7ef4
refs/heads/develop
2021-07-07T04:33:17.720969
2020-06-18T14:28:31
2020-06-18T14:28:31
137,071,585
0
0
Apache-2.0
2020-07-08T09:59:50
2018-06-12T12:55:24
Java
UTF-8
Java
false
false
2,803
java
/* Copyright Adaptris Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.adaptris.core.es5; import static org.junit.Assert.assertEquals; import org.junit.Test; import com.adaptris.core.AdaptrisMessage; import com.adaptris.core.AdaptrisMessageFactory; import com.adaptris.core.util.CloseableIterable; import com.jayway.jsonpath.ReadContext; public abstract class CsvBuilderCase extends BuilderCase { public static final String JSON_PRODUCTUNIQUEID = "$.productuniqueid"; public static final String CSV_INPUT = "productuniqueid,productname,crop,productcategory,applicationweek,operationdate,manufacturer,applicationrate,measureunit,growthstagecode,iscanonical,latitude,longitude,recordid,id" + System.lineSeparator() + "UID-1,*A Simazine,,Insecticides,48,20051122,,1.5,Litres per Hectare,,0,52.68134,1.68928,5,1" + System.lineSeparator() + "UID-2,*Axial,,Herbicides,15,20100408,,0.25,Litres per Hectare,,0,52.12345,1.12345,6,6" + System.lineSeparator() + "UID-3,*Betanal Maxxim,,Herbicides,18,20130501,,0.07,Litres per Hectare,,0,51.12345,2.12345,21,21" + System.lineSeparator() + "UID-4,24-D Amine,Passion Fruit,Herbicides,19,20080506,,2.8,Litres per Hectare,,0,53.37969768091292,-0.18346963126415416,210,209" + System.lineSeparator() + "UID-5,26N35S,Rape Winter,Fungicides,12,20150314,,200,Kilograms per Hectare,,0,52.71896363632868,-1.2391368098336788,233,217" + System.lineSeparator(); @Test public void testBuild() throws Exception { AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(CSV_INPUT); msg.addMetadata(testName.getMethodName(), testName.getMethodName()); CSVDocumentBuilderImpl documentBuilder = createBuilder(); int count = 0; try (CloseableIterable<DocumentWrapper> docs = CloseableIterable.ensureCloseable(documentBuilder.build(msg))) { for (DocumentWrapper doc : docs) { count++; ReadContext context = parse(doc.content().string()); assertEquals("UID-" + count, context.read(JSON_PRODUCTUNIQUEID)); assertEquals("UID-" + count, doc.uniqueId()); } } assertEquals(5, count); } protected abstract CSVDocumentBuilderImpl createBuilder(); }
5e86711032c26ad1533e8a2110108932f77084b8
eb31bb4ed3139c0b504c67ab9fc55fb92d346ae6
/src/manager/exceptions/NonexistentEntityException.java
2208fb1919fb479f987081a24c7eb5cf563e7f14
[]
no_license
NathanMotoki/SistemaEscola
a57905da7f3b5e6b587e06bb37d2f75e99b871bb
c5d88a88b70d6d6632770b209bf7f8aae3ae027f
refs/heads/master
2023-08-10T15:35:04.541855
2021-09-20T18:21:57
2021-09-20T18:21:57
408,553,304
0
0
null
null
null
null
UTF-8
Java
false
false
287
java
package manager.exceptions; public class NonexistentEntityException extends Exception { public NonexistentEntityException(String message, Throwable cause) { super(message, cause); } public NonexistentEntityException(String message) { super(message); } }
368b084d13c24effc0e26f897b737580d728836e
f0ff3f7c5666758b2de2f5ad7d3abafc4fde50e9
/areca.ui/src/main/java/areca/ui/viewer/Viewer.java
53c2a1730988345528322084b6bb97f368fd50b9
[]
no_license
fb71/areca
b4b69888f8ba3d7692d15a0816c6326e34a88833
e86dafecf7703c79d398244f85ca345269fbf5a6
refs/heads/master
2023-08-17T03:28:08.265416
2023-08-16T13:56:49
2023-08-16T13:56:49
243,574,190
2
0
null
2022-06-29T19:49:31
2020-02-27T17:19:41
Java
UTF-8
Java
false
false
1,163
java
/* * Copyright (C) 2020, the @authors. All rights reserved. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 3.0 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package areca.ui.viewer; import areca.common.log.LogFactory; import areca.common.log.LogFactory.Log; import areca.ui.component2.UIComponent; /** * * @author Falko Bräutigam */ public abstract class Viewer<A extends ModelAdapter> { private static final Log log = LogFactory.getLog( Viewer.class ); protected A model; @SuppressWarnings("hiding") protected Viewer<A> init( A model ) { this.model = model; return this; } public abstract UIComponent create(); public abstract void store(); public abstract void load(); }
[ "falko@delli" ]
falko@delli
0d73436bb919c059c962008a6458056cc7140f29
36d2f4a1bb4849b7a89a8e9c0899442d1a29f607
/Code/DoubleAuctionWithNetworks/src/controller/network/export/GexfBean.java
1d7265e43e2d7cf5093f70c7b2b3a9a68a40d896
[]
no_license
thalerjonathan/Masterthesis
53a50e375583cfb6bc0cf75aa775e6a175972fa9
c9f3cb6c709c6742e8b69a23daa9ce2b03188135
refs/heads/master
2020-12-30T14:56:49.349000
2020-07-08T16:00:26
2020-07-08T16:00:26
32,147,765
0
0
null
null
null
null
UTF-8
Java
false
false
412
java
package controller.network.export; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; @XmlRootElement( name = "gefx" ) @XmlType( namespace = "http://www.gexf.net/1.2draft" ) public class GexfBean { private GraphBean graph; public GraphBean getGraph() { return graph; } public void setGraph(GraphBean graph) { this.graph = graph; } }
4370866a78cc67224ec536549d4fea6c796aacfd
e977c424543422f49a25695665eb85bfc0700784
/benchmark/icse15/1032780/buggy-version/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
116f7f82599f2d79d1134cc4c4c54e6977569476
[]
no_license
amir9979/pattern-detector-experiment
17fcb8934cef379fb96002450d11fac62e002dd3
db67691e536e1550245e76d7d1c8dced181df496
refs/heads/master
2022-02-18T10:24:32.235975
2019-09-13T15:42:55
2019-09-13T15:42:55
null
0
0
null
null
null
null
UTF-8
Java
false
false
124,460
java
/* Derby - Class org.apache.derby.client.am.PreparedStatement 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.derby.client.am; import org.apache.derby.shared.common.reference.JDBC40Translation; import org.apache.derby.shared.common.reference.SQLState; import org.apache.derby.shared.common.sanity.SanityManager; import java.io.InputStream; import java.io.Reader; import java.sql.Date; import java.sql.SQLException; import java.sql.Time; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import org.apache.derby.client.ClientPooledConnection; import org.apache.derby.jdbc.ClientDriver; public class PreparedStatement extends Statement implements java.sql.PreparedStatement, PreparedStatementCallbackInterface { //---------------------navigational cheat-links------------------------------- // Cheat-links are for convenience only, and are not part of the conceptual model. // Warning: // Cheat-links should only be defined for invariant state data. // That is, the state data is set by the constructor and never changes. // Alias for downcast (MaterialPreparedStatementProxy) super.materialStatement. public MaterialPreparedStatement materialPreparedStatement_ = null; //-----------------------------state------------------------------------------ public String sql_; // This variable is only used by Batch. // True if a call sql statement has an OUT or INOUT parameter registered. public boolean outputRegistered_ = false; // Parameter inputs are cached as objects so they may be sent on execute() public Object[] parameters_; boolean[] parameterSet_; boolean[] parameterRegistered_; void setInput(int parameterIndex, Object input) { parameters_[parameterIndex - 1] = input; parameterSet_[parameterIndex - 1] = true; } public ColumnMetaData parameterMetaData_; // type information for input sqlda private ArrayList parameterTypeList; // The problem with storing the scrollable ResultSet associated with cursorName in scrollableRS_ is // that when the PreparedStatement is re-executed, it has a new ResultSet, however, we always do // the reposition on the ResultSet that was stored in scrollableRS_, and we never update scrollableRS_ // when PreparedStatement is re-execute. So the new ResultSet that needs to be repositioned never // gets repositioned. // So instead of caching the scrollableRS_, we will cache the cursorName. And re-retrieve the scrollable // result set from the map using this cursorName every time the PreparedStatement excutes. String positionedUpdateCursorName_ = null; // the ClientPooledConnection object used to notify of the events that occur // on this prepared statement object protected final ClientPooledConnection pooledConnection_; private void initPreparedStatement() { materialPreparedStatement_ = null; sql_ = null; outputRegistered_ = false; parameters_ = null; parameterSet_ = null; parameterRegistered_ = null; parameterMetaData_ = null; parameterTypeList = null; isAutoCommittableStatement_ = true; isPreparedStatement_ = true; } protected void initResetPreparedStatement() { outputRegistered_ = false; isPreparedStatement_ = true; resetParameters(); } public void reset(boolean fullReset) throws SqlException { if (fullReset) { connection_.resetPrepareStatement(this); } else { super.initResetPreparedStatement(); initResetPreparedStatement(); } } /** * Resets the prepared statement for reuse in a statement pool. * * @throws SqlException if the reset fails * @see Statement#resetForReuse */ void resetForReuse() throws SqlException { resetParameters(); super.resetForReuse(); } private void resetParameters() { if (parameterMetaData_ != null) { Arrays.fill(parameters_, null); Arrays.fill(parameterSet_, false); Arrays.fill(parameterRegistered_, false); } } /** * * The PreparedStatement constructor used for JDBC 2 positioned update * statements. Called by material statement constructors. * It has the ClientPooledConnection as one of its parameters * this is used to raise the Statement Events when the prepared * statement is closed * * @param agent The instance of NetAgent associated with this * CallableStatement object. * @param connection The connection object associated with this * PreparedStatement Object. * @param sql A String object that is the SQL statement to be sent * to the database. * @param section Section * @param cpc The ClientPooledConnection wraps the underlying physical * connection associated with this prepared statement. * It is used to pass the Statement closed and the Statement * error occurred events that occur back to the * ClientPooledConnection. * @throws SqlException * */ public PreparedStatement(Agent agent, Connection connection, String sql, Section section,ClientPooledConnection cpc) throws SqlException { super(agent, connection); // PreparedStatement is poolable by default isPoolable = true; initPreparedStatement(sql, section); pooledConnection_ = cpc; } public void resetPreparedStatement(Agent agent, Connection connection, String sql, Section section) throws SqlException { super.resetStatement(agent, connection); initPreparedStatement(); initPreparedStatement(sql, section); } private void initPreparedStatement(String sql, Section section) throws SqlException { sql_ = sql; isPreparedStatement_ = true; parseSqlAndSetSqlModes(sql_); section_ = section; } /** * The PreparedStatementConstructor used for jdbc 2 prepared statements * with scroll attributes. Called by material statement constructors. * It has the ClientPooledConnection as one of its parameters * this is used to raise the Statement Events when the prepared * statement is closed * * @param agent The instance of NetAgent associated with this * CallableStatement object. * @param connection The connection object associated with this * PreparedStatement Object. * @param sql A String object that is the SQL statement * to be sent to the database. * @param type One of the ResultSet type constants. * @param concurrency One of the ResultSet concurrency constants. * @param holdability One of the ResultSet holdability constants. * @param autoGeneratedKeys a flag indicating whether auto-generated * keys should be returned. * @param columnNames an array of column names indicating the columns that * should be returned from the inserted row or rows. * @param columnIndexes an array of column names indicating the columns that * should be returned from the inserted row. * @param cpc The ClientPooledConnection wraps the underlying physical * connection associated with this prepared statement * it is used to pass the Statement closed and the Statement * error occurred events that occur back to the * ClientPooledConnection. * @throws SqlException */ public PreparedStatement(Agent agent, Connection connection, String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes, ClientPooledConnection cpc) throws SqlException { super(agent, connection, type, concurrency, holdability, autoGeneratedKeys, columnNames, columnIndexes); // PreparedStatement is poolable by default isPoolable = true; initPreparedStatement(sql); pooledConnection_ = cpc; } public void resetPreparedStatement(Agent agent, Connection connection, String sql, int type, int concurrency, int holdability, int autoGeneratedKeys, String[] columnNames, int[] columnIndexes) throws SqlException { super.resetStatement(agent, connection, type, concurrency, holdability, autoGeneratedKeys, columnNames, columnIndexes); initPreparedStatement(); initPreparedStatement(sql); } private void initPreparedStatement(String sql) throws SqlException { sql_ = super.escape(sql); parseSqlAndSetSqlModes(sql_); isPreparedStatement_ = true; // Check for positioned update statement and assign a section from the // same package as the corresponding query section. // Scan the sql for an "update...where current of <cursor-name>". String cursorName = null; if (sqlUpdateMode_ == isDeleteSql__ || sqlUpdateMode_ == isUpdateSql__) { String[] sqlAndCursorName = extractCursorNameFromWhereCurrentOf(sql_); if (sqlAndCursorName != null) { cursorName = sqlAndCursorName[0]; sql_ = sqlAndCursorName[1]; } } if (cursorName != null) { positionedUpdateCursorName_ = cursorName; // Get a new section from the same package as the query section section_ = agent_.sectionManager_.getPositionedUpdateSection(cursorName, false); // false means get a regular section if (section_ == null) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.CURSOR_INVALID_CURSOR_NAME), cursorName); } //scrollableRS_ = agent_.sectionManager_.getPositionedUpdateResultSet (cursorName); // if client's cursor name is set, and the cursor name in the positioned update // string is the same as the client's cursor name, replace client's cursor name // with the server's cursor name. // if the cursor name supplied in the sql string is different from the cursorName // set by setCursorName(), then server will return "cursor name not defined" error, // and no subsititution is made here. if (section_.getClientCursorName() != null && // cursor name is user defined cursorName.compareTo(section_.getClientCursorName()) == 0) // client's cursor name is substituted with section's server cursor name { sql_ = substituteClientCursorNameWithServerCursorName(sql_, section_); } } else { // We don't need to analyze the sql text to determine if it is a query or not. // This is up to the server to decide, we just pass thru the sql on flowPrepare(). section_ = agent_.sectionManager_.getDynamicSection(resultSetHoldability_); } } public void resetPreparedStatement(Agent agent, Connection connection, String sql, Section section, ColumnMetaData parameterMetaData, ColumnMetaData resultSetMetaData) throws SqlException { resetPreparedStatement(agent, connection, sql, section); initPreparedStatement(parameterMetaData, resultSetMetaData); } private void initPreparedStatement(ColumnMetaData parameterMetaData, ColumnMetaData resultSetMetaData) throws SqlException { isPreparedStatement_ = true; parameterMetaData_ = parameterMetaData; resultSetMetaData_ = resultSetMetaData; if (parameterMetaData_ != null) { parameters_ = new Object[parameterMetaData_.columns_]; //parameterSetOrRegistered_ = new boolean[parameterMetaData_.columns_]; parameterSet_ = new boolean[parameterMetaData_.columns_]; parameterRegistered_ = new boolean[parameterMetaData_.columns_]; } } // called immediately after the constructor by Connection prepare*() methods void prepare() throws SqlException { try { // flow prepare, no static initialization is needed flowPrepareDescribeInputOutput(); } catch (SqlException e) { this.markClosed(); throw e; } } //------------------- Prohibited overrides from Statement -------------------- public boolean execute(String sql) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.NOT_FOR_PREPARED_STATEMENT), "execute(String)").getSQLException(); } public java.sql.ResultSet executeQuery(String sql) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeQuery", sql); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.NOT_FOR_PREPARED_STATEMENT), "executeQuery(String)").getSQLException(); } public int executeUpdate(String sql) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate", sql); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.NOT_FOR_PREPARED_STATEMENT), "executeUpdate(String)").getSQLException(); } // ---------------------------jdbc 1------------------------------------------ public java.sql.ResultSet executeQuery() throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeQuery"); } ResultSet resultSet = executeQueryX(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "executeQuery", resultSet); } return resultSet; } } catch ( SqlException se ) { checkStatementValidity(se); throw se.getSQLException(); } } // also called by some DBMD methods ResultSet executeQueryX() throws SqlException { flowExecute(executeQueryMethod__); return resultSet_; } public int executeUpdate() throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate"); } int updateValue = executeUpdateX(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "executeUpdate", updateValue); } return updateValue; } } catch ( SqlException se ) { checkStatementValidity(se); throw se.getSQLException(); } } private int executeUpdateX() throws SqlException { flowExecute(executeUpdateMethod__); return updateCount_; } public void setNull(int parameterIndex, int jdbcType) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setNull", parameterIndex, jdbcType); } checkForClosedStatement(); // JDBC 4.0 requires us to throw // SQLFeatureNotSupportedException for certain target types if // they are not supported. Check for these types before // checking type compatibility. checkForSupportedDataType(jdbcType); final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.getPossibleTypesForNull( paramType ).checkType( jdbcType )){ //This exception mimic embedded behavior. //see http://issues.apache.org/jira/browse/DERBY-1610#action_12432568 PossibleTypes.throw22005Exception(agent_.logWriter_, jdbcType, paramType ); } setNullX(parameterIndex, jdbcType); } } catch ( SqlException se ) { throw se.getSQLException(); } } // also used by DBMD methods void setNullX(int parameterIndex, int jdbcType) throws SqlException { parameterMetaData_.clientParamtertype_[parameterIndex - 1] = jdbcType; if (!parameterMetaData_.nullable_[parameterIndex - 1]) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.LANG_NULL_INTO_NON_NULL), new Integer(parameterIndex)); } setInput(parameterIndex, null); } public void setNull(int parameterIndex, int jdbcType, String typeName) throws SQLException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setNull", parameterIndex, jdbcType, typeName); } setNull(parameterIndex, jdbcType); } } public void setBoolean(int parameterIndex, boolean x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBoolean", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_GENERIC_SCALAR.checkType(paramType) ) { PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.BOOLEAN, paramType); } parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.BIT; setInput(parameterIndex, new Short((short) (x ? 1 : 0))); } } catch ( SqlException se ) { throw se.getSQLException(); } } public void setByte(int parameterIndex, byte x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setByte", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_GENERIC_SCALAR.checkType( paramType ) ){ PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.TINYINT, paramType); } parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.TINYINT; setInput(parameterIndex, new Short(x)); } } catch ( SqlException se ) { throw se.getSQLException(); } } public void setShort(int parameterIndex, short x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setShort", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_GENERIC_SCALAR.checkType(paramType) ){ PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.SMALLINT, paramType); } setShortX(parameterIndex, x); } } catch ( SqlException se ) { throw se.getSQLException(); } } // also used by DBMD methods void setShortX(int parameterIndex, short x) throws SqlException { parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.SMALLINT; setInput(parameterIndex, new Short(x)); } public void setInt(int parameterIndex, int x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setInt", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_GENERIC_SCALAR.checkType(paramType) ){ PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.INTEGER, paramType); } setIntX(parameterIndex, x); } } catch ( SqlException se ) { throw se.getSQLException(); } } // also used by DBMD methods void setIntX(int parameterIndex, int x) throws SqlException { parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.INTEGER; setInput(parameterIndex, new Integer(x)); } public void setLong(int parameterIndex, long x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setLong", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_GENERIC_SCALAR.checkType(paramType) ){ PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.INTEGER, paramType); } setLongX(parameterIndex, x); } } catch ( SqlException se ) { throw se.getSQLException(); } } void setLongX(final int parameterIndex, final long x) { // Column numbers starts at 1, clientParamtertype_[0] refers to column 1 parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.BIGINT; setInput(parameterIndex, new Long(x)); } public void setFloat(int parameterIndex, float x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setFloat", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_GENERIC_SCALAR.checkType(paramType) ){ PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.FLOAT, paramType); } parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.REAL; setInput(parameterIndex, new Float(x)); } } catch ( SqlException se ) { throw se.getSQLException(); } } public void setDouble(int parameterIndex, double x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setDouble", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_GENERIC_SCALAR.checkType(paramType) ){ PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.DOUBLE, paramType); } parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.DOUBLE; setInput(parameterIndex, new Double(x)); } } catch ( SqlException se ) { throw se.getSQLException(); } } public void setBigDecimal(int parameterIndex, java.math.BigDecimal x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBigDecimal", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_GENERIC_SCALAR.checkType( paramType ) ){ PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.BIGINT, paramType); } parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.DECIMAL; if (x == null) { setNull(parameterIndex, java.sql.Types.DECIMAL); return; } int registerOutScale = 0; setInput(parameterIndex, x); } } catch ( SqlException se ) { throw se.getSQLException(); } } public void setDate(int parameterIndex, Date x, Calendar calendar) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry( this, "setDate", parameterIndex, x, calendar); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_DATE.checkType(paramType) ){ PossibleTypes.throw22005Exception(agent_.logWriter_ , java.sql.Types.DATE, paramType); } checkForClosedStatement(); if (calendar == null) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.INVALID_API_PARAMETER), "null", "calendar", "setDate()"); } parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.DATE; if (x == null) { setNull(parameterIndex, java.sql.Types.DATE); return; } setInput(parameterIndex, new DateTimeValue(x, calendar)); } } catch ( SqlException se ) { throw se.getSQLException(); } } public void setDate(int parameterIndex, Date x) throws SQLException { setDate(parameterIndex, x, Calendar.getInstance()); } public void setTime(int parameterIndex, Time x, Calendar calendar) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setTime", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_TIME.checkType( paramType ) ){ PossibleTypes.throw22005Exception( agent_.logWriter_, java.sql.Types.TIME, paramType ); } if (calendar == null) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.INVALID_API_PARAMETER), "null", "calendar", "setTime()"); } parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.TIME; if (x == null) { setNull(parameterIndex, java.sql.Types.TIME); return; } setInput(parameterIndex, new DateTimeValue(x, calendar)); } } catch ( SqlException se ) { throw se.getSQLException(); } } public void setTime(int parameterIndex, Time x) throws SQLException { setTime(parameterIndex, x, Calendar.getInstance()); } public void setTimestamp(int parameterIndex, Timestamp x, Calendar calendar) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setTimestamp", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_TIMESTAMP.checkType( paramType ) ) { PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.TIMESTAMP, paramType); } if (calendar == null) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.INVALID_API_PARAMETER), "null", "calendar", "setTimestamp()"); } parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.TIMESTAMP; if (x == null) { setNull(parameterIndex, java.sql.Types.TIMESTAMP); return; } setInput(parameterIndex, new DateTimeValue(x, calendar)); } } catch ( SqlException se ) { throw se.getSQLException(); } } public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { setTimestamp(parameterIndex, x, Calendar.getInstance()); } public void setString(int parameterIndex, String x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setString", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_STRING.checkType( paramType ) ){ PossibleTypes.throw22005Exception(agent_.logWriter_ , java.sql.Types.VARCHAR, paramType); } setStringX(parameterIndex, x); } } catch ( SqlException se ) { throw se.getSQLException(); } } // also used by DBMD methods void setStringX(int parameterIndex, String x) throws SqlException { parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.LONGVARCHAR; if (x == null) { setNullX(parameterIndex, java.sql.Types.LONGVARCHAR); return; } setInput(parameterIndex, x); } public void setBytes(int parameterIndex, byte[] x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBytes", parameterIndex, x); } final int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_BYTES.checkType( paramType ) ){ PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.VARBINARY, paramType ); } setBytesX(parameterIndex, x); } } catch ( SqlException se ) { throw se.getSQLException(); } } // also used by BLOB public void setBytesX(int parameterIndex, byte[] x) throws SqlException { parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.LONGVARBINARY; if (x == null) { setNullX(parameterIndex, java.sql.Types.LONGVARBINARY); return; } setInput(parameterIndex, x); } /** * sets the parameter to the Binary Stream object * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the java input stream which contains the binary parameter value * @param length the number of bytes in the stream * @exception SQLException thrown on failure. */ public void setBinaryStream(int parameterIndex, java.io.InputStream x, long length) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBinaryStream", parameterIndex, "<input stream>", new Long(length)); } checkTypeForSetBinaryStream(parameterIndex); checkStreamLength(length); setBinaryStreamX(parameterIndex, x, (int)length); } } catch ( SqlException se ) { throw se.getSQLException(); } } /** * sets the parameter to the Binary Stream object * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the java input stream which contains the binary parameter value * @param length the number of bytes in the stream * @exception SQLException thrown on failure. */ public void setBinaryStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException { setBinaryStream(parameterIndex,x,(long)length); } protected void setBinaryStreamX(int parameterIndex, java.io.InputStream x, int length) throws SqlException { parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.BLOB; if (x == null) { setNullX(parameterIndex, java.sql.Types.BLOB); return; } Blob blob; if (length == -1) { // Create a blob of unknown length. This might cause an // OutOfMemoryError due to the temporary implementation in Blob. // The whole stream will be materialzied. See comments in Blob. blob = new Blob(agent_, x); } else { blob = new Blob(agent_, x, length); } setInput(parameterIndex, blob); } /** * We do this inefficiently and read it all in here. The target type * is assumed to be a String. * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the java input stream which contains the ASCII parameter value * @param length the number of bytes in the stream * @exception SQLException thrown on failure. */ public void setAsciiStream(int parameterIndex, java.io.InputStream x, long length) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setAsciiStream", parameterIndex, "<input stream>", new Long(length)); } checkTypeForSetAsciiStream(parameterIndex); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.CLOB; if (x == null) { setNull(parameterIndex, java.sql.Types.LONGVARCHAR); return; } checkStreamLength(length); setInput(parameterIndex, new Clob(agent_, x, "ISO-8859-1", (int)length)); } } catch ( SqlException se ) { throw se.getSQLException(); } } /** * We do this inefficiently and read it all in here. The target type * is assumed to be a String. * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the java input stream which contains the ASCII parameter value * @param length the number of bytes in the stream * @exception SQLException thrown on failure. */ public void setAsciiStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException { setAsciiStream(parameterIndex,x,(long)length); } /** * Check the length passed in for the stream that is to be set. If length is * larger than Integer.MAX_VALUE or smaller that 0, we fail by throwing an * SQLException. * @param length The length of the stream being set * @throws SQLException Thrown for a negative or too large length. */ private void checkStreamLength(long length) throws SQLException { if(length > Integer.MAX_VALUE) { throw new SqlException( agent_.logWriter_, new ClientMessageId( SQLState.CLIENT_LENGTH_OUTSIDE_RANGE_FOR_DATATYPE), new Long(length), new Integer(Integer.MAX_VALUE) ).getSQLException(); } else if (length < 0) { throw new SqlException( agent_.logWriter_, new ClientMessageId(SQLState.NEGATIVE_STREAM_LENGTH) ).getSQLException(); } } private void checkTypeForSetAsciiStream(int parameterIndex) throws SqlException, SQLException { int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if ( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_ASCIISTREAM.checkType( paramType ) ) { PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.LONGVARCHAR, paramType); } } private void checkTypeForSetBinaryStream(int parameterIndex) throws SqlException, SQLException { int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if (!PossibleTypes.POSSIBLE_TYPES_IN_SET_BINARYSTREAM. checkType(paramType)) { PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.VARBINARY, paramType); } } private void checkTypeForSetCharacterStream(int parameterIndex) throws SqlException, SQLException { int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if (!PossibleTypes.POSSIBLE_TYPES_IN_SET_CHARACTERSTREAM. checkType(paramType)) { PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.LONGVARCHAR, paramType); } } private void checkTypeForSetBlob(int parameterIndex) throws SqlException, SQLException { int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_BLOB.checkType( paramType ) ){ PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.BLOB, paramType); } } private void checkTypeForSetClob(int parameterIndex) throws SqlException, SQLException { int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if( ! PossibleTypes.POSSIBLE_TYPES_IN_SET_CLOB.checkType( paramType ) ){ PossibleTypes.throw22005Exception(agent_.logWriter_, java.sql.Types.CLOB, paramType); } } /** * Sets the specified parameter to the given input stream. Deprecated * in JDBC 3.0 and this method will always just throw a feature not * implemented exception. * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the java input stream which contains the UNICODE parameter * value * @param length the number of bytes in the stream * @exception SQLException throws feature not implemented. * @deprecated */ public void setUnicodeStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceDeprecatedEntry(this, "setUnicodeStream", parameterIndex, "<input stream>", length); } throw SQLExceptionFactory.notImplemented ("setUnicodeStream"); } /** * Sets the designated parameter to the given <code>Reader</code> object. * When a very large UNICODE value is input to a LONGVARCHAR parameter, it * may be more practical to send it via a <code>java.io.Reader</code> * object. The data will be read from the stream as needed until * end-of-file is reached. The JDBC driver will do any necessary conversion * from UNICODE to the database char format. * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the <code>java.io.Reader</code> object that contains the * Unicode data * @throws SQLException if a database access error occurs or this method is * called on a closed <code>PreparedStatement</code> */ public void setCharacterStream(int parameterIndex, Reader x) throws SQLException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setCharacterStream", parameterIndex, x); } try { checkTypeForSetCharacterStream(parameterIndex); parameterMetaData_.clientParamtertype_[parameterIndex -1] = java.sql.Types.CLOB; if (x == null) { setNull(parameterIndex, java.sql.Types.LONGVARCHAR); return; } setInput(parameterIndex, new Clob(agent_, x)); } catch (SqlException se) { throw se.getSQLException(); } } } /** * Sets the designated parameter to the given Reader, which will have * the specified number of bytes. * * @param parameterIndex the index of the parameter to which this set * method is applied * @param x the java Reader which contains the UNICODE value * @param length the number of bytes in the stream * @exception SQLException thrown on failure. * */ public void setCharacterStream(int parameterIndex, java.io.Reader x, long length) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setCharacterStream", parameterIndex, x, new Long(length)); } checkTypeForSetCharacterStream(parameterIndex); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.CLOB; if (x == null) { setNull(parameterIndex, java.sql.Types.LONGVARCHAR); return; } checkStreamLength(length); setInput(parameterIndex, new Clob(agent_, x, (int)length)); } } catch ( SqlException se ) { throw se.getSQLException(); } } /** * Sets the designated parameter to the given Reader, which will have * the specified number of bytes. * * @param parameterIndex the index of the parameter to which this * set method is applied * @param x the java Reader which contains the UNICODE value * @param length the number of bytes in the stream * @exception SQLException thrown on failure. * */ public void setCharacterStream(int parameterIndex, java.io.Reader x, int length) throws SQLException { setCharacterStream(parameterIndex,x,(long)length); } public void setBlob(int parameterIndex, java.sql.Blob x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBlob", parameterIndex, x); } checkTypeForSetBlob(parameterIndex); setBlobX(parameterIndex, x); } } catch ( SqlException se ) { throw se.getSQLException(); } } // also used by Blob public void setBlobX(int parameterIndex, java.sql.Blob x) throws SqlException { parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.BLOB; if (x == null) { setNullX(parameterIndex, java.sql.Types.BLOB); return; } setInput(parameterIndex, x); } public void setClob(int parameterIndex, java.sql.Clob x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setClob", parameterIndex, x); } checkTypeForSetClob(parameterIndex); setClobX(parameterIndex, x); } } catch ( SqlException se ) { throw se.getSQLException(); } } // also used by Clob void setClobX(int parameterIndex, java.sql.Clob x) throws SqlException { parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.CLOB; if (x == null) { this.setNullX(parameterIndex, Types.CLOB); return; } setInput(parameterIndex, x); } public void setArray(int parameterIndex, java.sql.Array x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setArray", parameterIndex, x); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.JDBC_METHOD_NOT_IMPLEMENTED)); } } catch ( SqlException se ) { throw se.getSQLException(); } } public void setRef(int parameterIndex, java.sql.Ref x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setRef", parameterIndex, x); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.JDBC_METHOD_NOT_IMPLEMENTED)); } } catch ( SqlException se ) { throw se.getSQLException(); } } // The Java compiler uses static binding, so we must use instanceof // rather than to rely on separate setObject() methods for // each of the Java Object instance types recognized below. public void setObject(int parameterIndex, Object x) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setObject", parameterIndex, x); } int paramType = getColumnMetaDataX().getColumnType(parameterIndex); if ( paramType == java.sql.Types.JAVA_OBJECT ) { setUDTX( parameterIndex, x ); } else if (x == null) { // DERBY-1938: Allow setting Java null also when the // column type isn't specified explicitly by the // user. Maps Java null to SQL NULL. setNull(parameterIndex, paramType); } else if (x instanceof String) { setString(parameterIndex, (String) x); } else if (x instanceof Integer) { setInt(parameterIndex, ((Integer) x).intValue()); } else if (x instanceof Double) { setDouble(parameterIndex, ((Double) x).doubleValue()); } else if (x instanceof Float) { setFloat(parameterIndex, ((Float) x).floatValue()); } else if (x instanceof Boolean) { setBoolean(parameterIndex, ((Boolean) x).booleanValue()); } else if (x instanceof Long) { setLong(parameterIndex, ((Long) x).longValue()); } else if (x instanceof byte[]) { setBytes(parameterIndex, (byte[]) x); } else if (x instanceof java.math.BigDecimal) { setBigDecimal(parameterIndex, (java.math.BigDecimal) x); } else if (x instanceof java.sql.Date) { setDate(parameterIndex, (java.sql.Date) x); } else if (x instanceof java.sql.Time) { setTime(parameterIndex, (java.sql.Time) x); } else if (x instanceof java.sql.Timestamp) { setTimestamp(parameterIndex, (java.sql.Timestamp) x); } else if (x instanceof java.sql.Blob) { setBlob(parameterIndex, (java.sql.Blob) x); } else if (x instanceof java.sql.Clob) { setClob(parameterIndex, (java.sql.Clob) x); } else if (x instanceof java.sql.Array) { setArray(parameterIndex, (java.sql.Array) x); } else if (x instanceof java.sql.Ref) { setRef(parameterIndex, (java.sql.Ref) x); } else if (x instanceof Short) { setShort(parameterIndex, ((Short) x).shortValue()); } else if (x instanceof Byte) { setByte(parameterIndex, ((Byte) x).byteValue()); } else { checkForClosedStatement(); checkForValidParameterIndex(parameterIndex); throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.UNSUPPORTED_TYPE)); } } } catch ( SqlException se ) { throw se.getSQLException(); } } /** * Set a UDT parameter to an object value. */ private void setUDTX(int parameterIndex, Object x) throws SqlException, SQLException { int paramType = getColumnMetaDataX().getColumnType(parameterIndex); int expectedType = java.sql.Types.JAVA_OBJECT; if ( !( paramType == expectedType ) ) { PossibleTypes.throw22005Exception (agent_.logWriter_, expectedType, paramType ); } parameterMetaData_.clientParamtertype_[parameterIndex - 1] = expectedType; if (x == null) { setNullX(parameterIndex, expectedType ); return; } // // Make sure that we are setting the parameter to an instance of the UDT. // Throwable problem = null; String sourceClassName = x.getClass().getName(); String targetClassName = getColumnMetaDataX().getColumnClassName(parameterIndex); try { Class targetClass = Class.forName( targetClassName ); if ( targetClass.isInstance( x ) ) { setInput(parameterIndex, x); return; } } catch (ClassNotFoundException e) { problem = e; } throw new SqlException ( agent_.logWriter_, new ClientMessageId( SQLState.NET_UDT_COERCION_ERROR ), new Object[] { sourceClassName, targetClassName }, problem ); } public void setObject(int parameterIndex, Object x, int targetJdbcType) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setObject", parameterIndex, x, targetJdbcType); } checkForClosedStatement(); setObjectX(parameterIndex, x, targetJdbcType, 0); } } catch ( SqlException se ) { throw se.getSQLException(); } } public void setObject(int parameterIndex, Object x, int targetJdbcType, int scale) throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setObject", parameterIndex, x, targetJdbcType, scale); } checkForClosedStatement(); setObjectX(parameterIndex, x, targetJdbcType, scale); } } catch ( SqlException se ) { throw se.getSQLException(); } } private void setObjectX(int parameterIndex, Object x, int targetJdbcType, int scale) throws SqlException { checkForValidParameterIndex(parameterIndex); checkForValidScale(scale); // JDBC 4.0 requires us to throw SQLFeatureNotSupportedException for // certain target types if they are not supported. checkForSupportedDataType(targetJdbcType); if (x == null) { setNullX(parameterIndex, targetJdbcType); return; } // JDBC Spec specifies that conversion should occur on the client if // the targetJdbcType is specified. int inputParameterType = CrossConverters.getInputJdbcType(targetJdbcType); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = inputParameterType; x = agent_.crossConverters_.setObject(inputParameterType, x); // Set to round down on setScale like embedded does in SQLDecimal try { if (targetJdbcType == java.sql.Types.DECIMAL || targetJdbcType == java.sql.Types.NUMERIC) { x = ((java.math.BigDecimal) x).setScale(scale, java.math.BigDecimal.ROUND_DOWN); } } catch (ArithmeticException ae) { // Any problems with scale should have already been caught by // checkForvalidScale throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.JAVA_EXCEPTION), new Object[] {ae.getClass().getName(), ae.getMessage()}, ae); } try { setObject(parameterIndex, x); } catch ( SQLException se ) { throw new SqlException(se); } } // Since parameters are cached as objects in parameters_[], // java null may be used to represent SQL null. public void clearParameters() throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "clearParameters"); } checkForClosedStatement(); if (parameterMetaData_ != null) { Arrays.fill(parameters_, null); Arrays.fill(parameterSet_, false); } } } catch ( SqlException se ) { throw se.getSQLException(); } } public boolean execute() throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute"); } boolean b = executeX(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "execute", b); } return b; } } catch ( SqlException se ) { checkStatementValidity(se); throw se.getSQLException(); } } // also used by SQLCA boolean executeX() throws SqlException { flowExecute(executeMethod__); return resultSet_ != null; } //--------------------------JDBC 2.0----------------------------- public void addBatch() throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "addBatch"); } checkForClosedStatement(); checkThatAllParametersAreSet(); if (parameterTypeList == null) { parameterTypeList = new ArrayList(); } // ASSERT: since OUT/INOUT parameters are not allowed, there should // be no problem in sharing the JDBC Wrapper object instances // since they will not be modified by the driver. // batch up the parameter values -- deep copy req'd if (parameterMetaData_ != null) { Object[] inputsClone = new Object[parameters_.length]; System.arraycopy(parameters_, 0, inputsClone, 0, parameters_.length); batch_.add(inputsClone); // Get a copy of the parameter type data and save it in a list // which will be used later on at the time of batch execution. parameterTypeList.add(parameterMetaData_.clientParamtertype_.clone()); } else { batch_.add(null); parameterTypeList.add(null); } } } catch ( SqlException se ) { throw se.getSQLException(); } } // Batch requires that input types are exact, we perform no input cross conversion for Batch. // If so, this is an external semantic, and should go into the release notes public int[] executeBatch() throws SQLException, BatchUpdateException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeBatch"); } int[] updateCounts = null; updateCounts = executeBatchX(false); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "executeBatch", updateCounts); } return updateCounts; } } catch ( SqlException se ) { throw se.getSQLException(); } } public java.sql.ResultSetMetaData getMetaData() throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getMetaData"); } ColumnMetaData resultSetMetaData = getMetaDataX(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getMetaData", resultSetMetaData); } return resultSetMetaData; } } catch ( SqlException se ) { throw se.getSQLException(); } } private ColumnMetaData getMetaDataX() throws SqlException { super.checkForClosedStatement(); return resultSetMetaData_; } //------------------------- JDBC 3.0 ----------------------------------- public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql, autoGeneratedKeys); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.NOT_FOR_PREPARED_STATEMENT), "execute(String, int)").getSQLException(); } public boolean execute(String sql, String[] columnNames) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql, columnNames); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.NOT_FOR_PREPARED_STATEMENT), "execute(String, String[])").getSQLException(); } public boolean execute(String sql, int[] columnIndexes) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql, columnIndexes); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.NOT_FOR_PREPARED_STATEMENT), "execute(String, int[])").getSQLException(); } public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate", autoGeneratedKeys); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.NOT_FOR_PREPARED_STATEMENT), "executeUpdate(String, int)").getSQLException(); } public int executeUpdate(String sql, String[] columnNames) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate", columnNames); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.NOT_FOR_PREPARED_STATEMENT), "executeUpdate(String, String[])").getSQLException(); } public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate", columnIndexes); } throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.NOT_FOR_PREPARED_STATEMENT), "execute(String, int[])").getSQLException(); } public void setURL(int parameterIndex, java.net.URL x) throws SQLException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setURL", parameterIndex, x); } jdbc3FeatureNotSupported(false); } public java.sql.ParameterMetaData getParameterMetaData() throws SQLException { try { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getParameterMetaData"); } Object parameterMetaData = getParameterMetaDataX(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getParameterMetaData", parameterMetaData); } return (java.sql.ParameterMetaData) parameterMetaData; } } catch ( SqlException se ) { throw se.getSQLException(); } } private ParameterMetaData getParameterMetaDataX() throws SqlException { ParameterMetaData pm = ClientDriver.getFactory().newParameterMetaData ( getColumnMetaDataX() ); return pm; } private ColumnMetaData getColumnMetaDataX() throws SqlException { checkForClosedStatement(); return parameterMetaData_ != null ? parameterMetaData_ : ClientDriver.getFactory().newColumnMetaData(agent_.logWriter_, 0); } // ------------------------ box car and callback methods -------------------------------- public void writeExecute(Section section, ColumnMetaData parameterMetaData, Object[] inputs, int numInputColumns, boolean outputExpected, // This is a hint to the material layer that more write commands will follow. // It is ignored by the driver in all cases except when blob data is written, // in which case this boolean is used to optimize the implementation. // Otherwise we wouldn't be able to chain after blob data is sent. // Current servers have a restriction that blobs can only be chained with blobs boolean chainedWritesFollowingSetLob) throws SqlException { materialPreparedStatement_.writeExecute_(section, parameterMetaData, inputs, numInputColumns, outputExpected, chainedWritesFollowingSetLob); } public void readExecute() throws SqlException { materialPreparedStatement_.readExecute_(); } private void writeOpenQuery(Section section, int fetchSize, int resultSetType, int numInputColumns, ColumnMetaData parameterMetaData, Object[] inputs) throws SqlException { materialPreparedStatement_.writeOpenQuery_(section, fetchSize, resultSetType, numInputColumns, parameterMetaData, inputs); } public void writeDescribeInput(Section section) throws SqlException { materialPreparedStatement_.writeDescribeInput_(section); } public void readDescribeInput() throws SqlException { materialPreparedStatement_.readDescribeInput_(); } public void completeDescribeInput(ColumnMetaData parameterMetaData, Sqlca sqlca) { int sqlcode = super.completeSqlca(sqlca); if (sqlcode < 0) { return; } parameterMetaData_ = parameterMetaData; // The following code handles the case when // sqlxParmmode is not supported, in which case server will return 0 (unknown), and // this could clobber our guessed value for sqlxParmmode. This is a problem. // We can solve this problem for Non-CALL statements, since the parmmode is always IN (1). // But what about CALL statements. If CALLs are describable, then we have no // problem, we assume server won't return unknown. // If CALLs are not describable then nothing gets clobbered because we won't // parse out extended describe, so again no problem. if (sqlMode_ != isCall__ && parameterMetaData_ != null) { // 1 means IN parameter Arrays.fill(parameterMetaData_.sqlxParmmode_, (short)1); } if (agent_.loggingEnabled()) { agent_.logWriter_.traceParameterMetaData(this, parameterMetaData_); } } public void writeDescribeOutput(Section section) throws SqlException { materialPreparedStatement_.writeDescribeOutput_(section); } public void readDescribeOutput() throws SqlException { materialPreparedStatement_.readDescribeOutput_(); } public void completeDescribeOutput(ColumnMetaData resultSetMetaData, Sqlca sqlca) { int sqlcode = super.completeSqlca(sqlca); if (sqlcode < 0) { return; } resultSetMetaData_ = resultSetMetaData; if (agent_.loggingEnabled()) { agent_.logWriter_.traceResultSetMetaData(this, resultSetMetaData); } } void writePrepareDescribeInputOutput() throws SqlException { // Notice that sql_ is passed in since in general ad hoc sql must be passed in for unprepared statements writePrepareDescribeOutput(sql_, section_); writeDescribeInput(section_); } void readPrepareDescribeInputOutput() throws SqlException { readPrepareDescribeOutput(); readDescribeInput(); completePrepareDescribe(); } void writePrepareDescribeInput() throws SqlException { // performance will be better if we flow prepare with output enable vs. prepare then describe input for callable // Notice that sql_ is passed in since in general ad hoc sql must be passed in for unprepared statements writePrepare(sql_, section_); writeDescribeInput(section_); } void readPrepareDescribeInput() throws SqlException { readPrepare(); readDescribeInput(); completePrepareDescribe(); } void completePrepareDescribe() { if (parameterMetaData_ == null) { return; } parameters_ = expandObjectArray(parameters_, parameterMetaData_.columns_); parameterSet_ = expandBooleanArray(parameterSet_, parameterMetaData_.columns_); parameterRegistered_ = expandBooleanArray(parameterRegistered_, parameterMetaData_.columns_); } private Object[] expandObjectArray(Object[] array, int newLength) { if (array == null) { Object[] newArray = new Object[newLength]; return newArray; } if (array.length < newLength) { Object[] newArray = new Object[newLength]; System.arraycopy(array, 0, newArray, 0, array.length); return newArray; } return array; } private boolean[] expandBooleanArray(boolean[] array, int newLength) { if (array == null) { boolean[] newArray = new boolean[newLength]; return newArray; } if (array.length < newLength) { boolean[] newArray = new boolean[newLength]; System.arraycopy(array, 0, newArray, 0, array.length); return newArray; } return array; } void writePrepareDescribeInputOutput(String sql, Section section) throws SqlException { // Notice that sql_ is passed in since in general ad hoc sql must be passed in for unprepared statements writePrepareDescribeOutput(sql, section); writeDescribeInput(section); } void flowPrepareDescribeInputOutput() throws SqlException { agent_.beginWriteChain(this); if (sqlMode_ == isCall__) { writePrepareDescribeInput(); agent_.flow(this); readPrepareDescribeInput(); agent_.endReadChain(); } else { writePrepareDescribeInputOutput(); agent_.flow(this); readPrepareDescribeInputOutput(); agent_.endReadChain(); } } private void flowExecute(int executeType) throws SqlException { checkForClosedStatement(); checkAutoGeneratedKeysParameters(); clearWarningsX(); checkForAppropriateSqlMode(executeType, sqlMode_); checkThatAllParametersAreSet(); if (sqlMode_ == isUpdate__) { updateCount_ = 0; } else { updateCount_ = -1; } // DERBY-1036: Moved check till execute time to comply with embedded // behavior. Since we check here and not in setCursorName, several // statements can have the same cursor name as long as their result // sets are not simultaneously open. if (sqlMode_ == isQuery__) { checkForDuplicateCursorName(); } agent_.beginWriteChain(this); boolean piggybackedAutocommit = writeCloseResultSets(true); // true means permit auto-commits int numInputColumns; boolean outputExpected; try { numInputColumns = (parameterMetaData_ != null) ? parameterMetaData_.getColumnCount() : 0; outputExpected = (resultSetMetaData_ != null && resultSetMetaData_.getColumnCount() > 0); } catch ( SQLException se ) { // Generate a SqlException for this, we don't want to throw // SQLException in this internal method throw new SqlException(se); } boolean chainAutoCommit = false; boolean commitSubstituted = false; boolean repositionedCursor = false; boolean timeoutSent = false; ResultSet scrollableRS = null; if (doWriteTimeout) { timeoutArrayList.set(0, TIMEOUT_STATEMENT + timeout_); writeSetSpecialRegister(timeoutArrayList); doWriteTimeout = false; timeoutSent = true; } switch (sqlMode_) { case isUpdate__: if (positionedUpdateCursorName_ != null) { scrollableRS = agent_.sectionManager_.getPositionedUpdateResultSet(positionedUpdateCursorName_); } if (scrollableRS != null && !scrollableRS.isRowsetCursor_) { repositionedCursor = scrollableRS.repositionScrollableResultSetBeforeJDBC1PositionedUpdateDelete(); if (!repositionedCursor) { scrollableRS = null; } } chainAutoCommit = connection_.willAutoCommitGenerateFlow() && isAutoCommittableStatement_; boolean chainOpenQueryForAutoGeneratedKeys = (sqlUpdateMode_ == isInsertSql__ && autoGeneratedKeys_ == RETURN_GENERATED_KEYS); writeExecute(section_, parameterMetaData_, parameters_, numInputColumns, outputExpected, (chainAutoCommit || chainOpenQueryForAutoGeneratedKeys)// chain flag ); // chain flag if (chainOpenQueryForAutoGeneratedKeys) { prepareAutoGeneratedKeysStatement(); writeOpenQuery(preparedStatementForAutoGeneratedKeys_.section_, preparedStatementForAutoGeneratedKeys_.fetchSize_, preparedStatementForAutoGeneratedKeys_.resultSetType_); } if (chainAutoCommit) { // we have encountered an error in writing the execute, so do not // flow an autocommit if (agent_.accumulatedReadExceptions_ != null) { // currently, the only write exception we encounter is for // data truncation: SQLSTATE 01004, so we don't bother checking for this connection_.writeCommitSubstitute_(); commitSubstituted = true; } else { // there is no write error, so flow the commit connection_.writeCommit(); } } break; case isQuery__: writeOpenQuery(section_, fetchSize_, resultSetType_, numInputColumns, parameterMetaData_, parameters_); break; case isCall__: writeExecuteCall(outputRegistered_, // if no out/inout parameter, outputExpected = false null, section_, fetchSize_, false, // do not suppress ResultSets for regular CALLs resultSetType_, parameterMetaData_, parameters_); // cross conversion break; } agent_.flow(this); super.readCloseResultSets(true); // true means permit auto-commits // turn inUnitOfWork_ flag back on and add statement // back on commitListeners_ list if they were off // by an autocommit chained to a close cursor. if (piggybackedAutocommit) { connection_.completeTransactionStart(); } markResultSetsClosed(true); // true means remove from list of commit and rollback listeners if (timeoutSent) { readSetSpecialRegister(); // Read response to the EXCSQLSET } switch (sqlMode_) { case isUpdate__: // do not need to reposition for a rowset cursor if (scrollableRS != null && !scrollableRS.isRowsetCursor_) { scrollableRS.readPositioningFetch_(); } else { readExecute(); if (sqlUpdateMode_ == isInsertSql__ && autoGeneratedKeys_ == RETURN_GENERATED_KEYS) { readPrepareAutoGeneratedKeysStatement(); preparedStatementForAutoGeneratedKeys_.readOpenQuery(); generatedKeysResultSet_ = preparedStatementForAutoGeneratedKeys_.resultSet_; preparedStatementForAutoGeneratedKeys_.resultSet_ = null; } } if (chainAutoCommit) { if (commitSubstituted) { connection_.readCommitSubstitute_(); } else { connection_.readCommit(); } } break; case isQuery__: try { readOpenQuery(); } catch (DisconnectException dise) { throw dise; } catch (SqlException e) { throw e; } // resultSet_ is null if open query failed. // check for null resultSet_ before using it. if (resultSet_ != null) { resultSet_.parseScrollableRowset(); //if (resultSet_.scrollable_) resultSet_.getRowCount(); // DERBY-1183: If we set it up earlier, the entry in // clientCursorNameCache_ gets wiped out by the closing of // result sets happening during readCloseResultSets above // because ResultSet#markClosed calls // Statement#removeClientCursorNameFromCache. setupCursorNameCacheAndMappings(); } break; case isCall__: readExecuteCall(); break; } try { agent_.endReadChain(); } catch (SqlException e) { throw e; } if (sqlMode_ == isCall__) { parseStorProcReturnedScrollableRowset(); checkForStoredProcResultSetCount(executeType); // When there are no result sets back, we will commit immediately when autocommit is true. // make sure a commit is not performed when making the call to the sqlca message procedure if (connection_.autoCommit_ && resultSet_ == null && resultSetList_ == null && isAutoCommittableStatement_) { connection_.flowAutoCommit(); } } // The JDBC spec says that executeUpdate() should return 0 // when no row count is returned. if (executeType == executeUpdateMethod__ && updateCount_ < 0) { updateCount_ = 0; } // Throw an exception if holdability returned by the server is different from requested. if (resultSet_ != null && resultSet_.resultSetHoldability_ != resultSetHoldability_ && sqlMode_ != isCall__) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.UNABLE_TO_OPEN_RESULTSET_WITH_REQUESTED_HOLDABILTY), new Integer(resultSetHoldability_)); } } public int[] executeBatchX(boolean supportsQueryBatchRequest) throws SqlException, SQLException, BatchUpdateException { synchronized (connection_) { checkForClosedStatement(); // Per jdbc spec (see Statement.close() javadoc) clearWarningsX(); // Per jdbc spec 0.7, also see getWarnings() javadoc return executeBatchRequestX(supportsQueryBatchRequest); } } private int[] executeBatchRequestX(boolean supportsQueryBatchRequest) throws SqlException, BatchUpdateException { SqlException chainBreaker = null; int batchSize = batch_.size(); int[] updateCounts = new int[batchSize]; int numInputColumns; try { numInputColumns = parameterMetaData_ == null ? 0 : parameterMetaData_.getColumnCount(); } catch ( SQLException se ) { throw new SqlException(se); } Object[] savedInputs = null; // used to save/restore existing parameters boolean timeoutSent = false; if (batchSize == 0) { return updateCounts; } // The network client has a hard limit of 65,534 commands in a single // DRDA request. This is because DRDA uses a 2-byte correlation ID, // and the values 0 and 0xffff are reserved as special values. So // that imposes an upper limit on the batch size we can support: if (batchSize > 65534) throw new BatchUpdateException(agent_.logWriter_, new ClientMessageId(SQLState.TOO_MANY_COMMANDS_FOR_BATCH), new Integer(65534), updateCounts); // Initialize all the updateCounts to indicate failure // This is done to account for "chain-breaking" errors where we cannot // read any more replies for (int i = 0; i < batchSize; i++) { updateCounts[i] = -3; } if (!supportsQueryBatchRequest && sqlMode_ == isQuery__) { throw new BatchUpdateException(agent_.logWriter_, new ClientMessageId(SQLState.CANNOT_BATCH_QUERIES), updateCounts); } if (supportsQueryBatchRequest && sqlMode_ != isQuery__) { throw new BatchUpdateException(agent_.logWriter_, new ClientMessageId(SQLState.QUERY_BATCH_ON_NON_QUERY_STATEMENT), updateCounts); } resultSetList_ = null; if (sqlMode_ == isQuery__) { indexOfCurrentResultSet_ = -1; //reset ResultSetList resultSetList_ = new ResultSet[batchSize]; } //save the current input set so it can be restored savedInputs = parameters_; agent_.beginBatchedWriteChain(this); boolean chainAutoCommit = connection_.willAutoCommitGenerateFlow() && isAutoCommittableStatement_; if (doWriteTimeout) { timeoutArrayList.set(0, TIMEOUT_STATEMENT + timeout_); writeSetSpecialRegister(timeoutArrayList); doWriteTimeout = false; timeoutSent = true; } for (int i = 0; i < batchSize; i++) { if (parameterMetaData_ != null) { parameterMetaData_.clientParamtertype_ = (int[]) parameterTypeList.get(i); parameters_ = (Object[]) batch_.get(i); } if (sqlMode_ != isCall__) { boolean outputExpected; try { outputExpected = (resultSetMetaData_ != null && resultSetMetaData_.getColumnCount() > 0); } catch ( SQLException se ) { throw new SqlException(se); } writeExecute(section_, parameterMetaData_, parameters_, numInputColumns, outputExpected, chainAutoCommit || (i != batchSize - 1)); // more statements to chain } else if (outputRegistered_) // make sure no output parameters are registered { throw new BatchUpdateException(agent_.logWriter_, new ClientMessageId(SQLState.OUTPUT_PARAMS_NOT_ALLOWED), updateCounts); } else { writeExecuteCall(false, // no output expected for batched CALLs null, // no procedure name supplied for prepared CALLs section_, fetchSize_, true, // suppress ResultSets for batch resultSetType_, parameterMetaData_, parameters_); } } boolean commitSubstituted = false; if (chainAutoCommit) { // we have encountered an error in writing the execute, so do not // flow an autocommit if (agent_.accumulatedReadExceptions_ != null) { // currently, the only write exception we encounter is for // data truncation: SQLSTATE 01004, so we don't bother checking for this connection_.writeCommitSubstitute_(); commitSubstituted = true; } else { // there is no write error, so flow the commit connection_.writeCommit(); } } agent_.flowBatch(this, batchSize); if (timeoutSent) { readSetSpecialRegister(); // Read response to the EXCSQLSET } try { for (int i = 0; i < batchSize; i++) { agent_.setBatchedExceptionLabelIndex(i); parameters_ = (Object[]) batch_.get(i); if (sqlMode_ != isCall__) { readExecute(); } else { readExecuteCall(); } updateCounts[i] = updateCount_; } agent_.disableBatchedExceptionTracking(); // to prvent the following readCommit() from getting a batch label if (chainAutoCommit) { if (!commitSubstituted) { connection_.readCommit(); } else { connection_.readCommitSubstitute_(); } } } // for chain-breaking exception only, all read() methods do their own accumulation // this catches the entire accumulated chain, we need to be careful not to // reaccumulate it on the agent since the batch labels will be overwritten if // batch exception tracking is enabled. catch (SqlException e) { // for chain-breaking exception only chainBreaker = e; chainBreaker.setNextException(new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BATCH_CHAIN_BREAKING_EXCEPTION))); } // We need to clear the batch before any exception is thrown from agent_.endBatchedReadChain(). batch_.clear(); parameterTypeList = null; // restore the saved input set, setting it to "current" parameters_ = savedInputs; agent_.endBatchedReadChain(updateCounts, chainBreaker); return updateCounts; } //------------------material layer event callbacks follow----------------------- boolean listenToUnitOfWork_ = false; public void listenToUnitOfWork() { if (!listenToUnitOfWork_) { listenToUnitOfWork_ = true; connection_.CommitAndRollbackListeners_.put(this,null); } } public void completeLocalCommit(java.util.Iterator listenerIterator) { if (section_ != null) { openOnServer_ = false; } listenerIterator.remove(); listenToUnitOfWork_ = false; } public void completeLocalRollback(java.util.Iterator listenerIterator) { if (section_ != null) { openOnServer_ = false; } listenerIterator.remove(); listenToUnitOfWork_ = false; } //----------------------------internal use only helper methods---------------- /** * Returns the name of the java.sql interface implemented by this class. * @return name of java.sql interface */ protected String getJdbcStatementInterfaceName() { return "java.sql.PreparedStatement"; } void checkForValidParameterIndex(int parameterIndex) throws SqlException { if (parameterMetaData_ == null) throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.NO_INPUT_PARAMETERS)); if (parameterIndex < 1 || parameterIndex > parameterMetaData_.columns_) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.LANG_INVALID_PARAM_POSITION), new Integer(parameterIndex), new Integer(parameterMetaData_.columns_)); } } private void checkThatAllParametersAreSet() throws SqlException { if (parameterMetaData_ != null) { for (int i = 0; i < parameterMetaData_.columns_; i++) { if (!parameterSet_[i] && !parameterRegistered_[i]) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.LANG_MISSING_PARMS)); } } } } void checkForValidScale(int scale) throws SqlException { if (scale < 0 || scale > 31) { throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BAD_SCALE_VALUE), new Integer(scale)); } } /** * Checks whether a data type is supported for * <code>setObject(int, Object, int)</code> and * <code>setObject(int, Object, int, int)</code>. * * @param dataType the data type to check * @exception SqlException if the type is not supported */ private void checkForSupportedDataType(int dataType) throws SqlException { // JDBC 4.0 javadoc for setObject() says: // // Throws: (...) SQLFeatureNotSupportedException - if // targetSqlType is a ARRAY, BLOB, CLOB, DATALINK, // JAVA_OBJECT, NCHAR, NCLOB, NVARCHAR, LONGNVARCHAR, REF, // ROWID, SQLXML or STRUCT data type and the JDBC driver does // not support this data type // // Of these types, we only support BLOB, CLOB and // (sort of) JAVA_OBJECT. switch (dataType) { case java.sql.Types.ARRAY: case java.sql.Types.DATALINK: case JDBC40Translation.NCHAR: case JDBC40Translation.NCLOB: case JDBC40Translation.NVARCHAR: case JDBC40Translation.LONGNVARCHAR: case java.sql.Types.REF: case JDBC40Translation.ROWID: case JDBC40Translation.SQLXML: case java.sql.Types.STRUCT: throw new SqlException (agent_.logWriter_, new ClientMessageId(SQLState.DATA_TYPE_NOT_SUPPORTED), Types.getTypeString(dataType)); } } void checkScaleForINOUTDecimal(int parameterIndex, int registerOutScale) throws SqlException { java.math.BigDecimal decimalInput = (java.math.BigDecimal) parameters_[parameterIndex - 1]; if (decimalInput == null) { return; } // if the register out scale is greater than input scale, input scale is stored in sqlScale_ if (registerOutScale > parameterMetaData_.sqlScale_[parameterIndex - 1]) { int inputLength = decimalInput.toString().length(); int scaleDifference = registerOutScale - decimalInput.scale(); if (decimalInput.signum() == -1) { inputLength--; } // if the new Decimal (with bigger scale) cannot fit into the DA if ((32 - scaleDifference) < inputLength) { // TODO - FINISH THIS throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.REGOUTPARAM_SCALE_DOESNT_MATCH_SETTER)); } // if the new Decimal (with bigger scale) can fit else { parameters_[parameterIndex - 1] = decimalInput.setScale(registerOutScale); parameterMetaData_.sqlScale_[parameterIndex - 1] = registerOutScale; } } // if the register out sacle is smaller than input scale else if (registerOutScale < parameterMetaData_.sqlScale_[parameterIndex - 1]) { // remove 0's at the end of input try { // if the new Decimal (with smaller scale) can fit parameters_[parameterIndex - 1] = decimalInput.setScale(registerOutScale); parameterMetaData_.sqlScale_[parameterIndex - 1] = registerOutScale; } catch (ArithmeticException e) { // if the new Decimal (with smaller scale) cannot fit into the DA throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.REGOUTPARAM_SCALE_DOESNT_MATCH_SETTER)); } } } /* (non-Javadoc) * @see org.apache.derby.client.am.Statement#markClosed(boolean) */ protected void markClosed(boolean removeListener){ if(pooledConnection_ != null) pooledConnection_.onStatementClose(this); super.markClosed(removeListener); if (parameterMetaData_ != null) { parameterMetaData_.markClosed(); parameterMetaData_ = null; } sql_ = null; // Apparently, the JVM is not smart enough to traverse parameters_[] and null // out its members when the entire array is set to null (parameters_=null;). if (parameters_ != null) { Arrays.fill(parameters_, null); } parameters_ = null; if(removeListener) connection_.CommitAndRollbackListeners_.remove(this); } //jdbc 4.0 methods /** * Sets the designated parameter to the given input stream. * When a very large ASCII value is input to a <code>LONGVARCHAR</code> * parameter, it may be more practical to send it via a * <code>java.io.InputStream</code>. Data will be read from the stream as * needed until end-of-file is reached. The JDBC driver will do any * necessary conversion from ASCII to the database char format. * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the Java input stream that contains the ASCII parameter value * @throws SQLException if a database access error occurs or this method is * called on a closed <code>PreparedStatement</code> */ public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setAsciiStream", parameterIndex, x); } try { checkTypeForSetAsciiStream(parameterIndex); parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.CLOB; if (x == null) { setNull(parameterIndex, java.sql.Types.LONGVARCHAR); return; } setInput(parameterIndex, new Clob(agent_, x, "ISO-8859-1")); } catch (SqlException se) { throw se.getSQLException(); } } } /** * Sets the designated parameter to the given input stream. * When a very large binary value is input to a <code>LONGVARBINARY</code> * parameter, it may be more practical to send it via a * <code>java.io.InputStream</code> object. The data will be read from the * stream as needed until end-of-file is reached. * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the java input stream which contains the binary parameter value * @throws SQLException if a database access error occurs or this method is * called on a closed <code>PreparedStatement</code> */ public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBinaryStream", parameterIndex, x); } try { checkTypeForSetBinaryStream(parameterIndex); setBinaryStreamX(parameterIndex, x, -1); } catch (SqlException se) { throw se.getSQLException(); } } } /** * Sets the designated parameter to a <code>Reader</code> object. * * @param parameterIndex index of the first parameter is 1, the second is * 2, ... * @param reader an object that contains the data to set the parameter * value to. * @throws SQLException if parameterIndex does not correspond to a * parameter marker in the SQL statement; if a database access error * occurs; this method is called on a closed PreparedStatementor if * parameterIndex does not correspond to a parameter marker in the SQL * statement */ public void setClob(int parameterIndex, Reader reader) throws SQLException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setClob", parameterIndex, reader); } try { checkTypeForSetClob(parameterIndex); checkForClosedStatement(); } catch (SqlException se) { throw se.getSQLException(); } setInput(parameterIndex, new Clob(agent_, reader)); } } /** * Sets the designated parameter to a Reader object. * * @param parameterIndex index of the first parameter is 1, the second is 2, ... * @param reader An object that contains the data to set the parameter value to. * @param length the number of characters in the parameter data. * @throws SQLException if parameterIndex does not correspond to a parameter * marker in the SQL statement, or if the length specified is less than zero. * */ public void setClob(int parameterIndex, Reader reader, long length) throws SQLException{ synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setClob", parameterIndex, reader, new Long(length)); } try { checkForClosedStatement(); } catch (SqlException se) { throw se.getSQLException(); } if(length > Integer.MAX_VALUE) throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_TOO_LARGE_FOR_CLIENT), new Long(length), new Integer(Integer.MAX_VALUE)).getSQLException(); else setInput(parameterIndex, new Clob(agent_, reader, (int)length)); } } /** * Sets the designated parameter to a <code>InputStream</code> object. * This method differs from the <code>setBinaryStream(int, InputStream) * </code> method because it informs the driver that the parameter value * should be sent to the server as a <code>BLOB</code>. When the * <code>setBinaryStream</code> method is used, the driver may have to do * extra work to determine whether the parameter data should be sent to the * server as a <code>LONGVARBINARY</code> or a <code>BLOB</code> * * @param parameterIndex index of the first parameter is 1, the second is * 2, ... * @param inputStream an object that contains the data to set the parameter * value to. * @throws SQLException if a database access error occurs, this method is * called on a closed <code>PreparedStatement</code> or if * <code>parameterIndex</code> does not correspond to a parameter * marker in the SQL statement */ public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBlob", parameterIndex, inputStream); } try { checkTypeForSetBlob(parameterIndex); setBinaryStreamX(parameterIndex, inputStream, -1); } catch (SqlException se) { throw se.getSQLException(); } } } /** * Sets the designated parameter to a InputStream object. * * @param parameterIndex index of the first parameter is 1, * the second is 2, ... * @param inputStream An object that contains the data to set the parameter * value to. * @param length the number of bytes in the parameter data. * @throws SQLException if parameterIndex does not correspond * to a parameter marker in the SQL statement, if the length specified * is less than zero or if the number of bytes in the inputstream does not match * the specfied length. * */ public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException{ synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setBlob", parameterIndex, inputStream, new Long(length)); } if(length > Integer.MAX_VALUE) throw new SqlException(agent_.logWriter_, new ClientMessageId(SQLState.BLOB_TOO_LARGE_FOR_CLIENT), new Long(length), new Integer(Integer.MAX_VALUE)).getSQLException(); else { try { checkTypeForSetBlob(parameterIndex); setBinaryStreamX(parameterIndex, inputStream, (int)length); } catch(SqlException se){ throw se.getSQLException(); } } } } /* * Method calls onStatementError occurred on the * BrokeredConnectionControl class after checking the * SQLState of the SQLException thrown. * @param sqle SqlException * @throws java.sql.SQLException */ private void checkStatementValidity(SqlException sqle) throws SQLException { //check if the statement is already closed //This might be caused because the connection associated //with this prepared statement has been closed marking //its associated prepared statements also as //closed if(pooledConnection_!=null && isClosed()){ pooledConnection_.onStatementErrorOccurred(this, sqle.getSQLException()); } } /** * PossibleTypes is information which is set of types. * A given type is evaluated as *possible* at checkType method if same type was found in the set. */ private static class PossibleTypes{ final private int[] possibleTypes; private PossibleTypes(int[] types){ possibleTypes = types; Arrays.sort(possibleTypes); } /** * This is possibleTypes of variable which can be set by set method for generic scalar. */ final public static PossibleTypes POSSIBLE_TYPES_IN_SET_GENERIC_SCALAR = new PossibleTypes( new int[] { java.sql.Types.BIGINT, java.sql.Types.LONGVARCHAR , java.sql.Types.CHAR, java.sql.Types.DECIMAL, java.sql.Types.INTEGER, java.sql.Types.SMALLINT, java.sql.Types.REAL, java.sql.Types.DOUBLE, java.sql.Types.VARCHAR, java.sql.Types.BOOLEAN } ); /** * This is possibleTypes of variable which can be set by setDate method. */ final public static PossibleTypes POSSIBLE_TYPES_IN_SET_DATE = new PossibleTypes( new int[] { java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.VARCHAR, java.sql.Types.DATE, java.sql.Types.TIMESTAMP } ); /** * This is possibleTypes of variable which can be set by setTime method. */ final public static PossibleTypes POSSIBLE_TYPES_IN_SET_TIME = new PossibleTypes( new int[] { java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.VARCHAR, java.sql.Types.TIME } ); /** * This is possibleTypes of variable which can be set by setTimestamp method. */ final public static PossibleTypes POSSIBLE_TYPES_IN_SET_TIMESTAMP = new PossibleTypes( new int[] { java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.VARCHAR, java.sql.Types.DATE, java.sql.Types.TIME, java.sql.Types.TIMESTAMP } ); /** * This is possibleTypes of variable which can be set by setString method. */ final private static PossibleTypes POSSIBLE_TYPES_IN_SET_STRING = new PossibleTypes( new int[] { java.sql.Types.BIGINT, java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.DECIMAL, java.sql.Types.INTEGER, java.sql.Types.SMALLINT, java.sql.Types.REAL, java.sql.Types.DOUBLE, java.sql.Types.VARCHAR, java.sql.Types.DATE, java.sql.Types.TIME, java.sql.Types.TIMESTAMP, java.sql.Types.CLOB } ); /** * This is possibleTypes of variable which can be set by setBytes method. */ final public static PossibleTypes POSSIBLE_TYPES_IN_SET_BYTES = new PossibleTypes( new int[] { java.sql.Types.LONGVARBINARY, java.sql.Types.VARBINARY, java.sql.Types.BINARY, java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.VARCHAR, java.sql.Types.BLOB } ); /** * This is possibleTypes of variable which can be set by setBinaryStream method. */ final public static PossibleTypes POSSIBLE_TYPES_IN_SET_BINARYSTREAM = new PossibleTypes( new int[] { java.sql.Types.LONGVARBINARY, java.sql.Types.VARBINARY, java.sql.Types.BINARY, java.sql.Types.BLOB } ); /** * This is possibleTypes of variable which can be set by setAsciiStream method. */ final public static PossibleTypes POSSIBLE_TYPES_IN_SET_ASCIISTREAM = new PossibleTypes( new int[]{ java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.VARCHAR, java.sql.Types.CLOB } ); /** * This is possibleTypes of variable which can be set by setCharacterStream method. */ final public static PossibleTypes POSSIBLE_TYPES_IN_SET_CHARACTERSTREAM = new PossibleTypes( new int[] { java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.VARCHAR, java.sql.Types.CLOB } ); /** * This is possibleTypes of variable which can be set by setBlob method. */ final public static PossibleTypes POSSIBLE_TYPES_IN_SET_BLOB = new PossibleTypes( new int[] { java.sql.Types.BLOB } ); /** * This is possibleTypes of variable which can be set by setClob method. */ final public static PossibleTypes POSSIBLE_TYPES_IN_SET_CLOB = new PossibleTypes( new int[] { java.sql.Types.CLOB } ); /** * This is possibleTypes of null value which can be assigned to generic scalar typed variable. */ final public static PossibleTypes POSSIBLE_TYPES_FOR_GENERIC_SCALAR_NULL = new PossibleTypes( new int[] { java.sql.Types.BIT, java.sql.Types.TINYINT, java.sql.Types.BIGINT, java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.NUMERIC, java.sql.Types.DECIMAL, java.sql.Types.INTEGER, java.sql.Types.SMALLINT, java.sql.Types.FLOAT, java.sql.Types.REAL, java.sql.Types.DOUBLE, java.sql.Types.VARCHAR } ); /** * This is possibleTypes of null value which can be assigned to generic character typed variable. */ final public static PossibleTypes POSSIBLE_TYPES_FOR_GENERIC_CHARACTERS_NULL = new PossibleTypes( new int[] { java.sql.Types.BIT, java.sql.Types.TINYINT, java.sql.Types.BIGINT, java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.NUMERIC, java.sql.Types.DECIMAL, java.sql.Types.INTEGER, java.sql.Types.SMALLINT, java.sql.Types.FLOAT, java.sql.Types.REAL, java.sql.Types.DOUBLE, java.sql.Types.VARCHAR, java.sql.Types.DATE, java.sql.Types.TIME, java.sql.Types.TIMESTAMP } ); /** * This is possibleTypes of null value which can be assigned to VARBINARY typed variable. */ final public static PossibleTypes POSSIBLE_TYPES_FOR_VARBINARY_NULL = new PossibleTypes( new int[] { java.sql.Types.VARBINARY, java.sql.Types.BINARY, java.sql.Types.LONGVARBINARY } ); /** * This is possibleTypes of null value which can be assigned to BINARY typed variable. */ final public static PossibleTypes POSSIBLE_TYPES_FOR_BINARY_NULL = new PossibleTypes( new int[] { java.sql.Types.VARBINARY, java.sql.Types.BINARY, java.sql.Types.LONGVARBINARY } ); /** * This is possibleTypes of null value which can be assigned to LONGVARBINARY typed variable. */ final public static PossibleTypes POSSIBLE_TYPES_FOR_LONGVARBINARY_NULL = new PossibleTypes( new int[] { java.sql.Types.VARBINARY, java.sql.Types.BINARY, java.sql.Types.LONGVARBINARY } ); /** * This is possibleTypes of null value which can be assigned to DATE typed variable. */ final public static PossibleTypes POSSIBLE_TYPES_FOR_DATE_NULL = new PossibleTypes( new int[] { java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.VARCHAR, java.sql.Types.DATE, java.sql.Types.TIMESTAMP } ); /** * This is possibleTypes of null value which can be assigned to TIME typed variable. */ final public static PossibleTypes POSSIBLE_TYPES_FOR_TIME_NULL = new PossibleTypes( new int[] { java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.VARCHAR, java.sql.Types.TIME, java.sql.Types.TIMESTAMP } ); /** * This is possibleTypes of null value which can be assigned to TIMESTAMP typed variable. */ final public static PossibleTypes POSSIBLE_TYPES_FOR_TIMESTAMP_NULL = new PossibleTypes( new int[] { java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.VARCHAR, java.sql.Types.DATE, java.sql.Types.TIMESTAMP } ); /** * This is possibleTypes of null value which can be assigned to CLOB typed variable. */ final public static PossibleTypes POSSIBLE_TYPES_FOR_CLOB_NULL = new PossibleTypes( new int[] { java.sql.Types.LONGVARCHAR, java.sql.Types.CHAR, java.sql.Types.VARCHAR, java.sql.Types.CLOB } ); /** * This is possibleTypes of null value which can be assigned to BLOB typed variable. */ final public static PossibleTypes POSSIBLE_TYPES_FOR_BLOB_NULL = new PossibleTypes( new int[] { java.sql.Types.BLOB } ); /** * This is possibleTypes of null value which can be assigned to other typed variable. */ final public static PossibleTypes DEFAULT_POSSIBLE_TYPES_FOR_NULL = new PossibleTypes( new int[] { java.sql.Types.BIT, java.sql.Types.TINYINT, java.sql.Types.BIGINT, java.sql.Types.LONGVARBINARY, java.sql.Types.VARBINARY, java.sql.Types.BINARY, java.sql.Types.LONGVARCHAR, java.sql.Types.NULL, java.sql.Types.CHAR, java.sql.Types.NUMERIC, java.sql.Types.DECIMAL, java.sql.Types.INTEGER, java.sql.Types.SMALLINT, java.sql.Types.FLOAT, java.sql.Types.REAL, java.sql.Types.DOUBLE, java.sql.Types.VARCHAR, java.sql.Types.BOOLEAN, java.sql.Types.DATALINK, java.sql.Types.DATE, java.sql.Types.TIME, java.sql.Types.TIMESTAMP, java.sql.Types.OTHER, java.sql.Types.JAVA_OBJECT, java.sql.Types.DISTINCT, java.sql.Types.STRUCT, java.sql.Types.ARRAY, java.sql.Types.BLOB, java.sql.Types.CLOB, java.sql.Types.REF } ); /** * This method return true if the type is possible. */ boolean checkType(int type){ if(SanityManager.DEBUG){ for(int i = 0; i < possibleTypes.length - 1; i ++){ SanityManager.ASSERT(possibleTypes[i] < possibleTypes[i + 1]); } } return Arrays.binarySearch( possibleTypes, type ) >= 0; } static SqlException throw22005Exception( LogWriter logWriter, int valType, int paramType) throws SqlException{ throw new SqlException( logWriter, new ClientMessageId(SQLState.LANG_DATA_TYPE_GET_MISMATCH) , new Object[]{ Types.getTypeString(valType), Types.getTypeString(paramType) }, (Throwable) null); } /** * This method return possibleTypes of null value in variable typed as typeOfVariable. */ static PossibleTypes getPossibleTypesForNull(int typeOfVariable){ switch(typeOfVariable){ case java.sql.Types.SMALLINT: return POSSIBLE_TYPES_FOR_GENERIC_SCALAR_NULL; case java.sql.Types.INTEGER: return POSSIBLE_TYPES_FOR_GENERIC_SCALAR_NULL; case java.sql.Types.BIGINT: return POSSIBLE_TYPES_FOR_GENERIC_SCALAR_NULL; case java.sql.Types.REAL: return POSSIBLE_TYPES_FOR_GENERIC_SCALAR_NULL; case java.sql.Types.FLOAT: return POSSIBLE_TYPES_FOR_GENERIC_SCALAR_NULL; case java.sql.Types.DOUBLE: return POSSIBLE_TYPES_FOR_GENERIC_SCALAR_NULL; case java.sql.Types.DECIMAL: return POSSIBLE_TYPES_FOR_GENERIC_SCALAR_NULL; case java.sql.Types.CHAR: return POSSIBLE_TYPES_FOR_GENERIC_CHARACTERS_NULL; case java.sql.Types.VARCHAR: return POSSIBLE_TYPES_FOR_GENERIC_CHARACTERS_NULL; case java.sql.Types.LONGVARCHAR: return POSSIBLE_TYPES_FOR_GENERIC_CHARACTERS_NULL; case java.sql.Types.VARBINARY: return POSSIBLE_TYPES_FOR_VARBINARY_NULL; case java.sql.Types.BINARY: return POSSIBLE_TYPES_FOR_BINARY_NULL; case java.sql.Types.LONGVARBINARY: return POSSIBLE_TYPES_FOR_LONGVARBINARY_NULL; case java.sql.Types.DATE: return POSSIBLE_TYPES_FOR_DATE_NULL; case java.sql.Types.TIME: return POSSIBLE_TYPES_FOR_TIME_NULL; case java.sql.Types.TIMESTAMP: return POSSIBLE_TYPES_FOR_TIMESTAMP_NULL; case java.sql.Types.CLOB: return POSSIBLE_TYPES_FOR_CLOB_NULL; case java.sql.Types.BLOB: return POSSIBLE_TYPES_FOR_BLOB_NULL; } // as default, accept all type... return DEFAULT_POSSIBLE_TYPES_FOR_NULL; } } }
a87414cec90d0e18a3aed8510565a04460fe11ad
13608666b07385e44e860b7b2c9f4df6f2b8b695
/app/src/main/java/qianfeng/accountbook/viewPager/FourMyBaseAdapter.java
6dc5f5facfe4a5acd5387f02e5efafcaadf28776
[]
no_license
ab673103245/AccountBook
bafc50732c79c9fbd5d4517b5cf1f7af88675089
6ca0d49e51005c426f7deb15ab95e9ee833fec68
refs/heads/master
2020-05-29T08:51:40.665936
2016-09-30T04:35:49
2016-09-30T04:35:49
69,633,726
0
0
null
null
null
null
UTF-8
Java
false
false
807
java
package qianfeng.accountbook.viewPager; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import java.io.File; import java.util.List; /** * Created by Administrator on 2016/9/27 0027. */ public class FourMyBaseAdapter extends BaseAdapter { private List<File> fileList; private LayoutInflater inflater; private Context context; @Override public int getCount() { return 0; } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { return null; } }
e000d3badfd93fc1394b110bb361618bdea0ee24
685b234bb56cfbff855c221999bc4bd41d418256
/src/hackerRank/interviewPrep/StacksAndQueues/BalancedBrackets.java
f3da79f66b5d2a02fd71958b277c67ef4ad4ee1e
[]
no_license
maximbu/coding
1c81a20ceb258d530b37a4159bfb54933ba658b8
9be1f394babc4a0d37f0bfc91f8772adb7148ea9
refs/heads/master
2021-04-09T13:18:15.432970
2020-02-15T13:24:50
2020-02-20T20:58:41
125,671,705
0
0
null
null
null
null
UTF-8
Java
false
false
1,112
java
package hackerRank.interviewPrep.StacksAndQueues; import java.util.Stack; public class BalancedBrackets { static String isBalanced(String s) { Stack<Character> opening = new Stack<>(); for (char c : s.toCharArray()) { switch (c) { case '(': case '{': case '[': opening.push(c); break; case ')': if (opening.isEmpty() || opening.pop() != '(') return "NO"; break; case ']': if (opening.isEmpty() || opening.pop() != '[') return "NO"; break; case '}': if (opening.isEmpty() || opening.pop() != '{') return "NO"; break; default: break; } } return opening.isEmpty() ? "YES" : "NO"; } public static void main(String[] st) { System.out.println(isBalanced("{[()]}")); } }
3ebd591482c62cbf374c97768b4fac6bcf6a9859
f9f8bbf7c077059f18f74577479d035d37a208e0
/app/src/main/java/com/example/chery/dayday/LogInActivity.java
0630cc2285c239043819fb6f60c1074a483ebd86
[]
no_license
zhijunn6/DayDayMemberManagementApp
2c3aeb6dee3688376fe6cf68ab0cdd57db46aec8
1771274294664ce3fd8bbe693a2f64be444a2b9d
refs/heads/master
2020-04-09T18:21:36.327904
2018-12-05T11:50:23
2018-12-05T11:50:23
160,509,728
0
0
null
null
null
null
UTF-8
Java
false
false
4,522
java
package com.example.chery.dayday; import android.content.Intent; import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; import android.widget.Toast; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.firebase.auth.AuthResult; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; public class LogInActivity extends AppCompatActivity { private static final String TAG = "BAKA"; private EditText inputEmail, inputPassword; private Button loginButtonSignIn, loginButtonSignUp; private ProgressBar progressBar; private FirebaseAuth auth; private FirebaseUser user; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get FireBase auth instance auth = FirebaseAuth.getInstance(); user = auth.getCurrentUser(); // Check if user is signed in or not if (auth.getCurrentUser() != null) { startActivity(new Intent(LogInActivity.this, MainActivity.class)); finish(); } setContentView(R.layout.activity_log_in); inputEmail = (EditText) findViewById(R.id.email); inputPassword = (EditText) findViewById(R.id.password); progressBar = (ProgressBar) findViewById(R.id.progressBar); loginButtonSignIn = (Button) findViewById(R.id.login_button_signin); loginButtonSignUp = (Button) findViewById(R.id.login_button_signup); // Get FireBase auth instance again auth = FirebaseAuth.getInstance(); loginButtonSignUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(LogInActivity.this, SignUpActivity.class)); } }); loginButtonSignIn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String email = inputEmail.getText().toString(); final String password = inputPassword.getText().toString(); if (TextUtils.isEmpty(email)) { Toast.makeText(getApplicationContext(), "Please enter your email address!", Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(password)) { Toast.makeText(getApplicationContext(), "Please enter your password!", Toast.LENGTH_SHORT).show(); return; } progressBar.setVisibility(View.VISIBLE); // Create New User auth.signInWithEmailAndPassword(email, password) .addOnCompleteListener(LogInActivity.this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. progressBar.setVisibility(View.GONE); if (!task.isSuccessful()) { if(password.length() < 6){ inputPassword.setError(getString(R.string.minimum_password)); } else { Toast.makeText(LogInActivity.this, getString(R.string.auth_failed), Toast.LENGTH_LONG).show(); }} else{ Intent intent = new Intent(LogInActivity.this, MainActivity.class); startActivity(intent); finish(); } } }); } }); } // Disable going back to the MainActivity @Override public void onBackPressed() { moveTaskToBack(true); } }
237bd8b679b0a78cc0d514253926ff79f0a58569
1d3bd8670f6e1a6f001b698e15cccf5420173d51
/src/test/java/com/sriram/calculator/CalculatorApplicationTests.java
e80b78f95776bb9d842be4d8f980c17842f1aa27
[]
no_license
prashanth-sriram-by/calculator
ff2d3cf8a88fc4fa835d58f75df25da1e7bec39f
f18646b126225d96cc8cb8c02c86c6887f8d8d89
refs/heads/master
2022-08-31T02:30:48.351836
2020-05-24T16:19:43
2020-05-24T16:19:43
266,355,146
0
0
null
2020-05-24T16:19:44
2020-05-23T14:38:39
Java
UTF-8
Java
false
false
234
java
package com.sriram.calculator; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; /** * Tests */ @SpringBootTest class CalculatorApplicationTests { @Test void contextLoads() { } }
5b84b3c702d2e802a04017dd5c60e69c058bfef9
e8ec2952f25645ccf28fb9f333af2c13a0d294f5
/src/CompareVersionNumbers_165.java
5d71752899aae97c7a4bd8d0115b9a5927352fcc
[]
no_license
luffylg/leetcode
c2eff8e60ad881dceeee5d55cc8bdf4d59236c09
b8e7e89a8f6ef0ed12239f03bab56876bfe16756
refs/heads/master
2020-04-03T09:54:24.124958
2017-01-12T01:40:34
2017-01-12T01:40:34
70,323,036
0
0
null
null
null
null
UTF-8
Java
false
false
980
java
/** * Created by hp on 2016/12/21. */ public class CompareVersionNumbers_165 { public int compareVersion(String version1, String version2) { int[] v1=version2int(version1); int[] v2=version2int(version2); int cmp1,cmp2; for (int i = 0; i <Math.max(v1.length,v2.length) ; i++) { if (i>v1.length-1) cmp1=0; else cmp1=v1[i]; if (i>v2.length-1) cmp2=0; else cmp2=v2[i]; if (cmp1>cmp2) return 1; if (cmp1<cmp2) return -1; } return 0; } private int[] version2int(String version) { String[] split = version.split("\\."); int[] ints = new int[split.length]; for (int i = 0; i <split.length ; i++) { ints[i]=Integer.parseInt(split[i]); } return ints; } public static void main(String[] args) { System.out.println(new CompareVersionNumbers_165().compareVersion("0.1","0.0.1")); } }
9a3ebcaf8359d2a12edcb4d2aeba2939835bbdc3
842762078dfd9df191270f26533f80be7a7ac723
/app/src/main/java/com/example/chett/coach/outils/AsyncResponse.java
40af175d6e97743751b5a5332166ccf9e747711f
[]
no_license
nounou945/ProjetCoach
67b510021686d6f3406e29a114c7405f50c61e76
deffdd6d19f24e51b4a6d65e6e0989836c30653c
refs/heads/master
2021-01-12T05:56:12.507218
2016-12-29T15:18:29
2016-12-29T15:18:29
77,251,309
0
0
null
null
null
null
UTF-8
Java
false
false
157
java
package com.example.chett.coach.outils; /** * Created by emds on 07/08/2015. */ public interface AsyncResponse { void processFinish(String output); }
29bec7525c0f51a882e8a176131916cd393d7c96
451b70fc0a520076654c1865dad4e6f6cb9cdc12
/src/brut/androlib/res/data/ResType.java
48efb9ea84bf4090df6def80955aa031197b4351
[]
no_license
xiaomagexiao/Apktool
3cb0bde70b1ae3d63a2677c4f5192d50e4c22317
6e0917af61ae114819c7a8f73aac3ba5bb94b893
refs/heads/master
2021-01-20T19:39:09.686492
2016-06-11T04:45:11
2016-06-11T04:45:11
60,888,834
0
0
null
null
null
null
UTF-8
Java
false
false
2,074
java
/** * Copyright 2011 Ryszard Wiśniewski <[email protected]> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package brut.androlib.res.data; import brut.androlib.AndrolibException; import brut.androlib.err.UndefinedResObject; import java.util.*; /** * @author Ryszard Wiśniewski <[email protected]> */ public final class ResType { private final String mName; private final LinkedHashMap<String, ResResSpec> mResSpecs = new LinkedHashMap<String, ResResSpec>(); private final ResTable mResTable; private final ResPackage mPackage; public ResType(String name, ResTable resTable, ResPackage package_) { this.mName = name; this.mResTable = resTable; this.mPackage = package_; } public String getName() { return mName; } public Set<ResResSpec> listResSpecs() { return new LinkedHashSet<ResResSpec>(mResSpecs.values()); } public ResResSpec getResSpec(String name) throws AndrolibException { ResResSpec spec = mResSpecs.get(name); if (spec == null) { throw new UndefinedResObject(String.format("resource spec: %s/%s", getName(), name)); } return spec; } public void addResSpec(ResResSpec spec) throws AndrolibException { if (mResSpecs.put(spec.getName(), spec) != null) { throw new AndrolibException(String.format("Multiple res specs: %s/%s", getName(), spec.getName())); } } @Override public String toString() { return mName; } }
7e2a490a80ad5f6e0f8538bde0e9f0d886276a7a
c520849a5bced7b5e3cc31c590bb8b243f295b30
/src/main/java/com/obj/map/vo/car.java
8a1031140f164888cb3754bbc9d8459158856efc
[]
no_license
NivedhaLak/ObjectMapping
3e63898e38025067baf0ba57746a486dfb51fbf0
d16cfa995c9e291f5933d88d2590e8efa4af947c
refs/heads/master
2020-08-22T08:52:31.207157
2019-10-20T13:09:37
2019-10-20T13:09:37
216,359,925
0
0
null
null
null
null
UTF-8
Java
false
false
309
java
package com.obj.map.vo; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @Setter @Getter @AllArgsConstructor @NoArgsConstructor public class car { Long id; String name; String desc; String type; String noOfTyre; wheel wheel; tank tank; }
be036ba053d8e800b7438a7a8ed04ae0b44906fc
1db2b38812c3f0ce13cbfb328e0a7d339e302e1c
/src/org/abimon/omnis/ludus/gui/GuiEventChoice.java
6df6ba0f9482d14a474b2320802744e3e28f4495
[]
no_license
UnderMybrella/Omnis
11df89bf62c6b2dfeb9432b92e9914365becf082
14a1b0d90b1283fc1594bf9ced7162cf4289eaea
refs/heads/master
2020-04-06T12:48:53.582254
2016-09-24T09:32:09
2016-09-24T09:32:09
40,952,832
0
0
null
null
null
null
UTF-8
Java
false
false
3,335
java
package org.abimon.omnis.ludus.gui; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; import java.util.HashMap; import org.abimon.omnis.ludus.Ludus; import org.abimon.omnis.reflect.Function; public class GuiEventChoice extends GuiTextOverlay { HashMap<String, Function> events = new HashMap<String, Function>(); HashMap<String, String[]> eventText = new HashMap<String, String[]>(); BufferedImage selector; int choice = 0; /** * Creates a Text gui that gives occasional events * @param text The text to use. This will get separated down into individual lines. * @param events The events to use. Note that the key is a line of text <i>that does get displayed</i> * @param textBoxLocation * @param font */ public GuiEventChoice(String text, HashMap<String, String[]> eventText, HashMap<String, Function> events, String textBoxLocation, Font font) { super(text, textBoxLocation, font); this.events = events; this.eventText = eventText; selector = Ludus.getDataUnsafe("resources/Selector.png").getAsImage(); } public void render(Graphics g) { super.render(g); FontMetrics metrics = g.getFontMetrics(); String key = text.get(Math.min(3, text.size()) - 1); if(eventText.containsKey(key)){ int width = 0; String[] responses = eventText.get(key); for(String s : responses) { int strWidth = (int) (metrics.getStringBounds(s, g).getWidth() * 1.25); if(strWidth > width) width = strWidth; } width += imgs[1].getWidth() + imgs[7].getWidth() + selector.getWidth(); int height = imgs[3].getHeight() + imgs[5].getHeight() + (int) (metrics.getHeight() * eventText.get(key).length * 1.75); BufferedImage eventBox = constructTextBox(width, height); g.drawImage(eventBox, coords.x + Ludus.mainWindow.getFloor().getWidth() - eventBox.getWidth(), coords.y - eventBox.getHeight(), null); for(int i = 0; i < responses.length; i++){ g.drawString(responses[i], coords.x + selector.getWidth() + Ludus.mainWindow.getFloor().getWidth() - eventBox.getWidth() + ((int) (imgs[0].getWidth() * 1.25)), (int) (i * metrics.getHeight() * 1.75) + coords.y - eventBox.getHeight() + ((int) (imgs[3].getHeight() * 2.5))); if(i == choice) g.drawImage(selector, coords.x + Ludus.mainWindow.getFloor().getWidth() - eventBox.getWidth() + ((int) (imgs[0].getWidth() * 1.125)), (int) (i * metrics.getHeight() * 1.75) - selector.getHeight() + coords.y - eventBox.getHeight() + ((int) (imgs[3].getHeight() * 2.5)), null); } } } @Override public void keyPressed(KeyEvent e) { String key = text.get(Math.min(3, text.size()) - 1); if(eventText.containsKey(key)){ String[] responses = eventText.get(key); if(e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_KP_UP || e.getKeyCode() == KeyEvent.VK_W) choice--; if(e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_KP_DOWN || e.getKeyCode() == KeyEvent.VK_S) choice++; if(choice >= responses.length) choice = responses.length - 1; if(choice <= 0) choice = 0; if(e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_SPACE) events.get(key).invokeUnsafePartially(new Object[]{responses[choice]}); } else super.keyPressed(e); } }
1b069b0b252cc88fcc46e921dfdc7ea3e8a06a9e
41051cc461332bac77ec23a46694730d13b55b59
/home/build/tmp/kapt3/stubs/debug/com/victor/feature/activities/HomeActivity.java
a23a9ad57fbfcd032171d03337fdef6e79575048
[]
no_license
Victor4/PokemonApp
012562cdbe9de550057058ff86bb486b59f4d063
1079025d3490b80928a2c3515616f95a4bb512f8
refs/heads/main
2023-03-24T21:04:09.645449
2021-03-25T12:40:35
2021-03-25T12:40:35
344,335,832
0
0
null
2021-03-25T14:35:15
2021-03-04T03:18:55
HTML
UTF-8
Java
false
false
2,437
java
package com.victor.feature.activities; import java.lang.System; @kotlinx.coroutines.ExperimentalCoroutinesApi() @kotlin.Metadata(mv = {1, 4, 1}, bv = {1, 0, 3}, k = 1, d1 = {"\u00006\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0007\u0018\u00002\u00020\u0001B\u0005\u00a2\u0006\u0002\u0010\u0002J\b\u0010\u000f\u001a\u00020\u0010H\u0002J\u0012\u0010\u0011\u001a\u00020\u00102\b\u0010\u0012\u001a\u0004\u0018\u00010\u0013H\u0014J\b\u0010\u0014\u001a\u00020\u0010H\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u0004\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082.\u00a2\u0006\u0002\n\u0000R\u001b\u0010\u0007\u001a\u00020\b8FX\u0086\u0084\u0002\u00a2\u0006\f\n\u0004\b\u000b\u0010\f\u001a\u0004\b\t\u0010\nR\u0010\u0010\r\u001a\u0004\u0018\u00010\u000eX\u0082\u000e\u00a2\u0006\u0002\n\u0000\u00a8\u0006\u0015"}, d2 = {"Lcom/victor/feature/activities/HomeActivity;", "Landroidx/appcompat/app/AppCompatActivity;", "()V", "adapter", "Lcom/victor/feature/adapters/PokemonsAdapter;", "binding", "Lcom/victor/feature/databinding/ActivityHomeBinding;", "homeViewModel", "Lcom/victor/feature/viewModel/HomeViewModel;", "getHomeViewModel", "()Lcom/victor/feature/viewModel/HomeViewModel;", "homeViewModel$delegate", "Lkotlin/Lazy;", "searchJob", "Lkotlinx/coroutines/Job;", "initAdapter", "", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "search", "home_debug"}) public final class HomeActivity extends androidx.appcompat.app.AppCompatActivity { private com.victor.feature.databinding.ActivityHomeBinding binding; private kotlinx.coroutines.Job searchJob; private final com.victor.feature.adapters.PokemonsAdapter adapter = null; @org.jetbrains.annotations.NotNull() private final kotlin.Lazy homeViewModel$delegate = null; @org.jetbrains.annotations.NotNull() public final com.victor.feature.viewModel.HomeViewModel getHomeViewModel() { return null; } @java.lang.Override() protected void onCreate(@org.jetbrains.annotations.Nullable() android.os.Bundle savedInstanceState) { } private final void initAdapter() { } private final void search() { } public HomeActivity() { super(); } }
e2f4092981bbf7d75c3321fb804f4f391a8aa553
7ab9eed68195d396aa68324b3f558619a248b11d
/src/main/java/com/sg/SuperHeroSighting/daointerface/daoimpl/mapper/SightingMapper.java
8e96bed39f580e4b363835139b5e0a0cc6e8e1b6
[]
no_license
resinatedspade/SuperHeroSightings
b5604ff0500ffedb25b333e440d0a0736c0c5ae3
df0d4397bd415280137c9ffb303e58865a2c1aa3
refs/heads/master
2020-05-04T12:42:07.451521
2019-04-02T18:20:37
2019-04-02T18:20:37
179,121,156
0
0
null
null
null
null
UTF-8
Java
false
false
767
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 com.sg.SuperHeroSighting.daointerface.daoimpl.mapper; import com.sg.SuperHeroSighting.dto.Sighting; import java.sql.ResultSet; import java.sql.SQLException; import org.springframework.jdbc.core.RowMapper; /** * * @author RAC */ public final class SightingMapper implements RowMapper<Sighting> { @Override public Sighting mapRow(ResultSet rs, int index) throws SQLException { Sighting td = new Sighting(); td.setId(rs.getInt("id")); td.setDate(rs.getString("date")); td.setTime(rs.getString("time")); return td; } }
899c09f9d45873e67bb29c737f75ff06be1d8c9b
bc6c4f75349e21788e2e161fd12f5a2c67468796
/server/src/main/java/org/lacitysan/landfill/server/config/app/ApplicationConstant.java
f94d2f85487610f112fc8fff5dd4ae56389ade85
[]
no_license
landfill-eforms/landfill-web-app
ebd4b181b17bd54c402c25335c8e0d49f5850b36
948ec193eed3b44793a75029d0219786bb0a284e
refs/heads/master
2021-01-11T10:59:51.771160
2017-09-14T05:04:03
2017-09-14T05:04:34
76,153,055
1
2
null
2017-08-13T02:46:00
2016-12-11T03:58:49
Java
UTF-8
Java
false
false
2,112
java
package org.lacitysan.landfill.server.config.app; /** * Contains constants and other properties for classes that cannot be read from <code>*.properties</code> files, and should not be changed by the end user. * @author Alvin Quach */ public class ApplicationConstant { /** Whether to print debug messages to the console. */ public static final Boolean DEBUG = true; /** The number of rounds to use for the BCrypt algorithm when generating new password hashes. */ // This is set to the minimum for better performance on Android. // TODO Make this an application setting variable. public static final Integer BCRYPT_STRENGTH = 4; /** The name of the HTTP header field that contains the JWT. */ public static final String HTTP_TOKEN_HEADER_NAME = "Authorization"; /** The prefix that precedes the JWT string in HTTP header field. */ public static final String HTTP_TOKEN_PREFIX = "Bearer"; /** The path to the server's login resource. */ public static final String LOGIN_PATH = "/login"; /** The path to the server's REST resources. */ public static final String RESOURCE_PATH = "rest"; /** String representation of the super admin user permission. */ public static final String SUPER_ADMIN_PERMISSION_NAME = "SUPER_ADMIN"; /** The username of the super admin account. */ public static final String SUPER_ADMIN_USERNAME = "admin"; /** The default timezone of the server. */ public static final String TIMEZONE = "PST"; /** The hardcoded JWT secret to use in place of a randomly generated secret. */ public static final String TOKEN_SECRET_HARDCODED = "secret"; /** The length in bits of the randomly generated secret for JWTs. */ public static final Integer TOKEN_SECRET_RANDOM_LENGTH = 512; /** * Whether to use a randomly generated secret for JWTs. * If set to <code>false</code>, the hardcoded secret is used instead. * During development/testing, it is recommended to set to <code>false</code>, * so that the user can reuse the same JWT even after the server is restarted. */ public static final Boolean TOKEN_SECRET_USE_RANDOM = true; }
05c0ecf38ce2d521c4fe38d53ff0d8241f238a2d
6fee31ef3f6c3707de20a5956b2d96575fdf0aac
/code/src/ei-ads-buffer/src/main/java/com/znd/bus/binding/MapperRegistry.java
befdc771d87f634b9d5171de100e4f4a07368eb6
[]
no_license
hilockman/cim2ddl
605b05e5c67acde1f9b0c93e6b0a227dd27519a6
78ec9a3b4136710ac659fa40e3da28c9bb57c10f
refs/heads/master
2021-01-01T17:50:55.311126
2019-01-03T05:35:47
2019-01-03T05:35:47
98,163,859
3
6
null
null
null
null
UTF-8
Java
false
false
4,227
java
package com.znd.bus.binding; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.znd.bus.binding.MapperProxyFactory.Parser; import com.znd.bus.buffer.Buffer; import com.znd.bus.config.BufferConfig; import com.znd.bus.exception.BindingException; import com.znd.bus.mapping.RawArrayBufferMapper; public class MapperRegistry { private final Logger logger = LoggerFactory.getLogger(MapperRegistry.class); private final Map<Class<?>, MapperProxyFactory<?>> knownMappers = new HashMap<>(); private final Map<String, MapperProxyFactory<RawArrayBufferMapper>> defaultMappers = new HashMap<>(); public MapperRegistry() { } @SuppressWarnings("unchecked") public <T> T getMapper(Class<T> type, Buffer buffer) throws BindingException { final MapperProxyFactory<T> mapperProxyFactory = (MapperProxyFactory<T>) knownMappers.get(type); if (mapperProxyFactory == null) { throw new BindingException("Type " + type + " is not known to the MapperRegistry."); } try { return mapperProxyFactory.newInstance(buffer); } catch (Exception e) { throw new BindingException("Error getting mapper instance. Cause: " + e, e); } } public RawArrayBufferMapper getMapper(String tableName, Buffer buffer) throws BindingException { final MapperProxyFactory<RawArrayBufferMapper> mapperProxyFactory = defaultMappers.get(tableName); if (mapperProxyFactory == null) { throw new BindingException("Table " + tableName + " is not known to the MapperRegistry."); } try { return mapperProxyFactory.newInstance(buffer); } catch (Exception e) { throw new BindingException("Error getting mapper instance. Cause: " + e, e); } } public <T> boolean hasMapper(Class<T> type) { return knownMappers.containsKey(type); } public boolean hasMapper(String tableName) { return defaultMappers.containsKey(tableName); } public <T> void addMapper(Class<T> type) throws BindingException { if (type.isInterface()) { if (hasMapper(type)) { throw new BindingException("Type " + type + " is already known to the MapperRegistry."); } boolean loadCompleted = false; try { knownMappers.put(type, new MapperProxyFactory<T>(type)); // It's important that the type is added before the parser is run // otherwise the binding may automatically be attempted by the // mapper parser. If the type is already known, it won't try. // MapperAnnotationBuilder parser = new MapperAnnotationBuilder(config, type); // parser.parse(); Parser builder = new MapperProxyFactory.Parser(type); builder.parse(); loadCompleted = true; } finally { if (!loadCompleted) { knownMappers.remove(type); } } } } public void addRawMapper(String tableName) { if (hasMapper(tableName)) { return; } defaultMappers.put(tableName, new MapperProxyFactory<RawArrayBufferMapper>(RawArrayBufferMapper.class, tableName)); } /** * @since 3.2.2 */ public Collection<Class<?>> getMappers() { return Collections.unmodifiableCollection(knownMappers.keySet()); } /** * @throws BindingException * @since 3.2.2 */ public void addMappers(String packageName, Class<?> superType) throws BindingException { ResolverUtil<Class<?>> resolverUtil = new ResolverUtil<Class<?>>(); logger.info("Begin parse buffer ***************."); resolverUtil.find(new ResolverUtil.IsA(superType), packageName); Set<Class<? extends Class<?>>> mapperSet = resolverUtil.getClasses(); logger.info("Find {} mappers in package : {}.", mapperSet.size(), packageName); for (Class<?> mapperClass : mapperSet) { addMapper(mapperClass); } } /** * @throws BindingException * @since 3.2.2 */ public void addMappers(String packageName) throws BindingException { addMappers(packageName, Object.class); } }
e5de7bc0d78b2bce6184eb99500a6e8023084864
becbdc6a383c0cb02c419fd595597ce31cbc5f26
/fr.vitec.main/src/fr/vitec/main/handler/PopupDeleteHandler.java
9091bd09791c63575090530eea5a88f3505b3f9c
[]
no_license
jlebiannic/vitec-project
d85441030324f7726739930d317b2cc32d25885e
d42d94e26e7c1c6e12b331cfc4a24e9b4819a517
refs/heads/master
2021-01-10T09:50:33.143129
2015-06-03T14:37:46
2015-06-03T14:37:46
36,809,724
0
1
null
null
null
null
UTF-8
Java
false
false
1,153
java
package fr.vitec.main.handler; import java.util.List; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.IHandler; import org.eclipse.core.commands.IHandlerListener; import org.eclipse.core.expressions.EvaluationContext; import fr.vitec.model.VitecModel; import fr.vitec.model.xmlbinding.FilmType; public class PopupDeleteHandler implements IHandler { @Override public void addHandlerListener(IHandlerListener handlerListener) { } @Override public void dispose() { } @Override public Object execute(ExecutionEvent event) throws ExecutionException { EvaluationContext appContext = (EvaluationContext) event.getApplicationContext(); List<FilmType> filmsToDelete = (List<FilmType>) appContext.getDefaultVariable(); VitecModel.getInstance().deleteFilms(filmsToDelete); return null; } @Override public boolean isEnabled() { return true; } @Override public boolean isHandled() { return true; } @Override public void removeHandlerListener(IHandlerListener handlerListener) { } }
d8139c93bf2a82607b6e49e5912e44858cc682e7
18fa2e40b3b7cfe4ea1a471d72c99bba92225278
/curriculums/reflectionMethods/src/com/itranswarp/learnjava/Main.java
3f57d404dc2f2ead437f761e9284230affbca7e8
[]
no_license
fooSynaptic/java_Practice_Ground
268edef7ba054b79a9440f46cf56b143dc413dd4
363dba911c64ad6d766bf150bc4fcd496b04bc2d
refs/heads/master
2020-08-16T05:30:01.542306
2019-11-28T15:45:17
2019-11-28T15:45:17
215,461,055
0
0
null
null
null
null
UTF-8
Java
false
false
476
java
package com.itranswarp.learnjava; //import java.lang.reflect.Field; import java.lang.reflect.Method; public class Main { public static void main(String [] args) throws Exception { Method h = Person.class.getMethod("hello"); h.invoke(new Student()); } } class Person { public void hello() { System.out.println("Person:hello"); } } class Student extends Person { public void hello() { System.out.println("Student:hello"); } }
d67f513adb9c92478a760bb8793ab0577a1bc7ce
3706fa253f8ab4ba984915151df2654324afeee5
/FMS/houduan-BladeX-Boot/src/main/java/org/springblade/modules/dictionaries/dto/AirDTO.java
879ebcfce222f3e5d38289bdf3c60dc0f1a63ee2
[]
no_license
FanWenTao-Felix/yunjie
a15209af901b142a7b73c4af3532d6090a9c9552
3ebe4c95211261e116d28682036b2d463a374978
refs/heads/master
2020-09-02T00:55:45.328374
2019-10-31T03:33:42
2019-10-31T03:33:42
219,099,186
1
0
null
2019-11-02T03:40:32
2019-11-02T03:40:32
null
UTF-8
Java
false
false
1,202
java
/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 ([email protected]) */ package org.springblade.modules.dictionaries.dto; import org.springblade.modules.dictionaries.entity.Air; import lombok.Data; import lombok.EqualsAndHashCode; /** * 数据传输对象实体类 * * @author BladeX * @since 2019-08-20 */ @Data @EqualsAndHashCode(callSuper = true) public class AirDTO extends Air { private static final long serialVersionUID = 1L; }
069703c16b79b8b28b3bedb2fc379686f155f9bf
3f208a576fafae620ec03616080ac4ad61128616
/app/src/main/java/com/example/kakyenlam/friendfinder/Reminder.java
ee5befc48c70483a7ab1c60507a749b4404d09fa
[]
no_license
rmit-s3524228-KaKyen-Lam/FriendFinder
2ba265a54410ec91527382192f25264cbb967437
1617c2f9c6eea0e6ec334b8fed93040e29e50057
refs/heads/master
2021-07-09T05:47:03.912518
2017-10-09T03:22:21
2017-10-09T03:22:21
105,626,510
0
0
null
null
null
null
UTF-8
Java
false
false
1,934
java
package com.example.kakyenlam.friendfinder; import android.app.AlarmManager; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Reminder extends AppCompatActivity { private SharedPreferences preferences; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); manager.cancel(1); createReminder(); finish(); } public void createReminder() { long milliReminder = 0; preferences = PreferenceManager.getDefaultSharedPreferences(this); String alarmReminderMin = preferences.getString("alarmReminderMin", " "); SimpleDateFormat f = new SimpleDateFormat("mm"); try { Date d = f.parse(alarmReminderMin); milliReminder = d.getTime(); } catch (ParseException e) { e.printStackTrace(); } Calendar c = Calendar.getInstance(); Date currentDate = c.getTime(); long milliCurrent = currentDate.getTime(); long milliAlarm = milliCurrent + milliReminder; Intent notifIntent = new Intent(this, NotificationService.class); AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); PendingIntent pendingIntent = PendingIntent.getService(this, 0, notifIntent, 0); //set the alarm for particular time alarmManager.set(AlarmManager.RTC_WAKEUP, milliAlarm, pendingIntent); } }
1990cdf1c91f0214bc21bc8a02e9bc0700925cc3
c35c677d613523135209f50eabc23aae694f716c
/workspace/10_jdbc/src/ex03_dml/InsertMainClass2.java
32abaedae3bc61b1ce15cf72d49ea7ca87339640
[]
no_license
ha-taeyeong/javastudy
eb15daabe8dbb6270fa03e676d996f7db14fda88
6850aa23bda51a6de8c0353fe03a70d337ba8e5e
refs/heads/main
2023-03-24T00:30:40.564387
2021-03-30T08:23:12
2021-03-30T08:23:12
347,885,802
0
0
null
null
null
null
UTF-8
Java
false
false
1,343
java
package ex03_dml; import java.sql.Connection; import java.sql.Date; import java.sql.PreparedStatement; import connection.DBConnection; public class InsertMainClass2 { public static void main(String[] args) { Connection con = null; PreparedStatement ps = null; try { con = DBConnection.getConnection(); // 쿼리문에 변수 처리되는 부분은 ?으로 처리합니다. String sql = "INSERT INTO staff (no, name, department, hireDate) VALUES (?, ?, ?, ?)"; ps = con.prepareStatement(sql); // 변수 처리(?에 값을 전달합니다.) ps.setInt(1, 2); // 1번째 ?에 데이터 2 전달합니다 ps.setString(2, "emily"); // 2번째 ?에 데이터 emily 전달하기 ps.setString(3, "인사"); // 3번째 ?에 데이터 인사 전달하기 ps.setDate(4, new Date(System.currentTimeMillis())); // 4번째 ?에 데이터 new Date(System.currentTimeMillis() 전달하기 int result = ps.executeUpdate(); if (result == 0) { System.out.println("행이 추가되지 않았습니다."); } else { System.out.println("정상적으로 행이 추가되었습니다."); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (ps != null) { ps.close(); } if (con != null) { con.close(); } } catch (Exception e) { e.printStackTrace(); } } } }
a2e0f407d2bfb2370db1b5bd19a89d14464384c2
263f230335b462d999356906ff132fd9b8b1e87a
/app/src/main/java/com/example/ecommerce/MainActivity.java
f422a4b48c11a324cb8bc8daf47fd2d919534dbe
[]
no_license
Goodkatt/ECommerce
32654aea2808029fb2278108ad97b58469fe308c
884ed083d1fa66ac758c9ea51b1785b85af96ddb
refs/heads/master
2023-04-05T11:37:40.606187
2021-03-15T19:52:51
2021-03-15T19:52:51
348,103,017
0
0
null
null
null
null
UTF-8
Java
false
false
9,829
java
package com.example.ecommerce; import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.util.Log; import android.view.Display; import android.view.View; import android.widget.AdapterView; import android.widget.ImageView; import android.widget.ListView; import android.widget.Toast; import com.google.android.gms.tasks.OnFailureListener; import com.google.android.gms.tasks.OnSuccessListener; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.ValueEventListener; import com.google.firebase.storage.FirebaseStorage; import com.google.firebase.storage.StorageReference; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity { Bitmap my_image; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView listView = findViewById(R.id.categoryListView); DatabaseReference mDatabase; mDatabase = FirebaseDatabase.getInstance().getReference(); Bitmap directory = BitmapFactory.decodeResource(getResources(), R.drawable.iphone12); //Inıtial Products /* ModelPost m1 = new ModelPost("Elektronik", "Akıllı Telefon", "Apple", "iphone7", "4.000TL", "Latest iphone", "20/02/2021"); ModelPost m2 = new ModelPost("Elektronik", "Akıllı Telefon", "Apple", "iphone8", "5.000 TL", "Latest iphone", "20/02/2021"); ModelPost m3 = new ModelPost("Elektronik", "Akıllı Telefon", "Apple", "iphone9", "6.000 TL", "Latest iphone", "20/02/2021"); ModelPost m4 = new ModelPost("Elektronik", "Akıllı Telefon", "Apple", "iphone10", "7.000 TL", "Latest iphone", "20/02/2021"); ModelPost m5 = new ModelPost("Elektronik", "Akıllı Telefon", "Apple", "iphone11", "8.000 TL", "Latest iphone", "20/02/2021"); ModelPost m6 = new ModelPost("Elektronik", "Akıllı Telefon", "Apple", "iphone11max", "9.000 TL", "Latest iphone", "20/02/2021"); ModelPost m7 = new ModelPost("Elektronik", "Akıllı Telefon", "Apple", "iphone12", "10.000 TL", "Latest iphone", "20/02/2021"); ModelPost m8 = new ModelPost("Elektronik", "Akıllı Telefon", "Apple", "iphone12max", "11.000 TL", "Latest iphone", "20/02/2021"); ModelPost m9 = new ModelPost("Elektronik", "Akıllı Telefon", "Samsung", "Samsung1", "11.000 TL", "Latest iphone", "20/02/2021"); ModelPost m10 = new ModelPost("Elektronik", "Akıllı Telefon", "Samsung", "Samsung2", "11.000 TL", "Latest iphone", "20/02/2021"); ModelPost m11 = new ModelPost("Elektronik", "Akıllı Telefon", "Samsung", "Samsung3", "11.000 TL", "Latest iphone", "20/02/2021"); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Apple").child("iPhone7").setValue(m1); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Apple").child("iphone8").setValue(m2); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Apple").child("iphone9").setValue(m3); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Apple").child("iphone10").setValue(m4); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Apple").child("iphone11").setValue(m5); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Apple").child("iphone11max").setValue(m6); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Apple").child("iphone12").setValue(m7); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Apple").child("iphone12max").setValue(m8); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Samsung").child("samsung1").setValue(m9); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Samsung").child("samsung2").setValue(m10); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Samsung").child("samsung3").setValue(m11); ModelPost m1 = new ModelPost("Elektronik", "Akıllı Telefon", "Huawei", "Huawei1", "4.000TL", "First Huawei", "20/02/2021"); ModelPost m2 = new ModelPost("Elektronik", "Akıllı Telefon", "Huawei", "Huawei2", "5.000TL", "Second Huawei", "20/02/2021"); ModelPost m3 = new ModelPost("Elektronik", "Akıllı Telefon", "Huawei", "Huawei3", "6.000TL", "Third Huawei", "20/02/2021"); ModelPost m4 = new ModelPost("Elektronik", "Akıllı Telefon", "Huawei", "Huawei4", "7.000TL", "Fourth Huawei", "20/02/2021"); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Huawei").child("Huawei1").setValue(m1); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Huawei").child("Huawei2").setValue(m2); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Huawei").child("Huawei3").setValue(m3); mDatabase.child("Main").child("Elektrik").child("Akıllı Telefon").child("Huawei").child("Huawei4").setValue(m4); */ FirebaseStorage storage = FirebaseStorage.getInstance(); StorageReference storageRef = storage.getReference(); StorageReference pathReference = storageRef.child("images-apple-smart-phones/apple.png"); final long ONE_MEGABYTE = 1024 * 1024; pathReference.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() { @Override public void onSuccess(byte[] bytes) { // Data for "images/island.jpg" is returns, use this as needed my_image = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { // Handle any errors } }); //readFromDB(); ArrayList<Category> categoryList = new ArrayList<>(); Bitmap supermarket = BitmapFactory.decodeResource(getResources(), R.drawable.cart); Bitmap fashion = BitmapFactory.decodeResource(getResources(), R.drawable.dress); Bitmap sports = BitmapFactory.decodeResource(getResources(), R.drawable.dumbbell); Bitmap electronics = BitmapFactory.decodeResource(getResources(), R.drawable.electronics); Category c1 = new Category("Alışveriş", "Alışveriş ve süpermarket ihtiyaçlarına dair her şey.", supermarket); Category c2 = new Category("Elektronik", "Elektronik ve Beyaz eşyaya dair her şey.", electronics); Category c3 = new Category("Moda", "Kıayfet, Kozmetik modaya dair her şey.", fashion); Category c4 = new Category("Spor", "Spor ürünleri, besinleri ve aletleri", sports); categoryList.add(c1); categoryList.add(c2); categoryList.add(c3); categoryList.add(c4); CategoryAdapter categoryAdapter = new CategoryAdapter(this,categoryList); listView.setAdapter(categoryAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(MainActivity.this, categoryList.get(position).getCategoryName() + position, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(MainActivity.this, TitleActivity.class); if(position == 0){ String pass = categoryList.get(position).getCategoryName(); intent.putExtra("category", pass); } else if(position == 1){ String pass = categoryList.get(position).getCategoryName(); intent.putExtra("category", pass); } else if(position == 2){ String pass = categoryList.get(position).getCategoryName(); intent.putExtra("category", pass); } else if(position == 3){ String pass = categoryList.get(position).getCategoryName(); intent.putExtra("category", pass); } startActivity(intent); } }); } public void readFromDB(){ ModelPost m1 = new ModelPost(); DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference(); DatabaseReference chatSpaceRef = rootRef.child("Main").child("Elektrik").child("Akıllı Telefon").child("Samsung"); ValueEventListener eventListener = new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for (DataSnapshot ds : dataSnapshot.getChildren()) { //String key = ds.getKey(); //String msg = ds.child("price").getValue(String.class); //String keyy = ds.getKey(); //String value =ds.getValue().toString(); ModelPost m1 = ds.getValue(ModelPost.class); //System.out.println(keyy+value+"aqqq"); System.out.println(m1.getProductName()+"xD"); } } @Override public void onCancelled(DatabaseError databaseError) { } }; chatSpaceRef.addListenerForSingleValueEvent(eventListener); } }
82624f9f8d83d502157f6badcd74bf50c82f42c3
5ec2c2b6447cff5150af72b00db0e79d53b7207e
/src/main/java/com/djs/spring/BlackListNotifier.java
01a806b1b98ef485ecbad937925f0d719778abc2
[]
no_license
homefrontgarden/springevent
f07ca889a813706f36a0656e03311dcf26012a09
679b906af44b8fbbb26e7c82781bc45dd428a4b7
refs/heads/master
2022-12-05T14:34:08.823011
2020-08-26T14:00:45
2020-08-26T14:00:45
289,888,414
0
0
null
null
null
null
UTF-8
Java
false
false
499
java
package com.djs.spring; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; /** * 监听器类 */ public class BlackListNotifier implements ApplicationListener { public void onApplicationEvent(ApplicationEvent event) { System.out.println(event); if (event instanceof BlackListEvent) { System.out.println(((BlackListEvent) event).getAddress()); //TODO 处理这个邮件地址 } } }
c557f811bdda3f024f4e55d51827f6306df72cca
efc4eddaa4ccca45794a5a5b24ebe90952135459
/SpringMVCController/src/main/java/com/capgemini/HelloController2.java
4617c462bd828855c2b0384919730bf619b29fc9
[]
no_license
priti-evva/MYPROJECT
b9623d2693f0715ed7355f1699c1f41baf67bc9e
efbb1971ad83903a6c4b3146f0fdfe1a5768ff7c
refs/heads/master
2023-03-05T13:58:43.012912
2021-02-04T19:09:10
2021-02-04T19:09:10
327,079,696
0
0
null
null
null
null
UTF-8
Java
false
false
309
java
package com.capgemini; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HelloController2 { @RequestMapping("/hello2") public String display() { return "viewpage2"; } }
b55ffbad36f5923e849dbda50fd03f39fb392ef1
8a2a65b8f478d8f4cbe09139bf12567b5e603cc6
/lib_common/src/main/java/com/hwq/lib_common/utils/compression/Preconditions.java
7d74ae11fbf1b5d3c42f9975237f465854a4a941
[]
no_license
JoinKing/KingMvvm
c501ece9809029694077ccf685d78451540d7401
299982ec04dd3d822eff132cdd4786f0f1ff2529
refs/heads/master
2020-04-13T07:03:36.483094
2019-03-12T02:10:04
2019-03-12T02:10:04
163,039,034
1
1
null
null
null
null
UTF-8
Java
false
false
1,260
java
package com.hwq.lib_common.utils.compression; import android.support.annotation.Nullable; final class Preconditions { /** * Ensures that an object reference passed as a parameter to the calling method is not null. * * @param reference an object reference * @return the non-null reference that was validated * @throws NullPointerException if {@code reference} is null */ static <T> T checkNotNull(T reference) { if (reference == null) { throw new NullPointerException(); } return reference; } /** * Ensures that an object reference passed as a parameter to the calling method is not null. * * @param reference an object reference * @param errorMessage the exception message to use if the check fails; will be converted to a * string using {@link String#valueOf(Object)} * @return the non-null reference that was validated * @throws NullPointerException if {@code reference} is null */ static <T> T checkNotNull(T reference, @Nullable Object errorMessage) { if (reference == null) { throw new NullPointerException(String.valueOf(errorMessage)); } return reference; } }
0016e046bb4c86d746e08cfccfae36624588ac99
36838dfcd53c4d2c73b9a6b0b7a8a28e4a331517
/cn/com/smartdevices/bracelet/chart/util/f.java
3f5ff32025c0c1a8e0cac7811e0efb16b7245236
[]
no_license
ShahmanTeh/MiFit-Java
fbb2fd578727131b9ac7150b86c4045791368fe8
93bdf88d39423893b294dec2f5bf54708617b5d0
refs/heads/master
2021-01-20T13:05:10.408158
2016-02-03T21:02:55
2016-02-03T21:02:55
null
0
0
null
null
null
null
UTF-8
Java
false
false
405
java
package cn.com.smartdevices.bracelet.chart.util; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.view.View; final class f extends AnimatorListenerAdapter { f() { } public void onAnimationEnd(Animator animator) { ((View) ((ObjectAnimator) animator).getTarget()).setRotationY(0.0f); } }
fbb4fd894605c30d7618bd78cde30f8e03ebc691
6d4c51c57b22719fe33246dbe3582eefe51cd360
/gen/com/mrfu/listviewfooter/BuildConfig.java
31af7835c3a9e3819e85c06900343a8c45cf6611
[]
no_license
MrFuFuFu/MrFuListViewFooter
fd5087a6841efbd0626014d23b839632e9bd03cc
a465ff10db833b837642eb9a269077c576cbe341
refs/heads/master
2020-03-30T07:49:25.776377
2014-12-01T12:54:30
2014-12-01T12:54:30
27,379,482
1
0
null
null
null
null
UTF-8
Java
false
false
165
java
/** Automatically generated file. DO NOT MODIFY */ package com.mrfu.listviewfooter; public final class BuildConfig { public final static boolean DEBUG = true; }
53185e7194e1073eaef3f3e1cd287504b76701b1
6fe4293750e2538bbf654eebb48e9cd7d418b3b8
/src/main/java/enums/Driver.java
a9a3a8e51bea305588ffab508b44f9d578698937
[]
no_license
prasadpalkar94/ParkingLot
9d49f501e15e30371451024bde6537b4daf6dc8a
3a80f34e9d585623be198a97667d4cb56747d39f
refs/heads/master
2021-05-21T01:11:46.096191
2020-04-12T23:11:50
2020-04-12T23:11:50
252,480,927
0
0
null
null
null
null
UTF-8
Java
false
false
59
java
package enums; public enum Driver { NORMAL,HANDICAP }
5ed4d89084c68e265b860d207a1c21ef45a3d596
c1939ffc307cfab4d9f5055017be7cdde5712d5b
/sb16/src/main/java/com/vic/sb16/Sb16Application.java
864d6cb22b6547e046d791b74970b6fd0714661d
[]
no_license
fxcjj/sb
98f36e15fb5bfb738db164b5c5078ef9558c07cb
a0dd3607a63ed956cb95e46499d728aede7bcb61
refs/heads/master
2022-06-25T00:44:57.066587
2021-08-09T15:10:09
2021-08-09T15:10:09
183,625,206
0
1
null
2022-06-17T03:31:59
2019-04-26T12:32:12
Java
UTF-8
Java
false
false
386
java
package com.vic.sb16; import de.codecentric.boot.admin.server.config.EnableAdminServer; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @EnableAdminServer @SpringBootApplication public class Sb16Application { public static void main(String[] args) { SpringApplication.run(Sb16Application.class, args); } }
3ce8b8d6a6dc6eadf085d5ef0c1c8f816e51a3a2
dcc5f46a74befbf5923b77f0f741334222ad3e23
/src/br/cefet/ratingreader/utils/Values.java
64eef4d6d5650657f68c65a32e9cdc39f912b1e1
[ "MIT" ]
permissive
chico3434/rating-reader
1e11ac167bb9995e370505488cb35bf16d174adf
3374a7effab06d5a38455c7e5cfc3a0c62e9b722
refs/heads/master
2020-05-03T00:02:47.220555
2019-04-07T22:45:29
2019-04-07T22:45:29
178,298,042
0
0
MIT
2019-04-07T22:45:30
2019-03-28T23:35:31
Java
UTF-8
Java
false
false
761
java
package br.cefet.ratingreader.utils; public class Values { public static boolean console = false; public static boolean save = false; public static boolean readFile = false; // Ainda não foi implementado corretamente caso essa opção seja falsa public static boolean standardOutput = true; public static String source; public static String out; // Ainda pode ser implementada a possibilidade de mudança dos valores abaixo (Caso seja uma fonte diferente) public static int indexOfName = 2; public static int indexOfType = 10; public static int indexOfRating = 16; public static void setDefault() { console = true; save = true; readFile = true; standardOutput = true; } }
d6b6e0eb0dbe159d2795757145883fb00608aaaf
e66e91c19f2570eb76b9ec213687c2842cd22a7f
/src/main/java/com/cdk/gist/access/specifier/msuper/Super.java
7fd132e986219cfa525a3222bce2e31430210389
[]
no_license
kapilgupta1990/CoreJavaPracticeMVN
213c6cd8f2d1790814fee55466fadc9c40246e03
1c1a6d47e71135b2cff6b53230471b89a966b9a4
refs/heads/master
2020-03-21T09:43:50.549358
2018-11-13T08:43:39
2018-11-13T08:43:39
138,414,891
0
0
null
null
null
null
UTF-8
Java
false
false
235
java
package com.cdk.gist.access.specifier.msuper; public class Super { void display() { System.out.println("Super class display"); } public void display1() { } protected void display2() { } private void display3() { } }
1f26179f057c6e36760599188bd4fd6281de1890
e48950188427800298b831ba722098c945accb89
/src/main/java/com/muchi/community/shiro/dao/PermissionDao.java
2337d5b58f50c166e3bcd54b50ae52e00788db6c
[ "Apache-2.0" ]
permissive
communityboot/community
3c38c721a6fe4d3e16be10bfa25687b40c60352b
dcbf6b9a3d8a1b07f6c153443974b356bcb4688b
refs/heads/master
2022-11-01T21:00:47.591977
2019-09-02T08:31:24
2019-09-02T08:31:24
202,123,927
1
0
Apache-2.0
2022-10-12T20:30:31
2019-08-13T10:50:23
Java
UTF-8
Java
false
false
496
java
package com.muchi.community.shiro.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.muchi.community.shiro.entity.Permission; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Component; import java.util.List; @Mapper @Component public interface PermissionDao extends BaseMapper<Permission> { /** * 通过用户名获取权限集合 * @param userName * @return */ List<Permission> getPermissionsByUserName(String userName); }
5da22781c0aaa283315decb852c1b487474819a7
48cfb883502eb0baac6da45494fc9e26294e0d2d
/Veslo/app/src/main/java/com/clogic/veslo/Adapter/FeedAdapter.java
fa5ae9060c5ccd2c67ea1c4bceb3afe30d1b1e07
[]
no_license
choiseungil29/Veslo
87c54c3e18b70745628524379554d5853b586320
d57d198be33661fd2a7cf1a6182575a6cca774d4
refs/heads/master
2021-01-10T13:40:34.693204
2016-01-09T08:45:54
2016-01-09T08:45:54
46,166,348
0
0
null
null
null
null
UTF-8
Java
false
false
1,468
java
package com.clogic.veslo.Adapter; import android.support.v7.widget.RecyclerView; import android.view.ViewGroup; import com.clogic.veslo.Model.Feed; import com.clogic.veslo.Util.Provider; import com.clogic.veslo.View.FeedView; /** * Created by clogic on 2015. 11. 18.. */ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { @Override public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { FeedView view = new FeedView(viewGroup.getContext()); ViewHolder holder = new ViewHolder(view); return holder; } @Override public void onBindViewHolder(ViewHolder viewHolder, int i) { FeedView view = viewHolder.view; Feed feed = Provider.getInstance().getAllNewsfeed().get(i); view.setId(feed.getId()); view.setTime(feed.getUpdateTime()); view.setTextDescribe(feed.getTextDescribe()); try { view.setLove(feed.getLove()); } catch (Exception e) { e.printStackTrace(); } view.setProfileRes(feed.getDescribeResId()); view.setDescribeRes(feed.getDescribeResId()); } @Override public int getItemCount() { return Provider.getInstance().getAllNewsfeed().size(); } public static class ViewHolder extends RecyclerView.ViewHolder { public FeedView view; public ViewHolder(FeedView v) { super(v); view = v; } } }
cabdf61f91d40b5d1fc93674b84b19f931fae4b4
a45a1017844f1655b7b3441336ed54974e7447c4
/app/src/main/java/com/ajndroid/edublog/Activities/MYmessagingService.java
0accc5a8ed09d19a7a0535bf4fffdaea53b74384
[]
no_license
Ridvmodi/EDUBLOGs
30d83da7ccd36d1320ab7c186f947d6bf7936fd3
acdd171dc2d04e9fdd8c0eda5c792f997fa95a9c
refs/heads/master
2022-05-28T20:14:52.497522
2020-05-05T11:06:15
2020-05-05T11:06:15
257,000,245
0
0
null
2020-04-19T13:00:54
2020-04-19T13:00:54
null
UTF-8
Java
false
false
1,110
java
package com.ajndroid.edublog.Activities; import androidx.annotation.NonNull; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; import com.ajndroid.edublog.R; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; public class MYmessagingService extends FirebaseMessagingService { @Override public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); showNotification(remoteMessage.getNotification().getTitle(),remoteMessage.getNotification().getBody()); } public void showNotification(String title,String message){ NotificationCompat.Builder builder = new NotificationCompat.Builder(this,"MyNotification") .setContentTitle(title) .setSmallIcon(R.drawable.ic_launcher_background) .setAutoCancel(true) .setContentText(message); NotificationManagerCompat manager = NotificationManagerCompat.from(this); manager.notify(999,builder.build()); } }
8b18ddd5f1c4133aa1c5ee7aeb3b581ccdb1bc57
1cc621f0cf10473b96f10fcb5b7827c710331689
/Ex6/Procyon/edu/cg/GameState.java
6859e0598afb707ec8e712bfbfe30c188647d89a
[]
no_license
nitaiaharoni1/Introduction-to-Computer-Graphics
eaaa16bd2dba5a51f0f7442ee202a04897cbaa1f
4467d9f092c7e393d9549df9e10769a4b07cdad4
refs/heads/master
2020-04-28T22:56:29.061748
2019-06-06T18:55:51
2019-06-06T18:55:51
175,635,562
0
0
null
null
null
null
UTF-8
Java
false
false
6,219
java
// // Decompiled by Procyon v0.5.30 // package edu.cg; import edu.cg.algebra.Vec; import java.util.Timer; import java.util.TimerTask; public class GameState { private SteeringState steeringState; private AccelarationState accelearationState; private double carVelocity; private Vec nextTranslation; private Timer timer; private final long TIMER_INTERVAL_MS = 8L; private final double MAX_ROTATION = 20.0; private final double MAX_TRANSLATION_X = 5.0; private final double MAX_VELOCITY = 115.0; private final double CAR_ACCELRATION = 30.0; private static /* synthetic */ int[] $SWITCH_TABLE$edu$cg$GameState$AccelarationState; private static /* synthetic */ int[] $SWITCH_TABLE$edu$cg$GameState$SteeringState; public GameState() { this.steeringState = SteeringState.STRAIGHT; this.accelearationState = AccelarationState.CRUISE; this.carVelocity = 0.0; this.nextTranslation = new Vec(0.0, 0.0, 0.0); (this.timer = new Timer()).schedule(new UpdateTranslation(), 0L, 8L); } private synchronized double getCarVelocity() { return this.carVelocity; } private synchronized void updateCarVelocity(final double newVelocity) { this.carVelocity = Math.max(0.0, newVelocity); this.carVelocity = Math.min(115.0, this.carVelocity); } private synchronized double getCarAccelaration() { switch ($SWITCH_TABLE$edu$cg$GameState$AccelarationState()[this.accelearationState.ordinal()]) { case 1: { return 30.0; } case 2: { return -60.0; } case 3: { return -150.0; } default: { return 0.0; } } } public synchronized double getCarRotation() { switch ($SWITCH_TABLE$edu$cg$GameState$SteeringState()[this.steeringState.ordinal()]) { case 1: { return -20.0; } case 3: { return 20.0; } case 2: { return 0.0; } default: { return 0.0; } } } public synchronized void updateSteering(final SteeringState newState) { this.steeringState = newState; } public synchronized void updateAccelaration(final AccelarationState newState) { this.accelearationState = newState; } private synchronized void updateNextTranslation(final Vec deltaTranslation) { this.nextTranslation = this.nextTranslation.add(deltaTranslation); this.nextTranslation.x = (float)Math.max(this.nextTranslation.x, -5.0); this.nextTranslation.x = (float)Math.min(this.nextTranslation.x, 5.0); } public synchronized Vec getNextTranslation() { final Vec retVal = new Vec(this.nextTranslation); this.nextTranslation = new Vec(0.0); return retVal; } static /* synthetic */ int[] $SWITCH_TABLE$edu$cg$GameState$AccelarationState() { final int[] $switch_TABLE$edu$cg$GameState$AccelarationState = GameState.$SWITCH_TABLE$edu$cg$GameState$AccelarationState; if ($switch_TABLE$edu$cg$GameState$AccelarationState != null) { return $switch_TABLE$edu$cg$GameState$AccelarationState; } final int[] array = new int[AccelarationState.values().length]; try { array[AccelarationState.BREAKS.ordinal()] = 3; } catch (NoSuchFieldError noSuchFieldError) {} try { array[AccelarationState.CRUISE.ordinal()] = 2; } catch (NoSuchFieldError noSuchFieldError2) {} try { array[AccelarationState.GAS.ordinal()] = 1; } catch (NoSuchFieldError noSuchFieldError3) {} return array; } static /* synthetic */ int[] $SWITCH_TABLE$edu$cg$GameState$SteeringState() { final int[] $switch_TABLE$edu$cg$GameState$SteeringState = GameState.$SWITCH_TABLE$edu$cg$GameState$SteeringState; if ($switch_TABLE$edu$cg$GameState$SteeringState != null) { return $switch_TABLE$edu$cg$GameState$SteeringState; } final int[] array = new int[SteeringState.values().length]; try { array[SteeringState.LEFT.ordinal()] = 1; } catch (NoSuchFieldError noSuchFieldError) {} try { array[SteeringState.RIGHT.ordinal()] = 3; } catch (NoSuchFieldError noSuchFieldError2) {} try { array[SteeringState.STRAIGHT.ordinal()] = 2; } catch (NoSuchFieldError noSuchFieldError3) {} return array; } public enum AccelarationState { GAS("GAS", 0), CRUISE("CRUISE", 1), BREAKS("BREAKS", 2); private AccelarationState(final String s, final int n) { } } public enum SteeringState { LEFT("LEFT", 0), STRAIGHT("STRAIGHT", 1), RIGHT("RIGHT", 2); private SteeringState(final String s, final int n) { } } class UpdateTranslation extends TimerTask { @Override public void run() { final double theta = GameState.this.getCarRotation() * 3.141592653589793 / 180.0; final double cosTheta = Math.cos(theta); final double sinTheta = Math.sin(theta); final double currentCarVelocity = GameState.this.getCarVelocity(); double currentCarAccelaration = GameState.this.getCarAccelaration(); currentCarAccelaration += -0.1 * Math.abs(sinTheta) * 30.0; final double dt = 0.008; final double dr = currentCarVelocity * dt + currentCarAccelaration * dt * dt; final double dz = Math.min(0.0, -cosTheta * dr); final double dx = sinTheta * dr; final double newVelocity = Math.min(115.0, currentCarVelocity + cosTheta * currentCarAccelaration * dt); GameState.this.updateCarVelocity(newVelocity); GameState.this.updateNextTranslation(new Vec(dx, 0.0, dz)); } } }
368203ef67d7bff7b4442bd453bcdad7a8586c83
f7fbc015359f7e2a7bae421918636b608ea4cef6
/base-one/tags/hsqldb_1_8_0_RC9/src/org/hsqldb/lib/FileAccess.java
b8098d319a589ae72c24bdcf50a8af6697ff22f5
[]
no_license
svn2github/hsqldb
cdb363112cbdb9924c816811577586f0bf8aba90
52c703b4d54483899d834b1c23c1de7173558458
refs/heads/master
2023-09-03T10:33:34.963710
2019-01-18T23:07:40
2019-01-18T23:07:40
155,365,089
0
0
null
null
null
null
UTF-8
Java
false
false
2,846
java
/* Copyright (c) 2001-2005, The HSQL Development Group * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the HSQL Development Group nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG, * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.hsqldb.lib; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * * @author Ocke Janssen [email protected] * @version 1.8.0 * @since 1.80 */ public interface FileAccess { int ELEMENT_READ = 1; int ELEMENT_SEEKABLEREAD = 3; int ELEMENT_WRITE = 4; int ELEMENT_READWRITE = 7; int ELEMENT_TRUNCATE = 8; InputStream openInputStreamElement(java.lang.String streamName) throws java.io.IOException; OutputStream openOutputStreamElement(java.lang.String streamName) throws java.io.IOException; boolean isStreamElement(java.lang.String elementName); void createParentDirs(java.lang.String filename); void removeElement(java.lang.String filename) throws java.util.NoSuchElementException, java.io.IOException; void renameElement(java.lang.String oldName, java.lang.String newName) throws java.util.NoSuchElementException, java.io.IOException; public interface FileSync { void sync() throws java.io.IOException; } public FileSync getFileSync(OutputStream os) throws java.io.IOException; }
[ "(no author)@7c7dc5f5-a22d-0410-a3af-b41755a11667" ]
(no author)@7c7dc5f5-a22d-0410-a3af-b41755a11667
c8da4b7a8aa68532a422dca78399bc59e4fdd857
6b47cfed1afeb0a80afdd2149eec2ef237d88f9d
/src/gameView/commands/LoadCommand.java
890cbc66d2f8859eaed0a2088bb3f824e6cf09c7
[ "MIT" ]
permissive
bilva-sanaba/Game-Salad
686ed33f8fc80c6268fe711b411bd5949da52506
cd72520401b7bf55e4ada5e69ccaae58aa597bed
refs/heads/master
2021-05-16T05:00:20.882845
2019-02-18T19:22:19
2019-02-18T19:22:19
106,234,835
2
1
null
null
null
null
UTF-8
Java
false
false
623
java
package gameView.commands; import javafx.stage.Stage; import gameView.ICommandView; import gameView.tools.GameChooser; public class LoadCommand extends AbstractCommand { public LoadCommand(ICommandView m) { super(m); } @Override public boolean execute(Stage s) { getView().pauseGame(); GameChooser gameChoice = new GameChooser(s); Stage newStage = fileChoice(gameChoice); newStage.showAndWait(); getView().loadGame(gameChoice.getFile()); return true; } @Override public String getName() { return "Load"; } protected Stage fileChoice(GameChooser picker) { return picker.selectFile(); } }
29877f023eca9c99b25aa921f731ee976d976598
54d4181dc13df2ded09b686ca5cfdd9385b317fb
/src/test/java/com/assignment/onlinebookstore/services/SearchServiceTest.java
ac42c2ceaf9b912069933939cb66af28a1cbeb23
[]
no_license
bhagirathi08/OnlineBookStore
c42b813ebce5645632d6a7e19e6b3c97986ec09c
c373c2515be49b3d0a50b98b3ac9b8669e621feb
refs/heads/master
2022-04-19T21:47:53.434606
2020-04-12T09:37:32
2020-04-12T09:37:32
254,543,523
0
0
null
2020-04-12T09:37:33
2020-04-10T04:27:39
Java
UTF-8
Java
false
false
2,827
java
package com.assignment.onlinebookstore.services; import com.assignment.onlinebookstore.entities.*; import com.assignment.onlinebookstore.repositories.*; import org.junit.jupiter.api.*; import org.junit.runner.*; import org.springframework.beans.factory.annotation.*; import org.springframework.boot.test.context.*; import org.springframework.test.context.junit4.*; import java.util.*; import static org.junit.jupiter.api.Assertions.*; @SpringBootTest @RunWith(SpringRunner.class) class SearchServiceTest { Book book1; Book book2; Book book3; @Autowired BookService bookService; @Autowired SearchService searchService; @Autowired BookRepository bookRepository; @BeforeEach public void init() { book1 = new Book(1L,"maths_1","maths_1_author","maths_1_isbn",110.0,10); book2 = new Book(2L,"maths_2","maths_2_author","maths_2_isbn",120.0,20); book3 = new Book(3L,"phy_1","phy_1_author","phy_1_isbn",130.0,30); } @Test void searchBooks() { //creating the books bookService.addBooks(Arrays.asList(book1,book2,book3)); Filter filter = new Filter("maths",null,null); List<Book> books = searchService.searchBooks(filter); Assertions.assertEquals(2,books.size()); //deleting testing data book1 = bookRepository.findByIsbn("maths_1_isbn"); book2 = bookRepository.findByIsbn("maths_2_isbn"); book3 = bookRepository.findByIsbn("phy_1_isbn"); bookRepository.deleteById(book1.getId()); bookRepository.deleteById(book2.getId()); bookRepository.deleteById(book3.getId()); } @Test void searchMediaCoverage() { String searchIsbn = "searchIsbn"; book1.setIsbn(searchIsbn); book1.setTitle("qui"); bookService.addBooks(Arrays.asList(book1)); try { List<String> titles = searchService.searchMediaCoverage(searchIsbn); Assertions.assertEquals(89,titles.size()); } catch (Exception e) { e.printStackTrace(); } //deleting testing data book1 = bookRepository.findByIsbn(searchIsbn); bookRepository.deleteById(book1.getId()); } @Test void searchMediaCoverageWithNoPosts() { String searchIsbn = "searchIsbn"; book1.setIsbn(searchIsbn); book1.setTitle("non-existing"); bookService.addBooks(Arrays.asList(book1)); try { List<String> titles = searchService.searchMediaCoverage(searchIsbn); Assertions.assertEquals(0,titles.size()); } catch (Exception e) { e.printStackTrace(); } //deleting testing data book1 = bookRepository.findByIsbn(searchIsbn); bookRepository.deleteById(book1.getId()); } }
203d1ce9fa3b55e72f32c9cb968f2ef7a65bec3c
8a590c92db3925294f379e6aae2446f1b56cb236
/histogram/src/main/java/com/baidu/histogram/Config.java
27359d37beae92b706b5e60ff9f1facb79bd942e
[ "Apache-2.0" ]
permissive
Buxiaohui/bnavhistogram
d7e829a20820d04da7c013789e4159c3ace151aa
2c7db1b47f8099cd1192cbb4f5c61157a2948dfe
refs/heads/master
2022-04-17T15:49:42.273044
2020-04-21T09:38:45
2020-04-21T09:38:45
256,692,928
0
0
null
null
null
null
UTF-8
Java
false
false
735
java
package com.baidu.histogram; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import androidx.annotation.IntDef; public class Config { public static boolean DEBUG_UI = BuildConfig.DEBUG; @IntDef({ItemState.EMPTY, ItemState.SELECT, ItemState.UN_SELECT}) @Retention(RetentionPolicy.SOURCE) public @interface ItemState { int EMPTY = 0; int SELECT = 1; int UN_SELECT = 2; } @IntDef({RequestState.INVALID, RequestState.LOADING, RequestState.FAIL, RequestState.SUCCESS}) @Retention(RetentionPolicy.SOURCE) public @interface RequestState { int INVALID = -1; int LOADING = 0; int FAIL = 1; int SUCCESS = 2; } }
77b9f05096ca37b70f1e0996b8357dad16c8db6c
760b638f29d7bca55fa5ce1700dfe9d1ce7e4e67
/yu_yu_hakusho_extended/app/src/main/java/com/example/sony/yuyuhakushoextended/MainActivity.java
cbc43cea451897fb9db0577a73b8092b7bdd9b41
[]
no_license
st2092/Android-Applications
0f3cd3e04c9e84972c0f10f73f33e241386621bd
77e1cea8eebed550823c52b3fa21421f106226e0
refs/heads/master
2020-06-03T17:14:35.711066
2015-08-30T01:53:31
2015-08-30T01:53:31
38,952,589
0
0
null
null
null
null
UTF-8
Java
false
false
10,788
java
package com.example.sony.yuyuhakushoextended; import android.graphics.Bitmap; import android.provider.MediaStore; import android.support.v7.app.*; import android.os.*; import android.view.*; import android.media.MediaPlayer; import android.content.*; import android.util.Log; import android.widget.*; public class MainActivity extends ActionBarActivity { // "request codes" used to identify sub-activities that return results private static final int REQUEST_CODE_DETAILS_ACTIVITY = 1234; private static final int REQUEST_CODE_TAKE_PHOTO = 4321; private MediaPlayer media_player; //media player to play theme song private RadioButton previous_radio_button; private int previous_id = -1; private int previous_choice_group = 0; /* * This function gets call when the user clicks on the character image. This * function displays the character's information */ public void display_char_info(View view) { //create intent for new activity to display chosen character's information Intent intent = new Intent(this, DetailsActivity.class); //find out which character was chosen by user RadioGroup radio_group1 = (RadioGroup) findViewById(R.id.group1); RadioGroup radio_group2 = (RadioGroup) findViewById(R.id.group2); int id1 = radio_group1.getCheckedRadioButtonId(); int id2 = radio_group2.getCheckedRadioButtonId(); // if no buttons in a radio group is chosen getCheckedRadioButtonId returns -1 if (previous_choice_group == 1) { intent.putExtra("YuYuHakusho_char_id", id1); } //else if (id1 == -1 && id2 != -1) // a button in group 2 is chosen else if (previous_choice_group == 2) { intent.putExtra("YuYuHakusho_char_id", id2); } //start the new activity to display the character's info startActivityForResult(intent, REQUEST_CODE_DETAILS_ACTIVITY); } /* * This function gets call when the user choose a character via radio button. This * function displays the character's picture */ public void display_char_icon(View view) { //ImageButton image_button = (ImageButton) findViewById(R.id.char_image_button); RadioGroup radio_group_to_clear; if (previous_choice_group != 0) { switch (previous_choice_group) { case 1: // group 1 was picked previously radio_group_to_clear = (RadioGroup) findViewById(R.id.group1); radio_group_to_clear.clearCheck(); break; case 2: // group 2 was picked previously radio_group_to_clear = (RadioGroup) findViewById(R.id.group2); radio_group_to_clear.clearCheck(); break; default: break; } } previous_id = view.getId(); // set previous id for next use int id = view.getId(); update_character_display(id); } /* * This function updates the image base on the selected character. */ private void update_character_display(int id) { ImageButton image_button = (ImageButton) findViewById(R.id.char_image_button); // determines which character was chosen and set the image to corresponding character if (id == R.id.yusuke) // yusuke { image_button.setImageResource(R.drawable.yusuke); previous_radio_button = (RadioButton) findViewById(R.id.yusuke); previous_radio_button.setChecked(true); previous_choice_group = 1; } else if (id == R.id.kuwabara) // kuwabara { image_button.setImageResource(R.drawable.kuwabara); previous_radio_button = (RadioButton) findViewById(R.id.kuwabara); previous_radio_button.setChecked(true); previous_choice_group = 1; } else if (id == R.id.hiei) // hiei { image_button.setImageResource(R.drawable.hiei); previous_radio_button = (RadioButton) findViewById(R.id.hiei); previous_radio_button.setChecked(true); previous_choice_group = 1; } else if (id == R.id.kurama) // kurama { image_button.setImageResource(R.drawable.kurama); previous_radio_button = (RadioButton) findViewById(R.id.kurama); previous_radio_button.setChecked(true); previous_choice_group = 2; } else if (id == R.id.keiko) // keiko { image_button.setImageResource(R.drawable.keiko); previous_radio_button = (RadioButton) findViewById(R.id.keiko); previous_radio_button.setChecked(true); previous_choice_group = 2; } else if (id == R.id.botan) //botan { image_button.setImageResource(R.drawable.botan); previous_radio_button = (RadioButton) findViewById(R.id.botan); previous_radio_button.setChecked(true); previous_choice_group = 2; } // adjust image to fit button image_button.setScaleType(ImageView.ScaleType.CENTER_INSIDE); } /* * This function gets call when the take photo button is clicked on. * Create a new intent to take photo and then return to this activity the image. */ public void take_photo_for_specific_character(View v) { Intent take_photo_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(take_photo_intent, REQUEST_CODE_TAKE_PHOTO); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //initialize media player to play theme song of yu yu hakusho media_player = MediaPlayer.create(this, R.raw.yu_yu_hakusho_theme); media_player.setLooping(true); // log info to check flow of app Log.d("testing", "onCreate got called"); } /* * Event handler that is called when a sub-activity returns. * We can then extract data that came back from the other activity via Intent and use it here. */ @Override protected void onActivityResult(int request_code, int result_code, Intent intent) { super.onActivityResult(request_code, result_code, intent); if (request_code == REQUEST_CODE_TAKE_PHOTO && result_code == RESULT_OK) { //returned from taking a photo with the camera; grab the photo and show it in place of current character Bitmap bmp = (Bitmap) intent.getExtras().get("data"); ImageButton img_button = (ImageButton) findViewById(R.id.char_image_button); img_button.setImageBitmap(bmp); img_button.setScaleType(ImageView.ScaleType.CENTER_INSIDE); } } /* * Gets call when the activity is stopped and wants to save its state. * We save which character is selected and showing so that the will stay on that turtle * when the user comes back later. */ @Override protected void onSaveInstanceState(Bundle out_state) { super.onSaveInstanceState(out_state); Log.d("testing", "onSaveInstanceState got called"); RadioGroup radio_group = (RadioGroup) findViewById(R.id.group1); int id = radio_group.getCheckedRadioButtonId(); // returns -1 if no button is chosen in this group if (id >= 0) //a character in group 1 chosen { out_state.putInt("group", 1); out_state.putInt("id", id); } else //a character in group 2 chosen { //find out which character is chosen in group 2 radio_group = (RadioGroup) findViewById(R.id.group2); id = radio_group.getCheckedRadioButtonId(); out_state.putInt("group", 2); out_state.putInt("id", id); out_state.putInt("previous_choice_group", previous_choice_group); } } /* * Gets call when the activity returns to an active running state and wants to restore its state. * We restore which character was previously selected. */ @Override protected void onRestoreInstanceState(Bundle saved_instance_state) { super.onRestoreInstanceState(saved_instance_state); Log.d("testing", "onRestoreInstanceState got called"); int group_number = saved_instance_state.getInt("group"); int id = saved_instance_state.getInt("id"); previous_choice_group = saved_instance_state.getInt("previous_choice_group"); RadioGroup radio_group; if (group_number == 1) { radio_group = (RadioGroup) findViewById(R.id.group1); } else { radio_group = (RadioGroup) findViewById(R.id.group2); } radio_group.check(id); update_character_display(id); } //////////////////////////////////////////////////////////////////////////////////////////////// // Functions for media player //////////////////////////////////////////////////////////////////////////////////////////////// public void onPause() { super.onPause(); media_player.pause(); Log.d("testing", "onPause got called"); } public void onResume() { super.onResume(); if (media_player != null) { media_player.setLooping(true); media_player.start(); } Log.d("testing", "onResume got called"); } public void onStart() { super.onStart(); Log.d("testing", "onStart got called"); } public void onStop() { super.onStop(); Log.d("testing", "onStop got called"); } public void onDestroy() { super.onDestroy(); Log.d("testing", "onDestroy got called"); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }
ea81a647f2c4f5f9145933017d24979c0f429d01
4db354db720019d0ce1564a56330746318d68ece
/BeanScope/src/main/java/com/liangwei/learnspring/PrototypeBean.java
3d3032352769ab78cf16a522c28273b1352e2ca0
[]
no_license
devilwolfcsu/spring-learn
720076542f8ef25efdadedc259fb811ccf611822
26aaf90305b65c1c34d26845471293a7de5f6a3d
refs/heads/master
2021-01-22T10:41:08.103814
2017-04-15T09:26:29
2017-04-15T09:26:29
82,029,761
1
3
null
null
null
null
UTF-8
Java
false
false
321
java
package com.liangwei.learnspring; /** * Prototype Bean例子 * Created by liangwei on 2017/3/12. */ public class PrototypeBean { private static int num = 0; private int count; public PrototypeBean() { num++; count = num; } public int getCount() { return count; } }
f42f10e0450b62405bbe19eead3abbae97bb813f
d7550339466956db71156b5d43a2d9cf2aa44c1d
/TenDir-parent/TenDir-web/src/test/java/com/intflag/tendir/test/BaseTest.java
9ffd597c4e8af14e2e0119ce538afbb33c1979c3
[]
no_license
jcl12345/TenDir-SSH
195c0ac0deb7cc03e692071437dd9fdd94c87eca
54970329da158c8656942ea6f43312f8f27474f6
refs/heads/master
2021-03-21T06:23:45.647794
2019-07-03T15:26:50
2019-07-03T15:26:50
null
0
0
null
null
null
null
UTF-8
Java
false
false
281
java
package com.intflag.tendir.test; import org.junit.Test; /** * @author 刘国鑫 QQ:1598749808 * @date 2018年5月23日 下午8:11:05 * @Description * @version V1.0 */ public class BaseTest { @Test public void fun1() { System.out.println(System.currentTimeMillis()); } }
f3b7e90b89d92c080d0dff28ab5795db9034500f
df969c6e79549b1fbc78b91b67af1c1ac7f20a7f
/app/src/main/java/com/example/belajarbahasainggris/MainActivity.java
0ad9ca084ef8682ad3307a8fe12a87d104098633
[]
no_license
okidwijaya/bahasainggris
b62bb53d3506b4ee072c885045625624548edc30
93a2265209a4f231cba45e93d6e7ec5d2366484b
refs/heads/master
2022-11-30T01:59:25.541648
2020-08-14T08:55:21
2020-08-14T08:55:21
287,486,054
0
0
null
null
null
null
UTF-8
Java
false
false
2,602
java
package com.example.belajarbahasainggris; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.content.DialogInterface; import android.content.Intent; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.view.WindowManager; import android.widget.ImageButton; public class MainActivity extends AppCompatActivity { ImageButton pindah; ImageButton keluar; MediaPlayer mp; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); final MediaPlayer suaraButton = MediaPlayer.create(this, R.raw.button); //Tombol Belajar pindah = (ImageButton) findViewById (R.id.buttonBelajar); pindah.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { suaraButton.start(); Intent intent = new Intent(MainActivity.this,BelajarActivity.class); startActivity(intent); mp.stop(); } }); //Tombol Keluar keluar= (ImageButton) findViewById(R.id.buttonExit); keluar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showAlertDialog(); } }); } //exit-----> @Override public void onBackPressed(){ showAlertDialog(); } //Dialog Exit private void showAlertDialog(){ AlertDialog.Builder builder = new AlertDialog.Builder(this) //Alert .setMessage("Tutup Aplikasi Ini?") // Jika tidak .setNegativeButton("Tidak", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }) //Jika ya .setPositiveButton("Ya", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); finish(); } }); AlertDialog dialog= builder.create(); dialog.show(); } }