blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
listlengths
0
51
license_type
stringclasses
2 values
repo_name
stringlengths
5
132
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
80
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.85k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
131 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
9.45M
extension
stringclasses
32 values
content
stringlengths
3
9.45M
authors
listlengths
1
1
author_id
stringlengths
0
313
f136bbd37f888e68a8db27c97af72828126d4000
5d7854e54c2f46a1f3915e6b8caba2c2de495a4e
/src/graphics/Sprite.java
ca7fab61266541a4c4907b883ce58deb18b5439f
[]
no_license
SimpleSol/Rain
0d5d64211341be9f5b922576a6439eb83d776f27
f3e09a230d51d72afb6fd4d57f0bd872ed7c80a2
refs/heads/master
2021-01-01T05:22:09.456648
2016-06-04T11:30:11
2016-06-04T11:30:11
58,905,548
0
0
null
null
null
null
UTF-8
Java
false
false
792
java
package graphics; /** * Created by Leon on 02.06.2016. */ public class Sprite { public static Sprite grass = new Sprite(16, 0, 0, SpriteSheet.tiles); public final int SIZE; public int[] pixels; private int x; private int y; private SpriteSheet sheet; public Sprite(int size, int x, int y, SpriteSheet sheet) { this.SIZE = size; pixels = new int[SIZE * SIZE]; this.x = x * SIZE; this.y = y * SIZE; this.sheet = sheet; load(); } private void load() { for (int y = 0; y < SIZE; y++) { for (int x = 0; x < SIZE; x++) { pixels[x + (y * SIZE)] = sheet.pixels[(x + this.x) + ( (y + this.y) * sheet.SIZE)]; } } } }
4441886f8a75df1c91d0e1044dc75973ff0cef6c
9254e7279570ac8ef687c416a79bb472146e9b35
/cdn-20180510/src/main/java/com/aliyun/cdn20180510/models/UpdateFCTriggerRequest.java
206c59fd1dc5831a4ab64f01b3a89b60a2a26525
[ "Apache-2.0" ]
permissive
lquterqtd/alibabacloud-java-sdk
3eaa17276dd28004dae6f87e763e13eb90c30032
3e5dca8c36398469e10cdaaa34c314ae0bb640b4
refs/heads/master
2023-08-12T13:56:26.379027
2021-10-19T07:22:15
2021-10-19T07:22:15
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,911
java
// This file is auto-generated, don't edit it. Thanks. package com.aliyun.cdn20180510.models; import com.aliyun.tea.*; public class UpdateFCTriggerRequest extends TeaModel { @NameInMap("OwnerId") public Long ownerId; @NameInMap("TriggerARN") public String triggerARN; @NameInMap("SourceARN") public String sourceARN; @NameInMap("FunctionARN") public String functionARN; @NameInMap("RoleARN") public String roleARN; @NameInMap("Notes") public String notes; public static UpdateFCTriggerRequest build(java.util.Map<String, ?> map) throws Exception { UpdateFCTriggerRequest self = new UpdateFCTriggerRequest(); return TeaModel.build(map, self); } public UpdateFCTriggerRequest setOwnerId(Long ownerId) { this.ownerId = ownerId; return this; } public Long getOwnerId() { return this.ownerId; } public UpdateFCTriggerRequest setTriggerARN(String triggerARN) { this.triggerARN = triggerARN; return this; } public String getTriggerARN() { return this.triggerARN; } public UpdateFCTriggerRequest setSourceARN(String sourceARN) { this.sourceARN = sourceARN; return this; } public String getSourceARN() { return this.sourceARN; } public UpdateFCTriggerRequest setFunctionARN(String functionARN) { this.functionARN = functionARN; return this; } public String getFunctionARN() { return this.functionARN; } public UpdateFCTriggerRequest setRoleARN(String roleARN) { this.roleARN = roleARN; return this; } public String getRoleARN() { return this.roleARN; } public UpdateFCTriggerRequest setNotes(String notes) { this.notes = notes; return this; } public String getNotes() { return this.notes; } }
7ae5269ee4662f88e0656daed85b4ef7eb24bd40
848c563ddecdefdb4e6d91dfb9651c67ddcbee78
/tangminet/service-api/merchant-service-api/src/main/java/com.topaiebiz.merchant/dto/template/FreightTemplateDetailDTO.java
391bdba5e76088e8678745a21b436641080019ef
[]
no_license
liveqmock/tangxIdea
264481ca7e087d5d8cf23854fb677b0c1376c188
7e780c538434638a79d50e33f45ab0be3ae90625
refs/heads/master
2020-04-04T14:44:18.241241
2018-06-29T14:51:49
2018-06-29T14:51:49
null
0
0
null
null
null
null
UTF-8
Java
false
false
876
java
package com.topaiebiz.merchant.dto.template; import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; /** * zxp */ @Data public class FreightTemplateDetailDTO implements Serializable { /** 全局主键id */ private Long id; /** 关联的运费模板ID */ private Long freightId; /** 配送方式 */ private Integer type; /** 配送区域集合 */ private List<Long> supportCityIds; /** 首次价格 */ private BigDecimal firstPrice; /** 首次件数 */ private BigDecimal firstNum; /** 续件价格 */ private BigDecimal addPrice; /** 续件件数 */ private BigDecimal addNum; /** 是否为默认运费 */ private Integer isDefault; private String nameListStr; public boolean isDefaultFreight(){ return 0 == isDefault; } }
972232957532896cd6abef4e6407fcee51117489
a354ddb5559ae048519814aa3d2f6c1513a3a1d3
/Java/Error02.java
92c6797f7eccb3a26971abb2a68ce21113aa4d22
[]
no_license
ufdilla/backUp
4050309674f00423bcc2ba62247fa629b4927ed9
bcdce3d34bee9a0ba3157d2641ab41c086094312
refs/heads/master
2021-05-11T23:04:48.149473
2018-01-15T06:34:36
2018-01-15T06:34:36
117,506,517
0
0
null
null
null
null
UTF-8
Java
false
false
798
java
import java.util.Scanner; import java.util.InputMismatchException; class Error02 { public static void main (String[] Lined_operands) { Scanner An_input_device = new Scanner (System.in); System.out.print ("Please input the numerator value : "); int numerator = An_input_device.nextInt(); System.out.print ("Please input the denominator value : "); int denominator = An_input_device.nextInt(); try { double result = numerator / denominator; System.out.printf ("\nResult: %d / %d == %5.2f\n"); } catch (InputMismatchException A_mismatch_error) { System.err.printf ("\nError: %s", A_mismatch_error); } catch (ArithmeticException Math_errr) { System.err.printf ("\nError: %s", Math_errr); System.out.println ("Denominator must be nonzer0"); } } }
fda1a9e6e418afefd3b135bf58401a0f40655786
b8ba70194e0dbfbc1db0544bba628e1ae134a380
/project/src/main/java/utils/ui/SwipeHelper.java
5f9276356c86e9657216d66bb7d3fc86da7c820f
[]
no_license
sunstream/multiplatform-testing
1bf10a87480d1bf49561380ac1c2d0d3bd8e59f3
61524e91ab09921ea739d12857a9128a9fcf0c70
refs/heads/master
2021-01-19T14:21:25.816124
2017-06-29T16:22:31
2017-06-29T16:22:31
88,150,151
0
0
null
null
null
null
UTF-8
Java
false
false
3,505
java
package utils.ui; import io.appium.java_client.MobileElement; import io.appium.java_client.SwipeElementDirection; import org.openqa.selenium.By; public class SwipeHelper { private SwipeHelper() {} public static void swipeRight(MobileElement inElement) { Swipe swipe = buildGenericSwipe(null, inElement); swipe.direction(SwipeElementDirection.RIGHT); swipe.withOffsetFromBorderRatio(0.1); swipe.swipe(); } public static void swipeLeft(MobileElement inElement) { Swipe swipe = buildGenericSwipe(null, inElement); swipe.direction(SwipeElementDirection.LEFT); swipe.withOffsetFromBorderRatio(0.1); swipe.swipe(); } public static void scrollDown() { Swipe swipe = new Swipe(); swipe.withOffsetFromBorderRatio(0.05); swipe.swipe(); } public static void scrollUp() { Swipe swipe = new Swipe(); swipe.withOffsetFromBorderRatio(0.05); swipe.direction(SwipeElementDirection.DOWN); swipe.swipe(); } public static void scrollDownToText(String text) { By textLocator = ByHelper.getLocatorByText(text); Swipe swipe = buildGenericSwipe(textLocator, null); swipe.swipe(); } public static void scrollDownToText(String text, MobileElement container) { By textLocator = ByHelper.getLocatorByText(text); Swipe swipe = buildGenericSwipe(textLocator, container); swipe.swipe(); } public static void scrollDownToText(String text, By container) { By textLocator = ByHelper.getLocatorByText(text); Swipe swipe = buildGenericSwipe(textLocator, container); swipe.swipe(); } public static void scrollDownToElement(MobileElement toElement) { Swipe swipe = buildGenericSwipe(toElement, null); swipe.swipe(); } public static void scrollDownToElement(MobileElement toElement, MobileElement inContainer) { Swipe swipe = buildGenericSwipe(toElement, inContainer); swipe.swipe(); } public static void scrollDownToElement(MobileElement toElement, By inContainer) { Swipe swipe = buildGenericSwipe(toElement, inContainer); swipe.swipe(); } public static void scrollDownToElement(By toElement) { Swipe swipe = buildGenericSwipe(toElement, null); swipe.swipe(); } public static void scrollDownToElement(By toElement, MobileElement inContainer) { Swipe swipe = buildGenericSwipe(toElement, inContainer); swipe.swipe(); } public static void scrollDownToElement(By toElement, By inContainer) { Swipe swipe = buildGenericSwipe(toElement, inContainer); } private static Swipe buildGenericSwipe(final Object toElement, final Object inContainer) { verifyProvidedObject(toElement, "Target element"); verifyProvidedObject(inContainer, "Container"); Swipe swipe = new Swipe(); if (toElement != null) { if (toElement instanceof By) { swipe.toElement((By) toElement); } else { swipe.toElement((MobileElement) toElement); } } if (inContainer != null) { if (inContainer instanceof By) { swipe.container((By) inContainer); } else { swipe.container((MobileElement) inContainer); } } return swipe; } private static void verifyProvidedObject(final Object elementOrLocator, final String objectDescription) { final String errorTemplate = "%s should be MobileElement or By, but %s found"; boolean isExpectedArgumentType = elementOrLocator == null || elementOrLocator instanceof MobileElement || elementOrLocator instanceof By; if (!isExpectedArgumentType) { throw new IllegalArgumentException(String.format(errorTemplate,objectDescription, elementOrLocator.getClass())); } } }
f10df8216d177d9d8125aa027a31e40b2e24cd46
ffb6e60458ccdc6830040eafb01b3444476d9bc9
/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/login/CreateAccountActivity.java
ced8803c8001db0c4e3b4e3ebc2eab35a6fe8be2
[]
no_license
coderark/shop-co
92d1437cd6e588811e3af5b3f6152eabe984660b
0362745b5e8b6e508fa747c315e2bfe6fbd6bb42
refs/heads/master
2021-01-01T05:22:38.409945
2016-06-04T14:45:48
2016-06-04T14:45:48
59,714,438
1
0
null
null
null
null
UTF-8
Java
false
false
7,675
java
package com.udacity.firebase.shoppinglistplusplus.ui.login; import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.util.Log; import android.util.Patterns; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; 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.FirebaseAuthUserCollisionException; 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.udacity.firebase.shoppinglistplusplus.R; import com.udacity.firebase.shoppinglistplusplus.model.User; import com.udacity.firebase.shoppinglistplusplus.ui.BaseActivity; import com.udacity.firebase.shoppinglistplusplus.utils.Constants; import com.udacity.firebase.shoppinglistplusplus.utils.Utils; /** * Represents Sign up screen and functionality of the app */ public class CreateAccountActivity extends BaseActivity { private static final String LOG_TAG = CreateAccountActivity.class.getSimpleName(); private ProgressDialog mAuthProgressDialog; private EditText mEditTextUsernameCreate, mEditTextEmailCreate, mEditTextPasswordCreate; private String username, email, password; DatabaseReference mReference=FirebaseDatabase.getInstance().getReference(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_account); /** * Link layout elements from XML and setup the progress dialog */ initializeScreen(); Button button=(Button)findViewById(R.id.btn_create_account_final); final DatabaseReference ref= FirebaseDatabase.getInstance().getReference(); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { onCreateAccountPressed(v); } catch (FirebaseAuthUserCollisionException e){ mEditTextEmailCreate.setError(e.getMessage()); } } }); } /** * Override onCreateOptionsMenu to inflate nothing * * @param menu The menu with which nothing will happen */ @Override public boolean onCreateOptionsMenu(Menu menu) { return true; } /** * Link layout elements from XML and setup the progress dialog */ public void initializeScreen() { mEditTextUsernameCreate = (EditText) findViewById(R.id.edit_text_username_create); mEditTextEmailCreate = (EditText) findViewById(R.id.edit_text_email_create); mEditTextPasswordCreate = (EditText) findViewById(R.id.edit_text_password_create); LinearLayout linearLayoutCreateAccountActivity = (LinearLayout) findViewById(R.id.linear_layout_create_account_activity); initializeBackground(linearLayoutCreateAccountActivity); /* Setup the progress dialog that is displayed later when authenticating with Firebase */ mAuthProgressDialog = new ProgressDialog(this); mAuthProgressDialog.setTitle(getResources().getString(R.string.progress_dialog_loading)); mAuthProgressDialog.setMessage(getResources().getString(R.string.progress_dialog_creating_user_with_firebase)); mAuthProgressDialog.setCancelable(false); } /** * Open LoginActivity when user taps on "Sign in" textView */ public void onSignInPressed(View view) { Intent intent = new Intent(CreateAccountActivity.this, LoginActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); } /** * Create new account using Firebase email/password provider */ public void onCreateAccountPressed(final View view) throws FirebaseAuthUserCollisionException{ username=mEditTextUsernameCreate.getText().toString(); email=mEditTextEmailCreate.getText().toString(); password=mEditTextPasswordCreate.getText().toString(); if(!isEmailValid(email) || !isUserNameValid(username) || !isPasswordValid(password)){ return; } mAuthProgressDialog.show(); final FirebaseAuth auth=FirebaseAuth.getInstance(); final DatabaseReference ref=mReference.child(Constants.FIREBASE_LOCATION_USER_ACCOUNTS).child(Utils.encodeEmail(email)); auth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()){ Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful()); mAuthProgressDialog.dismiss(); ref.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.getValue()==null){ User user=new User(username, email); ref.setValue(user); } else { showErrorToast(getResources().getString(R.string.error_email_taken)); } } @Override public void onCancelled(DatabaseError databaseError) { Log.e(LOG_TAG, databaseError.getMessage()); } }); onSignInPressed(view); } else { mAuthProgressDialog.dismiss(); Log.d(TAG, "createUserWithEmail:onFailure:" + task.getException()); showErrorToast(task.getException().getMessage()); } } }); } private boolean isEmailValid(String email) { if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()){ mEditTextEmailCreate.setError(getResources().getString(R.string.error_invalid_email_not_valid)); return false; } return true; } private boolean isUserNameValid(String userName) { if (userName.equals("")){ mEditTextUsernameCreate.setError(getResources().getString(R.string.error_cannot_be_empty)); return false; } return true; } private boolean isPasswordValid(String password) { if (password.equals("")){ mEditTextPasswordCreate.setError(getResources().getString(R.string.error_cannot_be_empty)); return false; } else if(password.length()<6){ mEditTextPasswordCreate.setError(getResources().getString(R.string.error_invalid_password_not_valid)); return false; } return true; } /** * Show error toast to users */ private void showErrorToast(String message) { Toast.makeText(CreateAccountActivity.this, message, Toast.LENGTH_LONG).show(); } }
824443ff50cacb1939547f7d440093ca2b5d5f7a
05f4c8e70a044acb9a74642b28fffbb356efd584
/src/level2/ordinary_rectangle/Problem.java
166de93d475cbb23fad1d5fd4e190d15a5a5c519
[]
no_license
YoungWukJeon/programmers-skill-checks
eaef43d6d8f9757407b5ce709210212494be92f8
7040f2ecfb4f37a12473eced663265b727d44d72
refs/heads/master
2023-02-16T06:54:22.225643
2021-01-17T13:50:06
2021-01-17T13:50:06
282,955,586
0
0
null
null
null
null
UTF-8
Java
false
false
547
java
package level2.ordinary_rectangle; public class Problem { public static void main(String[] args) { Solution solution = new Solution(); int w = 8; int h = 12; System.out.println(solution.solution(w, h)); } static class Solution { public long solution(int w, int h) { return (long) w * h - (w + h - getGCD(w, h)); } long getGCD(int a, int b) { if (b == 0) { return a; } return getGCD(b, a % b); } } }
087d842c600020800514660a1ab5ec2833902e75
f4dd1d089368f6f72b4518ebdf2b01cc1559d25b
/demo6/src/main/java/com/example/demo6/controller/TestController.java
a6bd2f835167f18a9873728e14a9ec3c0ffa22ed
[]
no_license
GUANJAIWEI/GUANJIAWEI001
4277654f87396d97ea80c4ddacf71f342d70a787
1e3eb6472644cfe38815482c2a8154eceab9a23e
refs/heads/master
2021-03-30T03:56:22.097312
2020-07-15T12:50:19
2020-07-15T12:50:19
248,013,193
0
0
null
2020-07-15T07:07:55
2020-03-17T16:02:01
Java
UTF-8
Java
false
false
587
java
package com.example.demo6.controller; import com.example.demo6.entity.TestEntity; import com.example.demo6.service.TestService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/demo6/test") public class TestController { @Autowired private TestService testService ; @RequestMapping(value = "/get/{id}",method = RequestMethod.GET) public TestEntity test(@PathVariable Integer id){ System.out.println("id:" + id); return testService.getById(id); } }
670c846ccc3b120677e05659d2e4eff58f2ff7d4
ed5ca6efefa9cab00f18c6cf50f878de02576f22
/JAVA_EE/jQueryAjax_maven/src/main/java/com/niit/service/impl/MessagesServiceImpl.java
81a2fd02932d1c9f6282370222f8fa02ee88a637
[]
no_license
fuxiaoyangAlex/IDEA_Project
97ac43c79012cf6ebb34c9ecffcc7dd14e0000a5
59f2c336d86f06e1f451b274e9f154935652e35c
refs/heads/master
2022-12-23T05:59:18.217172
2019-07-09T09:20:45
2019-07-09T09:20:45
195,971,157
0
0
null
2022-12-16T05:00:59
2019-07-09T08:55:43
JavaScript
UTF-8
Java
false
false
926
java
package com.niit.service.impl; import com.niit.dao.MessagesDao; import com.niit.entity.Messages; import com.niit.service.MessagesService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; /** * @ClassName MessagesServiceImpl * @Description TODO * @Author tree * @Date 2019/6/5 16:13 * @Version 1.8 **/ @Service @Transactional public class MessagesServiceImpl implements MessagesService { @Autowired private MessagesDao messagesDao; public int insertMessages(Messages messages) { return messagesDao.insertMessages(messages); } public Messages findMessagesById(Integer id){ return messagesDao.findMessagesById(id); } public ArrayList<Messages> getAllMessages(){ return messagesDao.getAllMessages(); } }
50f659b2a67ab9aec1713ca6e9e3068fa9b9b6bb
6c7832831d7d457ed0257049516950839f4dea01
/Test/src/app/App.java
2b7641edac26c8ac2c665d506a63624322df6c54
[]
no_license
w8990/lshaarp
476ad51534b8ba8fe21ac197a14a91bf91ebf693
df05d9cbb99878a6450855b45da360fb6dda45e7
refs/heads/master
2020-05-16T17:28:16.331863
2019-04-25T01:45:30
2019-04-25T01:45:30
183,195,129
0
0
null
2019-04-25T01:45:31
2019-04-24T09:27:09
null
UTF-8
Java
false
false
147
java
package app; public class App { public static void main(String[] args) throws Exception { System.out.println("Hello213 Java"); } }
61c4488656e8bfc4964902f9e1a1b2748f3b1dab
1a1fa9d2b103d3e8ba3d940316343ee34c2fe5b6
/ddal-sqlparser/src/main/java/studio/raptor/sqlparser/ast/statement/SQLAlterTableCoalescePartition.java
3a1db1f1b5b85fd3fb3f83487964e3a9744f4cfa
[ "Apache-2.0" ]
permissive
mf1389004071/incubator-ddal
70ab4f8c6bd0a8ca394f5f20253702777a168e39
b5a827dfcfbf07c380dc5ea3ecb4c61749426a81
refs/heads/master
2022-01-30T12:38:38.491395
2018-08-24T06:17:19
2018-08-24T06:17:19
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,287
java
/* * Copyright 1999-2017 Alibaba Group Holding 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 studio.raptor.sqlparser.ast.statement; import studio.raptor.sqlparser.ast.SQLExpr; import studio.raptor.sqlparser.ast.SQLObjectImpl; import studio.raptor.sqlparser.visitor.SQLASTVisitor; public class SQLAlterTableCoalescePartition extends SQLObjectImpl implements SQLAlterTableItem { private SQLExpr count; public SQLExpr getCount() { return count; } public void setCount(SQLExpr count) { if (count != null) { count.setParent(this); } this.count = count; } @Override protected void accept0(SQLASTVisitor visitor) { if (visitor.visit(this)) { acceptChild(visitor, count); } visitor.endVisit(this); } }
d05d14f8919b257c57171b1a4f78112d8d68c529
c80e6a84abef45bc7665cacb59e6839b7419f996
/src/main/java/com/zwl/learn/service/OrderService.java
4009efd1ac308857584d58faf7311c51b3b902bf
[]
no_license
weiliangzhou/learn-demo
fce5312c9328b847b9c3c4c7f1889ee1d20674c2
c08cab9e52f08610f2a62555db8118d0b1d34045
refs/heads/master
2023-04-10T14:41:52.628612
2021-04-16T06:55:54
2021-04-16T06:55:54
306,205,172
0
0
null
null
null
null
UTF-8
Java
false
false
181
java
package com.zwl.learn.service; /** @ClassName OrderService @Description @Author 二师兄 @Date 2020-07-15 14:19 @Version V1.0 */ public interface OrderService { void order(); }
6529b25cf7e83b7bcd5a0e3eee57af6faa760597
b7af7389d4878721fabdbe8d1ddeb4e055222af2
/src/test/java/com/example/demo/CustomerUpdateResourceTest.java
093c44918cf3152b3200292ab89e2601f8770584
[]
no_license
ramireddy11/DemoApp
bde67f4c50d336aeb4a68e3e5230c947b06f9a32
0f11722a719a009613c6cc9872a95e4af09f24d2
refs/heads/master
2022-11-20T15:32:56.829496
2020-07-08T16:10:33
2020-07-08T16:10:33
278,135,044
0
0
null
null
null
null
UTF-8
Java
false
false
742
java
package com.example.demo; import com.example.demo.entity.Customer; import com.example.demo.repository.CustomerRepository; @ExtendWith(SpringExtension.class) @SpringBootTest(classes = CustomerUpdateResource.class) public class CustomerUpdateResourceTest { @Autowired private CustomerRepository customerRepository; private Customer customer; @BeforeEach void setUp() { customer = new Customer(); customer.setId(1L); customer.setFirstName("aaa"); customer.setLastName("bbb"); customer.setUserName("ab"); } @Test void testFetchCustomer() { when(customerRepository.findById(1L)).thenReturn(customer); assertEquals(fetchCustomer(1L), customer); } }
06d1abbcd212dfcbb48be9ac7b08f3a6099a02eb
5ab6a03551e721fc08feae3ab3a746ef48cb1e25
/src/test/java/com/simplify/vms/onboard/data/config/WebConfigurerTestController.java
23b082f82353cb02374585dd2e6c70fd1748c046
[]
no_license
arpanm/VMSV2Data
6221f4ca6249c5c555ebbff565bafb0923e26081
70348865bf679048be827949f05380fa1f43eebe
refs/heads/main
2023-04-21T08:31:48.246245
2021-05-10T16:31:45
2021-05-10T16:31:45
365,219,238
0
0
null
2021-05-10T16:31:46
2021-05-07T12:00:15
Java
UTF-8
Java
false
false
382
java
package com.simplify.vms.onboard.data.config; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class WebConfigurerTestController { @GetMapping("/api/test-cors") public void testCorsOnApiPath() {} @GetMapping("/test/test-cors") public void testCorsOnOtherPath() {} }
c5afb28a9802f91bdf2373506a58e42665243068
82963b7aac94471acc0dcfc92e07e585948156b6
/src/test/java/http/SocketTest.java
cf2741b9cab8819dd47fc4788fb5c27880fbd475
[ "Apache-2.0" ]
permissive
hanweida/JerryCodeApp
fec72f884a459f4cd9fe8f9f6902eda26cde7e9b
b9cfd3ae4048c4154efe4f5ad17ae84aee035de6
refs/heads/master
2022-12-26T16:24:30.590244
2022-07-18T06:20:59
2022-07-18T06:20:59
110,661,228
0
0
Apache-2.0
2022-12-16T10:32:34
2017-11-14T08:22:51
Java
UTF-8
Java
false
false
752
java
package http; import org.junit.Test; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; /** * Socket编程 */ public class SocketTest { @Test public void Test(){ serverScoket(); } public static void serverScoket(){ try { ServerSocket serverSocket = new ServerSocket(8000); serverSocket.accept(); } catch (IOException e) { e.printStackTrace(); } } public static void serverClient(){ try { Socket socket = new Socket(); ServerSocket serverSocket = new ServerSocket(8000); serverSocket.accept(); } catch (IOException e) { e.printStackTrace(); } } }
353336e226c65444616fdb2d37f8fa93d73ea797
e394c797d57882823bb656f7a4904ea92909e274
/src/test/java/com/sezer/slackmessager/SlackmessagerApplicationTests.java
c98655c74dea54fb4d78b2dce596fd5ab8a55b7b
[]
no_license
ovuncsezer/SlackSMSMessagerServer
f9b86d318146699a4fb1ad4f561d4e7329aeb45f
ed305b8221717b4293e0666ba80974180c73eb1a
refs/heads/master
2023-05-02T10:45:24.240219
2019-07-31T14:32:52
2019-07-31T14:32:52
194,381,849
0
0
null
2023-04-14T17:48:39
2019-06-29T08:18:27
Java
UTF-8
Java
false
false
356
java
package com.sezer.slackmessager; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest public class SlackmessagerApplicationTests { @Test public void contextLoads() { } }
ccd29f526ab789eb2a37612fa1d40bb87ade8f0b
f61e573fc1e80ca8467b26820b8c398543cf6158
/src/main/java/com/example/dto/SimpleEmployee.java
e21b8a1872207e2758f60911546917fbc43ef879
[]
no_license
tanphat1896/leaveexample
a8d2ed7218007f361c3745eed3b18e362a6b82eb
8e03febbee5be67716b9e25da70172eea4f06b6d
refs/heads/master
2020-03-20T17:50:07.974816
2018-06-18T16:53:24
2018-06-18T16:53:24
137,566,815
0
0
null
null
null
null
UTF-8
Java
false
false
60
java
package com.example.dto; public class SimpleEmployee { }
18ac5a4f2d25da04f6a246dfca0313c328e1c718
47f0090f929417581c085918e20e12afc8d7ec18
/app/src/main/java/com/adshow/player/util/MigrationHelper.java
845beae86ef599837cbd00eca1dd2fdc7203ba1a
[]
no_license
xianguoguo/adplayer
e44dfe50d0f1bb5e81746f62387cec0a773ae3ef
bd05c057823111d1a4e36675131fbfac08e70edf
refs/heads/master
2020-03-28T10:53:09.758687
2018-10-11T15:40:11
2018-10-11T15:40:11
148,155,470
0
0
null
null
null
null
UTF-8
Java
false
false
6,866
java
package com.adshow.player.util; import android.database.Cursor; import android.text.TextUtils; import android.util.Log; import com.adshow.player.dao.DaoMaster; import org.greenrobot.greendao.AbstractDao; import org.greenrobot.greendao.database.Database; import org.greenrobot.greendao.internal.DaoConfig; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Created by zhangqie on 2016/3/26. */ public class MigrationHelper { private static final String CONVERSION_CLASS_NOT_FOUND_EXCEPTION = "MIGRATION HELPER - CLASS DOESN'T MATCH WITH THE CURRENT PARAMETERS"; private static MigrationHelper instance; public static MigrationHelper getInstance() { if (instance == null) { instance = new MigrationHelper(); } return instance; } private static List<String> getColumns(Database db, String tableName) { List<String> columns = new ArrayList<>(); Cursor cursor = null; try { cursor = db.rawQuery("SELECT * FROM " + tableName + " limit 1", null); if (cursor != null) { columns = new ArrayList<>(Arrays.asList(cursor.getColumnNames())); } } catch (Exception e) { Log.v(tableName, e.getMessage(), e); e.printStackTrace(); } finally { if (cursor != null) cursor.close(); } return columns; } public void migrate(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) { generateTempTables(db, daoClasses); DaoMaster.dropAllTables(db, true); DaoMaster.createAllTables(db, false); restoreData(db, daoClasses); } private void generateTempTables(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) { for (int i = 0; i < daoClasses.length; i++) { DaoConfig daoConfig = new DaoConfig(db, daoClasses[i]); String divider = ""; String tableName = daoConfig.tablename; String tempTableName = daoConfig.tablename.concat("_TEMP"); ArrayList<String> properties = new ArrayList<>(); StringBuilder createTableStringBuilder = new StringBuilder(); createTableStringBuilder.append("CREATE TABLE ").append(tempTableName).append(" ("); for (int j = 0; j < daoConfig.properties.length; j++) { String columnName = daoConfig.properties[j].columnName; if (getColumns(db, tableName).contains(columnName)) { properties.add(columnName); String type = null; try { type = getTypeByClass(daoConfig.properties[j].type); } catch (Exception exception) { exception.printStackTrace(); } createTableStringBuilder.append(divider).append(columnName).append(" ").append(type); if (daoConfig.properties[j].primaryKey) { createTableStringBuilder.append(" PRIMARY KEY"); } divider = ","; } } createTableStringBuilder.append(");"); Log.i("lxq", "创建临时表的SQL语句: " + createTableStringBuilder.toString()); db.execSQL(createTableStringBuilder.toString()); StringBuilder insertTableStringBuilder = new StringBuilder(); insertTableStringBuilder.append("INSERT INTO ").append(tempTableName).append(" ("); insertTableStringBuilder.append(TextUtils.join(",", properties)); insertTableStringBuilder.append(") SELECT "); insertTableStringBuilder.append(TextUtils.join(",", properties)); insertTableStringBuilder.append(" FROM ").append(tableName).append(";"); Log.i("lxq", "在临时表插入数据的SQL语句:" + insertTableStringBuilder.toString()); db.execSQL(insertTableStringBuilder.toString()); } } private void restoreData(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) { for (int i = 0; i < daoClasses.length; i++) { DaoConfig daoConfig = new DaoConfig(db, daoClasses[i]); String tableName = daoConfig.tablename; String tempTableName = daoConfig.tablename.concat("_TEMP"); ArrayList<String> properties = new ArrayList(); ArrayList<String> propertiesQuery = new ArrayList(); for (int j = 0; j < daoConfig.properties.length; j++) { String columnName = daoConfig.properties[j].columnName; if (getColumns(db, tempTableName).contains(columnName)) { properties.add(columnName); propertiesQuery.add(columnName); } else { try { if (getTypeByClass(daoConfig.properties[j].type).equals("INTEGER")) { propertiesQuery.add("0 as " + columnName); properties.add(columnName); } } catch (Exception e) { e.printStackTrace(); } } } StringBuilder insertTableStringBuilder = new StringBuilder(); insertTableStringBuilder.append("INSERT INTO ").append(tableName).append(" ("); insertTableStringBuilder.append(TextUtils.join(",", properties)); insertTableStringBuilder.append(") SELECT "); insertTableStringBuilder.append(TextUtils.join(",", propertiesQuery)); insertTableStringBuilder.append(" FROM ").append(tempTableName).append(";"); StringBuilder dropTableStringBuilder = new StringBuilder(); dropTableStringBuilder.append("DROP TABLE ").append(tempTableName); Log.i("lxq", "插入正式表的SQL语句:" + insertTableStringBuilder.toString()); Log.i("lxq", "销毁临时表的SQL语句:" + dropTableStringBuilder.toString()); db.execSQL(insertTableStringBuilder.toString()); db.execSQL(dropTableStringBuilder.toString()); } } private String getTypeByClass(Class<?> type) throws Exception { if (type.equals(String.class)) { return "TEXT"; } if (type.equals(Long.class) || type.equals(Integer.class) || type.equals(long.class) || type.equals(int.class)) { return "INTEGER"; } if (type.equals(Boolean.class) || type.equals(boolean.class)) { return "BOOLEAN"; } Exception exception = new Exception(CONVERSION_CLASS_NOT_FOUND_EXCEPTION.concat(" - Class: ").concat(type.toString())); exception.printStackTrace(); throw exception; } }
60773769ebd5ed23f540c918661cdceb871d49d3
b5ba81d0395afc2bd02e3272855b488516dd1799
/src/test/java/com/demo/test/TestIOUtils.java
81a00bc7b419c490598de40bec4bd94adfa0a9b5
[]
no_license
chirvin/complex
50a113ab73ee07eb0fc392811de4f525848719a7
ef842e7acd7e840fa86fd5dfc83b52016b0b7d43
refs/heads/main
2023-03-22T16:16:20.794916
2021-03-01T07:37:00
2021-03-01T07:37:00
343,309,847
0
0
null
null
null
null
UTF-8
Java
false
false
1,312
java
package com.demo.test; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; import java.io.*; import static org.hamcrest.Matchers.notNullValue; import static org.junit.Assert.assertThat; /** * @author scc * @date 2020/5/28 15:36 */ public class TestIOUtils { private File filePath = null; private File file = null; @Before public void testInit() { // filePath = new File("D:\\Downloads\\主题和字体"); // file = new File("D:\\Downloads\\主题和字体\\hello.txt"); filePath = FileUtils.getFile("D:\\Downloads\\主题和字体"); file = FileUtils.getFile("D:\\Downloads\\主题和字体\\hello.txt"); } @Test public void testBase() throws Exception { InputStream is = FileUtils.openInputStream(file); BufferedInputStream bi = IOUtils.buffer(is); // BufferedInputStream bi = IOUtils.buffer(is, 8196); } @Test public void testRead() throws Exception { InputStream is = FileUtils.openInputStream(file); InputStream isBu = IOUtils.toBufferedInputStream(is); assertThat(is, notNullValue()); Reader reader = new FileReader(file); BufferedReader brTmp = IOUtils.toBufferedReader(reader); } }
f9c7903d3720226c0976c27729105573dc25d5ce
33fab5d2c4ff50e560c08902267aabe33c07ddf7
/src/se/hig/project/maze/CreatMazeClass.java
9c38f5114fff7188ebbfc834ab75c3dff2cb11e5
[]
no_license
AghyadJabali/Create-and-solve-a-maze-by-BFS-and-DFS-algorithms
8163b5cd64b0d5964d592018735ef0d0bf533044
ef65f4865045f1992ef2ed2b96cfc7df02255e79
refs/heads/master
2022-04-13T20:22:45.373317
2020-04-12T10:32:47
2020-04-12T10:32:47
255,057,420
1
0
null
null
null
null
UTF-8
Java
false
false
2,947
java
package se.hig.project.maze; import java.awt.Point; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.Stack; public class CreatMazeClass<T> implements CreatMaze<T> { private static final int ROW_MAZE[] = { -1, 0, 0, 1 }; private static final int COLUM_MAZE[] = { 0, -1, 1, 0 }; private Stack<Point> stack = new Stack<>(); private Random rand = new Random(); private Integer[][] maze; private StringBuilder sb; private int dimension; CreatMazeClass(int dim) { maze = new Integer[dim][dim]; for (int i = 0; i < maze.length; i++) { for (int j = 0; j < maze.length; j++) { maze[i][j] = 0; } } dimension = dim; } @SuppressWarnings("unchecked") @Override public T[][] creatTheMaze() { // TODO Auto-generated method stub stack.push(new Point(0, 0)); while (!stack.empty()) { Point next = stack.pop(); if (checkNextPoint(next)) { maze[next.x][next.y] = 1; List<Point> neighbors = findNeighbors(next); addNeighborsRandom(neighbors); } } return (T[][]) maze; } @Override public String getTheMaze() { // TODO Auto-generated method stub sb = new StringBuilder(); for (Integer[] row : maze) { sb.append(Arrays.toString(row) + "\n"); } return sb.toString(); } @Override public boolean checkNextPoint(Point point) { // TODO Auto-generated method stub int numNeighbor = 0; for (int i = 0; i < 4; i++) { int row = point.x + ROW_MAZE[i]; int col = point.y + COLUM_MAZE[i]; if (pointInMaze(row, col) && notSamePoint(point, row, col) && maze[row][col] == 1) { numNeighbor++; } } return (numNeighbor < 3) && maze[point.x][point.y] != 1; } @Override public void addNeighborsRandom(List<Point> point) { // TODO Auto-generated method stub int pointIndex; while (!point.isEmpty()) { pointIndex = rand.nextInt(point.size()); stack.push(point.remove(pointIndex)); } } @Override public List<Point> findNeighbors(Point pt) { // TODO Auto-generated method stub List<Point> neighbors = new ArrayList<>(); for (int i = 0; i < 4; i++) { int row = pt.x + ROW_MAZE[i]; int col = pt.y + COLUM_MAZE[i]; if (pointInMaze(row, col) && pointNotCorner(pt, row, col) && notSamePoint(pt, row, col)) { neighbors.add(new Point(row, col)); } } return neighbors; } @Override public boolean pointInMaze(int x, int y) { // TODO Auto-generated method stub return (x >= 0 && y >= 0 && x < dimension && y < dimension); } @Override public boolean pointNotCorner(Point point, int x, int y) { // TODO Auto-generated method stub return (x == point.x || y == point.y); } @Override public boolean notSamePoint(Point point, int x, int y) { // TODO Auto-generated method stub return !(x == point.x && y == point.y); } }
7ecc79f46faf738d2ef84129430f7bc4a8942636
8246da9a0ea49ef6e70bfb6bc05148fb6134ed89
/dianping2/src/main/java/com/dianping/travel/SceneryOrderListActivity.java
927c817209b4a04c96af64054292b562b0d92157
[]
no_license
hezhongqiang/Dianping
2708824e30339e1abfb85e028bd27778e26adb56
b1a4641be06857fcf65466ce04f3de6b0b6f05ef
refs/heads/master
2020-05-29T08:48:38.251791
2016-01-13T08:09:05
2016-01-13T08:09:05
null
0
0
null
null
null
null
UTF-8
Java
false
false
5,535
java
package com.dianping.travel; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import com.dianping.accountservice.AccountService; import com.dianping.adapter.BasicLoadAdapter; import com.dianping.app.Environment; import com.dianping.archive.DPObject; import com.dianping.base.widget.NovaListActivity; import com.dianping.dataservice.mapi.BasicMApiRequest; import com.dianping.dataservice.mapi.CacheType; import com.dianping.dataservice.mapi.MApiRequest; import com.dianping.travel.view.SceneryOrderItem; import com.dianping.v1.R.drawable; import com.dianping.v1.R.id; import com.dianping.v1.R.layout; import java.util.ArrayList; public class SceneryOrderListActivity extends NovaListActivity implements AdapterView.OnItemClickListener { public static final String ACTION_SCENERY_ORDER_LIST_CHANGED = "scenery_order_list_changed"; private Adapter adapter; private BroadcastReceiver receiver = new BroadcastReceiver() { public void onReceive(Context paramContext, Intent paramIntent) { if ("scenery_order_list_changed".equals(paramIntent.getAction())) SceneryOrderListActivity.this.adapter.reset(); } }; public void onCreate(Bundle paramBundle) { super.onCreate(paramBundle); this.adapter = new Adapter(); this.listView.setAdapter(this.adapter); this.listView.setOnItemClickListener(this); paramBundle = new IntentFilter("scenery_order_list_changed"); registerReceiver(this.receiver, paramBundle); } protected void onDestroy() { unregisterReceiver(this.receiver); super.onDestroy(); } public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong) { paramAdapterView = paramAdapterView.getItemAtPosition(paramInt); if (paramAdapterView == this.adapter.HELP) { startActivity(new Intent("android.intent.action.VIEW", Uri.parse("dianping://web?url=http://m1.s1.dpfile.com/sc/api_res/scenery/sceneryorderhelp.html?v=2"))); statisticsEvent("myticket5", "myticket5_help", "", 0); } do return; while (!(paramAdapterView instanceof DPObject)); startActivity(new Intent("android.intent.action.VIEW", Uri.parse("dianping://sceneryorder?orderid=" + ((DPObject)paramAdapterView).getInt("ID")))); paramInt = ((DPObject)paramAdapterView).getInt("Status"); paramAdapterView = "预订成功"; if (paramInt == 1) paramAdapterView = "已取消"; while (true) { statisticsEvent("myticket5", "myticket5_list", paramAdapterView, 0); return; if (paramInt != 2) continue; paramAdapterView = "已使用"; } } protected void setEmptyView() { super.setEmptyView(); WebView localWebView = new WebView(this); localWebView.loadUrl("http://m1.s1.dpfile.com/sc/api_res/scenery/sceneryorderhelp.html?v=2"); this.emptyView.addView(localWebView); } class Adapter extends BasicLoadAdapter { private final Object HELP = new Object(); Adapter() { super(); } public MApiRequest createRequest(int paramInt) { if (SceneryOrderListActivity.this.accountService() == null); for (String str = ""; ; str = SceneryOrderListActivity.this.accountService().token()) return BasicMApiRequest.mapiGet("http://m.api.dianping.com/getsceneryorders.bin?token=" + str + "&start=" + paramInt + "&clientUUID=" + Environment.uuid(), CacheType.DISABLED); } public int getCount() { if (this.mData.size() > 0) return super.getCount() + 1; return super.getCount(); } public Object getItem(int paramInt) { if (this.mData.size() > 0) { if (paramInt == 0) return this.HELP; return super.getItem(paramInt - 1); } return super.getItem(paramInt); } public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) { if (getItem(paramInt) == this.HELP) { paramView = SceneryOrderListActivity.this.getLayoutInflater().inflate(R.layout.ticket_item, paramViewGroup, false); ((ImageView)paramView.findViewById(R.id.img00)).setImageResource(R.drawable.ic_info); ((TextView)paramView.findViewById(16908308)).setText("订票帮助"); return paramView; } return super.getView(paramInt, paramView, paramViewGroup); } protected View itemViewWithData(DPObject paramDPObject, int paramInt, View paramView, ViewGroup paramViewGroup) { if (paramView != null) { paramViewGroup = paramView; if ((paramView instanceof SceneryOrderItem)); } else { paramViewGroup = SceneryOrderListActivity.this.getLayoutInflater().inflate(R.layout.scenery_order_item, null); } ((SceneryOrderItem)paramViewGroup).setData(paramDPObject); return paramViewGroup; } } } /* Location: C:\Users\xuetong\Desktop\dazhongdianping7.9.6\ProjectSrc\classes-dex2jar.jar * Qualified Name: com.dianping.travel.SceneryOrderListActivity * JD-Core Version: 0.6.0 */
444b547a7964e4a8c50683a815288c3774971d6d
c41760cf7d9efe59190b8f5314bba283fb75dc27
/consolidator/src/main/java/com/mercadolibre/mutant/consolidator/config/ContainerFactoryConfigurer.java
55617538e1e98430be1939042138c5e72e9b24b3
[]
no_license
deiru87/mutant-seeker
8c5479fe0b174e5d01f8c22e91a65c2b04842b2c
5c780424fbaaa02cc10c56915c3ddfbd1c8b0307
refs/heads/master
2022-12-12T23:56:47.673333
2020-09-15T01:14:33
2020-09-15T01:14:33
295,515,169
0
0
null
null
null
null
UTF-8
Java
false
false
400
java
package com.mercadolibre.mutant.consolidator.config; import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; import org.springframework.stereotype.Component; @Component class ContainerFactoryConfigurer { ContainerFactoryConfigurer(ConcurrentKafkaListenerContainerFactory<?, ?> factory) { factory.getContainerProperties().setMissingTopicsFatal(false); } }
[ "Deimer87" ]
Deimer87
41f5f9f80b33a7a13b7df65d777591f47dfce170
de05dff4cc5b8fb97dfbb857bad2394ed8f79ae4
/src/jd/plugins/hoster/UploadKeepCom.java
6cddfab89017dfa93eda68c8ffb5ce818508b98c
[]
no_license
thiagocrestani/jdownloader-service
3a6c4929b808eb596c66f156812310701f4508eb
2d24d86bb97a1e5f93feb474f688a6a289447553
refs/heads/master
2020-12-24T18:12:38.941947
2010-11-16T13:34:57
2010-11-16T13:34:57
35,786,842
0
0
null
null
null
null
UTF-8
Java
false
false
19,953
java
// jDownloader - Downloadmanager // Copyright (C) 2009 JD-Team [email protected] // // 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 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/>. package jd.plugins.hoster; import java.io.File; import java.io.IOException; import java.util.SortedMap; import java.util.TreeMap; import jd.PluginWrapper; import jd.nutils.encoding.Encoding; import jd.parser.Regex; import jd.parser.html.Form; import jd.parser.html.HTMLParser; import jd.plugins.DownloadLink; import jd.plugins.HostPlugin; import jd.plugins.LinkStatus; import jd.plugins.Plugin; import jd.plugins.PluginException; import jd.plugins.PluginForHost; import jd.plugins.DownloadLink.AvailableStatus; import jd.utils.JDUtilities; @HostPlugin(revision = "$Revision: 11261 $", interfaceVersion = 2, names = { "uploadkeep.com" }, urls = { "http://[\\w\\.]*?dweg6532401238ohXfrthCSWEwerhtetUE/[a-z0-9]{12}" }, flags = { 0 }) public class UploadKeepCom extends PluginForHost { public UploadKeepCom(PluginWrapper wrapper) { super(wrapper); } @Override public String getAGBLink() { return "http://www.uploadkeep.com/tos.html"; } // Links are coming from a decrypter! public void correctDownloadLink(DownloadLink link) { link.setUrlDownload(link.getDownloadURL().replace("dweg6532401238ohXfrthCSWEwerhtetUE", "uploadkeep.com")); } // using XfileSharingProBasic Version 1.3, availablecheck 1.6, password // handling deactivated due problems, modified waittime handling private static final String COOKIE_HOST = "http://uploadkeep.com"; @Override public AvailableStatus requestFileInformation(DownloadLink link) throws IOException, PluginException { this.setBrowserExclusive(); br.setCookie(COOKIE_HOST, "lang", "english"); br.getPage(link.getDownloadURL()); if (br.containsHTML("You have reached the download-limit")) { logger.warning("Waittime detected, please reconnect to make the linkchecker work!"); return AvailableStatus.UNCHECKABLE; } if (br.containsHTML("(No such file|No such user exist|File not found)")) { logger.warning("file is 99,99% offline, throwing \"file not found\" now..."); throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } String filename = br.getRegex("You have requested.*?http://.*?[a-z0-9]{12}/(.*?)</font>").getMatch(0); if (filename == null) { filename = br.getRegex("fname\" value=\"(.*?)\"").getMatch(0); if (filename == null) { filename = br.getRegex("<h2>Download File(.*?)</h2>").getMatch(0); if (filename == null) { filename = br.getRegex("Filename:</b></td><td >(.*?)</td>").getMatch(0); if (filename == null) { filename = br.getRegex("Filename.*?nowrap.*?>(.*?)</td").getMatch(0); if (filename == null) { filename = br.getRegex("File Name.*?nowrap>(.*?)</td").getMatch(0); } } } } } String filesize = br.getRegex("<small>\\((.*?)\\)</small>").getMatch(0); if (filesize == null) { filesize = br.getRegex("\\(([0-9]+ bytes)\\)").getMatch(0); if (filesize == null) { filesize = br.getRegex("</font>[ ]+\\((.*?)\\)(.*?)</font>").getMatch(0); if (filesize == null) { filesize = br.getRegex("Download File :.*?\\((.*?)\\)").getMatch(0); } } } if (filename == null || filename.equals("")) { logger.warning("The filename equals null, throwing \"file not found\" now..."); throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } filename = filename.replaceAll("(</b>|<b>|\\.html)", ""); link.setName(filename.trim()); if (filesize != null && !filesize.equals("")) { logger.info("Filesize found, filesize = " + filesize); link.setDownloadSize(Regex.getSize(filesize)); } return AvailableStatus.TRUE; } @Override public void handleFree(DownloadLink downloadLink) throws Exception, PluginException { requestFileInformation(downloadLink); // If the filesize regex above doesn't match you can copy this part into // the available status (and delete it here) Form freeform = br.getFormBySubmitvalue("Kostenloser+Download"); if (freeform == null) { freeform = br.getFormBySubmitvalue("Free+Download"); if (freeform == null) { freeform = br.getFormbyKey("download1"); } } if (freeform != null) br.submitForm(freeform); // Handling for only-premium links if (br.containsHTML("(You can download files up to.*?only|Upgrade your account to download bigger files)")) { String filesizelimit = br.getRegex("You can download files up to(.*?)only").getMatch(0); if (filesizelimit != null) { filesizelimit = filesizelimit.trim(); logger.warning("As free user you can download files up to " + filesizelimit + " only"); throw new PluginException(LinkStatus.ERROR_FATAL, "Free users can only download files up to " + filesizelimit); } else { logger.warning("Only downloadable via premium"); throw new PluginException(LinkStatus.ERROR_FATAL, "Only downloadable via premium"); } } if (br.containsHTML("This file reached max downloads")) { throw new PluginException(LinkStatus.ERROR_FATAL, "This file reached max downloads"); } if (br.containsHTML("You have to wait")) { int minutes = 0, seconds = 0, hours = 0; String tmphrs = br.getRegex("\\s+(\\d+)\\s+hours?").getMatch(0); if (tmphrs != null) hours = Integer.parseInt(tmphrs); String tmpmin = br.getRegex("\\s+(\\d+)\\s+minutes?").getMatch(0); if (tmpmin != null) minutes = Integer.parseInt(tmpmin); String tmpsec = br.getRegex("\\s+(\\d+)\\s+seconds?").getMatch(0); if (tmpsec != null) seconds = Integer.parseInt(tmpsec); int waittime = ((3600 * hours) + (60 * minutes) + seconds + 1) * 1000; logger.info("Detected waittime #1, waiting " + waittime + "milliseconds"); throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, waittime); } if (br.containsHTML("You have reached the download-limit")) { String tmphrs = br.getRegex("\\s+(\\d+)\\s+hours?").getMatch(0); String tmpmin = br.getRegex("\\s+(\\d+)\\s+minutes?").getMatch(0); String tmpsec = br.getRegex("\\s+(\\d+)\\s+seconds?").getMatch(0); if (tmphrs == null && tmpmin == null && tmpsec == null) { throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 60 * 60 * 1000l); } else { int minutes = 0, seconds = 0, hours = 0; if (tmphrs != null) hours = Integer.parseInt(tmphrs); if (tmpmin != null) minutes = Integer.parseInt(tmpmin); if (tmpsec != null) seconds = Integer.parseInt(tmpsec); int waittime = ((3600 * hours) + (60 * minutes) + seconds + 1) * 1000; logger.info("Detected waittime #2, waiting " + waittime + "milliseconds"); throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, waittime); } } String md5hash = br.getRegex("<b>MD5.*?</b>.*?nowrap>(.*?)<").getMatch(0); if (md5hash != null) { md5hash = md5hash.trim(); logger.info("Found md5hash: " + md5hash); downloadLink.setMD5Hash(md5hash); } br.setFollowRedirects(false); Form DLForm = br.getFormbyProperty("name", "F1"); if (DLForm == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); // Ticket Time String ttt = br.getRegex("countdown\">.*?(\\d+).*?</span>").getMatch(0); if (ttt == null) ttt = br.getRegex("id=\"countdown_str\".*?<span id=\".*?\">.*?(\\d+).*?</span").getMatch(0); if (ttt != null) { logger.info("Waittime detected, waiting " + ttt.trim() + " seconds from now on..."); int tt = Integer.parseInt(ttt); sleep(tt * 1001, downloadLink); } String passCode = null; boolean password = false; boolean recaptcha = false; if (br.containsHTML("(<br><b>Password:</b> <input|<br><b>Passwort:</b> <input)")) { password = true; logger.info("The downloadlink seems to be password protected."); } // Get the captcha if (br.containsHTML("background:#ccc;text-align") && !br.containsHTML("display:none;\">background:#ccc;text-align")) { logger.info("Detected captcha method \"plaintext captchas\" for this host"); // Captcha method by ManiacMansion String[][] letters = new Regex(Encoding.htmlDecode(br.toString()), "<span style='position:absolute;padding-left:(\\d+)px;padding-top:\\d+px;'>(\\d)</span>").getMatches(); if (letters == null || letters.length == 0) { logger.warning("plaintext captchahandling broken!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } SortedMap<Integer, String> capMap = new TreeMap<Integer, String>(); for (String[] letter : letters) { capMap.put(Integer.parseInt(letter[0]), letter[1]); } StringBuilder code = new StringBuilder(); for (String value : capMap.values()) { code.append(value); } DLForm.put("code", code.toString()); logger.info("Put captchacode " + code.toString() + " obtained by captcha metod\"plaintext captchas\" in the form."); } else if (br.containsHTML("/captchas/")) { logger.info("Detected captcha method \"Standard captcha\" for this host"); String[] sitelinks = HTMLParser.getHttpLinks(br.toString(), null); String captchaurl = null; if (sitelinks == null || sitelinks.length == 0) { logger.warning("Standard captcha captchahandling broken!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } for (String link : sitelinks) { if (link.contains("/captchas/")) { captchaurl = link; break; } } if (captchaurl == null) { logger.warning("Standard captcha captchahandling broken!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } String code = getCaptchaCode(captchaurl, downloadLink); DLForm.put("code", code); logger.info("Put captchacode " + code + " obtained by captcha metod \"Standard captcha\" in the form."); } else if (br.containsHTML("api.recaptcha.net") && !br.containsHTML("api\\.recaptcha\\.net.*?<Textarea.*?<input type=\"submit\" value.*?</Form>")) { // Some hosters also got commentfields with captchas, therefore is // the !br.contains...check Exampleplugin: // FileGigaCom logger.info("Detected captcha method \"Re Captcha\" for this host"); PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP"); jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br); rc.parse(); rc.load(); File cf = rc.downloadCaptcha(getLocalCaptchaFile()); String c = getCaptchaCode(cf, downloadLink); if (password == true) { if (downloadLink.getStringProperty("pass", null) == null) { passCode = Plugin.getUserInput("Password?", downloadLink); } else { /* gespeicherten PassCode holen */ passCode = downloadLink.getStringProperty("pass", null); } rc.getForm().put("password", passCode); logger.info("Put password \"" + passCode + "\" entered by user in the DLForm."); password = false; } recaptcha = true; rc.setCode(c); logger.info("Put captchacode " + c + " obtained by captcha metod\"Re Captcha\" in the form and submitted it."); } // Captcha end // If the hoster uses Re Captcha the form has already been sent before // here so here it's checked. Most hosters don't use Re Captcha so // usually recaptcha is false if (recaptcha == false) { if (password == true) { if (downloadLink.getStringProperty("pass", null) == null) { passCode = Plugin.getUserInput("Password?", downloadLink); } else { /* gespeicherten PassCode holen */ passCode = downloadLink.getStringProperty("pass", null); } DLForm.put("password", passCode); logger.info("Put password \"" + passCode + "\" entered by user in the DLForm."); } jd.plugins.BrowserAdapter.openDownload(br, downloadLink, DLForm, false, 1); logger.info("Submitted DLForm"); } boolean error = false; try { if (dl.getConnection().getContentType().contains("html")) { error = true; } } catch (Exception e) { error = true; } if (br.getRedirectLocation() != null || error == true) { br.followConnection(); logger.info("followed connection..."); String dllink = br.getRedirectLocation(); if (dllink == null) { if (br.containsHTML("You have to wait")) { int minutes = 0, seconds = 0, hours = 0; String tmphrs = br.getRegex("\\s+(\\d+)\\s+hours?").getMatch(0); if (tmphrs != null) hours = Integer.parseInt(tmphrs); String tmpmin = br.getRegex("\\s+(\\d+)\\s+minutes?").getMatch(0); if (tmpmin != null) minutes = Integer.parseInt(tmpmin); String tmpsec = br.getRegex("\\s+(\\d+)\\s+seconds?").getMatch(0); if (tmpsec != null) seconds = Integer.parseInt(tmpsec); int waittime = ((3600 * hours) + (60 * minutes) + seconds + 1) * 1000; logger.info("Detected waittime #1, waiting " + waittime + "milliseconds"); throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, waittime); } if (br.containsHTML("You have reached the download-limit")) { String tmphrs = br.getRegex("\\s+(\\d+)\\s+hours?").getMatch(0); String tmpmin = br.getRegex("\\s+(\\d+)\\s+minutes?").getMatch(0); String tmpsec = br.getRegex("\\s+(\\d+)\\s+seconds?").getMatch(0); if (tmphrs == null && tmpmin == null && tmpsec == null) { throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 60 * 60 * 1000l); } else { int minutes = 0, seconds = 0, hours = 0; if (tmphrs != null) hours = Integer.parseInt(tmphrs); if (tmpmin != null) minutes = Integer.parseInt(tmpmin); if (tmpsec != null) seconds = Integer.parseInt(tmpsec); int waittime = ((3600 * hours) + (60 * minutes) + seconds + 1) * 1000; logger.info("Detected waittime #2, waiting " + waittime + "milliseconds"); throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, waittime); } } if (br.containsHTML("You're using all download slots for IP")) throw new PluginException(LinkStatus.ERROR_IP_BLOCKED, null, 10 * 60 * 1001l); if (br.containsHTML("(<br><b>Password:</b> <input|<br><b>Passwort:</b> <input|Wrong password)")) { logger.warning("Wrong password, the entered password \"" + passCode + "\" is wrong, retrying..."); downloadLink.setProperty("pass", null); throw new PluginException(LinkStatus.ERROR_RETRY); } if (br.containsHTML("Wrong captcha")) { logger.warning("Wrong captcha or wrong password!"); throw new PluginException(LinkStatus.ERROR_CAPTCHA); } if (dllink == null) { dllink = br.getRegex("dotted #bbb;padding.*?<a href=\"(.*?)\"").getMatch(0); if (dllink == null) { dllink = br.getRegex("This direct link will be available for your IP.*?href=\"(http.*?)\"").getMatch(0); if (dllink == null) { // This was for fileop.com, maybe also works for // others! dllink = br.getRegex("Download: <a href=\"(.*?)\"").getMatch(0); } } } } if (dllink == null) { logger.warning("Final downloadlink (String is \"dllink\") regex didn't match!"); throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } logger.info("Final downloadlink found, starting the download..."); jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, false, 1); } if (passCode != null) { downloadLink.setProperty("pass", passCode); } boolean error2 = false; try { if (dl.getConnection().getContentType().contains("html")) { error2 = true; } } catch (Exception e) { error2 = true; } if (error2 == true) { logger.warning("The final dllink seems not to be a file!"); br.followConnection(); if (br.containsHTML("File Not Found")) { logger.warning("Server says link offline, please recheck that!"); throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND); } throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT); } dl.startDownload(); } @Override public void reset() { } @Override public void resetDownloadlink(DownloadLink link) { } @Override public int getMaxSimultanFreeDownloadNum() { return 1; } }
ea2f183d64e622d6bb429f9a7c455bafb4d517a1
ec230127bd9aa25a651a8dd9c0844ac23a792add
/app/src/test/java/com/example/lab3/clase13022019/ExampleUnitTest.java
4f288f6a8f060a83fa7245c286c2dbee0f48ab2e
[]
no_license
Julioolivares12/clase13022019
9f28866800b8d523b5e7d2b4bfd97d119cfba801
a551c753101b61d085db99ac643371941053a408
refs/heads/master
2020-04-22T23:44:05.037603
2019-02-14T20:11:27
2019-02-14T20:11:27
170,751,233
0
0
null
null
null
null
UTF-8
Java
false
false
391
java
package com.example.lab3.clase13022019; import org.junit.Test; import static org.junit.Assert.*; /** * Example local unit test, which will execute on the development machine (host). * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ public class ExampleUnitTest { @Test public void addition_isCorrect() { assertEquals(4, 2 + 2); } }
169f8980bb31951ddba67785bea13956cab40ff5
abfed6b51bb6e35fdc5c573dc93fed7188a0da95
/src/main/java/com/github/davidfantasy/mybatisplus/generatorui/service/MapperXmlParser.java
c90c1a62468fe0c1052a98a7a33189ac4bb1ee29
[ "Apache-2.0" ]
permissive
wenit/mybatis-plus-generator-ui
d163a03cbb4aad3163543f5528157449c0fc03c9
e1457f2adbc71786ce7490042a1dd2b514918632
refs/heads/master
2022-11-24T05:46:37.387549
2020-07-31T06:07:19
2020-07-31T06:07:19
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,160
java
package com.github.davidfantasy.mybatisplus.generatorui.service; import com.github.davidfantasy.mybatisplus.generatorui.common.ServiceException; import com.github.davidfantasy.mybatisplus.generatorui.dto.ElementPosition; import com.github.davidfantasy.mybatisplus.generatorui.dto.MapperElement; import com.google.common.base.Strings; import com.google.common.collect.Lists; import org.dom4j.*; import org.dom4j.dom.DOMComment; import org.dom4j.io.OutputFormat; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; import org.springframework.stereotype.Component; import java.io.*; import java.util.List; /** * Mapper XML的相关操作接口 */ @Component public class MapperXmlParser { private SAXReader reader = new SAXReader(); private OutputFormat format = OutputFormat.createPrettyPrint(); /** * 在Mapper文件中添加代码节点 * * @param mapperPath mapper.xml所在的位置 * @param elements 需要添加的节点内容 */ public void addElementInMapper(String mapperPath, MapperElement... elements) throws IOException, DocumentException { File mapperFile = new File(mapperPath); if (!mapperFile.exists()) { throw new ServiceException("XML文件不存在:" + mapperPath); } Document doc = reader.read(new FileInputStream(mapperFile)); List<Node> mapperNodes = doc.getRootElement().content(); List<Node> newNodes = Lists.newArrayList(); //从原有节点中剔除与即将添加的节点ID相同的节点 for (Node node : mapperNodes) { if (node instanceof Element) { boolean equals = false; Element oldEle = (Element) node; for (MapperElement newEle : elements) { if (!Strings.isNullOrEmpty(newEle.getId()) && newEle.getId().equals(oldEle.attributeValue("id"))) { equals = true; newEle.setExisted(true); } } if (!equals) { newNodes.add(node); } } else { newNodes.add(node); } } for (MapperElement ele : elements) { Element newEle = DocumentHelper.parseText(ele.getContent().trim()).getRootElement(); if (ele.getLocation().equals(ElementPosition.FIRST)) { newNodes.add(0, newEle); //仅在首次添加时才添加注释,避免注释重复添加 if (!ele.isExisted()) { newNodes.add(0, new DOMComment(ele.getComment())); } } else { //仅在首次添加时才添加注释,避免注释重复添加 if (!ele.isExisted()) { newNodes.add(new DOMComment(ele.getComment())); } newNodes.add(newEle); } } doc.getRootElement().setContent(newNodes); XMLWriter writer = new XMLWriter(new FileWriter(mapperFile), format); writer.write(doc); writer.flush(); } }
0d83fcfc1498d377d7850a7916e663f539367820
70b0c3a853060944161ce7d55e7458cd78eadf03
/The New Boston/src/com/example/theNewBoston/StatusBar.java
35d7e51f197d4279c0dfba2aa1fcaef08aa762ed
[]
no_license
ajayrkp/AndroidTutorials
129d5eafc77e4080647f04ff9aca3465982163be
3e13bc21b7b0135fdcf355ebf6b46cfccf0b2d6f
refs/heads/master
2016-09-05T16:37:17.561531
2012-10-25T15:17:21
2012-10-25T15:17:21
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,316
java
package com.example.theNewBoston; import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class StatusBar extends Activity implements OnClickListener { NotificationManager nm; static final int uniqueID = 135678; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.statusbar); Button stat = (Button) findViewById(R.id.bStatusBar); stat.setOnClickListener(this); nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.cancel(uniqueID); } @Override public void onClick(View v) { Intent intent = new Intent(this, StatusBar.class); PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0); String body = "This is a message from Ajay, thanks for hanging on..."; String title = "Ajay P."; @SuppressWarnings("deprecation") Notification n = new Notification(R.drawable.lightning, body, System.currentTimeMillis()); n.setLatestEventInfo(this, title, body, pi); n.defaults = Notification.DEFAULT_ALL; nm.notify(uniqueID, n); finish(); } }
bb65b5b2843e6e7e782d31492ff10126674d0841
884056b6a120b2a4c1c1202a4c69b07f59aecc36
/java projects/quickSort/result/slicedQuickSort/traditional_mutants/void_quickSort(int,int,int)/AOIS_18/slicedQuickSort.java
21eac4b2f943f5cb7425749e4e46a76957c84725
[ "MIT" ]
permissive
NazaninBayati/SMBFL
a48b16dbe2577a3324209e026c1b2bf53ee52f55
999c4bca166a32571e9f0b1ad99085a5d48550eb
refs/heads/master
2021-07-17T08:52:42.709856
2020-09-07T12:36:11
2020-09-07T12:36:11
204,252,009
3
0
MIT
2020-01-31T18:22:23
2019-08-25T05:47:52
Java
UTF-8
Java
false
false
1,084
java
// This is mutant program. // Author : ysma public class slicedQuickSort { public static void quickSort( int[] list ) { quickSort( list, 0, list.length - 1 ); } private static void quickSort( int[] list, int first, int last ) { if (last > first) { int pivotIndex = partition( list, first, last ); quickSort( list, first--, pivotIndex - 1 ); quickSort( list, pivotIndex + 1, last ); } } private static int partition( int[] list, int first, int last ) { int pivot = list[first]; int low = first + 1; int high = last; if (pivot > list[high]) { list[first] = list[high]; list[high] = pivot; return high; } else { return first; } } public static void main( java.lang.String[] args ) { int[] list = { 2, 3, 2, 5, 6, 1, -2, 3, 14, 12 }; quickSort( list ); for (int i = 0; i < list.length; i++) { System.out.print( list[i] + " " ); } } }
5477492e347f95201738f584a6858f8c973050e0
f096ad3cc9a8e8a4313c1bd82890f39592d6d9d3
/app/src/androidTest/java/com/familybiz/greg/moviepaint/ApplicationTest.java
a4b00a8c5b8e8f44e376b738927f0e9cf6677efd
[]
no_license
greganderson/MoviePaint
4ff5e142152b6aa479d109ed270d3bd461160836
2ea1cd4a6725fd3839ab6e66c9decb963b60683e
refs/heads/master
2021-03-12T22:36:24.330938
2014-10-23T20:11:15
2014-10-23T20:11:15
null
0
0
null
null
null
null
UTF-8
Java
false
false
360
java
package com.familybiz.greg.moviepaint; 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); } }
e52092adf485732b23152c86d8ea05c56d75e307
0c698e4eff8601ae27a1a833ef506aed19e2b2cb
/src/main/java/repetition/proba001/NotAbstract.java
ecc52079afb3578400a81e458741979333ff2165
[]
no_license
alsamancov/BruceEckel
ea432e9de1c8be3148a0750c13c8987707fa0a2a
b827917220304c8dd0a8f0708ea505214ba395da
refs/heads/master
2020-04-04T20:17:40.864127
2019-03-14T13:39:38
2019-03-14T13:39:38
156,241,215
1
0
null
null
null
null
UTF-8
Java
false
false
169
java
package repetition.proba001; public class NotAbstract extends Basic { @Override void uniplemented() { System.out.println("print something!"); } }
dcb8f55c822f3a096e85b1cc9b206c06b1aca29f
2fc600bc6ff91ce842cbe99ca80f5227b066dcf5
/Android Text Code/Sign_in/src/main/java/com/example/sajibpal/singinsingout/Account.java
2e8c9ce04209ce46800d0ec02006375919e58db5
[]
no_license
sajibpal/Android-Text-Code
9991ae0d2101fe1146829948ca8f9064bf431fc3
2f4584d78357c0e2035d0f152beae31efb1aaac9
refs/heads/main
2023-04-15T14:32:14.138746
2021-04-13T09:06:17
2021-04-13T09:06:17
357,930,773
1
0
null
null
null
null
UTF-8
Java
false
false
1,503
java
package com.example.sajibpal.singinsingout; import android.database.sqlite.SQLiteDatabase; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class Account extends AppCompatActivity { Connection connection; EditText txt,txt1,txt2,txt3; Button btn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_account); connection=new Connection(this); SQLiteDatabase database=connection.getWritableDatabase(); txt= (EditText) findViewById(R.id.text); txt1= (EditText) findViewById(R.id.text1); txt2= (EditText) findViewById(R.id.text2); txt3= (EditText) findViewById(R.id.text3); btn= (Button) findViewById(R.id.button); } public void save(View v){ String name=txt.getText().toString(); String email=txt1.getText().toString(); String password=txt2.getText().toString(); if(v.getId()==R.id.button){ long rowid=connection.insetData(name,email,password); if(rowid==-1){ Toast.makeText(this, "Data not add Successfully", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(this, "Data add Successfully", Toast.LENGTH_SHORT).show(); } } } }
b00dbbfa3e1f40bebb62feb8c41704be9b8baa49
30614192ae67d9cced3866bd310f9fb58dfa2fbe
/src/main/java/ke/co/turbosoft/med/repository/AgentRepo.java
ea3bfc2ea9c2454ff70dd658c06554bebaa856ec
[]
no_license
ktonym/turbomed-underwriting
33086bc08787347401b0b2037e0fbc1891f28d4c
0daa864ab8aeac3f6be5caf3cc14659434e79372
refs/heads/master
2021-01-01T15:31:04.373863
2015-02-27T16:41:30
2015-02-27T16:41:30
27,634,219
0
0
null
null
null
null
UTF-8
Java
false
false
257
java
package ke.co.turbosoft.med.repository; import ke.co.turbosoft.med.entity.Agent; import org.springframework.data.jpa.repository.JpaRepository; /** * Created by akipkoech on 12/8/14. */ public interface AgentRepo extends JpaRepository<Agent,Integer> { }
df2a1703e0b897b3474d96bde9f840442ca62d50
0478e72cf7af4c00453ea1815e2630a1b25f917c
/src/main/java/cse/buffalo/edu/algorithms/string/LSD.java
890309f7ff90fcee13075661953b7dd1389b52ee
[]
no_license
sondrev/algorithm_training
7b5ace714cf51c4812133de2851dbdbd79b106ad
5b15d7a0e528aa9d2c5357ce79d8c1c290646256
refs/heads/master
2021-01-14T19:45:12.981472
2013-10-08T02:40:47
2013-10-08T02:40:47
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,040
java
package cse.buffalo.edu.algorithms.string; import cse.buffalo.edu.algorithms.stdlib.StdIn; import cse.buffalo.edu.algorithms.stdlib.StdOut; public class LSD { // W is the digits of the string public static void sort(String[] a, int W) { int N = a.length; int R = 256; String[] aux = new String[N]; for (int d = W - 1; d >= 0; d--) { // Compute frequency counts int[] count = new int[R+1]; for (int i = 0; i < N; i++) { count[a[i].charAt(d) + 1]++; } // Compute cumulates for (int r = 0; r < R; r++) { count[r+1] += count[r]; } // Move data for (int i = 0; i < N; i++) { aux[count[a[i].charAt(d)]++] = a[i]; } // Copy back for (int i = 0; i < N; i++) { a[i] = aux[i]; } } } public static void main(String[] args) { String[] a = StdIn.readStrings(); int N = a.length; int W = a[0].length(); sort(a, W); for (int i = 0; i < N; i++) { StdOut.println(a[i]); } } }
7c084e90a7ee219dd7946b6c4f6f11777494e578
06b0b357098ce5f237e3802fdee4d5f9ae341617
/medical_assistant/src/main/java/com/dao/TOtherSymptomsDAO.java
ac2ba2573891324bd34fc5795685f37581ebbfb8
[]
no_license
qinmp/maven_project
7e783c7a08bf4f7e59e39f61a1f6a3fc2d6a490b
3630894923f181dc2daf274e128f3b1c20b70e7d
refs/heads/master
2022-12-22T02:03:28.543109
2020-09-16T16:18:18
2020-09-16T16:18:18
101,548,822
1
0
null
2022-12-16T11:22:52
2017-08-27T11:49:01
Java
UTF-8
Java
false
false
131
java
package com.dao; import com.model.TOtherSymptoms; public interface TOtherSymptomsDAO extends BaseDao<TOtherSymptoms, Long> { }
91bdb8716b5a43274c79442cd12de131bbdfd57b
9071e58d1df855d65d58942ffc80b04291a4ec8e
/src/java/vinhnq/servlet/UpdateCartServlet.java
014023d55a4ec2d8155d2df51244000414882db9
[]
no_license
ThomasVinhSE/Food-Shop-Project
6762fe092ab973691a36d3be2da728013a73d6ca
e43aa300edaa99d436afe3c7db015558897c5049
refs/heads/master
2023-03-06T10:41:23.193446
2021-02-23T02:08:03
2021-02-23T02:08:03
331,569,610
0
0
null
null
null
null
UTF-8
Java
false
false
4,717
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 vinhnq.servlet; import java.io.IOException; import java.sql.SQLException; import java.util.Map; import javax.naming.NamingException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import vinhnq.cart.CartObject; /** * * @author Vinh */ @WebServlet(name = "UpdateCartServlet", urlPatterns = {"/UpdateCartServlet"}) public class UpdateCartServlet extends HttpServlet { private final String ERROR_PAGE = "error.jsp"; private final String VIEW_CART_SERVLET = "ViewCartServlet"; /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); String url = ERROR_PAGE; String txtProductId = request.getParameter("txtProductId"); String txtAmount = request.getParameter("txtAmount"); String txtNumber = request.getParameter("txtNumber"); try { int amount; int number; int id; amount = txtAmount == null || txtAmount.equals("") ? -1 : Integer.parseInt(txtAmount); number = txtNumber == null || txtAmount.equals("") ? -1 : Integer.parseInt(txtNumber); id = txtProductId == null || txtProductId.equals("") ? -1 : Integer.parseInt(txtProductId); if (amount <= 0 || number <= 0) { throw new Exception("Not < 0 for updating!"); } else { HttpSession session = request.getSession(false); if (session != null) { CartObject cart = (CartObject) session.getAttribute("CART"); if (cart != null) { Map<Integer, Integer> items = cart.getMap(); if (items != null) { if (items.containsKey(id)) { items.put(id, number); session.setAttribute("CART", cart); url = VIEW_CART_SERVLET; } } } } } } catch (SQLException e) { log("SQL_UpdateServlet: " + e.getMessage()); } catch (NamingException e) { log("Naming_UpdateServlet: " + e.getMessage()); } catch (NumberFormatException e) { log("NumberFormat_UpdateServlet: " + e.getMessage()); } catch (Exception ex) { log("Input param_UpdateServlet: " + ex.getMessage()); } finally { RequestDispatcher rd = request.getRequestDispatcher(url); rd.forward(request, response); } } // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> /** * Handles the HTTP <code>GET</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP <code>POST</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. * * @return a String containing servlet description */ @Override public String getServletInfo() { return "Short description"; }// </editor-fold> }
02bc3f95551a797256b874e6190427ced0da5460
ceab0f095f205dd7c2eb121c5c8f49ed53305164
/src/test/java/Positive_SuccessfullyRegisterInAmazon.java
b22d6d775e18e364eb495f3b414d08b0022b9d50
[]
no_license
mjuneja01/selenium-example.g8
3419b600420cb979cff96ff748dd4a7781219348
4d0586d2abb6dc5393ca471c72c030115d7677f8
refs/heads/master
2020-04-20T14:50:46.169968
2019-02-03T05:17:47
2019-02-03T05:17:47
168,911,236
0
0
null
null
null
null
UTF-8
Java
false
false
2,637
java
import org.openqa.selenium.By; import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.asserts.Assertion; import java.util.Random; //import java.util.concurrent.TimeUnit; public class Positive_SuccessfullyRegisterInAmazon { public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "/home/knoldus/Documents/mehak/chromedriver"); WebDriver driver=new ChromeDriver(); //driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS) ; driver.manage().window().maximize(); driver.get("https://www.amazon.com/"); WebElement SignInLink = driver.findElement(By.xpath("//a[@id=\"nav-link-accountList\"]//span[contains(text(), \"Hello\")]")); SignInLink.click(); Thread.sleep(5000); WebElement CreateYourAmazonAccountBbutton = driver.findElement(By.id("createAccountSubmit")); CreateYourAmazonAccountBbutton.click(); Thread.sleep(3000); Random rand = new Random(); int randomInteger = rand.nextInt(1000); WebElement NameTextBox = driver.findElement(By.id("ap_customer_name")); NameTextBox.sendKeys("Mehak"); Thread.sleep(3000); WebElement EmailTextBox = driver.findElement(By.id("ap_email")); EmailTextBox.sendKeys(String.format("mjuneja%[email protected]", randomInteger)); Thread.sleep(3000); WebElement PasswordTextBox = driver.findElement(By.id("ap_password")); PasswordTextBox.sendKeys("test@123"); Thread.sleep(3000); WebElement ConfirmPasswordTextBox = driver.findElement(By.id("ap_password_check")); ConfirmPasswordTextBox.sendKeys("test@123"); Thread.sleep(3000); WebElement CreateYourAmazonAccountButton = driver.findElement(By.id("continue")); CreateYourAmazonAccountButton.click(); new WebDriverWait(driver, 50) .ignoring(StaleElementReferenceException.class) .until(ExpectedConditions.elementToBeClickable(By .xpath("//a[@id=\"nav-link-accountList\"]//span[contains(text(), \"Hello\")]"))); Assertion hardAssert = new Assertion(); hardAssert.assertEquals("Hello, Mehak", SignInLink.getText()); System.out.println("The Registration has been done successfully."); driver.quit(); } }
bd69fdbc92377672df5746d92076a6a488da7c49
ee2b5f7b5d152ccae517c82b865e8bfa16659226
/src/main/java/com/springbasic/start/controller/MyController.java
60734465bf9bd2357d574dd3d33060795c1c15db
[]
no_license
Samhitha1193/Springtest
d50c3b48b6756d56ec6fef55ce58f356ddb73052
e5466ed703d042b62e38188f9d01d600adc1ca15
refs/heads/master
2020-09-06T01:39:24.570816
2019-11-07T16:05:53
2019-11-07T16:05:53
220,086,393
0
0
null
null
null
null
UTF-8
Java
false
false
1,672
java
package com.springbasic.start.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import com.springbasic.start.service.EmployeeService; import com.springbasic.start.model.Employee; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @RestController public class MyController { private static final Logger logger = LogManager.getLogger(MyController.class); @Autowired private EmployeeService employeeService; @GetMapping(value = "/hello") public String sayHello() { logger.debug("Hello from Log4j"); return "hello"; } @GetMapping(value = "/employees") public List<Employee> getEmployees() { logger.debug("get all the employees"); return employeeService.getEmployees(); } @PostMapping(value = "/saveEmployee") public Employee add(Employee employee) { logger.debug("save Employee"); return employeeService.add(employee); } @PostMapping(value = "/removeEmployee") public void remove(Employee employee) { logger.debug("remove Employee"); employeeService.remove(employee); } @PostMapping(value = "/updateEmployee") public Employee update(Employee employee) { logger.debug("update Employee"); return employeeService.update(employee); } }
9cfae6755a1e2140a5cdfa85b5a10c8702819cc2
fe92205836844a17836c2c4b849e763d4018686d
/src/Selenium/OrangeHRM_TableTextVerification.java
7b7d80f38213de04931d8c6e45b51d8885881a87
[]
no_license
cherukuripavanteja318/TM_1
f436b3dcbe8bfa1a6f284304311fc1e54fb1d95a
982e3535c560fa4b12d0a1527ced851019a507e0
refs/heads/master
2020-11-27T11:26:07.336482
2019-12-21T12:04:16
2019-12-21T12:04:16
229,420,631
0
0
null
null
null
null
UTF-8
Java
false
false
2,007
java
package Selenium; import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; public class OrangeHRM_TableTextVerification { public static void main(String[] args) throws InterruptedException { // launch app System.setProperty("webdriver.chrome.driver", "C:\\Users\\S3\\Downloads\\chromedriver_win32\\chromedriver.exe"); ChromeDriver driver = new ChromeDriver(); driver.get("http://testingmasters.com/hrm/symfony/web/index.php/auth/login"); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); // logi into app driver.findElement(By.id("txtUsername")).sendKeys("user02"); driver.findElement(By.id("txtPassword")).sendKeys("TM1234"); driver.findElement(By.id("btnLogin")).click(); // navigate and click on my leave Actions act_leave = new Actions(driver); WebElement leave = driver.findElement(By.id("menu_leave_viewLeaveModule")); act_leave.moveToElement(leave).build().perform(); Thread.sleep(2000); driver.findElement(By.xpath("//a[@id='menu_leave_viewMyLeaveList']")).click(); // table names List<WebElement> row=driver.findElements(By.xpath("//table[@id='resultTable']/tbody/tr")); int rowcunt=row.size(); System.out.println(rowcunt); List<WebElement> column=driver.findElements(By.xpath("//table[@id='resultTable']/tbody/tr/td")); int columncunt=column.size(); System.out.println(columncunt); for (int i = 1; i <50; i++) { for (int j = 1; j < 8; j++) { WebElement cell = driver.findElement(By.xpath("//table[@id='resultTable']/tbody/tr[" + i + "]/td[" + j + "]")); String s = cell.getText(); String a = "Personal reason"; if (s.equals(a)) { System.out.println(i + " row " +"-"+ j + " column consists of " +a); } } } driver.close(); } }
918236ea04e024d89d5cd096c953eaaf07b4f42b
4c4c017d3eb765902a87f4f9d76fa43ae1268d1f
/src/main/java/compiler/CompilationUnit.java
4348bcb6744d5cd11feb1339408bef19b04c4221
[]
no_license
sergiotaborda/compilelittle
fe282b0036835a23ad9290b028a883908f12c632
0c40969b81ade6a8e01556921e7784ae26238f26
refs/heads/master
2023-01-08T14:00:45.823418
2023-01-04T14:38:17
2023-01-04T14:38:17
36,563,803
1
0
null
2020-10-13T10:03:47
2015-05-30T15:30:46
Java
UTF-8
Java
false
false
325
java
/** * */ package compiler; import java.io.IOException; import java.io.Reader; import compiler.filesystem.SourcePath; /** * */ public interface CompilationUnit { public Reader read() throws IOException; /** * @return */ public String getName(); public SourcePath getOrigin(); }
b55ebee2de1b0ffdf8280e43c75379dcfb50297f
ed5159d056e98d6715357d0d14a9b3f20b764f89
/src/irvine/oeis/a260/A260575.java
94c8f2c1d78ea5480b53c7a86edf346cf27cedf3
[]
no_license
flywind2/joeis
c5753169cf562939b04dd246f8a2958e97f74558
e5efd6971a0062ac99f4fae21a7c78c9f9e74fea
refs/heads/master
2020-09-13T18:34:35.080552
2019-11-19T05:40:55
2019-11-19T05:40:55
null
0
0
null
null
null
null
UTF-8
Java
false
false
699
java
package irvine.oeis.a260; // Generated by gen_pattern.pl - DO NOT EDIT here! import irvine.oeis.GeneratingFunctionSequence; /** * A260575 Number of ways to place <code>2n</code> rooks on <code>n X n</code> board, 2 rooks in each row and each column, multiple rooks in a cell allowed, and exactly 3 rooks below the main diagonal. * @author Georg Fischer */ public class A260575 extends GeneratingFunctionSequence { /** Construct the sequence. */ public A260575() { super(3, new long[] {0, 0, 0, -4, -2, 300, -1748, 4674, -7058, 6648, -4397, 2206, -625}, new long[] {-1, 28, -350, 2592, -12713, 43682, -108337, 196626, -261466, 251874, -171025, 77590, -21100, 2600}); } }
ae6aafbae6ec3651495171bb7dedd4c4bf3f329e
9cada71ecbcc25e79a718e0c170ae7113af0c8ed
/app/src/main/java/ru/geekbrains/android3_4/view/MainActivity.java
98911de61379890c058bada7fb59176889f0bf12
[]
no_license
AlekseyYakovlev/android3_4
f006f8d13a6fef45db1d693f14fe2b2cc4ed895d
f18c0f47a5ee4f8cca7d1f3d990b0e88dc791585
refs/heads/master
2020-03-19T04:36:30.492873
2018-06-02T19:21:12
2018-06-02T19:25:02
135,845,831
1
0
null
null
null
null
UTF-8
Java
false
false
1,841
java
package ru.geekbrains.android3_4.view; import android.os.Bundle; import android.widget.ImageView; import android.widget.TextView; import com.arellomobile.mvp.MvpAppCompatActivity; import com.arellomobile.mvp.presenter.InjectPresenter; import com.arellomobile.mvp.presenter.ProvidePresenter; import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; import io.reactivex.android.schedulers.AndroidSchedulers; import ru.geekbrains.android3_4.R; import ru.geekbrains.android3_4.model.image.IImageLoader; import ru.geekbrains.android3_4.model.image.android.GlideImageLoader; import ru.geekbrains.android3_4.model.image.android.PicassoImageLoader; import ru.geekbrains.android3_4.presenter.MainPresenter; public class MainActivity extends MvpAppCompatActivity implements MainView { @BindView(R.id.iv_avatar) ImageView avatarImageView; @BindView(R.id.tv_username) TextView usernameTextView; @BindView(R.id.gists) TextView gistsTextView; @InjectPresenter MainPresenter presenter; IImageLoader<ImageView> imageLoader; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); imageLoader = new PicassoImageLoader(); } @ProvidePresenter public MainPresenter provideMainPresenter() { return new MainPresenter(AndroidSchedulers.mainThread()); } @Override public void setUsernameText(String username) { usernameTextView.setText(username); } @Override public void loadImage(String url) { imageLoader.loadInto(url, avatarImageView); } @Override public void updateRepoTextView(String repoName) { gistsTextView.append("\n"+repoName); } }
99b9e40c1f91d8abe8b2a18bd0440970a6dfedef
2f1a31afcad0129f6b2d37cbe57c0b27fd910e92
/core/src/com/mygdx/game/States/MenuState.java
6e70f610ba409548658ce6fcb5c8fd1d1731083a
[]
no_license
s60912frank/FlappyDemo
b2e414e4174d5bd1becabd83ca3e27dbb9ce9712
62c64c949d57af0dda38d284676e16bb111d8981
refs/heads/master
2021-01-10T04:31:06.940161
2016-03-15T03:54:09
2016-03-15T03:54:09
53,737,379
0
0
null
null
null
null
UTF-8
Java
false
false
1,343
java
package com.mygdx.game.States; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.mygdx.game.flappyDemo; /** * Created by 繼民 on 2016/2/29. */ public class MenuState extends State { private Texture background; private Texture playBtn; private OrthographicCamera cam; public MenuState(GameStateManager gsm, OrthographicCamera cam) { super(gsm); this.cam = cam; background = new Texture("bg.png"); playBtn = new Texture("playbtn.png"); } @Override public void handleInput() { if(Gdx.input.justTouched()){ gsm.Set(new PlayState(gsm, cam)); } } @Override public void update(float dt) { handleInput(); } @Override public void render(SpriteBatch sb) { sb.begin(); sb.draw(background, 0, 0, flappyDemo.WIDTH, flappyDemo.HEIGHT); //sb.draw(background, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); sb.draw(playBtn, flappyDemo.WIDTH / 2 - playBtn.getWidth() / 2, flappyDemo.HEIGHT / 2- playBtn.getHeight() / 2); sb.end(); } @Override public void dispose() { background.dispose(); playBtn.dispose(); } }
[ "陳繼民" ]
陳繼民
75632485212126af5ba092bbf54635a51c896e76
6d3ea1f8617dc237ea015ca0544c5f44d04c9f4f
/email-service/src/main/java/com/email/common/MsgStatus.java
7fd2683aa78651716d5432115e4cf2f9b94f9b91
[]
no_license
mahisandip/spring-boot
d12e682050dd2ab50f014dd57b1ebc24f155f767
6ffc3d9740022193c6628882b374313c169b2225
refs/heads/master
2021-05-20T20:00:33.340286
2020-08-05T06:16:22
2020-08-05T06:16:22
252,399,825
0
0
null
null
null
null
UTF-8
Java
false
false
225
java
package com.email.common; public enum MsgStatus { SUCCESS("Ok"), FAILED("Failed"), ERROR("Error"); private final String val; MsgStatus(String val) { this.val = val; } public String getVal() { return val; } }
e48eaade8982aa7ad5efb1ca96fb202df74ae787
827030803119007ac05f08ca385bfcdf9d204821
/src/java/lang/Enum.java
ad19bf432daf9d416e7a21404e3460c01cbff2aa
[ "Apache-2.0" ]
permissive
AdrianodeOS/pedido-venda
e64945996d7080a4272545e24d41aeac7108e4e3
7df89e3a4e63e2e60e4c062aa08ec3660667307e
refs/heads/master
2021-01-22T06:12:07.762440
2017-03-09T14:13:18
2017-03-09T14:13:18
81,745,039
0
0
null
null
null
null
UTF-8
Java
false
false
60
java
package java.lang; public abstract class Enum<E> { }
7e43d6580bce220166d868b4a457ba5da1b6bfcd
3e898a0edf2aebd3345c79615d9c533139d6666e
/sdk/network/mgmt/src/main/java/com/azure/management/network/BgpCommunity.java
f940e3b0f01c52b64e9c22a86972daa8fd40a289
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-or-later", "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-generic-cla" ]
permissive
JasonWHowell/azure-sdk-for-java
81fd8988895511080b0d1feff5112e1c47dad620
346475e8f6ebbcd09047797f7fcef4129c78ce43
refs/heads/master
2023-04-16T05:16:52.441674
2020-06-03T16:38:26
2020-06-03T16:38:26
269,185,086
0
0
MIT
2020-06-03T20:14:00
2020-06-03T20:14:00
null
UTF-8
Java
false
false
5,700
java
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.management.network; import com.azure.core.annotation.Fluent; import com.azure.core.util.logging.ClientLogger; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; /** The BgpCommunity model. */ @Fluent public final class BgpCommunity { @JsonIgnore private final ClientLogger logger = new ClientLogger(BgpCommunity.class); /* * The region which the service support. e.g. For O365, region is Global. */ @JsonProperty(value = "serviceSupportedRegion") private String serviceSupportedRegion; /* * The name of the bgp community. e.g. Skype. */ @JsonProperty(value = "communityName") private String communityName; /* * The value of the bgp community. For more information: * https://docs.microsoft.com/en-us/azure/expressroute/expressroute-routing. */ @JsonProperty(value = "communityValue") private String communityValue; /* * The prefixes that the bgp community contains. */ @JsonProperty(value = "communityPrefixes") private List<String> communityPrefixes; /* * Customer is authorized to use bgp community or not. */ @JsonProperty(value = "isAuthorizedToUse") private Boolean isAuthorizedToUse; /* * The service group of the bgp community contains. */ @JsonProperty(value = "serviceGroup") private String serviceGroup; /** * Get the serviceSupportedRegion property: The region which the service support. e.g. For O365, region is Global. * * @return the serviceSupportedRegion value. */ public String serviceSupportedRegion() { return this.serviceSupportedRegion; } /** * Set the serviceSupportedRegion property: The region which the service support. e.g. For O365, region is Global. * * @param serviceSupportedRegion the serviceSupportedRegion value to set. * @return the BgpCommunity object itself. */ public BgpCommunity withServiceSupportedRegion(String serviceSupportedRegion) { this.serviceSupportedRegion = serviceSupportedRegion; return this; } /** * Get the communityName property: The name of the bgp community. e.g. Skype. * * @return the communityName value. */ public String communityName() { return this.communityName; } /** * Set the communityName property: The name of the bgp community. e.g. Skype. * * @param communityName the communityName value to set. * @return the BgpCommunity object itself. */ public BgpCommunity withCommunityName(String communityName) { this.communityName = communityName; return this; } /** * Get the communityValue property: The value of the bgp community. For more information: * https://docs.microsoft.com/en-us/azure/expressroute/expressroute-routing. * * @return the communityValue value. */ public String communityValue() { return this.communityValue; } /** * Set the communityValue property: The value of the bgp community. For more information: * https://docs.microsoft.com/en-us/azure/expressroute/expressroute-routing. * * @param communityValue the communityValue value to set. * @return the BgpCommunity object itself. */ public BgpCommunity withCommunityValue(String communityValue) { this.communityValue = communityValue; return this; } /** * Get the communityPrefixes property: The prefixes that the bgp community contains. * * @return the communityPrefixes value. */ public List<String> communityPrefixes() { return this.communityPrefixes; } /** * Set the communityPrefixes property: The prefixes that the bgp community contains. * * @param communityPrefixes the communityPrefixes value to set. * @return the BgpCommunity object itself. */ public BgpCommunity withCommunityPrefixes(List<String> communityPrefixes) { this.communityPrefixes = communityPrefixes; return this; } /** * Get the isAuthorizedToUse property: Customer is authorized to use bgp community or not. * * @return the isAuthorizedToUse value. */ public Boolean isAuthorizedToUse() { return this.isAuthorizedToUse; } /** * Set the isAuthorizedToUse property: Customer is authorized to use bgp community or not. * * @param isAuthorizedToUse the isAuthorizedToUse value to set. * @return the BgpCommunity object itself. */ public BgpCommunity withIsAuthorizedToUse(Boolean isAuthorizedToUse) { this.isAuthorizedToUse = isAuthorizedToUse; return this; } /** * Get the serviceGroup property: The service group of the bgp community contains. * * @return the serviceGroup value. */ public String serviceGroup() { return this.serviceGroup; } /** * Set the serviceGroup property: The service group of the bgp community contains. * * @param serviceGroup the serviceGroup value to set. * @return the BgpCommunity object itself. */ public BgpCommunity withServiceGroup(String serviceGroup) { this.serviceGroup = serviceGroup; return this; } /** * Validates the instance. * * @throws IllegalArgumentException thrown if the instance is not valid. */ public void validate() { } }
54478edce6c93fef04611465c464531c9757f745
2e036b061d4808893d732d0fe44a33d52448f324
/src/net/sourceforge/kolmafia/request/ContactListRequest.java
79b0cf9cbde13f2de2aa135c5f8113912bfabb51
[]
no_license
gumpshroom/kolmafia-githhub
a2c31fed4170caec5a5f3306fe9e8beb44ac9cff
7c6b7591f71c0b07d3b97d7e497186043891f3bf
refs/heads/master
2022-04-16T14:01:45.012629
2020-04-11T14:48:26
2020-04-11T14:48:26
254,889,543
1
1
null
null
null
null
UTF-8
Java
false
false
3,125
java
/** * Copyright (c) 2005-2020, KoLmafia development team * http://kolmafia.sourceforge.net/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * [1] Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * [2] 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. * [3] Neither the name "KoLmafia" 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 THE * COPYRIGHT OWNER 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 net.sourceforge.kolmafia.request; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sourceforge.kolmafia.KoLCharacter; import net.sourceforge.kolmafia.KoLmafia; import net.sourceforge.kolmafia.RequestThread; import net.sourceforge.kolmafia.session.ContactManager; public class ContactListRequest extends GenericRequest { private static final Pattern LIST_PATTERN = Pattern.compile( "<b>Contact List</b>.*?</table>" ); private static final Pattern ENTRY_PATTERN = Pattern.compile( "<a href=\"showplayer.php\\?who=(\\d+)\".*?<b>(.*?)</b>" ); public ContactListRequest() { super( "account_contactlist.php" ); } @Override protected boolean retryOnTimeout() { return true; } @Override public void run() { super.run(); } @Override public void processResults() { ContactListRequest.parseResponse( this.getURLString(), this.responseText ); } public static final void parseResponse( final String urlString, final String responseText ) { ContactManager.clearMailContacts(); ContactManager.addMailContact( KoLCharacter.getUserName(), KoLCharacter.getPlayerId() ); Matcher listMatcher = ContactListRequest.LIST_PATTERN.matcher( responseText ); if ( listMatcher.find() ) { Matcher entryMatcher = ContactListRequest.ENTRY_PATTERN.matcher( listMatcher.group() ); while ( entryMatcher.find() ) { ContactManager.addMailContact( entryMatcher.group( 2 ), entryMatcher.group( 1 ) ); } } } }
96349a703eb2603ca9ce6d168d1a099f8a10c94d
a4a51084cfb715c7076c810520542af38a854868
/src/main/java/com/tencent/ugc/TXRecordCommon.java
194126df6aae0711334265a8edfcd1a69ae70931
[]
no_license
BharathPalanivelu/repotest
ddaf56a94eb52867408e0e769f35bef2d815da72
f78ae38738d2ba6c9b9b4049f3092188fabb5b59
refs/heads/master
2020-09-30T18:55:04.802341
2019-12-02T10:52:08
2019-12-02T10:52:08
null
0
0
null
null
null
null
UTF-8
Java
false
false
5,853
java
package com.tencent.ugc; import android.graphics.Bitmap; import android.os.Bundle; import com.garena.android.gpns.utility.CONSTANT; public class TXRecordCommon { public static final int AUDIO_SAMPLERATE_16000 = 16000; public static final int AUDIO_SAMPLERATE_32000 = 32000; public static final int AUDIO_SAMPLERATE_44100 = 44100; public static final int AUDIO_SAMPLERATE_48000 = 48000; public static final int AUDIO_SAMPLERATE_8000 = 8000; public static final int EVT_CAMERA_CANNOT_USE = 3; public static final String EVT_DESCRIPTION = "EVT_DESCRIPTION"; public static final int EVT_ID_PAUSE = 1; public static final int EVT_ID_RESUME = 2; public static final int EVT_MIC_CANNOT_USE = 4; public static final String EVT_PARAM1 = "EVT_PARAM1"; public static final String EVT_PARAM2 = "EVT_PARAM2"; public static final String EVT_TIME = "EVT_TIME"; public static final int RECORD_RESULT_COMPOSE_CANCEL = -7; public static final int RECORD_RESULT_COMPOSE_INTERNAL_ERR = -9; public static final int RECORD_RESULT_COMPOSE_SET_DST_PATH_ERR = -5; public static final int RECORD_RESULT_COMPOSE_SET_SRC_PATH_ERR = -4; public static final int RECORD_RESULT_COMPOSE_START_ERR = -6; public static final int RECORD_RESULT_COMPOSE_VERIFY_FAIL = -8; public static final int RECORD_RESULT_FAILED = -1; public static final int RECORD_RESULT_FILE_ERR = -3; public static final int RECORD_RESULT_OK = 0; public static final int RECORD_RESULT_OK_LESS_THAN_MINDURATION = 1; public static final int RECORD_RESULT_OK_REACHED_MAXDURATION = 2; public static final int RECORD_RESULT_SUSPEND_FOR_NO_TASK = -2; public static final int RECORD_SPEED_FAST = 3; public static final int RECORD_SPEED_FASTEST = 4; public static final int RECORD_SPEED_NORMAL = 2; public static final int RECORD_SPEED_SLOW = 1; public static final int RECORD_SPEED_SLOWEST = 0; public static final int RECORD_TYPE_STREAM_SOURCE = 1; public static final int START_RECORD_ERR_API_IS_LOWER_THAN_18 = -3; public static final int START_RECORD_ERR_IS_IN_RECORDING = -1; public static final int START_RECORD_ERR_LICENCE_VERIFICATION_FAILED = -5; public static final int START_RECORD_ERR_NOT_INIT = -4; public static final int START_RECORD_ERR_VIDEO_PATH_IS_EMPTY = -2; public static final int START_RECORD_OK = 0; public static final int VIDEO_ASPECT_RATIO_1_1 = 2; public static final int VIDEO_ASPECT_RATIO_3_4 = 1; public static final int VIDEO_ASPECT_RATIO_9_16 = 0; public static final int VIDEO_QUALITY_HIGH = 2; public static final int VIDEO_QUALITY_LOW = 0; public static final int VIDEO_QUALITY_MEDIUM = 1; public static final int VIDEO_RENDER_MODE_ADJUST_RESOLUTION = 1; public static final int VIDEO_RENDER_MODE_FULL_FILL_SCREEN = 0; public static final int VIDEO_RESOLUTION_1080_1920 = 3; public static final int VIDEO_RESOLUTION_360_640 = 0; public static final int VIDEO_RESOLUTION_540_960 = 1; public static final int VIDEO_RESOLUTION_720_1280 = 2; public static final int VIDOE_REVERB_TYPE_0 = 0; public static final int VIDOE_REVERB_TYPE_1 = 1; public static final int VIDOE_REVERB_TYPE_2 = 2; public static final int VIDOE_REVERB_TYPE_3 = 3; public static final int VIDOE_REVERB_TYPE_4 = 4; public static final int VIDOE_REVERB_TYPE_5 = 5; public static final int VIDOE_REVERB_TYPE_6 = 6; public static final int VIDOE_REVERB_TYPE_7 = 7; public static final int VIDOE_VOICECHANGER_TYPE_0 = 0; public static final int VIDOE_VOICECHANGER_TYPE_1 = 1; public static final int VIDOE_VOICECHANGER_TYPE_10 = 10; public static final int VIDOE_VOICECHANGER_TYPE_11 = 11; public static final int VIDOE_VOICECHANGER_TYPE_2 = 2; public static final int VIDOE_VOICECHANGER_TYPE_3 = 3; public static final int VIDOE_VOICECHANGER_TYPE_4 = 4; public static final int VIDOE_VOICECHANGER_TYPE_6 = 6; public static final int VIDOE_VOICECHANGER_TYPE_7 = 7; public static final int VIDOE_VOICECHANGER_TYPE_8 = 8; public static final int VIDOE_VOICECHANGER_TYPE_9 = 9; public interface ITXBGMNotify { void onBGMComplete(int i); void onBGMProgress(long j, long j2); void onBGMStart(); } public interface ITXSnapshotListener { void onSnapshot(Bitmap bitmap); } public interface ITXVideoRecordListener { void onRecordComplete(TXRecordResult tXRecordResult); void onRecordEvent(int i, Bundle bundle); void onRecordProgress(long j); } public static final class TXRecordResult { public String coverPath; public String descMsg; public int retCode; public String videoPath; } public static final class TXUGCCustomConfig { public int audioSampleRate = 48000; boolean enableHighResolutionCapture = false; public boolean isFront = true; public int maxDuration = CONSTANT.TIME.MIN_1; public int minDuration = 5000; public boolean needEdit = true; public boolean touchFocus = false; public int videoBitrate = 1800; public int videoFps = 20; public int videoGop = 3; public int videoResolution = 1; public Bitmap watermark = null; public int watermarkX = 0; public int watermarkY = 0; } public static final class TXUGCSimpleConfig { public boolean isFront = true; public int maxDuration = CONSTANT.TIME.MIN_1; public int minDuration = 5000; public boolean needEdit = true; public boolean touchFocus = false; public int videoQuality = 1; public Bitmap watermark = null; public int watermarkX = 0; public int watermarkY = 0; } }
519903f2a296cd7c69b396c7f912e194c32fabf2
7ae169648c4b1848401bf87d5fd86dd26bb9ac6f
/src/main/java/net/dev123/sns/facebook/FacebookUserAdapter.java
d355a560259bdadf93baba9d642fb32e2ee2293c
[ "Apache-2.0" ]
permissive
NeoCN/yibo-library
ef76ef099eac3b4458f0012d879a11661ba69ba7
90701c36bac5a3ac173909ebaee755ab09b035d3
refs/heads/master
2021-01-16T21:47:16.110891
2013-03-24T01:18:01
2013-03-24T01:18:01
8,941,478
1
0
null
null
null
null
UTF-8
Java
false
false
8,372
java
package net.dev123.sns.facebook; import static net.dev123.commons.util.ParseUtil.getRawString; import java.text.ParseException; import java.util.ArrayList; import java.util.List; import net.dev123.commons.ServiceProvider; import net.dev123.commons.util.ParseUtil; import net.dev123.entity.Education; import net.dev123.entity.Education.SchoolType; import net.dev123.entity.Gender; import net.dev123.entity.Work; import net.dev123.exception.ExceptionCode; import net.dev123.exception.LibException; import net.dev123.sns.entity.FriendList; import net.dev123.sns.entity.User; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class FacebookUserAdapter { public static User createSimpleUser(String jsonString) throws LibException { try { JSONObject json = new JSONObject(jsonString); return createSimpleUser(json); } catch (JSONException e) { throw new LibException(ExceptionCode.JSON_PARSE_ERROR, e); } } public static User createUser(String jsonString) throws LibException { try { JSONObject json = new JSONObject(jsonString); return createUser(json); } catch (JSONException e) { throw new LibException(ExceptionCode.JSON_PARSE_ERROR, e); } } /** * 从JSON字符串创建User对象列表 * * @param jsonString * JSON字符串 * @return User对象列表 * @throws LibException */ public static List<User> createSimpleUserList(String jsonString) throws LibException { try { if ("[]".equals(jsonString) || "{}".equals(jsonString)) { return new ArrayList<User>(0); } JSONArray jsonArray = new JSONArray(jsonString); int size = jsonArray.length(); List<User> userList = new ArrayList<User>(size); for (int i = 0; i < size; i++) { userList.add(createSimpleUser(jsonArray.getJSONObject(i))); } return userList; } catch (JSONException e) { throw new LibException(ExceptionCode.JSON_PARSE_ERROR, e); } } public static List<FriendList> createFriendListList(String jsonString) throws LibException { try { if ("[]".equals(jsonString) || "{}".equals(jsonString)) { return new ArrayList<FriendList>(0); } JSONArray jsonArray = new JSONArray(jsonString); int size = jsonArray.length(); List<FriendList> friendListList = new ArrayList<FriendList>(size); FriendList friendList = null; JSONObject json = null; for (int i = 0; i < size; i++) { json = jsonArray.getJSONObject(i); friendList = new FriendList(); friendList.setId(ParseUtil.getRawString("id", json)); friendList.setName(ParseUtil.getRawString("name", json)); friendListList.add(friendList); } return friendListList; } catch (JSONException e) { throw new LibException(ExceptionCode.JSON_PARSE_ERROR, e); } } public static List<User> createUserList(String jsonString) throws LibException { try { if ("[]".equals(jsonString) || "{}".equals(jsonString)) { return new ArrayList<User>(0); } JSONArray jsonArray = new JSONArray(jsonString); int size = jsonArray.length(); List<User> userList = new ArrayList<User>(size); for (int i = 0; i < size; i++) { userList.add(createUser(jsonArray.getJSONObject(i))); } return userList; } catch (JSONException e) { throw new LibException(ExceptionCode.JSON_PARSE_ERROR, e); } } public static List<String> createUserIdList(String jsonString) throws LibException { try { if ("[]".equals(jsonString) || "{}".equals(jsonString)) { return new ArrayList<String>(0); } JSONArray jsonArray = new JSONArray(jsonString); int size = jsonArray.length(); List<String> listUserId = new ArrayList<String>(size); for (int i = 0; i < size; i++) { listUserId.add(ParseUtil.getRawString("id", jsonArray.getJSONObject(i))); } return listUserId; } catch (JSONException e) { throw new LibException(ExceptionCode.JSON_PARSE_ERROR, e); } } /** * 从JSON对象创建User对象,包级别访问权限控制 * * @param json * JSON对象 * @return User对象 * @throws LibException */ static User createSimpleUser(JSONObject json) throws LibException { User user = new User(); user.setId(ParseUtil.getRawString("id", json)); user.setScreenName(ParseUtil.getRawString("name", json)); user.setName(user.getScreenName()); user.setHeadUrl(String.format(Facebook.PICTURE_URL_FORMAT, user.getId())); user.setServiceProvider(ServiceProvider.Facebook); return user; } static User createUser(JSONObject json) throws LibException { try { User user = new User(); user.setServiceProvider(ServiceProvider.Facebook); user.setId(json.getString("id")); user.setScreenName(getRawString("name", json)); user.setName(getRawString("username", json)); user.setHeadUrl(String.format(Facebook.PICTURE_URL_FORMAT, user.getId())); user.setBirthday(ParseUtil.getDate("birthday", json , "MM/dd/yyyy")); user.setDescription(getRawString("bio", json)); try { user.setGender(Gender.valueOf(getRawString("gender", json))); } catch (Exception e) { user.setGender(Gender.UNKNOW); } if (json.has("hometown")) { user.setHometown(getRawString("name", json.getJSONObject("hometown"))); } if (json.has("location")) { user.setLocation(getRawString("name", json.getJSONObject("location"))); } if (json.has("work")) { List<Work> workHistory = new ArrayList<Work>(); JSONArray jsonArray = json.getJSONArray("work"); JSONObject workJson = null; Work work = null; for (int i = 0; i < jsonArray.length(); i++) { workJson = jsonArray.getJSONObject(i); work = new Work(); work.setEmployer(getRawString("name", workJson.getJSONObject("employer"))); work.setStartDate(ParseUtil.getDate("start_date", workJson, "yyyy-MM")); work.setStartDate(ParseUtil.getDate("end_date", workJson, "yyyy-MM")); if (workJson.has("location")) { work.setLocation(getRawString("name", workJson.getJSONObject("location"))); } if (workJson.has("position")) { work.setPosition(getRawString("name", workJson.getJSONObject("position"))); } if (workJson.has("projects")) { JSONArray projectsArray = workJson.getJSONArray("projects"); int length = projectsArray.length(); Work.Project[] projects = new Work.Project[length]; Work.Project project = null; JSONObject projectJson = null; for (int j = 0; j < length; j++) { projectJson = projectsArray.getJSONObject(j); project = new Work.Project(); project.setName(getRawString("name", projectJson)); project.setDescription(getRawString("description", projectJson)); project.setStartDate(ParseUtil.getDate("start_date", projectJson, "yyyy-MM")); project.setEndDate(ParseUtil.getDate("end_date", projectJson, "yyyy-MM")); project.setServiceProvider(ServiceProvider.Facebook); projects[j] = project; } work.setProjects(projects); } workHistory.add(work); } user.setWorkHistory(workHistory); } List<Education> educationHistory = new ArrayList<Education>(); if (json.has("education")) { JSONArray jsonArray = json.getJSONArray("education"); JSONObject educationJson = null; Education education = null; for (int i = 0; i < jsonArray.length(); i++) { educationJson = jsonArray.getJSONObject(i); education = new Education(); education.setSchool(ParseUtil.getRawString("name", educationJson.getJSONObject("school"))); String type = getRawString("type", educationJson); if ("College".equals(type)) { education.setSchoolType(SchoolType.COLLEGE); } else if ("Graduate School".equals(type)) { education.setSchoolType(SchoolType.GRADUATE_SCHOOL); } else if ("High School".equals(type)) { education.setSchoolType(SchoolType.HIGH_SCHOOL); } if (educationJson.has("year")) { education.setYear(getRawString("year", educationJson.getJSONObject("year"))); } education.setDepartment(getRawString("department", educationJson)); educationHistory.add(education); } } user.setEducationHistory(educationHistory); return user; } catch (JSONException e) { throw new LibException(ExceptionCode.JSON_PARSE_ERROR, e); } catch (ParseException e) { throw new LibException(ExceptionCode.DATE_PARSE_ERROR, e); } } }
080508b59c8926b7c0eb37594a3511b4dc9664f8
41b416b9c30ff4139775f3d546d204d360668dd9
/racgroup/springboot/src/main/java/com/oracle/stcdc/racgroup/repository/MySecondLevelRepository.java
0439f996ed6498feff0da41a114600eb24a22181
[]
no_license
RiverXiao/spring
be45b3b71f23f5736784863a48089287b432ed05
734eb1e440680f6810971a6d4a5eb0711bb5735c
refs/heads/master
2022-12-20T23:14:54.130254
2019-09-26T07:08:58
2019-09-26T07:08:58
211,020,575
0
0
null
2022-03-31T21:41:55
2019-09-26T06:53:04
Java
UTF-8
Java
false
false
331
java
package com.oracle.stcdc.racgroup.repository; import com.oracle.stcdc.racgroup.annotation.SecondLevelRepository; @SecondLevelRepository(value = "JunheSecondLevelRepository") public class MySecondLevelRepository { public static void print(String s){ System.out.println("JunheSecondLevelRepository: = " + s); } }
17470322262ed9d91a8e2787df7eb7f1fd5fe7e6
80de34da51012e6472dc836fe7e325fe89f025d1
/src/GUIFTC.java
b33eaf525c77f101387cf2b0eb5fb75bef2fdf11
[]
no_license
Kondalf/PathGeneration
a183ca2f65690bfb38aec449c2c3362cbba4fb0b
4f36ca65d293d0da77462c101ee0eb66b3a15ad4
refs/heads/master
2021-01-23T16:19:10.174378
2017-06-02T20:21:46
2017-06-02T20:21:46
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,923
java
/** * Created by Florent Astié on 5/31/2017. */ import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import javax.swing.*; import static java.awt.Color.DARK_GRAY; public class GUIFTC extends JFrame implements ActionListener,MouseListener{ JLabel field; JTextField filein; JLabel width; JTextField widthInput; double xInput,yInput; JLabel filepath; JButton reset; JLabel feedback; JLabel angInput; JLabel totalWaypoints; JButton export; JButton setWidth; JButton addWaypoint; JTextField angleInput; double pixelsPerInchY = 1200 / 12.0 / 12.0; double pixelsPerInchX = 1200 / 12.0 / 12.0; ArrayList<Waypoint> waypoints = new ArrayList(); Trajectory test = new Trajectory(15,waypoints,10,3,"Testpath",0.05); public GUIFTC(){ super("Trajectory Planner"); setSize(1700,1200); setVisible(true); setWidth = new JButton("Remove Last Waypoint"); SpringLayout layout = new SpringLayout(); setLayout(layout); ImageIcon icon = new ImageIcon("field.jpg"); field = new JLabel(icon); widthInput = new JTextField(4); width = new JLabel("Wheelbase width:"); angInput = new JLabel("Angle in degrees: "); feedback = new JLabel(); filein = new JTextField(10); filepath = new JLabel("Target filename: "); totalWaypoints = new JLabel("Total Waypoints: 0"); export = new JButton("To text file!"); reset = new JButton("Reset"); addWaypoint = new JButton("Add Waypoint"); angleInput = new JTextField(10); reset.setVisible(true); field.setBounds(0, 0, 1201, 1201); add(filepath); add(field); add(angInput); add(reset); add(angleInput); add(totalWaypoints); add(feedback); add(addWaypoint); add(filein); add(export); add(setWidth); export.addActionListener(this); reset.addActionListener(this); addWaypoint.addActionListener(this); field.addMouseListener(this); setWidth.addActionListener(this); layout.putConstraint(SpringLayout.WEST, field, 0, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, field, 0, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, reset,1200 +15,SpringLayout.WEST, field); layout.putConstraint(SpringLayout.NORTH, reset, 120, SpringLayout.NORTH, field); layout.putConstraint(SpringLayout.WEST, feedback,1200 +15,SpringLayout.WEST, field); layout.putConstraint(SpringLayout.NORTH, feedback, 43, SpringLayout.NORTH, field); layout.putConstraint(SpringLayout.WEST, angleInput,1200 +15,SpringLayout.WEST, field); layout.putConstraint(SpringLayout.NORTH, angleInput, -20, SpringLayout.NORTH, reset); layout.putConstraint(SpringLayout.WEST, addWaypoint,1200 +15,SpringLayout.WEST, field); layout.putConstraint(SpringLayout.NORTH, addWaypoint, 5, SpringLayout.SOUTH, reset); layout.putConstraint(SpringLayout.WEST, angInput,1200 +15,SpringLayout.WEST, field); layout.putConstraint(SpringLayout.NORTH, angInput, -25, SpringLayout.NORTH, angleInput); layout.putConstraint(SpringLayout.WEST, export,1200 +15,SpringLayout.WEST, field); layout.putConstraint(SpringLayout.NORTH, export, 35, SpringLayout.NORTH, addWaypoint); layout.putConstraint(SpringLayout.WEST, totalWaypoints,1200 +15,SpringLayout.WEST, field); layout.putConstraint(SpringLayout.NORTH, totalWaypoints, 35, SpringLayout.NORTH, export); layout.putConstraint(SpringLayout.WEST, filepath,1200 +15,SpringLayout.WEST, field); layout.putConstraint(SpringLayout.NORTH, filepath, 20, SpringLayout.NORTH, totalWaypoints); layout.putConstraint(SpringLayout.WEST, filein,1200 +15,SpringLayout.WEST, field); layout.putConstraint(SpringLayout.NORTH, filein, 15, SpringLayout.NORTH, filepath); layout.putConstraint(SpringLayout.WEST, setWidth,1200 +15,SpringLayout.WEST, field); layout.putConstraint(SpringLayout.NORTH, setWidth, 20, SpringLayout.NORTH, filein); // add the button to the JFrame setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } public void paint(Graphics g){ super.paint(g); Graphics2D g2 = (Graphics2D) g; for(int scount = 0; scount<test.Segments.size();scount++){ for(double t =0;t<1; t+= 1/test.SAMPLE_RATE) { Double xin = test.Segments.get(scount).calculateCenterPositionX(t) * pixelsPerInchX; Double yin = test.Segments.get(scount).calculateCenterPositionY(t) * pixelsPerInchY; Double xin2 = test.Segments.get(scount).calculateCenterPositionX(t+ 1/test.SAMPLE_RATE) * pixelsPerInchX; Double yin2 = test.Segments.get(scount).calculateCenterPositionY(t+ 1/test.SAMPLE_RATE) * pixelsPerInchY; Double xin3 = test.Segments.get(scount).calculateLeftSplinePositionX(t) * pixelsPerInchX; Double yin3 = test.Segments.get(scount).calculateLeftSplinePositionY(t) * pixelsPerInchY; Double xin4 = test.Segments.get(scount).calculateLeftSplinePositionX(t+ 1/test.SAMPLE_RATE) * pixelsPerInchX; Double yin4= test.Segments.get(scount).calculateLeftSplinePositionY(t+ 1/test.SAMPLE_RATE) * pixelsPerInchY; Double xin5 =test.Segments.get(scount).calculateRightSplinePositionX(t) * pixelsPerInchX; Double yin5 = test.Segments.get(scount).calculateRightSplinePositionY(t) * pixelsPerInchY; Double xin6 =test.Segments.get(scount).calculateRightSplinePositionX(t+ 1/test.SAMPLE_RATE) * pixelsPerInchX; Double yin6 = test.Segments.get(scount).calculateRightSplinePositionY(t+ 1/test.SAMPLE_RATE) * pixelsPerInchY; Double t1 = test.Waypoints.get(scount).getX() * pixelsPerInchX; Double t2 = test.Waypoints.get(scount).getY() * pixelsPerInchY; Double t3 = test.Waypoints.get(scount).getX() * pixelsPerInchX; Double t4 = test.Waypoints.get(scount).getY() * pixelsPerInchY; //g2.drawLine(t1.intValue(),t2.intValue(),t3.intValue(),t4.intValue()); g2.setColor(Color.GREEN); g2.setStroke(new BasicStroke(2)); g2.drawLine(xin.intValue()+10 , yin.intValue() +39, xin2.intValue()+10 , yin2.intValue()+39); g2.setColor(Color.MAGENTA); g2.drawLine(xin3.intValue()+10 , yin3.intValue()+39 , xin4.intValue()+10 , yin4.intValue()+39 ); g2.drawLine(xin5.intValue() +10, yin5.intValue()+39 , xin6.intValue() +10, yin6.intValue()+39 ); //g2.drawLine(11,39,100,39); } } } public void actionPerformed( ActionEvent evt) { if(evt.getSource()==reset){ test.Waypoints.clear(); test.Segments.clear(); totalWaypoints.setText("Total waypoints: "+ test.Waypoints.size()); repaint(); } if(evt.getSource()==export){ test.Filename = filein.getText() + ".txt"; test.toTextFile(); filein.setText(""); feedback.setText("Wrote path to text file."); test.Waypoints.clear(); test.Segments.clear(); repaint(); } if(evt.getSource() == addWaypoint){ test.Waypoints.add(new Waypoint((double)(xInput),(double)(yInput),-Math.toRadians(Double.parseDouble(angleInput.getText())))); feedback.setText("<html>Added Waypoint!<br>Click next waypoint location.</html>"); totalWaypoints.setText("Total waypoints: "+ test.Waypoints.size()); test.Segments.clear(); test.Generate(); if(test.Segments.size() >= 1){ repaint(); //feedback.setText(String.valueOf(test.Segments.size())); } } if(evt.getSource() == setWidth){ //recycled to remove last waypoint test.Waypoints.remove(test.Waypoints.size()-1); test.Segments.clear(); test.Generate(); repaint(); } } public static void main(String[] args){ GUIFTC gui = new GUIFTC(); gui.setVisible(true); } @Override public void mouseClicked(MouseEvent e) { feedback.setText(e.getX()+" , " + e.getY()); xInput = e.getX() / pixelsPerInchX; yInput = e.getY() / pixelsPerInchY; } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } }
f86ed57f33681e89fcbd3b2aaebdbd3dddcc0688
735145b5fce4713ecaeb6acb4fca304122523a3e
/mileston2/XqueryBaseVisitor.java
33ae8d86c9e6e995b27e2d99b2f143ecc006fb2a
[]
no_license
Angelababe/cse232b
f67e5e4b7f573afbf7f02063bc83b7a19ccc3dea
e24bc96727286dfe05430ec146f0694d27a421e7
refs/heads/main
2023-03-23T17:54:04.314202
2021-03-16T08:01:02
2021-03-16T08:01:02
334,608,923
0
0
null
null
null
null
UTF-8
Java
false
false
12,595
java
// Generated from E:/IntelliJ IDEA 2020.3.1/projects/ms2/src\Xquery.g4 by ANTLR 4.9.1 import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; /** * This class provides an empty implementation of {@link XqueryVisitor}, * which can be extended to create a visitor which only needs to handle a subset * of the available methods. * * @param <T> The return type of the visit operation. Use {@link Void} for * operations with no return type. */ public class XqueryBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements XqueryVisitor<T> { /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitForClause(XqueryParser.ForClauseContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitLetClause(XqueryParser.LetClauseContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitWhereClause(XqueryParser.WhereClauseContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitReturnClause(XqueryParser.ReturnClauseContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitVar(XqueryParser.VarContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitList(XqueryParser.ListContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_flwer(XqueryParser.Xq_flwerContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_rpchildren(XqueryParser.Xq_rpchildrenContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_Stringconstant(XqueryParser.Xq_StringconstantContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_rpall(XqueryParser.Xq_rpallContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_variable(XqueryParser.Xq_variableContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_ap(XqueryParser.Xq_apContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_join(XqueryParser.Xq_joinContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_merge(XqueryParser.Xq_mergeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_self(XqueryParser.Xq_selfContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_tag(XqueryParser.Xq_tagContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitXq_let(XqueryParser.Xq_letContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCond_and(XqueryParser.Cond_andContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCond_empty(XqueryParser.Cond_emptyContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCond_self(XqueryParser.Cond_selfContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCond_equal(XqueryParser.Cond_equalContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCond_is(XqueryParser.Cond_isContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCond_satisfy(XqueryParser.Cond_satisfyContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCond_not(XqueryParser.Cond_notContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitCond_or(XqueryParser.Cond_orContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitDoc(XqueryParser.DocContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitFilename(XqueryParser.FilenameContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitAp_children(XqueryParser.Ap_childrenContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitAp_all(XqueryParser.Ap_allContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_txt(XqueryParser.Rp_txtContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_attName(XqueryParser.Rp_attNameContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_parent(XqueryParser.Rp_parentContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_sibling(XqueryParser.Rp_siblingContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_descendant(XqueryParser.Rp_descendantContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_self(XqueryParser.Rp_selfContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_children(XqueryParser.Rp_childrenContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_tagName(XqueryParser.Rp_tagNameContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_merge(XqueryParser.Rp_mergeContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_filter(XqueryParser.Rp_filterContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitRp_all(XqueryParser.Rp_allContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitFilter_rp(XqueryParser.Filter_rpContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitFilter_and(XqueryParser.Filter_andContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitFilter_parent(XqueryParser.Filter_parentContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitFilter_is(XqueryParser.Filter_isContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitFilter_txt(XqueryParser.Filter_txtContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitFilter_equal(XqueryParser.Filter_equalContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitFilter_or(XqueryParser.Filter_orContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * * <p>The default implementation returns the result of calling * {@link #visitChildren} on {@code ctx}.</p> */ @Override public T visitFilter_not(XqueryParser.Filter_notContext ctx) { return visitChildren(ctx); } }
ab5d352b53fece5712c68825263fea611fb18665
da7d94957965c6263c2b81e6850219e87b07e903
/src/filter/UpperFilter.java
a4973af889e161a44f483dce0e7a59732e4b3836
[]
no_license
yuyue888/DesignPatternLearning
b4981b6c3663cdb8b6e9031f26bf6aa5f480c6f7
4981577b4d84a6bcf26bea99538e5430ee24a5d9
refs/heads/master
2021-09-02T07:34:31.351959
2017-12-31T14:22:14
2017-12-31T14:22:14
114,445,346
0
0
null
null
null
null
UTF-8
Java
false
false
348
java
package filter; import java.util.List; import java.util.stream.Collectors; /** * 大写过滤器 * Created by ssc on 2017/12/24. */ public class UpperFilter implements Filter<String> { @Override public List<String> filter(List<String> list) { return list.stream().map(String::toUpperCase).collect(Collectors.toList()); } }
eae726a6c8ecc53a55eafbee97a24a9011bb0a7b
c2b1c7102e33e062c48055cb42b3ce6a783d4284
/app/src/main/java/luan/localmotion/MessageReceiver.java
cb0c5aec148aa30496746ed89530c7bdee4cb00a
[]
no_license
ngoluan/localmotionnew
4cb0cd463cc69109759cc97f7a443e18989316a3
866a69b947cebe98215659142b7ce33374f677af
refs/heads/master
2020-04-12T06:45:19.208634
2016-10-14T22:05:03
2016-10-14T22:05:03
62,257,129
0
0
null
null
null
null
UTF-8
Java
false
false
817
java
package luan.localmotion; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; /** * Created by luann on 2016-07-20. */ public class MessageReceiver extends BroadcastReceiver { OnReceiveMessage onReceiveMessage; @Override public void onReceive(Context context, Intent intent) { Log.d(MainActivity.TAG, "New Message received:" + intent.toString()); if (onReceiveMessage != null) { Chat Message = (Chat) intent.getExtras().get("Message"); onReceiveMessage.onReceiveMessage(Message); } } public void setListener(OnReceiveMessage listener) { onReceiveMessage = listener; } interface OnReceiveMessage{ void onReceiveMessage(Chat Message); } }
315bb0ea4000f0f4c5a7aff60aad1fcc99b53c46
d0f1de3d67f017868798527b6b221c00ad40d804
/src/main/java/com/javastart/rest/repository/ProductRepository.java
62890ba3bc21b1dce9ab5e91db53f62e3b750354
[]
no_license
MaViProg/rest
86f5ed182e4a4f55c6ad410bf29ad50001cc0764
823d0fa597e7f9c4c9257f7913fec205b9f994ce
refs/heads/main
2023-07-10T07:40:16.653282
2021-08-11T20:03:42
2021-08-11T20:03:42
395,095,602
0
0
null
null
null
null
UTF-8
Java
false
false
223
java
package com.javastart.rest.repository; import com.javastart.rest.entity.Product; import org.springframework.data.jpa.repository.JpaRepository; public interface ProductRepository extends JpaRepository<Product, Long> { }
6a41c7cce6243bac8c96438fd63b4090abc5d9db
4110c4a8be73c6ab77a1d944c381f0432feba525
/app/src/main/java/com/delsart/bookdownload/utils/StatusBarUtils.java
6091d3d03d2a7c4a4410de46a23694ca0a58650b
[ "Apache-2.0" ]
permissive
QMSCount/Bookster
a5e2ae13ccc6337d1d9e8a7a1135a06e42c06bac
a761cbfd71bdfbe63afe954bc82c5dbb8152c3c2
refs/heads/master
2023-03-23T07:22:38.791825
2021-03-06T12:09:57
2021-03-06T12:10:22
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,867
java
package com.delsart.bookdownload.utils; import android.app.Activity; import android.os.Build; import android.view.View; import android.view.Window; import java.lang.reflect.Field; import java.lang.reflect.Method; public class StatusBarUtils { public static boolean MIUISetStatusBarLightMode(Activity activity, boolean dark) { boolean result = false; Window window = activity.getWindow(); if (window != null) { Class clazz = window.getClass(); try { int darkModeFlag = 0; Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams"); Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE"); darkModeFlag = field.getInt(layoutParams); Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class); if (dark) { extraFlagField.invoke(window, darkModeFlag, darkModeFlag);//状态栏透明且黑色字体 } else { extraFlagField.invoke(window, 0, darkModeFlag);//清除黑色字体 } result = true; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { //开发版 7.7.13 及以后版本采用了系统API,旧方法无效但不会报错,所以两个方式都要加上 if (dark) { activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } else { activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); } } } catch (Exception ignored) { } } return result; } }
a5e23bd6d44d5e77269f558323638b4512de5b6e
a774498904656397aa0e58a72f573f9c6ea010a0
/Exercise802/src/exercise802/Person.java
bdb14943ceea7526b5af7b536e35f6de2b3bbd86
[]
no_license
KAdams01/SDJ1
a543acfd7ece83ad1009b585542b10b59055bbc1
b097c45e98df9e388135858b6cdd704aa0c2ff2f
refs/heads/master
2021-10-08T05:30:22.966282
2018-12-08T12:37:38
2018-12-08T12:37:38
103,536,844
0
0
null
null
null
null
UTF-8
Java
false
false
349
java
package exercise802; public class Person { private String person; private String birthday; public Person(String p, String b) { person=p; birthday=b; } public void setName(String p) { person=p; } public void setBirthday(String b) { birthday=b; } public String getName() { return person; } public String getBirthday() { return birthday; } }
101c6609f1c6c5efafd8bbe55fe554b8a2d9d0b3
7d8008a6b28aa4d42db3b03b18e25199c2aeac0a
/SenseSim-mathModel/src/main/java/org/mdyk/netsim/mathModel/observer/ConfigurationSpaceFactory.java
35866cd5dad999de0cb78b07c531785599dae52b
[]
no_license
mdyk/SenseSim
46ff276dc4a49a4c61470956bba4de14f433a084
a5104bd8a11956b3ea51addcd1ac1915ab87f28b
refs/heads/master
2023-04-07T22:08:46.436827
2019-06-01T13:04:27
2019-06-01T13:04:27
114,037,101
0
0
null
2021-04-26T18:38:46
2017-12-12T20:42:15
Java
UTF-8
Java
false
false
411
java
package org.mdyk.netsim.mathModel.observer; public interface ConfigurationSpaceFactory { /** * Builds configuration space basing on its string value * @param value * value of the configuration space as string * @return * instance of the configuration space */ //TODO określić rzucany wyjątek ConfigurationSpace buildConfigurationSpace(String value); }
78b4983d2eb0933ff4760cf316ece8fcfdf0896d
2b6e3a34ec277f72a5da125afecfe3f4a61419f5
/Ruyicai_168/v3.5.4/v3.5.4/src/com/ruyicai/dialog/LogOutDialog.java
b58c4e8d3c9694f2cb1fe5e8f56d514145c38e9f
[]
no_license
surport/Android
03d538fe8484b0ff0a83b8b0b2499ad14592c64b
afc2668728379caeb504c9b769011f2ba1e27d25
refs/heads/master
2020-04-02T10:29:40.438348
2013-12-18T09:55:42
2013-12-18T09:55:42
15,285,717
3
5
null
null
null
null
UTF-8
Java
false
false
2,142
java
package com.ruyicai.dialog; import com.palmdream.RuyicaiAndroid168.R; import com.ruyicai.activity.common.UserLogin; import com.ruyicai.constant.ShellRWConstants; import com.ruyicai.util.RWSharedPreferences; import android.app.Activity; import android.widget.Toast; /** * 注销对话框 * @author Administrator * */ public class LogOutDialog extends BaseDialog{ static MyDialogListener dialogListener; private RWSharedPreferences shellRW; public static LogOutDialog dialog = null; public LogOutDialog(Activity activity, String title, String message) { super(activity, title, message); // TODO Auto-generated constructor stub } public static LogOutDialog createDialog(Activity activity){ // if(dialog == null){ dialog = new LogOutDialog(activity, activity.getString(R.string.log_out_title), activity.getString(R.string.log_out_content)); dialog.showDialog(); dialog.createMyDialog(); // }else{ // dialog.showDialog(); // } return dialog; } /** * 按钮的回调函数 */ public void setOnClik(MyDialogListener dialogListener){ this.dialogListener = dialogListener; } /** * 清空上次的登录信息 */ public void clearLastLoginInfo() { shellRW = new RWSharedPreferences(activity, "addInfo"); String userno = shellRW.getStringValue("userno"); if(userno.equals("")||userno == null){ Toast.makeText(activity,activity.getString(R.string.log_out_toast_no_login), Toast.LENGTH_SHORT).show(); }else{ shellRW.putStringValue("sessionid", ""); shellRW.putStringValue("userno", ""); shellRW.putStringValue("password", ""); shellRW.putBooleanValue(ShellRWConstants.AUTO_LOGIN, false); shellRW.putStringValue(ShellRWConstants.RANDOMNUMBER, ""); Toast.makeText(activity,activity.getString(R.string.log_out_toast_msg), Toast.LENGTH_SHORT).show(); } } @Override public void onOkButton() { // TODO Auto-generated method stub dialogListener.onOkClick(); } @Override public void onCancelButton() { // TODO Auto-generated method stub } }
ae8bca1c5105eaa37909e609672117b460cfb56e
d60bd7144cb4428a6f7039387c3aaf7b295ecc77
/ScootAppSource/android/support/v4/view/a/z.java
cd7e52080d66e92bdd9a72f88f32de0ce72fe83e
[]
no_license
vaquarkhan/Scoot-mobile-app
4f58f628e7e2de0480f7c41998cdc38100dfef12
befcfb58c1dccb047548f544dea2b2ee187da728
refs/heads/master
2020-06-10T19:14:25.985858
2016-12-08T04:39:10
2016-12-08T04:39:10
75,902,491
1
0
null
null
null
null
UTF-8
Java
false
false
5,340
java
package android.support.v4.view.a; import android.graphics.Rect; import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; final class z { public static Object a() { return AccessibilityNodeInfo.obtain(); } public static Object a(View paramView) { return AccessibilityNodeInfo.obtain(paramView); } public static Object a(Object paramObject) { return AccessibilityNodeInfo.obtain((AccessibilityNodeInfo)paramObject); } public static void a(Object paramObject, int paramInt) { ((AccessibilityNodeInfo)paramObject).addAction(paramInt); } public static void a(Object paramObject, Rect paramRect) { ((AccessibilityNodeInfo)paramObject).getBoundsInParent(paramRect); } public static void a(Object paramObject, View paramView) { ((AccessibilityNodeInfo)paramObject).addChild(paramView); } public static void a(Object paramObject, CharSequence paramCharSequence) { ((AccessibilityNodeInfo)paramObject).setClassName(paramCharSequence); } public static void a(Object paramObject, boolean paramBoolean) { ((AccessibilityNodeInfo)paramObject).setClickable(paramBoolean); } public static int b(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).getActions(); } public static void b(Object paramObject, Rect paramRect) { ((AccessibilityNodeInfo)paramObject).getBoundsInScreen(paramRect); } public static void b(Object paramObject, View paramView) { ((AccessibilityNodeInfo)paramObject).setParent(paramView); } public static void b(Object paramObject, CharSequence paramCharSequence) { ((AccessibilityNodeInfo)paramObject).setContentDescription(paramCharSequence); } public static void b(Object paramObject, boolean paramBoolean) { ((AccessibilityNodeInfo)paramObject).setEnabled(paramBoolean); } public static CharSequence c(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).getClassName(); } public static void c(Object paramObject, Rect paramRect) { ((AccessibilityNodeInfo)paramObject).setBoundsInParent(paramRect); } public static void c(Object paramObject, View paramView) { ((AccessibilityNodeInfo)paramObject).setSource(paramView); } public static void c(Object paramObject, CharSequence paramCharSequence) { ((AccessibilityNodeInfo)paramObject).setPackageName(paramCharSequence); } public static void c(Object paramObject, boolean paramBoolean) { ((AccessibilityNodeInfo)paramObject).setFocusable(paramBoolean); } public static CharSequence d(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).getContentDescription(); } public static void d(Object paramObject, Rect paramRect) { ((AccessibilityNodeInfo)paramObject).setBoundsInScreen(paramRect); } public static void d(Object paramObject, CharSequence paramCharSequence) { ((AccessibilityNodeInfo)paramObject).setText(paramCharSequence); } public static void d(Object paramObject, boolean paramBoolean) { ((AccessibilityNodeInfo)paramObject).setFocused(paramBoolean); } public static CharSequence e(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).getPackageName(); } public static void e(Object paramObject, boolean paramBoolean) { ((AccessibilityNodeInfo)paramObject).setLongClickable(paramBoolean); } public static CharSequence f(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).getText(); } public static void f(Object paramObject, boolean paramBoolean) { ((AccessibilityNodeInfo)paramObject).setScrollable(paramBoolean); } public static void g(Object paramObject, boolean paramBoolean) { ((AccessibilityNodeInfo)paramObject).setSelected(paramBoolean); } public static boolean g(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).isCheckable(); } public static boolean h(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).isChecked(); } public static boolean i(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).isClickable(); } public static boolean j(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).isEnabled(); } public static boolean k(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).isFocusable(); } public static boolean l(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).isFocused(); } public static boolean m(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).isLongClickable(); } public static boolean n(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).isPassword(); } public static boolean o(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).isScrollable(); } public static boolean p(Object paramObject) { return ((AccessibilityNodeInfo)paramObject).isSelected(); } public static void q(Object paramObject) { ((AccessibilityNodeInfo)paramObject).recycle(); } } /* Location: D:\Android\dex2jar-2.0\classes-dex2jar.jar!\android\support\v4\view\a\z.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */
4f4bf3bc6c5627dc80bffb366439f107ef50da11
b85d0ce8280cff639a80de8bf35e2ad110ac7e16
/com/fossil/dao.java
17ac2d45ba3cffef278718c3b9d15203cd723d02
[]
no_license
MathiasMonstrey/fosil_decompiled
3d90433663db67efdc93775145afc0f4a3dd150c
667c5eea80c829164220222e8fa64bf7185c9aae
refs/heads/master
2020-03-19T12:18:30.615455
2018-06-07T17:26:09
2018-06-07T17:26:09
136,509,743
1
0
null
null
null
null
UTF-8
Java
false
false
764
java
package com.fossil; import com.fossil.daj.C2602b; public final class dao implements emi<C2602b> { static final /* synthetic */ boolean $assertionsDisabled = (!dao.class.desiredAssertionStatus()); private final dam cNC; public /* synthetic */ Object get() { return akW(); } public dao(dam com_fossil_dam) { if ($assertionsDisabled || com_fossil_dam != null) { this.cNC = com_fossil_dam; return; } throw new AssertionError(); } public C2602b akW() { return (C2602b) emj.m10873f(this.cNC.akV(), "Cannot return null from a non-@Nullable @Provides method"); } public static emi<C2602b> m8096b(dam com_fossil_dam) { return new dao(com_fossil_dam); } }
2062ad3001c5e710e918aad4a7a0c05c62a393e9
70749fa5903ad075b552cfe9434af178f8758bc9
/app/src/main/java/io/github/vpaladino778/pacecalculator/ErgCalculation/ErgSplit.java
bcf202d8530ecb21592c015d8536380a03b558bc
[ "MIT" ]
permissive
vpaladino778/PaceCalculator
0ae692f1bfdf931214be807dcc638ddb675af614
734d9c8da7149132ed639d131862a55e98a7cb12
refs/heads/master
2020-03-19T07:11:11.378448
2019-10-11T15:21:49
2019-10-11T15:21:49
136,094,301
3
0
null
2018-08-14T18:40:33
2018-06-04T23:37:31
Java
UTF-8
Java
false
false
1,988
java
package io.github.vpaladino778.pacecalculator.ErgCalculation; import android.widget.EditText; import android.widget.TextView; import java.text.DecimalFormat; /** * Represents the users 500m split time. * Allows for conversion from ErgSplit to ErgTime and ErgDistance */ public class ErgSplit { private EditText splitText; private int minutes; private double seconds; public ErgSplit(EditText splitText){ this.splitText = splitText; reset(); } /** * Parses a time string into an ErgSplit object * @return True if string was parsed correctly, false if there was an error */ public boolean parseTimeString(String timeString){ String[] timeSplit = timeString.split(":"); // Splits (timeSplit[0]) minutes from seconds (timeSplit[1]) if(timeSplit.length > 2) return false; try { setMinutes(Integer.parseInt(timeSplit[0])); setSeconds(Double.parseDouble(timeSplit[1])); }catch(NumberFormatException e){ e.printStackTrace(); return false; } return true; } public double getSeconds() { return seconds; } public int getMinutes() { return minutes; } /** * Sets seconds text of EditText * @param s Seconds value */ public void setSeconds(Double s){ seconds = s; updateSplitText(); } /** * Sets minutes of EditText and updates minutes * @param m Minutes value */ public void setMinutes(int m){ minutes = m; updateSplitText(); } public void updateSplitText(){ DecimalFormat df = new DecimalFormat("00.0"); splitText.setText(getMinutes() + ":" + df.format(getSeconds())); } public double getTotalSeconds(){ return (getMinutes() * 60) + getSeconds(); } public void reset(){ setMinutes(2); setSeconds(00.0); updateSplitText(); } }
87703e5cad916e529b16f17c0dfc652542c13c97
08c537a7f390fbc85b40298f9595ea380e59fc8e
/app/src/main/java/com/azalea/www/piccap/PicPreViewActivity.java
076c3ed08f1a77bdb3b5e872dd2f56515c78c3da
[]
no_license
kapaseker/PicCap
47eecc2a3747408521a3c542cc3f7f6cd7d9f012
ba4cb992c0090b90d52dd189356ed8cf47cf7b7e
refs/heads/master
2021-01-10T09:38:05.538194
2015-06-11T05:24:34
2015-06-11T05:24:34
36,967,442
0
0
null
null
null
null
UTF-8
Java
false
false
1,011
java
package com.azalea.www.piccap; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; public class PicPreViewActivity extends ActionBarActivity { public static final String BUNDLE_PIC_FILE_PATH = "PicPreViewActivity.filepath"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pic_pre_view); } // @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_pic_pre_view, menu); // return true; // } // // @Override // public boolean onOptionsItemSelected(MenuItem item) { // // int id = item.getItemId(); // if (id == R.id.action_settings) { // return true; // } // // return super.onOptionsItemSelected(item); // } }
6403f6f9f32ae5f4b19fae008923b55cc827e13b
7402de91eb9268dcfe26e1b91c24b1e7ede40fd8
/Keiko/src/java/net/instantcom/util/BitField.java
fee44979b59a3d622a9f874fb148a199e3c48892
[ "Apache-2.0" ]
permissive
InstantCom/Keiko
1a907fb8e00667ead7ae0149c0622e742175c5cf
92860784447e010b1a7e5525d2535811dc3e6869
refs/heads/master
2019-01-02T04:00:34.548869
2015-04-20T07:48:28
2015-04-20T07:48:28
34,246,205
5
1
null
null
null
null
UTF-8
Java
false
false
4,001
java
package net.instantcom.util; import java.io.Serializable; public class BitField implements Serializable { private static final long serialVersionUID = 20080119L; private static final int[] BITS = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; private static final int[] LAST_BYTE_FIX = { 0xff, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe }; public BitField(int size) { this.size = size; int arraySize = size / 8; if (0 != (size & 7)) { ++arraySize; } data = new byte[arraySize]; } // make sure all unused bits in last byte are cleared protected void fixLastByte() { data[data.length - 1] &= LAST_BYTE_FIX[size & 7]; } public synchronized void clearAll() { for (int i = 0; i < data.length; i++) { data[i] = 0x00; } } public synchronized void setAll() { for (int i = 0; i < data.length; i++) { data[i] = (byte) 0xff; } fixLastByte(); } public boolean get(int index) { return 0 != (data[index / 8] & BITS[index & 7]); } public synchronized void clear(int index) { data[index / 8] &= ~BITS[index & 7]; } public synchronized void set(int index) { data[index / 8] |= BITS[index & 7]; } public int getSize() { return size; } public byte[] getData() { return data; } public void setData(byte[] data) { this.data = data; fixLastByte(); } /** * Checks if all bits are set. * * @return true if all bits are set */ public boolean allBitsSet() { return size == getNumOnes(); } /** * Checks if all bits are cleared. * * @return true if all bits are cleared */ public boolean allBitsCleared() { return size == getNumZeroes(); } /** * Returns new BitField which is bitwise AND of specified BitField and this * one. Both BitFields must be of the same size. * * @param other * other BitField * @return bitwise ANDed result */ public BitField and(BitField other) { if (size != other.getSize()) { throw new IllegalArgumentException("sizes do not match"); } BitField result = new BitField(size); byte[] resultData = result.getData(); byte[] otherData = other.getData(); for (int i = 0; i < data.length; i++) { resultData[i] = (byte) (data[i] & otherData[i]); } result.fixLastByte(); return result; } /** * Returns new BitField which is bitwise NOT of this one. * * @return bitwise NOTed result */ public BitField not() { BitField result = new BitField(size); byte[] resultData = result.getData(); for (int i = 0; i < data.length; i++) { resultData[i] = (byte) ~data[i]; } result.fixLastByte(); return result; } /** * Gets number of set bits (1). * * @return number of set bits */ public int getNumOnes() { int count = 0; for (int element : data) { if (element < 0) { element += 0x100; } count += Integer.bitCount(element); } return count; } /** * Gets number of cleared bits (0). * * @return number of cleared bits */ public int getNumZeroes() { return size - getNumOnes(); } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer sb = new StringBuffer(); for (byte element : data) { String s = "0000000" + Integer.toBinaryString(element); sb.append(s.substring(s.length() - 8)); } return sb.substring(0, size); } private int size; private byte[] data; }
13b580cec4a3db81b6224f4fea9b75b6fb9e1bad
e157fa3ecc29d779c8c584791bc64f61155fbc41
/android/app/src/main/java/com/dailyworkouts/MainApplication.java
7f1dc5139ea6e43640b1d029d126f242eac08849
[]
no_license
dominiclind/daily
372a074687ec259f44385173f360e212ffebddc6
f11ec4631c27b2dfc89e3c8e74eca69c9b23917c
refs/heads/master
2021-08-20T10:14:03.067341
2017-11-28T21:26:39
2017-11-28T21:26:39
111,936,325
0
0
null
null
null
null
UTF-8
Java
false
false
2,101
java
package com.dailyworkouts; import android.app.Application; import com.facebook.react.ReactApplication; import com.microsoft.codepush.react.CodePush; import com.microsoft.appcenter.reactnative.crashes.AppCenterReactNativeCrashesPackage; import com.microsoft.appcenter.reactnative.analytics.AppCenterReactNativeAnalyticsPackage; import com.microsoft.appcenter.reactnative.appcenter.AppCenterReactNativePackage; import com.BV.LinearGradient.LinearGradientPackage; import com.oblador.vectoricons.VectorIconsPackage; import com.facebook.reactnative.androidsdk.FBSDKPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import java.util.Arrays; import java.util.List; public class MainApplication extends Application implements ReactApplication { private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { @Override protected String getJSBundleFile() { return CodePush.getJSBundleFile(); } @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), new CodePush(null, getApplicationContext(), BuildConfig.DEBUG), new AppCenterReactNativeCrashesPackage(MainApplication.this, getResources().getString(R.string.appcenterCrashes_whenToSendCrashes)), new AppCenterReactNativeAnalyticsPackage(MainApplication.this, getResources().getString(R.string.appcenterAnalytics_whenToEnableAnalytics)), new AppCenterReactNativePackage(MainApplication.this), new LinearGradientPackage(), new VectorIconsPackage(), new FBSDKPackage() ); } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); } }
65dfa707bb0bbe4eb5e357391f8a4881f0dc6f8d
a36d5ce588c7f9712ff2b1e1f780dd0e058cf865
/贪心/src/种花问题/CanPlaceFlowers.java
c5d360b845ac328ef91bc3397840043de2e8d1d8
[]
no_license
ThereNoTeaThisAfternoon/Algorithms
92461f5f9d8805655d705d1d28bfe4b602fe0259
cfc5743579043565a22b5972c75633f2704ea750
refs/heads/master
2023-04-13T18:50:43.266638
2021-04-18T02:18:27
2021-04-18T02:18:27
297,070,779
2
0
null
null
null
null
UTF-8
Java
false
false
2,482
java
package 种花问题; import Greedy公共方法.PublicMethod; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * FileName: CanPlaceFlowers.java * 类的详细说明 * 假设你有一个很长的花坛,一部分地块种植了花,另一部分却没有。 * 可是,花卉不能种植在相邻的地块上,它们会争夺水源,两者都会死去。 * 给定一个花坛(表示为一个数组包含0和1,其中0表示没种植花,1表示种植了花),和一个数 n 。 * 能否在不打破种植规则的情况下种入 n 朵花?能则返回True,不能则返回False。 * <p> * 数组内已种好的花不会违反种植规则。 * 输入的数组长度范围为 [1, 20000]。 * n 是非负整数,且不会超过输入数组的大小。 * * @author &#x8c2f;&#x535a; * @version 1.00 * @date 2021.1.1 - 下午 2:25 * @label Greedy Array */ public class CanPlaceFlowers { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line; System.out.println("请输入一个一维数组表示花坛flowerbed:[1,0,0,0,1,0,0]"); while ((line = in.readLine()) != null) { int[] flowerbed = PublicMethod.stringToIntegerArray(line); System.out.println("请输入需要种植的花的数量n:2"); int n = Integer.parseInt(in.readLine()); boolean result = new Solution().canPlaceFlowers(flowerbed, n); System.out.println((result ? "" : "不") + "能种" + n + "朵花"); } } } /** * 防御式编程思想:在 flowerbed 数组两端各增加一个 0,这样处理的好处在于不用考虑边界条件, * 任意位置处只要连续出现三个 0 就可以栽上一棵花。 */ class Solution { public boolean canPlaceFlowers(int[] flowerbed, int n) { int len = flowerbed.length; int[] lands = new int[len + 2]; System.arraycopy(flowerbed, 0, lands, 1, len); // 若该土地上没有花,且相邻两边没有种花,那么就在该地上种花。 for (int i = 1; i < lands.length - 1; ++i) { if (lands[i] != 1 && lands[i - 1] == 0 && lands[i + 1] == 0) { n--; lands[i] = 1; // 种花 } if (n <= 0) { return true; } } return false; } }
6f016ac36f9e0219c0d7b998109499e2505c0b9e
5262588f35289d1a0fc75a19d317daa25f6a9933
/customerhist/src/main/java/gmfd/Registerd.java
ed3d22f2efce9e616b374c0d993d3865442930fb
[]
no_license
sakata2kr/Team5
b02d6a487dbd796fda28729add0db4d06d2f4a89
cdaea4d82cd4ca55ddc6b38ee9cebf0671dd2cfb
refs/heads/main
2023-02-24T20:02:07.706111
2021-01-21T06:59:32
2021-01-21T06:59:32
330,551,104
0
0
null
null
null
null
UTF-8
Java
false
false
1,252
java
package gmfd; public class Registerd extends AbstractEvent { private Long id; private Long customerid; private String name; private String phone; private String address; private Integer age; private String status; public Registerd(){ super(); } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Long getCustomerid() { return customerid; } public void setCustomerid(Long customerid) { this.customerid = customerid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } }
17cabf5c538343c53d47c805d9100c7028e368a0
ea87cc36876ab6acdf9cd6bee7d59e85cd473c64
/app/src/main/java/com/example/smart/wishlist.java
0d86ca291210d53ddbcc455056f37d9a13818637
[]
no_license
chinmay3445/smart-basket
05686baa9ec2bb04c9ee42dc021b6ead721522a4
d085747e60581a321dd26fb3ec34d45412af3973
refs/heads/main
2023-05-31T22:06:22.950948
2021-06-10T08:58:27
2021-06-10T08:58:27
375,633,579
0
0
null
null
null
null
UTF-8
Java
false
false
3,996
java
package com.example.smart; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ListView; import android.widget.Toast; import com.firebase.ui.database.FirebaseRecyclerOptions; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import java.util.ArrayList; public class wishlist extends AppCompatActivity { private FloatingActionButton fbtn; private DatabaseReference ref; private FirebaseAuth mAuth; RecyclerView recyclerView; WishlistAdapter toDoAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wishlist); ref = FirebaseDatabase.getInstance().getReference(); mAuth = FirebaseAuth.getInstance(); String uid = mAuth.getCurrentUser().getUid().toString(); recyclerView = findViewById(R.id.recyclerView1); recyclerView.setLayoutManager(new LinearLayoutManager(this)); fbtn = findViewById(R.id.fab); fbtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(wishlist.this); final EditText editText = new EditText(wishlist.this); FrameLayout container = new FrameLayout(wishlist.this); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.leftMargin = getResources().getDimensionPixelSize(R.dimen.dialog_margin); editText.setLayoutParams(params); container.addView(editText); editText.setHint("e.g. paneer"); builder.setTitle("Wishlist Item"); builder.setView(container); builder.setPositiveButton("Add", new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { Item item = new Item(); item.text=editText.getText().toString(); item.done=false; item.UID = ref.child("Users/"+uid+"/wishlist/").push().getKey(); ref.child("Users/"+uid+"/wishlist/"+item.UID).setValue(item); dialog.dismiss(); Toast.makeText(getApplicationContext(),"Item saved",Toast.LENGTH_LONG).show(); } }); AlertDialog alertDialog = builder.create(); // Show the Alert Dialog box alertDialog.show(); } }); FirebaseRecyclerOptions<Item> options = new FirebaseRecyclerOptions.Builder<Item>() .setQuery(FirebaseDatabase.getInstance().getReference().child("Users/"+uid+"/wishlist/"), Item.class) .build(); toDoAdapter = new WishlistAdapter(options); recyclerView.setAdapter(toDoAdapter); } @Override protected void onStart(){ super.onStart(); toDoAdapter.startListening(); } @Override protected void onStop() { super.onStop(); toDoAdapter.stopListening(); } }
6e9e5005a63849e495d5696d7ecadde6a4028b7d
0df45b3fee02b8ff0481d72049ded464a98f833d
/app/src/main/java/com/carlShen/jsbridge/fmwebviewjsbridge/MainActivity.java
1ae8ac30fdb22b35249e598da1b0b63a6a6165df
[ "MIT" ]
permissive
carlSQ/FMWebViewJSBridge
6264c3e4097a3a3c61f62ef7c2372c43d73a4bf7
413b2b878c923cebe13417426994331cfa5853b4
refs/heads/master
2021-01-20T20:56:39.008732
2016-08-08T10:01:25
2016-08-08T10:01:25
64,657,331
4
0
null
null
null
null
UTF-8
Java
false
false
4,274
java
package com.carlShen.jsbridge.fmwebviewjsbridge; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.widget.Button; import android.widget.TextView; import com.carlShen.jsbridge.library.FMJSBridgeResponse; import com.carlShen.jsbridge.library.FMWebViewJSBridge; import java.util.ArrayList; import java.util.List; import com.google.gson.annotations.SerializedName; public class MainActivity extends Activity implements View.OnClickListener { private final String TAG = "MainActivity"; WebView webView; Button button; TextView textView; int RESULT_CODE; FMWebViewJSBridge jsBridge; ValueCallback<Uri> mUploadMessage; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); webView = (WebView) findViewById(R.id.webView); jsBridge = new FMWebViewJSBridge(webView, null); TestJavaInterface javaInterface = new TestJavaInterface(this); jsBridge.addJavascriptInterface(javaInterface, "javaInterface"); button = (Button) findViewById(R.id.button); textView = (TextView) findViewById(R.id.text); button.setOnClickListener(this); webView.setWebChromeClient(new WebChromeClient() { public void openFileChooser(ValueCallback<Uri> uploadMsg, String AcceptType, String capture) { this.openFileChooser(uploadMsg); } public void openFileChooser(ValueCallback<Uri> uploadMsg, String AcceptType) { this.openFileChooser(uploadMsg); } public void openFileChooser(ValueCallback<Uri> uploadMsg) { mUploadMessage = uploadMsg; pickFile(); } }); webView.loadUrl("file:///android_asset/demo.html"); } public void pickFile() { Intent chooserIntent = new Intent(Intent.ACTION_GET_CONTENT); chooserIntent.setType("image/*"); startActivityForResult(chooserIntent, RESULT_CODE); } protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == RESULT_CODE) { if (mUploadMessage == null) { return; } Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData(); mUploadMessage.onReceiveValue(result); mUploadMessage = null; } } public void onClick(View v) { User user = new User(); Location location = new Location(); location.address = "SDU"; user.location = location; user.name = "Bruce"; user.age = 8; List<Object> args = new ArrayList(); args.add("i love you "); args.add(user); jsBridge.callJSFunction("testObj", "testMethod", args, new FMJSBridgeResponse<User>() { @Override public void asynchronousResponse(User data) { if (data != null) { textView.setText(String.format("functionInJs %s+%s", data.age, data.name)); } } }); } static class Location { String address; @Override public String toString() { return "Location{" + "address='" + address + '\'' + '}'; } } static class User { String name; int age; Location location; @Override public String toString() { return "User{" + "name='" + name + '\'' + ", location=" + location + '}'; } } static class Login { @SerializedName("username") String username; @SerializedName("password") String password; @Override public String toString() { return "Login{" + "username='" + username + '\'' + ", password='" + password + '\'' + '}'; } } }
e3faf987a9befa7459dc02cff5c59bb0cbc1a6f6
6ef4869c6bc2ce2e77b422242e347819f6a5f665
/devices/google/Pixel 2/29/QPP6.190730.005/src/ext/gov/nist/javax/sip/header/TimeStamp.java
2bdd13cda6a55d3a42d0d2510e4e13a56bdd6ba2
[]
no_license
hacking-android/frameworks
40e40396bb2edacccabf8a920fa5722b021fb060
943f0b4d46f72532a419fb6171e40d1c93984c8e
refs/heads/master
2020-07-03T19:32:28.876703
2019-08-13T03:31:06
2019-08-13T03:31:06
202,017,534
2
0
null
2019-08-13T03:33:19
2019-08-12T22:19:30
Java
UTF-8
Java
false
false
4,122
java
/* * Decompiled with CFR 0.145. */ package gov.nist.javax.sip.header; import gov.nist.javax.sip.header.SIPHeader; import javax.sip.InvalidArgumentException; import javax.sip.header.TimeStampHeader; public class TimeStamp extends SIPHeader implements TimeStampHeader { private static final long serialVersionUID = -3711322366481232720L; protected int delay = -1; protected float delayFloat = -1.0f; protected long timeStamp = -1L; private float timeStampFloat = -1.0f; public TimeStamp() { super("Timestamp"); } private String getDelayAsString() { if (this.delay == -1 && this.delayFloat == -1.0f) { return ""; } int n = this.delay; if (n != -1) { return Integer.toString(n); } return Float.toString(this.delayFloat); } private String getTimeStampAsString() { if (this.timeStamp == -1L && this.timeStampFloat == -1.0f) { return ""; } long l = this.timeStamp; if (l != -1L) { return Long.toString(l); } return Float.toString(this.timeStampFloat); } @Override public String encodeBody() { StringBuffer stringBuffer = new StringBuffer(); String string = this.getTimeStampAsString(); String string2 = this.getDelayAsString(); if (string.equals("") && string2.equals("")) { return ""; } if (!string.equals("")) { stringBuffer.append(string); } if (!string2.equals("")) { stringBuffer.append(" "); stringBuffer.append(string2); } return stringBuffer.toString(); } @Override public float getDelay() { float f; float f2 = f = this.delayFloat; if (f == -1.0f) { f2 = Float.valueOf(this.delay).floatValue(); } return f2; } @Override public long getTime() { long l; long l2 = l = this.timeStamp; if (l == -1L) { l2 = (long)this.timeStampFloat; } return l2; } @Override public int getTimeDelay() { int n; int n2 = n = this.delay; if (n == -1) { n2 = (int)this.delayFloat; } return n2; } @Override public float getTimeStamp() { float f; block0 : { f = this.timeStampFloat; if (f != -1.0f) break block0; f = Float.valueOf(this.timeStamp).floatValue(); } return f; } @Override public boolean hasDelay() { boolean bl = this.delay != -1; return bl; } @Override public void removeDelay() { this.delay = -1; } @Override public void setDelay(float f) throws InvalidArgumentException { if (f < 0.0f && f != -1.0f) { throw new InvalidArgumentException("JAIN-SIP Exception, TimeStamp, setDelay(), the delay parameter is <0"); } this.delayFloat = f; this.delay = -1; } @Override public void setTime(long l) throws InvalidArgumentException { if (l >= -1L) { this.timeStamp = l; this.timeStampFloat = -1.0f; return; } throw new InvalidArgumentException("Illegal timestamp"); } @Override public void setTimeDelay(int n) throws InvalidArgumentException { if (n >= -1) { this.delay = n; this.delayFloat = -1.0f; return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("Value out of range "); stringBuilder.append(n); throw new InvalidArgumentException(stringBuilder.toString()); } @Override public void setTimeStamp(float f) throws InvalidArgumentException { if (!(f < 0.0f)) { this.timeStamp = -1L; this.timeStampFloat = f; return; } throw new InvalidArgumentException("JAIN-SIP Exception, TimeStamp, setTimeStamp(), the timeStamp parameter is <0"); } }
ef6c79cdbf6d0e303c760a293e1e27a0e2a34c66
aa8a3972d192dc27805b6c564e6bd5a34eb34636
/examples/adwords_axis/src/main/java/adwords/axis/v201409/targeting/AddCampaignTargetingCriteria.java
bc340e3d12c4600afcb329856d45026859e87da2
[ "Apache-2.0" ]
permissive
nafae/developer
201e76ef6909097b07936dbc7f4ef05660fe2a26
ea3ad63c72009c83c2cdbeebfc3868905a188166
refs/heads/master
2021-01-19T17:48:32.453689
2014-11-11T22:17:32
2014-11-11T22:17:32
26,411,286
0
1
null
null
null
null
UTF-8
Java
false
false
7,827
java
// Copyright 2014 Google Inc. All Rights Reserved. // // 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 adwords.axis.v201409.targeting; import com.google.api.ads.adwords.axis.factory.AdWordsServices; import com.google.api.ads.adwords.axis.v201409.cm.CampaignCriterion; import com.google.api.ads.adwords.axis.v201409.cm.CampaignCriterionOperation; import com.google.api.ads.adwords.axis.v201409.cm.CampaignCriterionReturnValue; import com.google.api.ads.adwords.axis.v201409.cm.CampaignCriterionServiceInterface; import com.google.api.ads.adwords.axis.v201409.cm.ConstantOperand; import com.google.api.ads.adwords.axis.v201409.cm.ConstantOperandConstantType; import com.google.api.ads.adwords.axis.v201409.cm.ConstantOperandUnit; import com.google.api.ads.adwords.axis.v201409.cm.Criterion; import com.google.api.ads.adwords.axis.v201409.cm.Function; import com.google.api.ads.adwords.axis.v201409.cm.FunctionArgumentOperand; import com.google.api.ads.adwords.axis.v201409.cm.FunctionOperator; import com.google.api.ads.adwords.axis.v201409.cm.GeoTargetOperand; import com.google.api.ads.adwords.axis.v201409.cm.IncomeOperand; import com.google.api.ads.adwords.axis.v201409.cm.IncomeTier; import com.google.api.ads.adwords.axis.v201409.cm.Language; import com.google.api.ads.adwords.axis.v201409.cm.Location; import com.google.api.ads.adwords.axis.v201409.cm.LocationExtensionOperand; import com.google.api.ads.adwords.axis.v201409.cm.LocationGroups; import com.google.api.ads.adwords.axis.v201409.cm.Operator; import com.google.api.ads.adwords.axis.v201409.cm.PlacesOfInterestOperand; import com.google.api.ads.adwords.axis.v201409.cm.PlacesOfInterestOperandCategory; import com.google.api.ads.adwords.lib.client.AdWordsSession; import com.google.api.ads.common.lib.auth.OfflineCredentials; import com.google.api.ads.common.lib.auth.OfflineCredentials.Api; import com.google.api.client.auth.oauth2.Credential; import java.util.ArrayList; import java.util.List; /** * This example adds various types of targeting criteria to a campaign. To get * campaigns, run GetCampaigns.java * * Credentials and properties in {@code fromFile()} are pulled from the * "ads.properties" file. See README for more info. * * Tags: CampaignCriterionService.mutate * * @author Kevin Winter */ public class AddCampaignTargetingCriteria { public static void main(String[] args) throws Exception { // Generate a refreshable OAuth2 credential similar to a ClientLogin token // and can be used in place of a service account. Credential oAuth2Credential = new OfflineCredentials.Builder() .forApi(Api.ADWORDS) .fromFile() .build() .generateCredential(); // Construct an AdWordsSession. AdWordsSession session = new AdWordsSession.Builder() .fromFile() .withOAuth2Credential(oAuth2Credential) .build(); Long campaignId = Long.valueOf("INSERT_CAMPAIGN_ID_HERE"); AdWordsServices adWordsServices = new AdWordsServices(); runExample(adWordsServices, session, campaignId); } public static void runExample( AdWordsServices adWordsServices, AdWordsSession session, Long campaignId) throws Exception { // Get the CampaignService. CampaignCriterionServiceInterface campaignCriterionService = adWordsServices.get(session, CampaignCriterionServiceInterface.class); // Create locations. The IDs can be found in the documentation or // retrieved with the LocationCriterionService. Location california = new Location(); california.setId(21137L); Location mexico = new Location(); mexico.setId(2484L); // Create languages. The IDs can be found in the documentation or // retrieved with the ConstantDataService. Language english = new Language(); english.setId(1000L); Language spanish = new Language(); spanish.setId(1003L); // Location groups criteria. These represent targeting by household income // or places of interest. The IDs can be found in the documentation or // retrieved with the LocationCriterionService. LocationGroups locationGroupTier3 = new LocationGroups(); Function tier3MatchingFunction = new Function(); tier3MatchingFunction.setLhsOperand(new FunctionArgumentOperand[] { // Tiers are numbered 1-10, and represent 10% segments of earners. // For example, TIER_1 is the top 10%, TIER_2 is the 80-90%, etc. // Tiers 6 through 10 are grouped into TIER_6_TO_10. new IncomeOperand(null, IncomeTier.TIER_3) }); tier3MatchingFunction.setOperator(FunctionOperator.AND); tier3MatchingFunction.setRhsOperand(new FunctionArgumentOperand[] { new GeoTargetOperand(null, new long[]{ 1015116L }) // Miami, FL }); locationGroupTier3.setMatchingFunction(tier3MatchingFunction); LocationGroups locationGroupDowntown = new LocationGroups(); Function downtownMatchingFunction = new Function(); downtownMatchingFunction.setLhsOperand(new FunctionArgumentOperand[] { new PlacesOfInterestOperand(null, PlacesOfInterestOperandCategory.DOWNTOWN) }); downtownMatchingFunction.setOperator(FunctionOperator.AND); downtownMatchingFunction.setRhsOperand(new FunctionArgumentOperand[] { new GeoTargetOperand(null, new long[]{ 1015116L }) // Miami, FL }); locationGroupDowntown.setMatchingFunction(downtownMatchingFunction); // Distance targeting. Area of 10 miles around targets above. LocationGroups radiusLocationGroup = new LocationGroups(); ConstantOperand radius = new ConstantOperand(); radius.setType(ConstantOperandConstantType.DOUBLE); radius.setUnit(ConstantOperandUnit.MILES); radius.setDoubleValue(10d); LocationExtensionOperand distance = new LocationExtensionOperand(); distance.setRadius(radius); Function radiusMatchingFunction = new Function(); radiusMatchingFunction.setOperator(FunctionOperator.IDENTITY); radiusMatchingFunction.setLhsOperand(new FunctionArgumentOperand[] {distance}); radiusLocationGroup.setMatchingFunction(radiusMatchingFunction); List<CampaignCriterionOperation> operations = new ArrayList<CampaignCriterionOperation>(); for (Criterion criterion : new Criterion[] {california, mexico, english, spanish, locationGroupTier3, locationGroupDowntown, radiusLocationGroup}) { CampaignCriterionOperation operation = new CampaignCriterionOperation(); CampaignCriterion campaignCriterion = new CampaignCriterion(); campaignCriterion.setCampaignId(campaignId); campaignCriterion.setCriterion(criterion); operation.setOperand(campaignCriterion); operation.setOperator(Operator.ADD); operations.add(operation); } CampaignCriterionReturnValue result = campaignCriterionService.mutate(operations .toArray(new CampaignCriterionOperation[operations.size()])); // Display campaigns. for (CampaignCriterion campaignCriterion : result.getValue()) { System.out.printf("Campaign criterion with campaign id '%s', criterion id '%s', " + "and type '%s' was added.\n", campaignCriterion.getCampaignId(), campaignCriterion .getCriterion().getId(), campaignCriterion.getCriterion().getCriterionType()); } } }
5f2b5aea4770487790c50d1401bd47e584c9ee87
925ac84a742f94494ae079168db9b511c613cd3c
/MyLinkedList.java
c32466972d895bd435855571a3fdbda4cb732e97
[]
no_license
mwang20/RadixSort
5b1786fc3fd25e1e095f0f2e2dce64d69a02c460
04f8fc8c4b3314a04421ddad2982ceb575af1412
refs/heads/main
2023-02-21T09:03:07.954555
2021-01-20T03:32:26
2021-01-20T03:32:26
329,073,853
0
0
null
null
null
null
UTF-8
Java
false
false
3,506
java
import java.lang.IllegalArgumentException; public class MyLinkedList{ private int size; private Node start,end; public MyLinkedList(){ size = 0; start = null; end = null; } public int size(){ return size; } public boolean add(String value){ Node node = new Node(value); if (size == 0){ start = end = node; } else { end.getNext().setPrev(end); end.setNext(node); end = node; } size++; return true; } public void add(int index, String value){ if (index > size){ throw new IndexOutOfBoundsException(); } Node node = new Node(value); Node current = end; int move = size; if (size == index){ end.getNext().setPrev(end); end.setNext(node); end = node; } else if (index == 0) { node.setNext(start); start.setPrev(node); start = node; } else { while (move >= index){ current.setNext(current); current = current.getPrev(); current.setPrev(current.getPrev()); if (move == index){ current.setNext(current); Node previous = current.getPrev(); current = node; current.setPrev(previous); } move--; } } size++; } public String get(int index){ if (index > size){ throw new IndexOutOfBoundsException(); } int move = index; Node current = start; while (move >= 0){ current = current.getNext(); move--; } return current.getData(); } public String set(int index, String value){ if (index > size){ throw new IndexOutOfBoundsException(); } Node node = new Node(value); int move = index; Node current = start; while (move != 0){ current = current.getNext(); move--; } current.setData(value); size++; return current.getData(); } public String toString(){ String listString = "["; Node current = start; if (size == 0){ return "[]"; } listString += current.getData(); while (current.getNext() != null){ current = current.getNext(); listString += ", " + current.getData(); } return listString + "]"; } public String toStringReversed(){ String listString = "["; Node current = end; if (size == 0){ return "[]"; } listString += current.getData(); while (current.getPrev() != null){ current = current.getPrev(); listString += ", " + current.getData(); } return listString + "]"; } public String remove(int index){ if (index > size){ throw new IndexOutOfBoundsException(); } int move = index; Node current = null; if (size == 1){ start = end = null; } else if (index == 0){ current = start; start = start.getNext(); start.setPrev(null); } else if (size - 1 == index ){ current = end; end = end.getPrev(); end.setNext(null); } else { while (move != 0){ current = current.getNext(); move--; } current.getPrev().setNext(current.getNext()); current.getNext().setPrev(current.getPrev()); } size--; String removed = current.getData(); return removed; } public int getSize(){ return size; } public void extend(MyLinkedList other){ for (int i = 0; i < other.getSize(); i++){ String removed = other.get(i); other.remove(i); add(removed); } } }
1bb3d8e4043d8dcb28c0f39892e361460de782bf
2999da83ea54ad656250f050c48ccbe7485119fc
/app/src/main/java/com/conan/xconan/download/db/DownDbManager.java
cedf063412a55bc6429b933ec8fbc77b9d92fc2c
[]
no_license
wjyconan/Xconan
96586c98f6e9d9d0d0e12f74420a8cce6cc64b8d
d9400fb782db04640e10b2baabd6df53f3e0687b
refs/heads/master
2021-01-22T02:40:13.773801
2017-02-06T08:20:41
2017-02-06T08:20:41
null
0
0
null
null
null
null
UTF-8
Java
false
false
7,038
java
package com.conan.xconan.download.db; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import com.conan.xconan.download.core.DownTask; import com.conan.xconan.download.mode.DownProgress; import com.conan.xconan.download.mode.DownRecord; import com.conan.xconan.download.mode.DownStatus; import java.util.ArrayList; import java.util.List; import rx.Observable; import rx.Subscriber; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; /** * @Description: 下载数据库操作管理 * @author: Conan * @date: 17/1/16 22:09. */ public class DownDbManager { private volatile static DownDbManager singleton; private final Object databaseLock = new Object(); private DownDbOpenHelper downDbOpenHelper; private volatile SQLiteDatabase readableDatabase; private volatile SQLiteDatabase writableDatabase; private DownDbManager(Context context) { downDbOpenHelper = new DownDbOpenHelper(context); } public static DownDbManager getSingleton(Context context) { if (singleton == null) { synchronized (DownDbManager.class) { if (singleton == null) { singleton = new DownDbManager(context); } } } return singleton; } public boolean recordNotExists(String url) { Cursor cursor = null; try { cursor = getReadableDatabase().query(DownDb.RecordTable.TABLE_NAME, new String[]{DownDb.RecordTable.COLUMN_ID}, "url=?", new String[]{url}, null, null, null); return cursor.getCount() == 0; } finally { if (cursor != null) { cursor.close(); } } } public long insertRecord(DownTask task) { return getWritableDatabase().insert(DownDb.RecordTable.TABLE_NAME, null, DownDb.RecordTable.insertTask(task)); } public long updateRecord(String url, DownProgress progress) { return getWritableDatabase().update(DownDb.RecordTable.TABLE_NAME, DownDb.RecordTable.updateProgress(progress), "url=?", new String[]{url}); } public long updateRecord(String url, int status) { return getWritableDatabase().update(DownDb.RecordTable.TABLE_NAME, DownDb.RecordTable.updateStatus(status), "url=?", new String[]{url}); } public int deleteRecord(String url) { return getWritableDatabase().delete(DownDb.RecordTable.TABLE_NAME, "url=?", new String[]{url}); } public DownRecord readSingleRecord(String url) { Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("select * from " + DownDb.RecordTable.TABLE_NAME + " where url=?", new String[]{url}); cursor.moveToFirst(); return DownDb.RecordTable.readRecord(cursor); } finally { if (cursor != null) { cursor.close(); } } } public DownProgress readProgress(String url) { Cursor cursor = null; try { cursor = getReadableDatabase().query( DownDb.RecordTable.TABLE_NAME, new String[]{DownDb.RecordTable.COLUMN_DOWNLOAD_SIZE, DownDb.RecordTable.COLUMN_TOTAL_SIZE, DownDb.RecordTable.COLUMN_IS_CHUNKED}, "url=?", new String[]{url}, null, null, null); if (cursor.getCount() == 0) { return new DownProgress(); } else { cursor.moveToFirst(); return DownDb.RecordTable.readProgress(cursor); } } finally { if (cursor != null) { cursor.close(); } } } public void closeDataBase() { synchronized (databaseLock) { readableDatabase = null; writableDatabase = null; downDbOpenHelper.close(); } } public Observable<List<DownRecord>> readAllRecords() { return Observable.create(new Observable.OnSubscribe<List<DownRecord>>() { @Override public void call(Subscriber<? super List<DownRecord>> subscriber) { Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("select * from " + DownDb.RecordTable.TABLE_NAME, new String[]{}); List<DownRecord> result = new ArrayList<>(); while (cursor.moveToNext()) { result.add(DownDb.RecordTable.readRecord(cursor)); } subscriber.onNext(result); subscriber.onCompleted(); } finally { if (cursor != null) { cursor.close(); } } } }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()); } public long repairErrorStatus() { return getWritableDatabase().update(DownDb.RecordTable.TABLE_NAME, DownDb.RecordTable.updateStatus(DownStatus.PAUSED.getStatus()), DownDb.RecordTable.COLUMN_DOWNLOAD_STATUS + "=? or " + DownDb.RecordTable.COLUMN_DOWNLOAD_STATUS + "=?", new String[]{DownStatus.WAITING.getStatus() + "", DownStatus.STARTED.getStatus() + ""}); } public Observable<DownRecord> readRecord(final String url) { return Observable.create(new Observable.OnSubscribe<DownRecord>() { @Override public void call(Subscriber<? super DownRecord> subscriber) { Cursor cursor = null; try { cursor = getReadableDatabase().rawQuery("select * from " + DownDb.RecordTable.TABLE_NAME + " where " + "url=?", new String[]{url}); while (cursor.moveToNext()) { subscriber.onNext(DownDb.RecordTable.readRecord(cursor)); } subscriber.onCompleted(); } finally { if (cursor != null) { cursor.close(); } } } }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()); } private SQLiteDatabase getWritableDatabase() { SQLiteDatabase db = writableDatabase; if (db == null) { synchronized (databaseLock) { db = writableDatabase; if (db == null) { db = writableDatabase = downDbOpenHelper.getWritableDatabase(); } } } return db; } private SQLiteDatabase getReadableDatabase() { SQLiteDatabase db = readableDatabase; if (db == null) { synchronized (databaseLock) { db = readableDatabase; if (db == null) { db = readableDatabase = downDbOpenHelper.getReadableDatabase(); } } } return db; } }
d55168ad3f810fa56ff7e4bd22f580a621e65896
7f3847b4f29dd30c6492794afc24eaeb6682f3fa
/app/src/main/java/checklist/args/def/ArgsBlockDef.java
3713369e7a8baddd76ea7c4c5fa79f7037346f9c
[ "MIT" ]
permissive
anton0xf/checklist
4ac91bdd091d6874449888986d205cc1f9814aeb
6cd7d5dbcd2f1874b07a1e38e9852efa1314dfe2
refs/heads/main
2023-04-18T04:30:49.204433
2021-05-02T21:32:34
2021-05-02T21:32:34
330,450,003
0
0
MIT
2021-04-21T07:30:51
2021-01-17T17:42:46
Java
UTF-8
Java
false
false
5,861
java
package checklist.args.def; import java.util.function.Function; import java.util.function.Predicate; import checklist.args.ArgParseException; import checklist.args.OptionsUtil; import checklist.args.val.ArgsBlockVal; import checklist.args.val.OptionArgVal; import checklist.args.val.PositionalArgVal; import checklist.util.Strings; import io.vavr.Predicates; import io.vavr.Tuple; import io.vavr.Tuple2; import io.vavr.collection.List; import io.vavr.collection.Map; import io.vavr.collection.Seq; /** * Define sequence of options and positional (may be optional) arguments */ public class ArgsBlockDef implements ArgsDef<ArgsBlockVal> { private static final Predicate<PositionalArgDef> IS_MANDATORY = Predicates.not(PositionalArgDef::isOptional); private final Map<String, OptionArgDef> longOptions; private final Map<String, OptionArgDef> shortOptions; private final Seq<PositionalArgDef> positional; private static Seq<PositionalArgDef> validatePositional(Seq<PositionalArgDef> pos) { if (pos.dropWhile(IS_MANDATORY).exists(IS_MANDATORY)) { throw new IllegalArgumentException("Optional positional parameters should go at the end"); } return pos; } public ArgsBlockDef() { this(List.empty(), List.empty()); } public ArgsBlockDef(Seq<OptionArgDef> options, Seq<PositionalArgDef> positional) { this.longOptions = options.toMap(OptionArgDef::getName, Function.identity()); this.shortOptions = options .filter(option -> option.getShortName().isDefined()) .toMap(optionArgDef -> optionArgDef.getShortName().get(), Function.identity()); this.positional = validatePositional(positional); } @Override public <R> R visit(ArgsDefVisitor<R> visitor) { return visitor.visitArgsBlock(this); } @Override public Tuple2<ArgsBlockVal, Seq<String>> parse(Seq<String> args) throws ArgParseException { ParseState state = new ParseState(args, positional); while (state.hasNext()) { String arg = state.next(); if (arg.equals(OptionsUtil.POSITIONAL_SEPARATOR)) { state.skip(); state.parsePositionalArgs(); break; } Seq<String> parsedLongOpt = OptionsUtil.tryParseLongOpt(arg); if (!parsedLongOpt.isEmpty()) { String optName = parsedLongOpt.head(); OptionArgDef opt = longOptions.get(optName) .getOrElseThrow(() -> createUnexpectedOptException(optName, state)); state.parseOption(opt); continue; } Seq<String> parsedShortOpt = OptionsUtil.tryParseShortOpt(arg); if (!parsedShortOpt.isEmpty()) { String optName = parsedShortOpt.head(); OptionArgDef opt = shortOptions.get(optName) .getOrElseThrow(() -> createUnexpectedOptException(optName, state)); state.parseOption(opt); continue; } if (state.hasNextPositional()) { state.parsePositional(); continue; } break; // block is over } state.checkAllMandatoryPositionalPresent(); return state.getResult(); } private ArgParseException createUnexpectedOptException(String optName, ParseState state) { return new ArgParseException("Unexpected option '" + optName + "'", state.args); } private static class ParseState { private Seq<String> args; private Seq<PositionalArgDef> restPositionalDefs; private List<OptionArgVal> options = List.empty(); private List<PositionalArgVal> positionalVals = List.empty(); public ParseState(Seq<String> args, Seq<PositionalArgDef> positionalDefs) { this.args = args; restPositionalDefs = positionalDefs; } public boolean hasNext() { return args.nonEmpty(); } public String next() { return args.head(); } public void skip() { args = args.tail(); } public Seq<String> getArgs() { return args; } public void setArgs(Seq<String> args) { this.args = args; } private void parseOption(OptionArgDef opt) throws ArgParseException { Tuple2<OptionArgVal, Seq<String>> res = opt.parse(args); options = options.append(res._1); args = res._2; } public Tuple2<ArgsBlockVal, Seq<String>> getResult() { return Tuple.of(new ArgsBlockVal(options, positionalVals), args); } public boolean hasNextPositional() { return restPositionalDefs.nonEmpty(); } public void parsePositional() throws ArgParseException { Tuple2<PositionalArgVal, Seq<String>> res = restPositionalDefs.head().parse(args); restPositionalDefs = restPositionalDefs.tail(); positionalVals = positionalVals.append(res._1); args = res._2; } public void parsePositionalArgs() throws ArgParseException { while (hasNextPositional()) { parsePositional(); } } public void checkAllMandatoryPositionalPresent() throws ArgParseException { Seq<PositionalArgDef> restMandatoryArgs = restPositionalDefs.takeWhile(IS_MANDATORY); if (restMandatoryArgs.nonEmpty()) { String msg = "Expected positional parameters %s".formatted( Strings.seqToString(restMandatoryArgs.map(PositionalArgDef::getName))); throw new ArgParseException(msg, args); } } } }
924934fce641111c6ffeffe3b4a7569bcd3e331f
43669aab9f9fd22cbca4c6f2fdebfc8ed2159e05
/src/main/java/com/springboot/demo/entity/mongo/ProvinceYearGdp.java
2be05da4cee93641d8a11d47398934a7dddbd455
[]
no_license
zwj499/demo
6f593748136f7808e0c0e78556b8a52033723c9c
abeb939b13574c9f0cb7c8269ff3a9297fb2921b
refs/heads/master
2022-06-29T18:46:24.361464
2020-11-06T09:51:46
2020-11-06T09:51:46
244,869,809
0
0
null
2022-02-09T22:06:13
2020-03-04T10:19:35
Java
UTF-8
Java
false
false
1,062
java
package com.springboot.demo.entity.mongo; import org.apache.commons.lang3.StringUtils; /** * @author zwj * @since 1.0 */ public class ProvinceYearGdp { private String province; private Integer year; private Double value; private String unit = "万亿"; public String getProvince() { return province; } public void setProvince(String province) { this.province = province; } public Integer getYear() { return year; } public void setYear(Integer year) { this.year = year; } public Double getValue() { return value; } public void setValue(Double value) { this.value = value; } public String getUnit() { return unit; } public void setUnit(String unit) { this.unit = unit; } @Override public boolean equals(Object obj) { ProvinceYearGdp pyg = (ProvinceYearGdp) obj; return StringUtils.equals(this.province, pyg.getProvince()) && this.year.equals(pyg.getYear()); } }
08a5bfa917152b4c578e339d0a9ae66ee26e85e4
bbf5a755c31512dddc5999284921d394bf203e5c
/JavaExperiments/src/tyagiabhinav/leetcode/FourSum.java
daa38369ad8c4cc00e1354f495107454e0b2c37f
[ "MIT" ]
permissive
abhi007tyagi/JavaExperiments
e762a756ebe24724c5c5ac2cfc41c785c9072286
65fdd9bb982189babefbb9912cae9f1d3979731f
refs/heads/master
2022-02-26T07:45:34.240518
2022-02-11T16:11:28
2022-02-11T16:11:28
57,456,900
1
0
null
null
null
null
UTF-8
Java
false
false
1,082
java
package tyagiabhinav.leetcode; import java.util.*; public class FourSum { public static List<List<Integer>> fourSum(int[] nums, int target) { int size = nums.length; if (size < 4) return new ArrayList<>(); Arrays.sort(nums); Set<List<Integer>> set = new HashSet<>(); for (int r = 0; r < size - 3; r++) { for (int i = r + 1; i < size - 2; i++) { int j = i + 1; int k = size - 1; while (j < k) { int sum = nums[r] + nums[i] + nums[j] + nums[k]; if (sum == target) { set.add(Arrays.asList(nums[r], nums[i], nums[j++], nums[k--])); } else if (sum > target) { k--; } else { j++; } } } } return new ArrayList<>(set); } public static void main(String[] args) { int[] arr = {1, 0, -1, 0, -2, 2}; System.out.println(fourSum(arr, 0)); } }
a3806009e7d1ee3ec50a2ea0eac07bf32bcbead8
222967e9d652382604a856766ca0fedf7893db56
/wordnet-lib/src/main/java/kpaschal/wordnet/domain/semantics/path/RelationCAPath.java
063f6a5aaffdf648d5dc4a5ef8c058686f525253
[]
no_license
kpaschal/wordnet
0d5e61e928e94748840e12b3811bdb0572d44adb
94d925deb94a58ad752d8eac34fdcb5542bfe8c8
refs/heads/master
2020-03-19T07:42:43.808516
2018-06-16T03:54:59
2018-06-16T03:54:59
136,142,408
0
0
null
null
null
null
UTF-8
Java
false
false
1,537
java
package kpaschal.wordnet.domain.semantics.path; import kpaschal.wordnet.domain.semantics.node.RelationNode; import kpaschal.wordnet.domain.semantics.node.RelationNodeList; /** * * @author */ public class RelationCAPath extends RelationPath { int anchestorIndex_; public RelationCAPath() { this(new RelationNodeList()); } public RelationCAPath(RelationNodeList path) { this(path, -1); } public RelationCAPath(RelationNodeList path, int anchestorIndex) { super(path); anchestorIndex_ = anchestorIndex; } public RelationCAPath(RelationPath path) { this(path.getPath(), -1); } public RelationCAPath(RelationPath path, int anchestorIndex) { super(path.getPath()); anchestorIndex_ = anchestorIndex; } @Override public boolean hasCommonAnchestor() { return anchestorIndex_ != -1; } @Override public RelationNode getCommonAnchestor() { return hasCommonAnchestor() ? super.getPath().get(anchestorIndex_) : null; } public int getCommonAnchestorIndex() { return anchestorIndex_; } @Override public String toString() { StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < super.getPath().size(); i++) { strBuilder.append("->").append(super.getPath().get(i).toString()).append(anchestorIndex_ == i ? "(ca)" : ""); } return strBuilder.toString(); } }
173a20f6daefce2133fee66db02a5c5e3048f46d
c3ce97e279ef4dea8d76b3ad373d91517dcd8830
/gen/com/example/touchtest/BuildConfig.java
ca85f6f5394c5d15a41ba378fb331af19955271a
[]
no_license
ponJuice/TouchTest
67843a042ca980adbbc6d5263705da78c5a019e8
445a69da3bbeb5e645421e0c403729e3d20ca0e9
refs/heads/master
2021-01-20T17:32:49.388026
2016-07-08T07:11:57
2016-07-08T07:11:57
62,867,061
0
0
null
null
null
null
UTF-8
Java
false
false
163
java
/** Automatically generated file. DO NOT MODIFY */ package com.example.touchtest; public final class BuildConfig { public final static boolean DEBUG = true; }
ea230b9b877c791eccd3f53305b9c5d7cc232350
15e2cdbd472781c1d050dbef9cf811750ea0315d
/alfresco-integration/src/main/java/com/github/dynamicextensionsalfresco/osgi/Configuration.java
3c67d7832e0cac8bc8e8401c20ea5815466410de
[ "Apache-2.0" ]
permissive
tom-vandepoele/dynamic-extensions-for-alfresco
fd7453f8ab5d159f1a39e64269ee5259064296cf
82d21f6b85d6e09a81cdb26f7d270fccc009a676
refs/heads/master
2021-01-02T05:38:05.497394
2020-01-17T10:52:26
2020-01-17T10:52:26
239,513,196
0
0
Apache-2.0
2020-02-10T13:03:20
2020-02-10T13:03:19
null
UTF-8
Java
false
false
2,091
java
package com.github.dynamicextensionsalfresco.osgi; import java.io.File; /** * Value object representing the OSGi container configuration; */ public class Configuration { private static final String TMP_DIR = "java.io.tmpdir"; private boolean frameworkRestartEnabled = true; public boolean getFrameworkRestartEnabled() { return frameworkRestartEnabled; } public void setFrameworkRestartEnabled(boolean frameworkRestartEnabled) { this.frameworkRestartEnabled = frameworkRestartEnabled; } private boolean hotDeployEnabled = true; public boolean getHotDeployEnabled() { return hotDeployEnabled; } public void setHotDeployEnabled(boolean hotDeployEnabled) { this.hotDeployEnabled = hotDeployEnabled; } private boolean repositoryBundlesEnabled = true; public boolean getRepositoryBundlesEnabled() { return repositoryBundlesEnabled; } public void setRepositoryBundlesEnabled(boolean repositoryBundlesEnabled) { this.repositoryBundlesEnabled = repositoryBundlesEnabled; } private File storageDirectory = null; public File getStorageDirectory() { if(storageDirectory == null) { storageDirectory = createTempFile("bundles"); } return this.storageDirectory; } public void setStorageDirectory(File storageDirectory) { this.storageDirectory = storageDirectory; } private PackageCacheMode systemPackageCacheMode = null; public PackageCacheMode getSystemPackageCacheMode() { return this.systemPackageCacheMode; } public void setSystemPackageCacheMode(PackageCacheMode packageCacheMode) { this.systemPackageCacheMode = packageCacheMode; } private File systemPackageCache = null; public File getSystemPackageCache() { if(systemPackageCache == null) { systemPackageCache = createTempFile("system-packages.txt"); } return this.systemPackageCache; } private static File createTempFile(String child) { return new File(System.getProperty(TMP_DIR), child); } }
510cd9a80bae96bdff7d840566a09c838c93685d
3864b51de244041791ab1b896e9b56eef94477b6
/concurrency/src/main/java/ru/job4j/concurrency/training/threadfactory/Main.java
4b3885e5ee05f2f61b7a989a33a43c42d4fdeb62
[]
no_license
mankokolya/job4j_middle
0a7b88a27238b2df78f75acc10c386c37cb165d6
1c892a107b9b9ad8fab2a105f758e47a77db76a5
refs/heads/master
2023-01-27T21:24:03.803435
2020-12-17T21:41:07
2020-12-17T21:41:07
308,041,947
0
0
null
null
null
null
UTF-8
Java
false
false
537
java
package ru.job4j.concurrency.training.threadfactory; public class Main { public static void main(String[] args) { MyThreadFactory factory = new MyThreadFactory("MyThreadFactory"); Task task = new Task(); Thread thread; System.out.println("Starting the Threads\n"); for (int i = 0; i < 10; i++) { thread = factory.newThread(task); thread.start(); } System.out.println("Factory stats:\n"); System.out.printf("%s\n", factory.getStats()); } }
3988a01510d856df11c78b698e3f0afb0749aa6f
2aa86170dbaa2c08ef8bb3ba6af61cb124223bae
/worksheet/src/main/java/org/library/worksheet/cellstyles/WorkSheet.java
926606f56403a3a32c98c92dcbe6e76e3310ef6a
[ "Apache-2.0" ]
permissive
john-julius/worksheet
844f097185c504279a1a2b4f50fe7ba0f47e3fdc
85dcf7d64fe1cfa90bf1e6d4d3eb0768e6240aa6
refs/heads/master
2022-12-13T11:56:33.697372
2020-09-03T07:03:26
2020-09-03T07:03:26
292,296,848
0
0
Apache-2.0
2020-09-02T13:52:21
2020-09-02T13:52:21
null
UTF-8
Java
false
false
4,007
java
package org.library.worksheet.cellstyles; import android.content.Context; import org.library.worksheet.ExcelBookImpl; import java.io.IOException; import java.util.List; import java.util.Map; public class WorkSheet { private List<?> objects; private List<Map<String, List<?>>> map; private String path; private CellEnum title; private CellEnum cell; private CellEnum header; private CellEnum background; public WorkSheet(List<?> objects, List<Map<String, List<?>>> map, String path, CellEnum header, CellEnum title, CellEnum cell, CellEnum background) { this.objects = objects; this.path = path; this.title = title; this.cell = cell; this.header = header; this.background = background; this.map = map; } public WorkSheet(List<Map<String, List<?>>> map, String path, CellEnum header, CellEnum title, CellEnum cell, CellEnum background) { this.path = path; this.title = title; this.cell = cell; this.header = header; this.background = background; this.map = map; } public CellEnum getHeader() { return header; } public List<?> getObjects() { return objects; } public String getpath() { return path; } public CellEnum gettitle() { return title; } public CellEnum getcell() { return cell; } public CellEnum getBackground() { return background; } public List<Map<String, List<?>>> getMap() { return map; } public static class Builder { private List<?> objects; List<Map<String, List<?>>> map; private String path; private CellEnum title; private CellEnum cell; private CellEnum header; private CellEnum background; private ExcelBookImpl excelBook; public Builder(Context context, String path){ this.path = path; excelBook = new ExcelBookImpl(context); } public Builder(List<?> objects, List<Map<String, List<?>>> map, String path, CellEnum header, CellEnum title, CellEnum cell, CellEnum background) { this.objects = objects; this.path = path; this.title = title; this.cell = cell; this.header = header; this.background = background; this.map = map; } public Builder(String path) { this.path = path; } public Builder(List<?> objects, String path) { this.objects = objects; this.path = path; } public Builder(String path, List<Map<String, List<?>>> map) { this.map = map; this.path = path; } public Builder setSheets(List<Map<String, List<?>>> map) { this.map = map; return this; } public Builder setSheet(List<?> objects) { this.objects = objects; return this; } public Builder title(CellEnum title) { this.title = title; return this; } public Builder cell(CellEnum cell) { this.cell = cell; return this; } public Builder header(CellEnum header) { this.header = header; return this; } public Builder background(CellEnum background) { this.background = background; return this; } public WorkSheet writeSheet() throws IOException { excelBook.ExcelSheet(this.objects, path, header, title, cell); return new WorkSheet(objects, null, path, header, title, cell, background); } public WorkSheet writeSheets() throws IOException { excelBook.ExcelSheets(this.map , path, header, title, cell); return new WorkSheet( map, path, header, title, cell, background); } } }
[ "=" ]
=
f4947c90e9aa875d6f84e5eeb4162d3b5a1fcbcb
33f83d1bd89be63fe16036d1d5a2fb00c7c1cf28
/CustomAuthFailureHandler.java
13f78992eb9cfec408033598157ed1d639b41155
[ "Unlicense", "MIT" ]
permissive
nikhilg85/peerhuntr
ebbb6687919011e5655005139ff784ded294415e
44f258e66fa4216a1cedeac54379fa46b56e6670
refs/heads/master
2020-03-24T03:33:21.258173
2018-09-07T11:15:03
2018-09-07T11:15:03
142,424,146
0
0
null
null
null
null
UTF-8
Java
false
false
1,784
java
package com.infodart.peerhuntr.spring.config.security; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler; import org.springframework.stereotype.Component; import com.infodart.peerhuntr.dto.response.ResponseDTO; import net.sf.uadetector.ReadableUserAgent; import net.sf.uadetector.UserAgentStringParser; import net.sf.uadetector.service.UADetectorServiceFactory; @Component public class CustomAuthFailureHandler extends SimpleUrlAuthenticationFailureHandler { @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { String os= request.getHeader("os"); if(os!=null && (os.equals("iOS") || os.equals("Android"))) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); response.addHeader("WWW-Authenticate", "Basic realm= PEARHUNTR_REALM"); PrintWriter writer = response.getWriter(); String badCredential=exception.getMessage(); if(exception.getMessage().equals("Bad credentials")) { badCredential="Please enter valid emailId or password"; } writer.print("{\"message\":\""+badCredential+"\",\"statusCode\":\""+HttpServletResponse.SC_BAD_REQUEST+"\"}"); writer.flush(); writer.close(); } else getRedirectStrategy().sendRedirect(request, response, "/login?error=true"); } }
67e7aa7598bb48a5c0f765721c22220c644ba04b
64c495510a349aac8ca67cab242ca5d49c6cca9e
/app/src/main/java/com/nohttp/download/SyncDownloadExecutor.java
74e7047ab85e179c537001b1bed7caddca6781c2
[]
no_license
payencai/YunCheBao
6b303e1ccc74f85a168c948ddd796785758e010f
6870976cdda81a4cdf6835733c9d04b4c6c5478b
refs/heads/master
2020-04-15T18:11:04.702963
2019-06-20T10:50:48
2019-06-20T10:50:48
164,904,559
1
0
null
null
null
null
UTF-8
Java
false
false
1,312
java
/* * Copyright © Yan Zhenjie. All Rights Reserved * * 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.nohttp.download; import com.nohttp.NoHttp; /** * Created by Yan Zhenjie on 2016/10/12. */ public enum SyncDownloadExecutor { INSTANCE, AsyncRequestExecutor; private Downloader mDownloader; SyncDownloadExecutor() { mDownloader = new Downloader(NoHttp.getNetworkExecutor()); } /** * Start a download. * * @param what what. * @param downloadRequest {@link DownloadRequest}. * @param listener accept various download status callback.. */ public void execute(int what, DownloadRequest downloadRequest, DownloadListener listener) { mDownloader.download(what, downloadRequest, listener); } }
1576869afc307c94b19087116b99345358c855dc
0a4d4b808ee0724114e6153c1204de4e253c1dcb
/samples/135/a.java
8147f67541a809465a46d7c76b078bcdc667a4bb
[ "MIT" ]
permissive
yura-hb/sesame-sampled-pairs
543b19bf340f6a35681cfca1084349bd3eb8f853
33b061e3612a7b26198c17245c2835193f861151
refs/heads/main
2023-07-09T04:15:05.821444
2021-08-08T12:01:04
2021-08-08T12:01:04
393,947,142
0
0
null
null
null
null
UTF-8
Java
false
false
302
java
class Functions { /** Returns the identity function. */ // implementation is "fully variant"; E has become a "pass-through" type @SuppressWarnings("unchecked") public static &lt;E&gt; Function&lt;E, E&gt; identity() { return (Function&lt;E, E&gt;) IdentityFunction.INSTANCE; } }
e5f12317682a204af937311fa01846be0136186b
2c02b6ed8affe6a261a1692d386015e33185ada2
/src/galaxy/gabrielblink/galaxymambascore/Main.java
79d013521e9faf7e09486209e3a8934e9d5e2e1b
[]
no_license
GabrielAtlas/GalaxyMambaScoreBoard
885830bae7294ea4ebe927e5396b84af691e87dd
3c90f4db9cb7c9d1d6c6ea400ebc1a899662c122
refs/heads/master
2021-10-25T07:47:17.608680
2019-04-02T22:31:06
2019-04-02T22:31:06
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,559
java
package galaxy.gabrielblink.galaxymambascore; import java.io.File; import java.nio.charset.Charset; import org.black_ixx.playerpoints.PlayerPoints; import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; import com.google.common.io.Resources; import com.massivecraft.factions.entity.MPlayer; import galaxy.gabrielblink.GalaxyScoreBoard.ScoreBoard.ScoreBoard; import galaxy.gabrielblink.GalaxyScoreBoard.ScoreBoard.ScoreUpdater; import galaxy.gabrielblink.GalaxyScoreBoard.ScoreBoard.mcMMOScoreBoard; import galaxy.gabrielblink.licenseServer.Core; import net.milkbowl.vault.economy.Economy; public class Main extends JavaPlugin{ private static Economy econ = null; public static Main instance; private static PlayerPoints playerPoints; /** * Validate that we have access to PlayerPoints * * @return True if we have PlayerPoints, else false. */ private boolean hookPlayerPoints() { final Plugin plugin = this.getServer().getPluginManager().getPlugin("PlayerPoints"); playerPoints = PlayerPoints.class.cast(plugin); return playerPoints != null; } public static Economy getEconomy() { return econ; } /** * Accessor for other parts of your plugin to retrieve PlayerPoints. * * @return PlayerPoints plugin instance */ public static PlayerPoints getPlayerPoints() { return playerPoints; } public static Main getInstance() { return instance; } private boolean setupEconomy() { if (getServer().getPluginManager().getPlugin("Vault") == null) { return false; } RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class); if (rsp == null) { return false; } econ = rsp.getProvider(); return econ != null; } private void loadScoreTask() { Bukkit.getOnlinePlayers().forEach(p -> { MPlayer mp = MPlayer.get(p); if(mp.hasFaction()) { ScoreBoard.createScoreBoardWithFac(p); }else { ScoreBoard.createScoreBoardWithoutFac(p); } }); new ScoreUpdater().runTaskTimerAsynchronously(this, 40L, 100L); } public void onEnable() { if(!setupEconomy()) { Bukkit.getConsoleSender().sendMessage("§c[GalaxyMambaScoreBoard] Erro ao registrar o Vault / Economia do servidor, revise a pasta plugins."); super.onDisable(); } if(!hookPlayerPoints()) { Bukkit.getConsoleSender().sendMessage("§c[GalaxyMambaScoreBoard] Erro ao registrar o PlayerPoints, revise a pasta plugins."); super.onDisable(); } saveDefaultConfig(); try { File file = new File(getDataFolder() + File.separator, "config.yml"); String allText = Resources.toString(file.toURI().toURL(), Charset.forName("UTF-8")); getConfig().loadFromString(allText); } catch (Exception e) { e.printStackTrace(); } (Main.instance = this).saveDefaultConfig(); switch(Core.check("GalaxyMambaScoreBoard", Main.getPlugin(Main.class).getConfig().getString("Licenca"), Bukkit.getIp(), Bukkit.getPort())) { case INVALID_PLUGIN_NAME: Bukkit.getConsoleSender().sendMessage("§c[GalaxyMambaScoreBoard] INVALID_PLUGIN_NAME"); super.onDisable(); break; case INVALID_PORT: Bukkit.getConsoleSender().sendMessage("§c[GalaxyMambaScoreBoard] Porta inválida!"); super.onDisable(); break; case IP_ADRESS_INVALID: Bukkit.getConsoleSender().sendMessage("§c[GalaxyMambaScoreBoard] Endereço de IP inválido"); super.onDisable(); break; case LICENSE_INVALID: Bukkit.getConsoleSender().sendMessage("§c[GalaxyMambaScoreBoard] Licenca Inválida!"); super.onDisable(); break; case LICENSE_VALID: Bukkit.getConsoleSender().sendMessage("§a[GalaxyMambaScoreBoard] Obrigado por comprar conosco!."); ConfigurationManager.loadWorlds(); Bukkit.getPluginManager().registerEvents(new ScoreBoard(), this); Bukkit.getPluginManager().registerEvents(new mcMMOScoreBoard(), this); loadScoreTask(); break; case WEBSITE_ERROR: Bukkit.getConsoleSender().sendMessage("§c[GalaxyMambaScoreBoard] Conexão com o servidor de verificação ficou indisponivel , tente novamente mais tarde."); super.onDisable(); break; default: Bukkit.getConsoleSender().sendMessage("§c[GalaxyMambaScoreBoard] "+Core.check("GalaxyMambaScoreBoard", Main.getPlugin(Main.class).getConfig().getString("Licenca"), Bukkit.getIp(), Bukkit.getPort())); super.onDisable(); break; } } public void onDisable() { } }
cb56fc65c8c02450fe3b621834063beab5cb9c0b
dcea0c771ba995001c4b9ac8247e19b54908dde0
/app/src/main/java/fr/blahrache/hy/lapitchat/StatusActivity.java
8895ed1632e7dfb086d21513c488acab03c2841d
[]
no_license
Newstarstart/LapitChat
e31b54fc74a46ace8f116ad67e77e667548ecc45
2722b72d8ab04220f0e993cd1ebcad451cf98471
refs/heads/master
2021-05-13T14:44:38.060602
2018-01-09T01:20:20
2018-01-09T01:20:20
116,748,370
0
0
null
null
null
null
UTF-8
Java
false
false
3,402
java
package fr.blahrache.hy.lapitchat; import android.app.ProgressDialog; import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; public class StatusActivity extends AppCompatActivity { //Firebase private DatabaseReference mStatusDatabase; private FirebaseUser mCurrentUser; //The toolbar and the progress dialog private Toolbar mToolbar; private ProgressDialog mProgress; //The widgets of the activity private EditText mStatus; private Button mSavebtn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_status); //Firebase mCurrentUser = FirebaseAuth.getInstance().getCurrentUser(); String current_uid = mCurrentUser.getUid(); mStatusDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child(current_uid); //Show the toolbar mToolbar = (Toolbar) findViewById(R.id.status_app_bar); setSupportActionBar(mToolbar); getSupportActionBar().setTitle("Account Status"); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mStatus = (EditText) findViewById(R.id.status_input); mSavebtn = (Button) findViewById(R.id.status_save_btn); //Set the value of the status String status_value = getIntent().getStringExtra("status_value"); mStatus.setText(status_value); mSavebtn.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view) { String status = mStatus.getText().toString(); if(!TextUtils.isEmpty(status)){ //show the progress dialog mProgress = new ProgressDialog(StatusActivity.this); mProgress.setTitle("Saving changes"); mProgress.setMessage("Please waite wile we save the changes."); mProgress.show(); mStatusDatabase.child("status").setValue(status).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if(task.isSuccessful()){ mProgress.dismiss(); } else { mProgress.hide(); Toast.makeText(StatusActivity.this, "There wase some errors while saving changes.", Toast.LENGTH_LONG).show(); } } }); } else { Toast.makeText(StatusActivity.this, "The statsu cannot be empty.", Toast.LENGTH_LONG).show(); } } }); } }
628de63e2cffc3241f79b54ff6ac5b4dc863cc1f
4bed099200674d583d402abd6fab609233f543e9
/src/main/java/domain/Panel.java
6e7847cf302a2e2f0d668036b02eadd884449fc6
[]
no_license
joslarmorETSII/Acme-Style
fb37f4d5b71ad081f1db3f6f213c6f830000c94e
b122f98249aed2b5426fcd9c88d191a9600e47a4
refs/heads/master
2020-03-17T07:39:17.890495
2018-06-08T17:52:17
2018-06-08T17:52:17
133,407,362
0
1
null
null
null
null
UTF-8
Java
false
false
1,332
java
package domain; import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.SafeHtml; import javax.persistence.*; import javax.validation.Valid; import javax.validation.constraints.NotNull; import java.util.Collection; @Entity @Access(AccessType.PROPERTY) public class Panel extends DomainEntity{ // Constructors ---------------------------------------------------------------------- public Panel() {super(); } // Attributes ------------------------------------------------------------------------ private String name; @NotBlank @SafeHtml(whitelistType = SafeHtml.WhiteListType.NONE) public String getName() { return name; } public void setName(String name) { this.name = name; } // Relationships ---------------------------------------------------------------------- private User user; private Collection<Photo> photos; @Valid @ManyToOne(optional = false) public User getUser() { return user; } public void setUser(User user) { this.user = user; } @Valid @NotNull @OneToMany(mappedBy = "panel") public Collection<Photo> getPhotos() { return photos; } public void setPhotos(Collection<Photo> photos) { this.photos = photos; } }
b8bceeec742d3dbca15f529da7e8c1d6c138ef3f
4bc963faf108b50aa14a8b537cc513015ad92e13
/app/src/main/java/com/hwang/min81/fullcount/Inning.java
2abdb5b9e1bd98f49ffd1bff9a1687d1897a0808
[]
no_license
minhwang/smart_umpire_android
7315a7e65b78c752c51e5f31c583c4e3cb527530
df9b99dcfaa616d2405c41cb0a92fcf43d6191e1
refs/heads/master
2021-01-10T06:42:44.868483
2016-03-10T01:19:09
2016-03-10T01:19:09
43,754,114
0
0
null
null
null
null
UTF-8
Java
false
false
1,200
java
package com.hwang.min81.fullcount; /** * Created by min on 2016. 1. 9.. */ public class Inning { private int inning; private boolean isTop; public Inning() { setInning(0); setIsTop(true); } public Inning(int inning, boolean isTop) { setInning(inning); setIsTop(isTop); } public void next() { int currentInning = getInning(); boolean isTopCurrently = getIsTop(); if(isTopCurrently == false) { setInning(currentInning + 1); } setIsTop(!isTopCurrently); } public void prev() { int currentInning = getInning(); boolean isTopCurrently = getIsTop(); if(currentInning == 0 && isTopCurrently == true) { return; } else if(isTopCurrently == true) { setInning(currentInning - 1); } setIsTop(!isTopCurrently); } public boolean getIsTop() { return this.isTop; } public int getInning() { return this.inning; } private void setInning(int inning) { this.inning = inning; } private void setIsTop(boolean isTop) { this.isTop = isTop; } }
e79713ee1af5567fe9474c80fe89024e924b7d84
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/28/28_c8e504cb9ab788d14767124d4eefa23234a24a49/AntlrParserPlugin/28_c8e504cb9ab788d14767124d4eefa23234a24a49_AntlrParserPlugin_t.java
2a9c1065fd9d02c60ee51c06bc6b6f377c4f8a99
[]
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
106,847
java
/* * Copyright 2003-2007 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.codehaus.groovy.antlr; import antlr.RecognitionException; import antlr.TokenStreamException; import antlr.TokenStreamRecognitionException; import antlr.collections.AST; import com.thoughtworks.xstream.XStream; import org.codehaus.groovy.GroovyBugError; import org.codehaus.groovy.antlr.parser.GroovyLexer; import org.codehaus.groovy.antlr.parser.GroovyRecognizer; import org.codehaus.groovy.antlr.parser.GroovyTokenTypes; import org.codehaus.groovy.antlr.treewalker.*; import org.codehaus.groovy.ast.*; import org.codehaus.groovy.ast.expr.*; import org.codehaus.groovy.ast.stmt.*; import org.codehaus.groovy.control.CompilationFailedException; import org.codehaus.groovy.control.ParserPlugin; import org.codehaus.groovy.control.SourceUnit; import org.codehaus.groovy.syntax.*; import org.objectweb.asm.Opcodes; import java.io.*; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; /** * A parser plugin which adapts the JSR Antlr Parser to the Groovy runtime * * @author <a href="mailto:[email protected]">James Strachan</a> * @version $Revision$ */ public class AntlrParserPlugin extends ASTHelper implements ParserPlugin, GroovyTokenTypes { private AST ast; private ClassNode classNode; private String[] tokenNames; public Reduction parseCST(final SourceUnit sourceUnit, Reader reader) throws CompilationFailedException { ast = null; setController(sourceUnit); final SourceBuffer sourceBuffer = new SourceBuffer(); UnicodeEscapingReader unicodeReader = new UnicodeEscapingReader(reader,sourceBuffer); GroovyLexer lexer = new GroovyLexer(unicodeReader); unicodeReader.setLexer(lexer); GroovyRecognizer parser = GroovyRecognizer.make(lexer); parser.setSourceBuffer(sourceBuffer); tokenNames = parser.getTokenNames(); parser.setFilename(sourceUnit.getName()); // start parsing at the compilationUnit rule try { parser.compilationUnit(); } catch (TokenStreamRecognitionException tsre) { RecognitionException e = tsre.recog; SyntaxException se = new SyntaxException(e.getMessage(),e,e.getLine(),e.getColumn()); se.setFatal(true); sourceUnit.addError(se); } catch (RecognitionException e) { SyntaxException se = new SyntaxException(e.getMessage(),e,e.getLine(),e.getColumn()); se.setFatal(true); sourceUnit.addError(se); } catch (TokenStreamException e) { sourceUnit.addException(e); } ast = parser.getAST(); AntlrASTProcessor snippets = new AntlrASTProcessSnippets(); ast = snippets.process(ast); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { outputASTInVariousFormsIfNeeded(sourceUnit, sourceBuffer); return null; } }); return null; //new Reduction(Tpken.EOF); } private void outputASTInVariousFormsIfNeeded(SourceUnit sourceUnit, SourceBuffer sourceBuffer) { // straight xstream output of AST if ("xml".equals(System.getProperty("antlr.ast"))) { saveAsXML(sourceUnit.getName(), ast); } // 'pretty printer' output of AST if ("groovy".equals(System.getProperty("antlr.ast"))) { try { PrintStream out = new PrintStream(new FileOutputStream(sourceUnit.getName() + ".pretty.groovy")); Visitor visitor = new SourcePrinter(out,tokenNames); AntlrASTProcessor treewalker = new SourceCodeTraversal(visitor); treewalker.process(ast); } catch (FileNotFoundException e) { System.out.println("Cannot create " + sourceUnit.getName() + ".pretty.groovy"); } } // output AST in format suitable for opening in http://freemind.sourceforge.net // which is a really nice way of seeing the AST, folding nodes etc if ("mindmap".equals(System.getProperty("antlr.ast"))) { try { PrintStream out = new PrintStream(new FileOutputStream(sourceUnit.getName() + ".mm")); Visitor visitor = new MindMapPrinter(out,tokenNames); AntlrASTProcessor treewalker = new PreOrderTraversal(visitor); treewalker.process(ast); } catch (FileNotFoundException e) { System.out.println("Cannot create " + sourceUnit.getName() + ".mm"); } } // include original line/col info and source code on the mindmap output if ("extendedMindmap".equals(System.getProperty("antlr.ast"))) { try { PrintStream out = new PrintStream(new FileOutputStream(sourceUnit.getName() + ".mm")); Visitor visitor = new MindMapPrinter(out,tokenNames,sourceBuffer); AntlrASTProcessor treewalker = new PreOrderTraversal(visitor); treewalker.process(ast); } catch (FileNotFoundException e) { System.out.println("Cannot create " + sourceUnit.getName() + ".mm"); } } // html output of AST if ("html".equals(System.getProperty("antlr.ast"))) { try { PrintStream out = new PrintStream(new FileOutputStream(sourceUnit.getName() + ".html")); List v = new ArrayList(); v.add(new NodeAsHTMLPrinter(out,tokenNames)); v.add(new SourcePrinter(out,tokenNames)); Visitor visitors = new CompositeVisitor(v); AntlrASTProcessor treewalker = new SourceCodeTraversal(visitors); treewalker.process(ast); } catch (FileNotFoundException e) { System.out.println("Cannot create " + sourceUnit.getName() + ".html"); } } } private void saveAsXML(String name, AST ast) { XStream xstream = new XStream(); try { xstream.toXML(ast, new FileWriter(name + ".antlr.xml")); System.out.println("Written AST to " + name + ".antlr.xml"); } catch (Exception e) { System.out.println("Couldn't write to " + name + ".antlr.xml"); e.printStackTrace(); } } public ModuleNode buildAST(SourceUnit sourceUnit, ClassLoader classLoader, Reduction cst) throws ParserException { setClassLoader(classLoader); makeModule(); try { convertGroovy(ast); } catch (ASTRuntimeException e) { throw new ASTParserException(e.getMessage() + ". File: " + sourceUnit.getName(), e); } return output; } /** * Converts the Antlr AST to the Groovy AST */ protected void convertGroovy(AST node) { while (node != null) { int type = node.getType(); switch (type) { case PACKAGE_DEF: packageDef(node); break; case STATIC_IMPORT: case IMPORT: importDef(node); break; case CLASS_DEF: classDef(node); break; case INTERFACE_DEF: interfaceDef(node); break; case METHOD_DEF: methodDef(node); break; case ENUM_DEF: enumDef(node); break; case ANNOTATION_DEF: annotationDef(node); break; default: { Statement statement = statement(node); output.addStatement(statement); } } node = node.getNextSibling(); } } // Top level control structures //------------------------------------------------------------------------- protected void packageDef(AST packageDef) { AST node = packageDef.getFirstChild(); if (isType(ANNOTATIONS, node)) { node = node.getNextSibling(); } String name = qualifiedName(node); setPackageName(name); } protected void importDef(AST importNode) { boolean isStatic = importNode.getType() == STATIC_IMPORT; AST node = importNode.getFirstChild(); String alias = null; if (isType(LITERAL_as, node)) { //import is like "import Foo as Bar" node = node.getFirstChild(); AST aliasNode = node.getNextSibling(); alias = identifier(aliasNode); } if (node.getNumberOfChildren()==0) { String name = identifier(node); // import is like "import Foo" ClassNode type = ClassHelper.make(name); configureAST(type,importNode); importClass(type, name, alias); return; } AST packageNode = node.getFirstChild(); String packageName = qualifiedName(packageNode); AST nameNode = packageNode.getNextSibling(); if (isType(STAR, nameNode)) { if (isStatic) { // import is like "import static foo.Bar.*" // packageName is actually a className in this case ClassNode type = ClassHelper.make(packageName); configureAST(type, importNode); staticImportClassWithStar(type, packageName); } else { // import is like "import foo.*" importPackageWithStar(packageName); } if (alias!=null) throw new GroovyBugError( "imports like 'import foo.* as Bar' are not "+ "supported and should be caught by the grammar"); } else { String name = identifier(nameNode); if (isStatic) { // import is like "import static foo.Bar.method" // packageName is really class name in this case ClassNode type = ClassHelper.make(packageName); configureAST(type, importNode); staticImportMethodOrField(type, name, alias); } else { // import is like "import foo.Bar" ClassNode type = ClassHelper.make(packageName+"."+name); configureAST(type, importNode); importClass(type, name, alias); } } } protected void annotationDef(AST classDef) { List annotations = new ArrayList(); AST node = classDef.getFirstChild(); int modifiers = Opcodes.ACC_PUBLIC; if (isType(MODIFIERS, node)) { modifiers = modifiers(node, annotations, modifiers); checkNoInvalidModifier(classDef, "Annotation Definition", modifiers, Opcodes.ACC_SYNCHRONIZED, "synchronized"); node = node.getNextSibling(); } modifiers |= Opcodes.ACC_ABSTRACT | Opcodes.ACC_INTERFACE | Opcodes.ACC_ANNOTATION; String name = identifier(node); node = node.getNextSibling(); ClassNode superClass = ClassHelper.OBJECT_TYPE; GenericsType[] genericsType = null; if (isType(TYPE_PARAMETERS,node)) { genericsType = makeGenericsType(node); node = node.getNextSibling(); } ClassNode[] interfaces = ClassNode.EMPTY_ARRAY; if (isType(EXTENDS_CLAUSE, node)) { interfaces = interfaces(node); node = node.getNextSibling(); } addNewClassName(name); classNode = new ClassNode(dot(getPackageName(), name), modifiers, superClass, interfaces, null); classNode.addAnnotations(annotations); classNode.setGenericsTypes(genericsType); classNode.addInterface(ClassHelper.Annotation_TYPE); configureAST(classNode, classDef); assertNodeType(OBJBLOCK, node); objectBlock(node); output.addClass(classNode); classNode = null; } protected void interfaceDef(AST classDef) { List annotations = new ArrayList(); AST node = classDef.getFirstChild(); int modifiers = Opcodes.ACC_PUBLIC; if (isType(MODIFIERS, node)) { modifiers = modifiers(node, annotations, modifiers); checkNoInvalidModifier(classDef, "Interface", modifiers, Opcodes.ACC_SYNCHRONIZED, "synchronized"); node = node.getNextSibling(); } modifiers |= Opcodes.ACC_ABSTRACT | Opcodes.ACC_INTERFACE; String name = identifier(node); node = node.getNextSibling(); ClassNode superClass = ClassHelper.OBJECT_TYPE; GenericsType[] genericsType = null; if (isType(TYPE_PARAMETERS,node)) { genericsType = makeGenericsType(node); node = node.getNextSibling(); } ClassNode[] interfaces = ClassNode.EMPTY_ARRAY; if (isType(EXTENDS_CLAUSE, node)) { interfaces = interfaces(node); node = node.getNextSibling(); } addNewClassName(name); classNode = new ClassNode(dot(getPackageName(), name), modifiers, superClass, interfaces, null); classNode.addAnnotations(annotations); classNode.setGenericsTypes(genericsType); configureAST(classNode, classDef); assertNodeType(OBJBLOCK, node); objectBlock(node); output.addClass(classNode); classNode = null; } protected void classDef(AST classDef) { List annotations = new ArrayList(); AST node = classDef.getFirstChild(); int modifiers = Opcodes.ACC_PUBLIC; if (isType(MODIFIERS, node)) { modifiers = modifiers(node, annotations, modifiers); checkNoInvalidModifier(classDef, "Class", modifiers, Opcodes.ACC_SYNCHRONIZED, "synchronized"); node = node.getNextSibling(); } String name = identifier(node); node = node.getNextSibling(); GenericsType[] genericsType = null; if (isType(TYPE_PARAMETERS,node)) { genericsType = makeGenericsType(node); node = node.getNextSibling(); } ClassNode superClass = null; if (isType(EXTENDS_CLAUSE, node)) { superClass = makeTypeWithArguments(node); node = node.getNextSibling(); } ClassNode[] interfaces = ClassNode.EMPTY_ARRAY; if (isType(IMPLEMENTS_CLAUSE, node)) { interfaces = interfaces(node); node = node.getNextSibling(); } // TODO read mixins MixinNode[] mixins = {}; addNewClassName(name); classNode = new ClassNode(dot(getPackageName(), name), modifiers, superClass, interfaces, mixins); classNode.addAnnotations(annotations); classNode.setGenericsTypes(genericsType); configureAST(classNode, classDef); assertNodeType(OBJBLOCK, node); objectBlock(node); output.addClass(classNode); classNode = null; } protected void objectBlock(AST objectBlock) { for (AST node = objectBlock.getFirstChild(); node != null; node = node.getNextSibling()) { int type = node.getType(); switch (type) { case OBJBLOCK: objectBlock(node); break; case ANNOTATION_FIELD_DEF: case METHOD_DEF: methodDef(node); break; case CTOR_IDENT: constructorDef(node); break; case VARIABLE_DEF: fieldDef(node); break; case STATIC_INIT: staticInit(node); break; case INSTANCE_INIT: objectInit(node); break; case ENUM_DEF: enumDef(node); break; case ENUM_CONSTANT_DEF: enumConstantDef(node); break; default: unknownAST(node); } } } protected void enumDef(AST enumNode) { assertNodeType(ENUM_DEF, enumNode); List annotations = new ArrayList(); AST node = enumNode.getFirstChild(); int modifiers = Opcodes.ACC_PUBLIC; if (isType(MODIFIERS, node)) { modifiers = modifiers(node,annotations,modifiers); node = node.getNextSibling(); } String name = identifier(node); node = node.getNextSibling(); ClassNode[] interfaces = interfaces(node); node = node.getNextSibling(); ClassNode enumClass = EnumHelper.makeEnumNode(dot(getPackageName(),name),modifiers,interfaces,classNode); ClassNode oldNode = classNode; classNode = enumClass; assertNodeType(OBJBLOCK, node); objectBlock(node); classNode = oldNode; output.addClass(enumClass); } protected void enumConstantDef(AST node) { assertNodeType(ENUM_CONSTANT_DEF, node); AST element = node.getFirstChild(); if (isType(ANNOTATIONS,element)) { element = element.getNextSibling(); } String identifier = identifier(element); Expression init = null; element = element.getNextSibling(); if (element!=null) init = expression(element); EnumHelper.addEnumConstant(classNode, identifier, init); } protected void throwsList(AST node,List list) { String name; if (isType(DOT, node)) { name = qualifiedName(node); } else { name = identifier(node); } ClassNode exception = ClassHelper.make(name); configureAST(exception, node); list.add(exception); AST next = node.getNextSibling(); if (next!=null) throwsList(next, list); } protected void methodDef(AST methodDef) { List annotations = new ArrayList(); AST node = methodDef.getFirstChild(); GenericsType[] generics=null; if (isType(TYPE_PARAMETERS, node)) { generics = makeGenericsType(node); node = node.getNextSibling(); } int modifiers = Opcodes.ACC_PUBLIC; if (isType(MODIFIERS, node)) { modifiers = modifiers(node, annotations, modifiers); checkNoInvalidModifier(methodDef, "Method", modifiers, Opcodes.ACC_VOLATILE, "volatile"); node = node.getNextSibling(); } if (isAnInterface()) { modifiers |= Opcodes.ACC_ABSTRACT; } ClassNode returnType = null; if (isType(TYPE, node)) { returnType = makeTypeWithArguments(node); node = node.getNextSibling(); } String name = identifier(node); if (classNode != null && !classNode.isAnnotationDefinition()) { if (classNode.getNameWithoutPackage().equals(name)) { if (isAnInterface()) { throw new ASTRuntimeException(methodDef, "Constructor not permitted within an interface."); } throw new ASTRuntimeException(methodDef, "Invalid constructor format. Remove '" + returnType.getName() + "' as the return type if you want a constructor, or use a different name if you want a method."); } } node = node.getNextSibling(); Parameter[] parameters = Parameter.EMPTY_ARRAY; ClassNode[] exceptions= ClassNode.EMPTY_ARRAY; if (classNode==null || !classNode.isAnnotationDefinition()) { assertNodeType(PARAMETERS, node); parameters = parameters(node); if (parameters==null) parameters = Parameter.EMPTY_ARRAY; node = node.getNextSibling(); if (isType(LITERAL_throws, node)) { AST throwsNode = node.getFirstChild(); List exceptionList = new ArrayList(); throwsList(throwsNode, exceptionList); exceptions = (ClassNode[]) exceptionList.toArray(exceptions); node = node.getNextSibling(); } } boolean hasAnnotationDefault = false; Statement code = null; if ((modifiers & Opcodes.ACC_ABSTRACT) == 0) { if (node==null) { throw new ASTRuntimeException(methodDef, "You defined a method without body. Try adding a body, or declare it abstract."); } assertNodeType(SLIST, node); code = statementList(node); } else if (node!=null && classNode.isAnnotationDefinition()) { code = statement(node); hasAnnotationDefault = true; } MethodNode methodNode = new MethodNode(name, modifiers, returnType, parameters, exceptions, code); methodNode.addAnnotations(annotations); methodNode.setGenericsTypes(generics); methodNode.setAnnotationDefault(hasAnnotationDefault); configureAST(methodNode, methodDef); if (classNode != null) { classNode.addMethod(methodNode); } else { output.addMethod(methodNode); } } private void checkNoInvalidModifier(AST node, String nodeType, int modifiers, int modifier, String modifierText) { if ((modifiers & modifier) != 0) { throw new ASTRuntimeException(node, nodeType + " has an incorrect modifier '" + modifierText + "'."); } } private boolean isAnInterface() { return classNode != null && (classNode.getModifiers() & Opcodes.ACC_INTERFACE) > 0; } protected void staticInit(AST staticInit) { BlockStatement code = (BlockStatement) statementList(staticInit); classNode.addStaticInitializerStatements(code.getStatements(),false); } protected void objectInit(AST init) { BlockStatement code = (BlockStatement) statementList(init); classNode.addObjectInitializerStatements(code); } protected void constructorDef(AST constructorDef) { List annotations = new ArrayList(); AST node = constructorDef.getFirstChild(); int modifiers = Opcodes.ACC_PUBLIC; if (isType(MODIFIERS, node)) { modifiers = modifiers(node, annotations, modifiers); node = node.getNextSibling(); } assertNodeType(PARAMETERS, node); Parameter[] parameters = parameters(node); if (parameters == null) parameters = Parameter.EMPTY_ARRAY; node = node.getNextSibling(); ClassNode[] exceptions= ClassNode.EMPTY_ARRAY; if (isType(LITERAL_throws, node)) { AST throwsNode = node.getFirstChild(); List exceptionList = new ArrayList(); throwsList(throwsNode, exceptionList); exceptions = (ClassNode[]) exceptionList.toArray(exceptions); node = node.getNextSibling(); } assertNodeType(SLIST, node); Statement code = statementList(node); ConstructorNode constructorNode = classNode.addConstructor(modifiers, parameters, exceptions, code); constructorNode.addAnnotations(annotations); configureAST(constructorNode, constructorDef); } protected void fieldDef(AST fieldDef) { List annotations = new ArrayList(); AST node = fieldDef.getFirstChild(); int modifiers = 0; if (isType(MODIFIERS, node)) { modifiers = modifiers(node, annotations, modifiers); node = node.getNextSibling(); } if (classNode.isInterface()) { modifiers |= Opcodes.ACC_STATIC | Opcodes.ACC_FINAL; if ( (modifiers & (Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED)) == 0) { modifiers |= Opcodes.ACC_PUBLIC; } } ClassNode type = null; if (isType(TYPE, node)) { type = makeTypeWithArguments(node); node = node.getNextSibling(); } String name = identifier(node); node = node.getNextSibling(); Expression initialValue = null; if (node != null) { assertNodeType(ASSIGN, node); initialValue = expression(node.getFirstChild()); } if (classNode.isInterface() && initialValue == null && type != null) { if (type==ClassHelper.int_TYPE) { initialValue = new ConstantExpression(Integer.valueOf(0)); } else if (type==ClassHelper.long_TYPE) { initialValue = new ConstantExpression(new Long(0L)); } else if (type==ClassHelper.double_TYPE) { initialValue = new ConstantExpression(new Double(0.0)); } else if (type==ClassHelper.float_TYPE) { initialValue = new ConstantExpression(new Float(0.0F)); } else if (type==ClassHelper.boolean_TYPE) { initialValue = ConstantExpression.FALSE; } else if (type==ClassHelper.short_TYPE) { initialValue = new ConstantExpression(new Short((short) 0)); } else if (type==ClassHelper.byte_TYPE) { initialValue = new ConstantExpression(new Byte((byte) 0)); } else if (type==ClassHelper.char_TYPE) { initialValue = new ConstantExpression(new Character((char) 0)); } } FieldNode fieldNode = new FieldNode(name, modifiers, type, classNode, initialValue); fieldNode.addAnnotations(annotations); configureAST(fieldNode, fieldDef); if (!hasVisibility(modifiers)) { // let's set the modifiers on the field int fieldModifiers = 0; int flags = Opcodes.ACC_STATIC | Opcodes.ACC_TRANSIENT | Opcodes.ACC_VOLATILE | Opcodes.ACC_FINAL; if (!hasVisibility(modifiers)) { modifiers |= Opcodes.ACC_PUBLIC; fieldModifiers |= Opcodes.ACC_PRIVATE; } // let's pass along any other modifiers we need fieldModifiers |= (modifiers & flags); fieldNode.setModifiers(fieldModifiers); fieldNode.setSynthetic(true); // in the case that there is already a field, we would // like to use that field, instead of the default field // for the property FieldNode storedNode = classNode.getDeclaredField(fieldNode.getName()); if (storedNode!=null && !classNode.hasProperty(name)) { fieldNode = storedNode; // we remove it here, because addProperty will add it // again and we want to avoid it showing up multiple // times in the fields list. classNode.getFields().remove(storedNode); } PropertyNode propertyNode = new PropertyNode(fieldNode, modifiers, null, null); configureAST(propertyNode, fieldDef); classNode.addProperty(propertyNode); } else { fieldNode.setModifiers(modifiers); // if there is a property of that name, then a field of that // name already exists, which means this new field here should // be used instead of the field the property originally has. PropertyNode pn = classNode.getProperty(name); if (pn!=null && pn.getField().isSynthetic()) { classNode.getFields().remove(pn.getField()); pn.setField(fieldNode); } classNode.addField(fieldNode); } } protected ClassNode[] interfaces(AST node) { List interfaceList = new ArrayList(); for (AST implementNode = node.getFirstChild(); implementNode != null; implementNode = implementNode.getNextSibling()) { interfaceList.add(makeTypeWithArguments(implementNode)); } ClassNode[] interfaces = ClassNode.EMPTY_ARRAY; if (!interfaceList.isEmpty()) { interfaces = new ClassNode[interfaceList.size()]; interfaceList.toArray(interfaces); } return interfaces; } protected Parameter[] parameters(AST parametersNode) { AST node = parametersNode.getFirstChild(); if (node == null) { if (isType(IMPLICIT_PARAMETERS, parametersNode)) return Parameter.EMPTY_ARRAY; return null; } else { List parameters = new ArrayList(); do { parameters.add(parameter(node)); node = node.getNextSibling(); } while (node != null); Parameter[] answer = new Parameter[parameters.size()]; parameters.toArray(answer); return answer; } } protected Parameter parameter(AST paramNode) { List annotations = new ArrayList(); boolean variableParameterDef = isType(VARIABLE_PARAMETER_DEF,paramNode); AST node = paramNode.getFirstChild(); int modifiers = 0; if (isType(MODIFIERS, node)) { modifiers = modifiers(node, annotations, modifiers); node = node.getNextSibling(); } ClassNode type = ClassHelper.DYNAMIC_TYPE; if (isType(TYPE, node)) { type = makeTypeWithArguments(node); if (variableParameterDef) type = type.makeArray(); node = node.getNextSibling(); } String name = identifier(node); node = node.getNextSibling(); VariableExpression leftExpression = new VariableExpression(name, type); configureAST(leftExpression, paramNode); Parameter parameter = null; if (node != null) { assertNodeType(ASSIGN, node); Expression rightExpression = expression(node.getFirstChild()); if (isAnInterface()) { throw new ASTRuntimeException(node, "Cannot specify default value for method parameter '" + name + " = " + rightExpression.getText() + "' inside an interface"); } parameter = new Parameter(type, name, rightExpression); } else parameter = new Parameter(type, name); configureAST(parameter, paramNode); parameter.addAnnotations(annotations); return parameter; } protected int modifiers(AST modifierNode, List annotations, int defaultModifiers) { assertNodeType(MODIFIERS, modifierNode); boolean access = false; int answer = 0; for (AST node = modifierNode.getFirstChild(); node != null; node = node.getNextSibling()) { int type = node.getType(); switch (type) { case STATIC_IMPORT: // ignore break; // annotations case ANNOTATION: annotations.add(annotation(node)); break; // core access scope modifiers case LITERAL_private: answer = setModifierBit(node, answer, Opcodes.ACC_PRIVATE); access = setAccessTrue(node, access); break; case LITERAL_protected: answer = setModifierBit(node, answer, Opcodes.ACC_PROTECTED); access = setAccessTrue(node, access); break; case LITERAL_public: answer = setModifierBit(node, answer, Opcodes.ACC_PUBLIC); access = setAccessTrue(node, access); break; // other modifiers case ABSTRACT: answer = setModifierBit(node, answer, Opcodes.ACC_ABSTRACT); break; case FINAL: answer = setModifierBit(node, answer, Opcodes.ACC_FINAL); break; case LITERAL_native: answer = setModifierBit(node, answer, Opcodes.ACC_NATIVE); break; case LITERAL_static: answer = setModifierBit(node, answer, Opcodes.ACC_STATIC); break; case STRICTFP: answer = setModifierBit(node, answer, Opcodes.ACC_STRICT); break; case LITERAL_synchronized: answer = setModifierBit(node, answer, Opcodes.ACC_SYNCHRONIZED); break; case LITERAL_transient: answer = setModifierBit(node, answer, Opcodes.ACC_TRANSIENT); break; case LITERAL_volatile: answer = setModifierBit(node, answer, Opcodes.ACC_VOLATILE); break; default: unknownAST(node); } } if (!access) { answer |= defaultModifiers; } return answer; } protected boolean setAccessTrue(AST node, boolean access) { if (!access) { return true; } else { throw new ASTRuntimeException(node, "Cannot specify modifier: " + node.getText() + " when access scope has already been defined"); } } protected int setModifierBit(AST node, int answer, int bit) { if ((answer & bit) != 0) { throw new ASTRuntimeException(node, "Cannot repeat modifier: " + node.getText()); } return answer | bit; } protected AnnotationNode annotation(AST annotationNode) { AST node = annotationNode.getFirstChild(); String name = qualifiedName(node); AnnotationNode annotatedNode = new AnnotationNode(ClassHelper.make(name)); configureAST(annotatedNode, node); while (true) { node = node.getNextSibling(); if (isType(ANNOTATION_MEMBER_VALUE_PAIR, node)) { AST memberNode = node.getFirstChild(); String param = identifier(memberNode); Expression expression = expression(memberNode.getNextSibling()); annotatedNode.addMember(param, expression); } else { break; } } return annotatedNode; } // Statements //------------------------------------------------------------------------- protected Statement statement(AST node) { Statement statement = null; int type = node.getType(); switch (type) { case SLIST: case LITERAL_finally: statement = statementList(node); break; case METHOD_CALL: statement = methodCall(node); break; case VARIABLE_DEF: statement = variableDef(node); break; case LABELED_STAT: statement = labelledStatement(node); break; case LITERAL_assert: statement = assertStatement(node); break; case LITERAL_break: statement = breakStatement(node); break; case LITERAL_continue: statement = continueStatement(node); break; case LITERAL_if: statement = ifStatement(node); break; case LITERAL_for: statement = forStatement(node); break; case LITERAL_return: statement = returnStatement(node); break; case LITERAL_synchronized: statement = synchronizedStatement(node); break; case LITERAL_switch: statement = switchStatement(node); break; case LITERAL_try: statement = tryStatement(node); break; case LITERAL_throw: statement = throwStatement(node); break; case LITERAL_while: statement = whileStatement(node); break; default: statement = new ExpressionStatement(expression(node)); } if (statement != null) { configureAST(statement, node); } return statement; } protected Statement statementList(AST code) { Statement st = statementListNoChild(code.getFirstChild()); if (st.getLineNumber()==-1) configureAST(st,code); return st; } protected Statement statementListNoChild(AST node) { BlockStatement block = new BlockStatement(); // no need to configureAST(block,node); as node is probably null for (; node != null; node = node.getNextSibling()) { block.addStatement(statement(node)); } return block; } protected Statement assertStatement(AST assertNode) { AST node = assertNode.getFirstChild(); BooleanExpression booleanExpression = booleanExpression(node); Expression messageExpression = null; node = node.getNextSibling(); if (node != null) { messageExpression = expression(node); } else { messageExpression = ConstantExpression.NULL; } AssertStatement assertStatement = new AssertStatement(booleanExpression, messageExpression); configureAST(assertStatement, assertNode); return assertStatement; } protected Statement breakStatement(AST node) { BreakStatement breakStatement = new BreakStatement(label(node)); configureAST(breakStatement, node); return breakStatement; } protected Statement continueStatement(AST node) { ContinueStatement continueStatement = new ContinueStatement(label(node)); configureAST(continueStatement, node); return continueStatement; } protected Statement forStatement(AST forNode) { AST inNode = forNode.getFirstChild(); Expression collectionExpression; Parameter forParameter; if (isType(CLOSURE_LIST, inNode)) { ClosureListExpression clist = closureListExpression(inNode); int size = clist.getExpressions().size(); if (size != 3) { throw new ASTRuntimeException(inNode, "3 expressions are required for the classic for loop, you gave " + size); } collectionExpression = clist; forParameter = ForStatement.FOR_LOOP_DUMMY; } else { AST variableNode = inNode.getFirstChild(); AST collectionNode = variableNode.getNextSibling(); ClassNode type = ClassHelper.OBJECT_TYPE; if (isType(VARIABLE_DEF, variableNode)) { AST node = variableNode.getFirstChild(); // skip the final modifier if it's present if (isType(MODIFIERS, node)) { int modifiersMask = modifiers(node, new ArrayList(), 0); // only final modifier allowed if ((modifiersMask & ~Opcodes.ACC_FINAL) != 0) { throw new ASTRuntimeException(node, "Only the 'final' modifier is allowed in front of the for loop variable."); } node = node.getNextSibling(); } type = makeTypeWithArguments(node); variableNode = node.getNextSibling(); } String variable = identifier(variableNode); collectionExpression = expression(collectionNode); forParameter = new Parameter(type, variable); configureAST(forParameter, variableNode); } final AST node = inNode.getNextSibling(); Statement block; if (isType(SEMI, node)) { block = EmptyStatement.INSTANCE; } else { block = statement(node); } ForStatement forStatement = new ForStatement(forParameter, collectionExpression, block); configureAST(forStatement, forNode); return forStatement; } protected Statement ifStatement(AST ifNode) { AST node = ifNode.getFirstChild(); assertNodeType(EXPR, node); BooleanExpression booleanExpression = booleanExpression(node); node = node.getNextSibling(); Statement ifBlock = statement(node); Statement elseBlock = EmptyStatement.INSTANCE; node = node.getNextSibling(); if (node != null) { elseBlock = statement(node); } IfStatement ifStatement = new IfStatement(booleanExpression, ifBlock, elseBlock); configureAST(ifStatement, ifNode); return ifStatement; } protected Statement labelledStatement(AST labelNode) { AST node = labelNode.getFirstChild(); String label = identifier(node); Statement statement = statement(node.getNextSibling()); statement.setStatementLabel(label); return statement; } protected Statement methodCall(AST code) { Expression expression = methodCallExpression(code); ExpressionStatement expressionStatement = new ExpressionStatement(expression); configureAST(expressionStatement, code); return expressionStatement; } protected Expression declarationExpression(AST variableDef) { AST node = variableDef.getFirstChild(); ClassNode type = null; List annotations = new ArrayList(); if (isType(MODIFIERS, node)) { // force check of modifier conflicts modifiers(node, annotations, 0); node = node.getNextSibling(); } if (isType(TYPE, node)) { type = makeTypeWithArguments(node); node = node.getNextSibling(); } Expression leftExpression; Expression rightExpression = ConstantExpression.NULL; AST right; if (isType(ASSIGN, node)) { node = node.getFirstChild(); AST left = node.getFirstChild(); ArgumentListExpression alist = new ArgumentListExpression(); for (AST varDef = left; varDef!=null; varDef=varDef.getNextSibling()) { assertNodeType(VARIABLE_DEF, varDef); DeclarationExpression de = (DeclarationExpression) declarationExpression(varDef); alist.addExpression(de.getVariableExpression()); } leftExpression = alist; right = node.getNextSibling(); if (right != null) rightExpression = expression(right); } else { String name = identifier(node); leftExpression = new VariableExpression(name, type); right = node.getNextSibling(); if (right != null) { assertNodeType(ASSIGN, right); rightExpression = expression(right.getFirstChild()); } } configureAST(leftExpression, node); Token token = makeToken(Types.ASSIGN, variableDef); DeclarationExpression expression = new DeclarationExpression(leftExpression, token, rightExpression); configureAST(expression, variableDef); ExpressionStatement expressionStatement = new ExpressionStatement(expression); configureAST(expressionStatement, variableDef); return expression; } protected Statement variableDef(AST variableDef) { ExpressionStatement expressionStatement = new ExpressionStatement(declarationExpression(variableDef)); configureAST(expressionStatement, variableDef); return expressionStatement; } protected Statement returnStatement(AST node) { AST exprNode = node.getFirstChild(); // This will pick up incorrect sibling node if 'node' is a plain 'return' // //if (exprNode == null) { // exprNode = node.getNextSibling(); //} if (exprNode != null) { Expression expression = expression(exprNode); if (expression instanceof ConstantExpression) { ConstantExpression constantExpr = (ConstantExpression) expression; if (constantExpr.getValue() == null) { return ReturnStatement.RETURN_NULL_OR_VOID; } } ReturnStatement returnStatement = new ReturnStatement(expression); configureAST(returnStatement, node); return returnStatement; } else { return ReturnStatement.RETURN_NULL_OR_VOID; } } protected Statement switchStatement(AST switchNode) { AST node = switchNode.getFirstChild(); Expression expression = expression(node); Statement defaultStatement = EmptyStatement.INSTANCE; List list = new ArrayList(); for (node = node.getNextSibling(); isType(CASE_GROUP, node); node = node.getNextSibling()) { AST child = node.getFirstChild(); if (isType(LITERAL_case, child)) { List cases = new LinkedList(); // default statement can be grouped with previous case defaultStatement = caseStatements(child, cases); list.addAll(cases); } else { defaultStatement = statement(child.getNextSibling()); } } if (node != null) { unknownAST(node); } SwitchStatement switchStatement = new SwitchStatement(expression, list, defaultStatement); configureAST(switchStatement, switchNode); return switchStatement; } protected Statement caseStatements(AST node, List cases) { List expressions = new LinkedList(); Statement statement = EmptyStatement.INSTANCE; Statement defaultStatement = EmptyStatement.INSTANCE; AST nextSibling = node; do { Expression expression = expression(nextSibling.getFirstChild()); expressions.add(expression); nextSibling = nextSibling.getNextSibling(); } while (isType(LITERAL_case, nextSibling)); if (nextSibling != null) { if (isType(LITERAL_default, nextSibling)) { defaultStatement = statement(nextSibling.getNextSibling()); statement = EmptyStatement.INSTANCE; } else { statement = statement(nextSibling); } } for (Iterator iterator = expressions.iterator(); iterator.hasNext();) { Expression expr = (Expression) iterator.next(); Statement stmt; if (iterator.hasNext()) { stmt = new CaseStatement(expr,EmptyStatement.INSTANCE); } else { stmt = new CaseStatement(expr,statement); } configureAST(stmt,node); cases.add(stmt); } return defaultStatement; } protected Statement synchronizedStatement(AST syncNode) { AST node = syncNode.getFirstChild(); Expression expression = expression(node); Statement code = statement(node.getNextSibling()); SynchronizedStatement synchronizedStatement = new SynchronizedStatement(expression, code); configureAST(synchronizedStatement, syncNode); return synchronizedStatement; } protected Statement throwStatement(AST node) { AST expressionNode = node.getFirstChild(); if (expressionNode == null) { expressionNode = node.getNextSibling(); } if (expressionNode == null) { throw new ASTRuntimeException(node, "No expression available"); } ThrowStatement throwStatement = new ThrowStatement(expression(expressionNode)); configureAST(throwStatement, node); return throwStatement; } protected Statement tryStatement(AST tryStatementNode) { AST tryNode = tryStatementNode.getFirstChild(); Statement tryStatement = statement(tryNode); Statement finallyStatement = EmptyStatement.INSTANCE; AST node = tryNode.getNextSibling(); // let's do the catch nodes List catches = new ArrayList(); for (; node != null && isType(LITERAL_catch, node); node = node.getNextSibling()) { catches.add(catchStatement(node)); } if (isType(LITERAL_finally, node)) { finallyStatement = statement(node); node = node.getNextSibling(); } TryCatchStatement tryCatchStatement = new TryCatchStatement(tryStatement, finallyStatement); configureAST(tryCatchStatement, tryStatementNode); for (Iterator iter = catches.iterator(); iter.hasNext();) { CatchStatement statement = (CatchStatement) iter.next(); tryCatchStatement.addCatch(statement); } return tryCatchStatement; } protected CatchStatement catchStatement(AST catchNode) { AST node = catchNode.getFirstChild(); Parameter parameter = parameter(node); ClassNode exceptionType = parameter.getType(); String variable = parameter.getName(); node = node.getNextSibling(); Statement code = statement(node); Parameter catchParameter = new Parameter(exceptionType,variable); CatchStatement answer = new CatchStatement(catchParameter, code); configureAST(answer, catchNode); return answer; } protected Statement whileStatement(AST whileNode) { AST node = whileNode.getFirstChild(); assertNodeType(EXPR, node); // TODO remove this once we support declarations in the while condition if (isType(VARIABLE_DEF, node.getFirstChild())) { throw new ASTRuntimeException(whileNode, "While loop condition contains a declaration; this is currently unsupported."); } BooleanExpression booleanExpression = booleanExpression(node); node = node.getNextSibling(); Statement block; if (isType(SEMI, node)) { block = EmptyStatement.INSTANCE; } else { block = statement(node); } WhileStatement whileStatement = new WhileStatement(booleanExpression, block); configureAST(whileStatement, whileNode); return whileStatement; } // Expressions //------------------------------------------------------------------------- protected Expression expression(AST node) { return expression(node,false); } protected Expression expression(AST node, boolean convertToConstant) { Expression expression = expressionSwitch(node); if (convertToConstant && expression instanceof VariableExpression) { // a method name can never be a VariableExprssion, so it must converted // to a ConstantExpression then. This is needed as the expression // method doesn't know we want a ConstantExpression instead of a // VariableExpression VariableExpression ve = (VariableExpression) expression; if (!ve.isThisExpression() && !ve.isSuperExpression()) { expression = new ConstantExpression(ve.getName()); } } configureAST(expression, node); return expression; } protected Expression expressionSwitch(AST node) { int type = node.getType(); switch (type) { case EXPR: return expression(node.getFirstChild()); case ELIST: return expressionList(node); case SLIST: return blockExpression(node); case CLOSABLE_BLOCK: return closureExpression(node); case SUPER_CTOR_CALL: return specialConstructorCallExpression(node,ClassNode.SUPER); case METHOD_CALL: return methodCallExpression(node); case LITERAL_new: return constructorCallExpression(node); case CTOR_CALL: return specialConstructorCallExpression(node,ClassNode.THIS); case QUESTION: case ELVIS_OPERATOR: return ternaryExpression(node); case OPTIONAL_DOT: case SPREAD_DOT: case DOT: return dotExpression(node); case IDENT: case LITERAL_boolean: case LITERAL_byte: case LITERAL_char: case LITERAL_double: case LITERAL_float: case LITERAL_int: case LITERAL_long: case LITERAL_short: case LITERAL_void: case LITERAL_this: case LITERAL_super: return variableExpression(node); case LIST_CONSTRUCTOR: return listExpression(node); case MAP_CONSTRUCTOR: return mapExpression(node); case LABELED_ARG: return mapEntryExpression(node); case SPREAD_ARG: return spreadExpression(node); case SPREAD_MAP_ARG: return spreadMapExpression(node); // commented out of groovy.g due to non determinisms //case MEMBER_POINTER_DEFAULT: // return defaultMethodPointerExpression(node); case MEMBER_POINTER: return methodPointerExpression(node); case INDEX_OP: return indexExpression(node); case LITERAL_instanceof: return instanceofExpression(node); case LITERAL_as: return asExpression(node); case TYPECAST: return castExpression(node); // literals case LITERAL_true: return literalExpression(node, Boolean.TRUE); case LITERAL_false: return literalExpression(node, Boolean.FALSE); case LITERAL_null: return literalExpression(node, null); case STRING_LITERAL: return literalExpression(node, node.getText()); case STRING_CONSTRUCTOR: return gstring(node); case NUM_DOUBLE: case NUM_FLOAT: case NUM_BIG_DECIMAL: return decimalExpression(node); case NUM_BIG_INT: case NUM_INT: case NUM_LONG: return integerExpression(node); // Unary expressions case LNOT: NotExpression notExpression = new NotExpression(expression(node.getFirstChild())); configureAST(notExpression, node); return notExpression; case UNARY_MINUS: return unaryMinusExpression(node); case BNOT: BitwiseNegationExpression bitwiseNegationExpression = new BitwiseNegationExpression(expression(node.getFirstChild())); configureAST(bitwiseNegationExpression, node); return bitwiseNegationExpression; case UNARY_PLUS: return unaryPlusExpression(node); // Prefix expressions case INC: return prefixExpression(node, Types.PLUS_PLUS); case DEC: return prefixExpression(node, Types.MINUS_MINUS); // Postfix expressions case POST_INC: return postfixExpression(node, Types.PLUS_PLUS); case POST_DEC: return postfixExpression(node, Types.MINUS_MINUS); // Binary expressions case ASSIGN: return binaryExpression(Types.ASSIGN, node); case EQUAL: return binaryExpression(Types.COMPARE_EQUAL, node); case NOT_EQUAL: return binaryExpression(Types.COMPARE_NOT_EQUAL, node); case COMPARE_TO: return binaryExpression(Types.COMPARE_TO, node); case LE: return binaryExpression(Types.COMPARE_LESS_THAN_EQUAL, node); case LT: return binaryExpression(Types.COMPARE_LESS_THAN, node); case GT: return binaryExpression(Types.COMPARE_GREATER_THAN, node); case GE: return binaryExpression(Types.COMPARE_GREATER_THAN_EQUAL, node); /** * TODO treble equal? return binaryExpression(Types.COMPARE_IDENTICAL, node); case ???: return binaryExpression(Types.LOGICAL_AND_EQUAL, node); case ???: return binaryExpression(Types.LOGICAL_OR_EQUAL, node); */ case LAND: return binaryExpression(Types.LOGICAL_AND, node); case LOR: return binaryExpression(Types.LOGICAL_OR, node); case BAND: return binaryExpression(Types.BITWISE_AND, node); case BAND_ASSIGN: return binaryExpression(Types.BITWISE_AND_EQUAL, node); case BOR: return binaryExpression(Types.BITWISE_OR, node); case BOR_ASSIGN: return binaryExpression(Types.BITWISE_OR_EQUAL, node); case BXOR: return binaryExpression(Types.BITWISE_XOR, node); case BXOR_ASSIGN: return binaryExpression(Types.BITWISE_XOR_EQUAL, node); case PLUS: return binaryExpression(Types.PLUS, node); case PLUS_ASSIGN: return binaryExpression(Types.PLUS_EQUAL, node); case MINUS: return binaryExpression(Types.MINUS, node); case MINUS_ASSIGN: return binaryExpression(Types.MINUS_EQUAL, node); case STAR: return binaryExpression(Types.MULTIPLY, node); case STAR_ASSIGN: return binaryExpression(Types.MULTIPLY_EQUAL, node); case STAR_STAR: return binaryExpression(Types.POWER, node); case STAR_STAR_ASSIGN: return binaryExpression(Types.POWER_EQUAL, node); case DIV: return binaryExpression(Types.DIVIDE, node); case DIV_ASSIGN: return binaryExpression(Types.DIVIDE_EQUAL, node); case MOD: return binaryExpression(Types.MOD, node); case MOD_ASSIGN: return binaryExpression(Types.MOD_EQUAL, node); case SL: return binaryExpression(Types.LEFT_SHIFT, node); case SL_ASSIGN: return binaryExpression(Types.LEFT_SHIFT_EQUAL, node); case SR: return binaryExpression(Types.RIGHT_SHIFT, node); case SR_ASSIGN: return binaryExpression(Types.RIGHT_SHIFT_EQUAL, node); case BSR: return binaryExpression(Types.RIGHT_SHIFT_UNSIGNED, node); case BSR_ASSIGN: return binaryExpression(Types.RIGHT_SHIFT_UNSIGNED_EQUAL, node); case VARIABLE_DEF: return declarationExpression(node); // Regex case REGEX_FIND: return binaryExpression(Types.FIND_REGEX, node); case REGEX_MATCH: return binaryExpression(Types.MATCH_REGEX, node); // Ranges case RANGE_INCLUSIVE: return rangeExpression(node, true); case RANGE_EXCLUSIVE: return rangeExpression(node, false); case DYNAMIC_MEMBER: return dynamicMemberExpression(node); case LITERAL_in: return binaryExpression(Types.KEYWORD_IN,node); case ANNOTATION: return new AnnotationConstantExpression(annotation(node)); case CLOSURE_LIST: return closureListExpression(node); case LBRACK: case LPAREN: return tupleExpression(node); default: unknownAST(node); } return null; } private TupleExpression tupleExpression(AST node) { TupleExpression exp = new TupleExpression(); configureAST(exp,node); node = node.getFirstChild(); while (node!=null) { assertNodeType(VARIABLE_DEF,node); AST nameNode = node.getFirstChild().getNextSibling(); VariableExpression varExp = new VariableExpression(nameNode.getText()); configureAST(varExp,nameNode); exp.addExpression(varExp); node = node.getNextSibling(); } return exp; } private ClosureListExpression closureListExpression(AST node) { AST exprNode = node.getFirstChild(); LinkedList list = new LinkedList(); while (exprNode!=null) { if (isType(EXPR,exprNode)) { Expression expr = expression(exprNode); configureAST(expr, exprNode); list.add(expr); } else { assertNodeType(EMPTY_STAT, exprNode); list.add(EmptyExpression.INSTANCE); } exprNode = exprNode.getNextSibling(); } ClosureListExpression cle = new ClosureListExpression(list); configureAST(cle,node); return cle; } protected Expression dynamicMemberExpression(AST dynamicMemberNode) { AST node = dynamicMemberNode.getFirstChild(); return expression(node); } protected Expression ternaryExpression(AST ternaryNode) { AST node = ternaryNode.getFirstChild(); Expression base = expression(node); node = node.getNextSibling(); Expression left = expression(node); node = node.getNextSibling(); Expression ret; if (node==null) { ret = new ElvisOperatorExpression(base, left); } else { Expression right = expression(node); BooleanExpression booleanExpression = new BooleanExpression(base); booleanExpression.setSourcePosition(base); ret = new TernaryExpression(booleanExpression, left, right); } configureAST(ret, ternaryNode); return ret; } protected Expression variableExpression(AST node) { String text = node.getText(); // TODO we might wanna only try to resolve the name if we are // on the left hand side of an expression or before a dot? VariableExpression variableExpression = new VariableExpression(text); configureAST(variableExpression, node); return variableExpression; } protected Expression literalExpression(AST node, Object value) { ConstantExpression constantExpression = new ConstantExpression(value); configureAST(constantExpression, node); return constantExpression; } protected Expression rangeExpression(AST rangeNode, boolean inclusive) { AST node = rangeNode.getFirstChild(); Expression left = expression(node); Expression right = expression(node.getNextSibling()); RangeExpression rangeExpression = new RangeExpression(left, right, inclusive); configureAST(rangeExpression, rangeNode); return rangeExpression; } protected Expression spreadExpression(AST node) { AST exprNode = node.getFirstChild(); AST listNode = exprNode.getFirstChild(); Expression right = expression(listNode); SpreadExpression spreadExpression = new SpreadExpression(right); configureAST(spreadExpression, node); return spreadExpression; } protected Expression spreadMapExpression(AST node) { AST exprNode = node.getFirstChild(); Expression expr = expression(exprNode); SpreadMapExpression spreadMapExpression = new SpreadMapExpression(expr); configureAST(spreadMapExpression, node); return spreadMapExpression; } protected Expression methodPointerExpression(AST node) { AST exprNode = node.getFirstChild(); Expression objectExpression = expression(exprNode); AST mNode = exprNode.getNextSibling(); Expression methodName; if (isType(DYNAMIC_MEMBER, mNode)) { methodName = expression(mNode); } else { methodName = new ConstantExpression(identifier(mNode)); } configureAST(methodName,mNode); MethodPointerExpression methodPointerExpression = new MethodPointerExpression(objectExpression, methodName); configureAST(methodPointerExpression, node); return methodPointerExpression; } /* commented out due to groovy.g non-determinisms protected Expression defaultMethodPointerExpression(AST node) { AST exprNode = node.getFirstChild(); String methodName = exprNode.toString(); MethodPointerExpression methodPointerExpression = new MethodPointerExpression(null, methodName); configureAST(methodPointerExpression, node); return methodPointerExpression; } */ protected Expression listExpression(AST listNode) { List expressions = new ArrayList(); AST elist = listNode.getFirstChild(); assertNodeType(ELIST, elist); for (AST node = elist.getFirstChild(); node != null; node = node.getNextSibling()) { // check for stray labeled arguments: switch (node.getType()) { case LABELED_ARG: assertNodeType(COMMA, node); break; // helpful error? case SPREAD_MAP_ARG: assertNodeType(SPREAD_ARG, node); break; // helpful error } expressions.add(expression(node)); } ListExpression listExpression = new ListExpression(expressions); configureAST(listExpression, listNode); return listExpression; } /** * Typically only used for map constructors I think? */ protected Expression mapExpression(AST mapNode) { List expressions = new ArrayList(); AST elist = mapNode.getFirstChild(); if (elist != null) { // totally empty in the case of [:] assertNodeType(ELIST, elist); for (AST node = elist.getFirstChild(); node != null; node = node.getNextSibling()) { switch (node.getType()) { case LABELED_ARG: case SPREAD_MAP_ARG: break; // legal cases case SPREAD_ARG: assertNodeType(SPREAD_MAP_ARG, node); break; // helpful error default: assertNodeType(LABELED_ARG, node); break; // helpful error } expressions.add(mapEntryExpression(node)); } } MapExpression mapExpression = new MapExpression(expressions); configureAST(mapExpression, mapNode); return mapExpression; } protected MapEntryExpression mapEntryExpression(AST node) { if (node.getType() == SPREAD_MAP_ARG) { AST rightNode = node.getFirstChild(); Expression keyExpression = spreadMapExpression(node); Expression rightExpression = expression(rightNode); MapEntryExpression mapEntryExpression = new MapEntryExpression(keyExpression, rightExpression); configureAST(mapEntryExpression, node); return mapEntryExpression; } else { AST keyNode = node.getFirstChild(); Expression keyExpression = expression(keyNode); AST valueNode = keyNode.getNextSibling(); Expression valueExpression = expression(valueNode); MapEntryExpression mapEntryExpression = new MapEntryExpression(keyExpression, valueExpression); configureAST(mapEntryExpression, node); return mapEntryExpression; } } protected Expression instanceofExpression(AST node) { AST leftNode = node.getFirstChild(); Expression leftExpression = expression(leftNode); AST rightNode = leftNode.getNextSibling(); ClassNode type = buildName(rightNode); assertTypeNotNull(type, rightNode); Expression rightExpression = new ClassExpression(type); configureAST(rightExpression, rightNode); BinaryExpression binaryExpression = new BinaryExpression(leftExpression, makeToken(Types.KEYWORD_INSTANCEOF, node), rightExpression); configureAST(binaryExpression, node); return binaryExpression; } protected void assertTypeNotNull(ClassNode type, AST rightNode) { if (type == null) { throw new ASTRuntimeException(rightNode, "No type available for: " + qualifiedName(rightNode)); } } protected Expression asExpression(AST node) { AST leftNode = node.getFirstChild(); Expression leftExpression = expression(leftNode); AST rightNode = leftNode.getNextSibling(); ClassNode type = buildName(rightNode); return CastExpression.asExpression(type, leftExpression); } protected Expression castExpression(AST castNode) { AST node = castNode.getFirstChild(); ClassNode type = buildName(node); assertTypeNotNull(type, node); AST expressionNode = node.getNextSibling(); Expression expression = expression(expressionNode); CastExpression castExpression = new CastExpression(type, expression); configureAST(castExpression, castNode); return castExpression; } protected Expression indexExpression(AST indexNode) { AST leftNode = indexNode.getFirstChild(); Expression leftExpression = expression(leftNode); AST rightNode = leftNode.getNextSibling(); Expression rightExpression = expression(rightNode); BinaryExpression binaryExpression = new BinaryExpression(leftExpression, makeToken(Types.LEFT_SQUARE_BRACKET, indexNode), rightExpression); configureAST(binaryExpression, indexNode); return binaryExpression; } protected Expression binaryExpression(int type, AST node) { Token token = makeToken(type, node); AST leftNode = node.getFirstChild(); Expression leftExpression = expression(leftNode); AST rightNode = leftNode.getNextSibling(); if (rightNode == null) { return leftExpression; } if (Types.ofType(type, Types.ASSIGNMENT_OPERATOR)) { if (leftExpression instanceof VariableExpression || leftExpression.getClass() == PropertyExpression.class || leftExpression instanceof FieldExpression || leftExpression instanceof AttributeExpression || leftExpression instanceof DeclarationExpression || leftExpression instanceof TupleExpression) { // Do nothing. } else if (leftExpression instanceof ConstantExpression) { throw new ASTRuntimeException(node, "\n[" + ((ConstantExpression) leftExpression).getValue() + "] is a constant expression, but it should be a variable expression"); } else if (leftExpression instanceof BinaryExpression) { Expression leftexp = ((BinaryExpression) leftExpression).getLeftExpression(); int lefttype = ((BinaryExpression) leftExpression).getOperation().getType(); if (!Types.ofType(lefttype, Types.ASSIGNMENT_OPERATOR) && lefttype != Types.LEFT_SQUARE_BRACKET) { throw new ASTRuntimeException(node, "\n" + ((BinaryExpression) leftExpression).getText() + " is a binary expression, but it should be a variable expression"); } } else if (leftExpression instanceof GStringExpression) { throw new ASTRuntimeException(node, "\n\"" + ((GStringExpression) leftExpression).getText() + "\" is a GString expression, but it should be a variable expression"); } else if (leftExpression instanceof MethodCallExpression) { throw new ASTRuntimeException(node, "\n\"" + ((MethodCallExpression) leftExpression).getText() + "\" is a method call expression, but it should be a variable expression"); } else if (leftExpression instanceof MapExpression) { throw new ASTRuntimeException(node, "\n'" + ((MapExpression) leftExpression).getText() + "' is a map expression, but it should be a variable expression"); } else { throw new ASTRuntimeException(node, "\n" + leftExpression.getClass() + ", with its value '" + leftExpression.getText() + "', is a bad expression as the left hand side of an assignment operator"); } } /*if (rightNode == null) { throw new NullPointerException("No rightNode associated with binary expression"); }*/ Expression rightExpression = expression(rightNode); BinaryExpression binaryExpression = new BinaryExpression(leftExpression, token, rightExpression); configureAST(binaryExpression, node); return binaryExpression; } protected Expression prefixExpression(AST node, int token) { Expression expression = expression(node.getFirstChild()); PrefixExpression prefixExpression = new PrefixExpression(makeToken(token, node), expression); configureAST(prefixExpression, node); return prefixExpression; } protected Expression postfixExpression(AST node, int token) { Expression expression = expression(node.getFirstChild()); PostfixExpression postfixExpression = new PostfixExpression(expression, makeToken(token, node)); configureAST(postfixExpression, node); return postfixExpression; } protected BooleanExpression booleanExpression(AST node) { BooleanExpression booleanExpression = new BooleanExpression(expression(node)); configureAST(booleanExpression, node); return booleanExpression; } protected Expression dotExpression(AST node) { // let's decide if this is a property invocation or a method call AST leftNode = node.getFirstChild(); if (leftNode != null) { AST identifierNode = leftNode.getNextSibling(); if (identifierNode != null) { Expression leftExpression = expression(leftNode); if (isType(SELECT_SLOT, identifierNode)) { Expression field = expression(identifierNode.getFirstChild(),true); AttributeExpression attributeExpression = new AttributeExpression(leftExpression, field, node.getType() != DOT); if (node.getType() == SPREAD_DOT) { attributeExpression.setSpreadSafe(true); } configureAST(attributeExpression, node); return attributeExpression; } Expression property = expression(identifierNode,true); PropertyExpression propertyExpression = new PropertyExpression(leftExpression, property, node.getType() != DOT); if (node.getType() == SPREAD_DOT) { propertyExpression.setSpreadSafe(true); } configureAST(propertyExpression, node); return propertyExpression; } } return methodCallExpression(node); } protected Expression specialConstructorCallExpression(AST methodCallNode, ClassNode special) { AST node = methodCallNode.getFirstChild(); Expression arguments = arguments(node); ConstructorCallExpression expression = new ConstructorCallExpression(special, arguments); configureAST(expression, methodCallNode); return expression; } private int getTypeInParenthesis(AST node) { if (! isType(EXPR,node) ) node = node.getFirstChild(); while (node!=null &&isType(EXPR,node) && node.getNextSibling()==null) { node = node.getFirstChild(); } if (node==null) return -1; return node.getType(); } protected Expression methodCallExpression(AST methodCallNode) { AST node = methodCallNode.getFirstChild(); /* // Bad idea, since foo(1)(2) is valid Groovy for foo(1).call(2). if (isType(METHOD_CALL, node)) { // sometimes method calls get wrapped in method calls for some wierd reason return methodCallExpression(node); } */ Expression objectExpression; AST selector; AST elist = node.getNextSibling(); boolean implicitThis = false; boolean safe = isType(OPTIONAL_DOT, node); boolean spreadSafe = isType(SPREAD_DOT, node); if (isType(DOT, node) || safe || spreadSafe) { AST objectNode = node.getFirstChild(); objectExpression = expression(objectNode); selector = objectNode.getNextSibling(); } else { implicitThis = true; objectExpression = VariableExpression.THIS_EXPRESSION; selector = node; } Expression name = null; if (isType(LITERAL_super, selector)) { implicitThis = true; name = new ConstantExpression("super"); if (objectExpression instanceof VariableExpression && ((VariableExpression)objectExpression).isThisExpression()) { objectExpression = VariableExpression.SUPER_EXPRESSION; } } else if (isPrimitiveTypeLiteral(selector)) { throw new ASTRuntimeException(selector, "Primitive type literal: " + selector.getText() + " cannot be used as a method name"); } else if (isType(SELECT_SLOT, selector)) { Expression field = expression(selector.getFirstChild(),true); AttributeExpression attributeExpression = new AttributeExpression(objectExpression, field, node.getType() != DOT); configureAST(attributeExpression, node); Expression arguments = arguments(elist); MethodCallExpression expression = new MethodCallExpression(attributeExpression, "call", arguments); configureAST(expression, methodCallNode); return expression; } else if (isType(DYNAMIC_MEMBER, selector) || isType(IDENT,selector) || isType(STRING_CONSTRUCTOR,selector) || isType (STRING_LITERAL,selector)) { name = expression(selector,true); } else { implicitThis = false; name = new ConstantExpression("call"); objectExpression = expression(selector,true); } // if node text is found to be "super"/"this" when a method call is being processed, it is a // call like this(..)/super(..) after the first statement, which shouldn't be allowed. GROOVY-2836 if(selector.getText().equals("this") || selector.getText().equals("super")) { throw new ASTRuntimeException(elist, "Constructor call must be the first statement in a constructor."); } Expression arguments = arguments(elist); MethodCallExpression expression = new MethodCallExpression(objectExpression, name, arguments); expression.setSafe(safe); expression.setSpreadSafe(spreadSafe); expression.setImplicitThis(implicitThis); Expression ret = expression; //FIXME: do we really want this() to create a new object regardless // the position.. for example not as first statement in a constructor // this=first statement in constructor is handled by specialConstructorCallExpression // we may have to add a check and remove this part of the code if (implicitThis && "this".equals(expression.getMethodAsString())) { ret = new ConstructorCallExpression(this.classNode, arguments); } configureAST(ret, methodCallNode); return ret; } protected Expression constructorCallExpression(AST node) { AST constructorCallNode = node; ClassNode type = makeTypeWithArguments(constructorCallNode); if (isType(CTOR_CALL, node) || isType(LITERAL_new, node)) { node = node.getFirstChild(); } AST elist = node.getNextSibling(); if (elist == null && isType(ELIST, node)) { elist = node; if ("(".equals(type.getName())) { type = classNode; } } if (isType(ARRAY_DECLARATOR, elist)) { AST expressionNode = elist.getFirstChild(); if (expressionNode == null) { throw new ASTRuntimeException(elist, "No expression for the array constructor call"); } List size = arraySizeExpression(expressionNode); ArrayExpression arrayExpression = new ArrayExpression(type, null, size); configureAST(arrayExpression, constructorCallNode); return arrayExpression; } Expression arguments = arguments(elist); ConstructorCallExpression expression = new ConstructorCallExpression(type, arguments); configureAST(expression, constructorCallNode); return expression; } protected List arraySizeExpression(AST node) { List list; Expression size = null; if (isType(ARRAY_DECLARATOR,node)) { AST right = node.getNextSibling(); if (right!=null) { size = expression(right); } else { size = ConstantExpression.EMTPY_EXPRESSION; } list = arraySizeExpression(node.getFirstChild()); } else { size = expression(node); list = new ArrayList(); } list.add(size); return list; } protected Expression arguments(AST elist) { List expressionList = new ArrayList(); // FIXME: all labeled arguments should follow any unlabeled arguments boolean namedArguments = false; for (AST node = elist; node != null; node = node.getNextSibling()) { if (isType(ELIST, node)) { for (AST child = node.getFirstChild(); child != null; child = child.getNextSibling()) { namedArguments |= addArgumentExpression(child, expressionList); } } else { namedArguments |= addArgumentExpression(node, expressionList); } } if (namedArguments) { if (!expressionList.isEmpty()) { // let's remove any non-MapEntryExpression instances // such as if the last expression is a ClosureExpression // so let's wrap the named method calls in a Map expression List argumentList = new ArrayList(); for (Iterator iter = expressionList.iterator(); iter.hasNext();) { Expression expression = (Expression) iter.next(); if (!(expression instanceof MapEntryExpression)) { argumentList.add(expression); } } if (!argumentList.isEmpty()) { expressionList.removeAll(argumentList); MapExpression mapExpression = new MapExpression(expressionList); configureAST(mapExpression, elist); argumentList.add(0, mapExpression); ArgumentListExpression argumentListExpression = new ArgumentListExpression(argumentList); configureAST(argumentListExpression, elist); return argumentListExpression; } } NamedArgumentListExpression namedArgumentListExpression = new NamedArgumentListExpression(expressionList); configureAST(namedArgumentListExpression, elist); return namedArgumentListExpression; } else { ArgumentListExpression argumentListExpression = new ArgumentListExpression(expressionList); configureAST(argumentListExpression, elist); return argumentListExpression; } } protected boolean addArgumentExpression(AST node, List expressionList) { if (node.getType() == SPREAD_MAP_ARG) { AST rightNode = node.getFirstChild(); Expression keyExpression = spreadMapExpression(node); Expression rightExpression = expression(rightNode); MapEntryExpression mapEntryExpression = new MapEntryExpression(keyExpression, rightExpression); expressionList.add(mapEntryExpression); return true; } else { Expression expression = expression(node); expressionList.add(expression); return expression instanceof MapEntryExpression; } } protected Expression expressionList(AST node) { List expressionList = new ArrayList(); for (AST child = node.getFirstChild(); child != null; child = child.getNextSibling()) { expressionList.add(expression(child)); } boolean isClassNodeForEnum = false; /* * For an enum, let it be wrapped in a ListExpression * even if it is of size 1 - GROOVY-2933 */ if (classNode != null && classNode.getSuperClass().getName().equals("java.lang.Enum")) { isClassNodeForEnum = true; } if (expressionList.size() == 1 && !isClassNodeForEnum) { return (Expression) expressionList.get(0); } else { ListExpression listExpression = new ListExpression(expressionList); configureAST(listExpression, node); return listExpression; } } protected ClosureExpression closureExpression(AST node) { AST paramNode = node.getFirstChild(); Parameter[] parameters = null; AST codeNode = paramNode; if (isType(PARAMETERS, paramNode) || isType(IMPLICIT_PARAMETERS, paramNode)) { parameters = parameters(paramNode); codeNode = paramNode.getNextSibling(); } Statement code = statementListNoChild(codeNode); ClosureExpression closureExpression = new ClosureExpression(parameters, code); configureAST(closureExpression, node); return closureExpression; } protected Expression blockExpression(AST node) { AST codeNode = node.getFirstChild(); if (codeNode == null) return ConstantExpression.NULL; if (codeNode.getType() == EXPR && codeNode.getNextSibling() == null) { // Simplify common case of {expr} to expr. return expression(codeNode); } Parameter[] parameters = Parameter.EMPTY_ARRAY; Statement code = statementListNoChild(codeNode); ClosureExpression closureExpression = new ClosureExpression(parameters, code); configureAST(closureExpression, node); // Call it immediately. String callName = "call"; Expression noArguments = new ArgumentListExpression(); MethodCallExpression call = new MethodCallExpression(closureExpression, callName, noArguments); configureAST(call, node); return call; } protected Expression unaryMinusExpression(AST unaryMinusExpr) { AST node = unaryMinusExpr.getFirstChild(); // if we are a number literal then let's just parse it // as the negation operator on MIN_INT causes rounding to a long String text = node.getText(); switch (node.getType()) { case NUM_DOUBLE: case NUM_FLOAT: case NUM_BIG_DECIMAL: ConstantExpression constantExpression = new ConstantExpression(Numbers.parseDecimal("-" + text)); configureAST(constantExpression, unaryMinusExpr); return constantExpression; case NUM_BIG_INT: case NUM_INT: case NUM_LONG: ConstantExpression constantLongExpression = new ConstantExpression(Numbers.parseInteger("-" + text)); configureAST(constantLongExpression, unaryMinusExpr); return constantLongExpression; default: UnaryMinusExpression unaryMinusExpression = new UnaryMinusExpression(expression(node)); configureAST(unaryMinusExpression, unaryMinusExpr); return unaryMinusExpression; } } protected Expression unaryPlusExpression(AST unaryPlusExpr) { AST node = unaryPlusExpr.getFirstChild(); switch (node.getType()) { case NUM_DOUBLE: case NUM_FLOAT: case NUM_BIG_DECIMAL: case NUM_BIG_INT: case NUM_INT: case NUM_LONG: return expression(node); default: UnaryPlusExpression unaryPlusExpression = new UnaryPlusExpression(expression(node)); configureAST(unaryPlusExpression, unaryPlusExpr); return unaryPlusExpression; } } protected ConstantExpression decimalExpression(AST node) { String text = node.getText(); ConstantExpression constantExpression = new ConstantExpression(Numbers.parseDecimal(text)); configureAST(constantExpression, node); return constantExpression; } protected ConstantExpression integerExpression(AST node) { String text = node.getText(); ConstantExpression constantExpression = new ConstantExpression(Numbers.parseInteger(text)); configureAST(constantExpression, node); return constantExpression; } protected Expression gstring(AST gstringNode) { List strings = new ArrayList(); List values = new ArrayList(); StringBuffer buffer = new StringBuffer(); boolean isPrevString = false; for (AST node = gstringNode.getFirstChild(); node != null; node = node.getNextSibling()) { int type = node.getType(); String text = null; switch (type) { case STRING_LITERAL: if (isPrevString) assertNodeType(IDENT, node); // parser bug isPrevString = true; text = node.getText(); ConstantExpression constantExpression = new ConstantExpression(text); configureAST(constantExpression, node); strings.add(constantExpression); buffer.append(text); break; default: { if (!isPrevString) assertNodeType(IDENT, node); // parser bug isPrevString = false; Expression expression = expression(node); values.add(expression); buffer.append("$"); buffer.append(expression.getText()); } break; } } GStringExpression gStringExpression = new GStringExpression(buffer.toString(), strings, values); configureAST(gStringExpression, gstringNode); return gStringExpression; } protected ClassNode type(AST typeNode) { // TODO intern types? // TODO configureAST(...) return buildName(typeNode.getFirstChild()); } public static String qualifiedName(AST qualifiedNameNode) { if (isType(IDENT, qualifiedNameNode)) { return qualifiedNameNode.getText(); } if (isType(DOT, qualifiedNameNode)) { AST node = qualifiedNameNode.getFirstChild(); StringBuffer buffer = new StringBuffer(); boolean first = true; for (; node != null && !isType(TYPE_ARGUMENTS,node); node = node.getNextSibling()) { if (first) { first = false; } else { buffer.append("."); } buffer.append(qualifiedName(node)); } return buffer.toString(); } else { return qualifiedNameNode.getText(); } } private static AST getTypeArgumentsNode(AST root) { while (root!=null && !isType(TYPE_ARGUMENTS,root)) { root = root.getNextSibling(); } return root; } private int getBoundType(AST node) { if (node==null) return -1; if (isType(TYPE_UPPER_BOUNDS,node)) return TYPE_UPPER_BOUNDS; if (isType(TYPE_LOWER_BOUNDS,node)) return TYPE_LOWER_BOUNDS; throw new ASTRuntimeException(node, "Unexpected node type: " + getTokenName(node) + " found when expecting type: " + getTokenName(TYPE_UPPER_BOUNDS) + " or type: " + getTokenName(TYPE_LOWER_BOUNDS)); } private GenericsType makeGenericsArgumentType(AST typeArgument) { GenericsType gt; AST rootNode = typeArgument.getFirstChild(); if (isType(WILDCARD_TYPE,rootNode)) { ClassNode base = ClassHelper.makeWithoutCaching("?"); if (rootNode.getNextSibling()!=null) { int boundType = getBoundType(rootNode.getNextSibling()); ClassNode[] gts = makeGenericsBounds(rootNode,boundType); if (boundType==TYPE_UPPER_BOUNDS) { gt = new GenericsType(base,gts,null); } else { gt = new GenericsType(base,null,gts[0]); } } else { gt = new GenericsType(base,null,null); } gt.setName("?"); gt.setWildcard(true); } else { ClassNode argument = makeTypeWithArguments(rootNode); gt = new GenericsType(argument); } configureAST(gt, typeArgument); return gt; } protected ClassNode makeTypeWithArguments(AST rootNode) { ClassNode basicType = makeType(rootNode); LinkedList typeArgumentList = new LinkedList(); AST node = rootNode.getFirstChild(); if (node==null || isType(INDEX_OP, node) || isType(ARRAY_DECLARATOR, node)) return basicType; //TODO: recognize combinatons of inner classes and generic types if (isType(DOT, node)) return basicType; node = node.getFirstChild(); if (node==null) return basicType; assertNodeType(TYPE_ARGUMENTS, node); AST typeArgument = node.getFirstChild(); while (typeArgument != null) { assertNodeType(TYPE_ARGUMENT, typeArgument); GenericsType gt = makeGenericsArgumentType(typeArgument); typeArgumentList.add(gt); typeArgument = typeArgument.getNextSibling(); } if (typeArgumentList.size()>0) { basicType.setGenericsTypes((GenericsType[]) typeArgumentList.toArray(new GenericsType[0])); } return basicType; } private ClassNode[] makeGenericsBounds(AST rn, int boundType) { AST boundsRoot = rn.getNextSibling(); if (boundsRoot==null) return null; assertNodeType(boundType, boundsRoot); LinkedList bounds = new LinkedList(); for ( AST boundsNode = boundsRoot.getFirstChild(); boundsNode!=null; boundsNode=boundsNode.getNextSibling() ) { ClassNode bound = null; bound = makeTypeWithArguments(boundsNode); configureAST(bound, boundsNode); bounds.add(bound); } if (bounds.size()==0) return null; return (ClassNode[]) bounds.toArray(new ClassNode[bounds.size()]); } protected GenericsType[] makeGenericsType(AST rootNode) { AST typeParameter = rootNode.getFirstChild(); LinkedList ret = new LinkedList(); assertNodeType(TYPE_PARAMETER, typeParameter); while (isType(TYPE_PARAMETER, typeParameter)) { AST typeNode = typeParameter.getFirstChild(); ClassNode type = makeType(typeParameter); GenericsType gt = new GenericsType(type, makeGenericsBounds(typeNode,TYPE_UPPER_BOUNDS),null); configureAST(gt, typeParameter); ret.add(gt); typeParameter = typeParameter.getNextSibling(); } return (GenericsType[]) ret.toArray(new GenericsType[0]); } protected ClassNode makeType(AST typeNode) { ClassNode answer = ClassHelper.DYNAMIC_TYPE; AST node = typeNode.getFirstChild(); if (node != null) { if (isType(INDEX_OP, node) || isType(ARRAY_DECLARATOR, node)) { answer = makeType(node).makeArray(); } else { answer = ClassHelper.make(qualifiedName(node)); } configureAST(answer,node); } return answer; } /** * Performs a name resolution to see if the given name is a type from imports, * aliases or newly created classes */ /*protected String resolveTypeName(String name, boolean safe) { if (name == null) { return null; } return resolveNewClassOrName(name, safe); }*/ /** * Extracts an identifier from the Antlr AST and then performs a name resolution * to see if the given name is a type from imports, aliases or newly created classes */ protected ClassNode buildName(AST node) { if (isType(TYPE, node)) { node = node.getFirstChild(); } ClassNode answer = null; if (isType(DOT, node) || isType(OPTIONAL_DOT, node)) { answer = ClassHelper.make(qualifiedName(node)); } else if (isPrimitiveTypeLiteral(node)) { answer = ClassHelper.make(node.getText()); } else if (isType(INDEX_OP, node) || isType(ARRAY_DECLARATOR, node)) { AST child = node.getFirstChild(); answer = buildName(child).makeArray(); configureAST(answer, node); return answer; } else { String identifier = node.getText(); answer = ClassHelper.make(identifier); } AST nextSibling = node.getNextSibling(); if (isType(INDEX_OP, nextSibling) || isType(ARRAY_DECLARATOR, node)) { answer = answer.makeArray(); configureAST(answer, node); return answer; } else { configureAST(answer, node); return answer; } } protected boolean isPrimitiveTypeLiteral(AST node) { int type = node.getType(); switch (type) { case LITERAL_boolean: case LITERAL_byte: case LITERAL_char: case LITERAL_double: case LITERAL_float: case LITERAL_int: case LITERAL_long: case LITERAL_short: return true; default: return false; } } /** * Extracts an identifier from the Antlr AST */ protected String identifier(AST node) { assertNodeType(IDENT, node); return node.getText(); } protected String label(AST labelNode) { AST node = labelNode.getFirstChild(); if (node == null) { return null; } return identifier(node); } // Helper methods //------------------------------------------------------------------------- /** * Returns true if the modifiers flags contain a visibility modifier */ protected boolean hasVisibility(int modifiers) { return (modifiers & (Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_PUBLIC)) != 0; } protected void configureAST(ASTNode node, AST ast) { if (ast==null) throw new ASTRuntimeException(ast, "PARSER BUG: Tried to configure "+node.getClass().getName()+" with null Node"); node.setColumnNumber(ast.getColumn()); node.setLineNumber(ast.getLine()); if (ast instanceof GroovySourceAST) { node.setLastColumnNumber(((GroovySourceAST)ast).getColumnLast()); node.setLastLineNumber(((GroovySourceAST)ast).getLineLast()); } // TODO we could one day store the Antlr AST on the Groovy AST // node.setCSTNode(ast); } protected static Token makeToken(int typeCode, AST node) { return Token.newSymbol(typeCode, node.getLine(), node.getColumn()); } protected String getFirstChildText(AST node) { AST child = node.getFirstChild(); return child != null ? child.getText() : null; } public static boolean isType(int typeCode, AST node) { return node != null && node.getType() == typeCode; } private String getTokenName(int token) { if (tokenNames==null) return ""+token; return tokenNames[token]; } private String getTokenName(AST node) { if (node==null) return "null"; return getTokenName(node.getType()); } protected void assertNodeType(int type, AST node) { if (node == null) { throw new ASTRuntimeException(node, "No child node available in AST when expecting type: " + getTokenName(type)); } if (node.getType() != type) { throw new ASTRuntimeException(node, "Unexpected node type: " + getTokenName(node) + " found when expecting type: " + getTokenName(type)); } } protected void notImplementedYet(AST node) { throw new ASTRuntimeException(node, "AST node not implemented yet for type: " + getTokenName(node)); } protected void unknownAST(AST node) { if (node.getType() == CLASS_DEF) { throw new ASTRuntimeException(node, "Class definition not expected here. Possible attempt to use inner class. " + "Inner classes not supported, perhaps try using a closure instead."); } throw new ASTRuntimeException(node, "Unknown type: " + getTokenName(node)); } protected void dumpTree(AST ast) { for (AST node = ast.getFirstChild(); node != null; node = node.getNextSibling()) { dump(node); } } protected void dump(AST node) { System.out.println("Type: " + getTokenName(node) + " text: " + node.getText()); } }
49b0e509a0a814513e294aa01f302131b9290899
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/7/7_431b6c9322e844225fda7e1faa1cd9a7e04a39e8/MessageDownloadThread/7_431b6c9322e844225fda7e1faa1cd9a7e04a39e8_MessageDownloadThread_t.java
e9defb69c3487707e828013bc0234885960ae9f3
[]
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
19,682
java
/* MessageDownloadThread.java / Frost Copyright (C) 2001 Jan-Thomas Czornack <[email protected]> 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ package frost.threads; import java.io.File; import java.util.*; import frost.*; import frost.crypt.*; import frost.gui.objects.*; import frost.messages.*; import frost.FcpTools.*; import frost.identities.*; /** * Downloads messages */ public class MessageDownloadThread extends BoardUpdateThreadObject implements BoardUpdateThread { public FrostBoardObject board; private int downloadHtl; private String keypool; private int maxMessageDownload; private String destination; private boolean secure; private String publicKey; private boolean flagNew; public int getThreadType() { if( flagNew ) { return BoardUpdateThread.MSG_DNLOAD_TODAY; } else { return BoardUpdateThread.MSG_DNLOAD_BACK; } } public void run() { notifyThreadStarted(this); try { String tofType; if( flagNew ) tofType="TOF Download"; else tofType="TOF Download Back"; // Wait some random time to speed up the update of the TOF table // ... and to not to flood the node int waitTime = (int)(Math.random() * 5000); // wait a max. of 5 seconds between start of threads mixed.wait(waitTime); Core.getOut().println("TOFDN: "+tofType + " Thread started for board "+board.toString()); if( isInterrupted() ) { notifyThreadFinished(this); return; } // switch public / secure board if( board.isPublicBoard() == false ) { publicKey = board.getPublicKey(); secure = true; } else // public board { secure = false; } GregorianCalendar cal= new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); if( this.flagNew ) { // download only actual date downloadDate(cal); } else { // download up to maxMessages days to the past GregorianCalendar firstDate = new GregorianCalendar(); firstDate.setTimeZone(TimeZone.getTimeZone("GMT")); firstDate.set(Calendar.YEAR, 2001); firstDate.set(Calendar.MONTH, 5); firstDate.set(Calendar.DATE, 11); int counter=0; while( !isInterrupted() && cal.after(firstDate) && counter < maxMessageDownload ) { counter++; cal.add(Calendar.DATE, -1); // Yesterday downloadDate(cal); } } Core.getOut().println("TOFDN: "+tofType+" Thread stopped for board "+board.toString()); } catch(Throwable t) { Core.getOut().println(Thread.currentThread().getName()+": Oo. Exception in MessageDownloadThread:"); t.printStackTrace(Core.getOut()); } notifyThreadFinished(this); } /**Returns true if message is duplicate*/ private boolean exists(File file) { File[] fileList = (file.getParentFile()).listFiles(); String one = null; if( fileList != null ) { for( int i = 0; i < fileList.length; i++ ) { if( ! fileList[i].equals(file) && fileList[i].getName().endsWith(".sig") == false && // dont check .sig files fileList[i].getName().indexOf(board.getBoardFilename()) != -1 && file.getName().indexOf(board.getBoardFilename()) != -1 ) { if( one == null ) // load new file only 1 time { one = FileAccess.readFile(file); } String two = FileAccess.readFile(fileList[i]); if( one.equals(two) ) { return true; } } } } return false; } protected void downloadDate(GregorianCalendar calDL) { VerifyableMessageObject currentMsg=null; String dirdate = DateFun.getDateOfCalendar(calDL); String fileSeparator = System.getProperty("file.separator"); destination = new StringBuffer().append(keypool).append(board.getBoardFilename()) .append(fileSeparator) .append(dirdate).append(fileSeparator).toString(); File makedir = new File(destination); if( !makedir.exists() ) { makedir.mkdirs(); } File checkLockfile = new File(destination + "locked.lck"); int index = 0; int failures = 0; int maxFailures; if( flagNew ) { maxFailures = 3; // skip a maximum of 2 empty slots for today } else { maxFailures = 2; // skip a maximum of 1 empty slot for backload } while( failures < maxFailures && (flagNew || !checkLockfile.exists()) ) { byte [] metadata = null; try { //make a wide net so that evil messages don't kill us String val = new StringBuffer().append(destination) .append(System.currentTimeMillis()) .append(".xml.msg").toString(); File testMe = new File(val); val = new StringBuffer().append(destination) .append(dirdate) .append("-") .append(board.getBoardFilename()) .append("-") .append(index) .append(".xml").toString(); File testMe2 = new File(val); if( testMe2.length() > 0 ) // already downloaded { index++; failures = 0; } else { String downKey = null; if( secure ) { downKey = new StringBuffer().append(publicKey) .append("/") .append(board.getBoardFilename()) .append("/") .append(dirdate) .append("-") .append(index) .append(".xml").toString(); } else { downKey = new StringBuffer().append("KSK@frost/message/") .append(frame1.frostSettings.getValue("messageBase")) .append("/") .append(dirdate) .append("-") .append(board.getBoardFilename()) .append("-") .append(index) .append(".xml").toString(); } try { boolean fastDownload = !flagNew; // for backload use fast download, deep for today FcpResults res = FcpRequest.getFile(downKey, null, testMe, downloadHtl, false, fastDownload); if (res == null) metadata =null; else metadata = res.getRawMetadata(); // TODO: if metadata==null, not signed message mixed.wait(111); // wait some time to not to hurt the node on next retry } catch(Throwable t) { Core.getOut().println(Thread.currentThread().getName()+" :TOFDN - Error in run()/FcpRequest.getFile:"); t.printStackTrace(Core.getOut()); } // Download successful? if( testMe.length() > 0 ) { testMe.renameTo(testMe2); testMe=testMe2; //check if it is a duplicate String messageId = Core.getCrypto().digest(testMe); // Does a duplicate message exist? if( !exists(testMe) && !Core.getMessageSet().contains(messageId)) { Core.getMessageSet().add(messageId); //if no metadata, message wasn't signed if (metadata == null) { //unzip byte[] unzippedXml = FileAccess.readZipFileBinary(testMe); FileAccess.writeByteArray(unzippedXml,testMe); try { currentMsg = new VerifyableMessageObject(testMe); } catch(Exception ex) { ex.printStackTrace(); // TODO: file could not be read, mark it invalid not to confuse gui index++; continue; } //set to unsigned currentMsg.setStatus(VerifyableMessageObject.OLD); if( currentMsg.isValid() ) { if( TOF.blocked(currentMsg, board) && testMe.length() > 0 ) { board.incBlocked(); Core.getOut().println("\nTOFDN: ########### blocked message for board '"+board.toString()+"' #########\n"); } else { frame1.displayNewMessageIcon(true); // write the NEW message indicator file FileAccess.writeFile("This message is new!", testMe.getPath() + ".lck"); // add new message or notify of arrival TOF.addNewMessageToTable(testMe, board); } } else { FileAccess.writeFile("Empty", testMe); } index++; continue; } //end of if no metadata part //verify the zipped message byte [] plaintext = FileAccess.readByteArray(testMe); MetaData metaData = null; try { metaData = new MetaData(plaintext,metadata); } catch(Throwable t) { //TODO: metadata failed, do something t.printStackTrace(Core.getOut()); Core.getOut().println("metadata couldn't be read. "+ "offending file saved as badmetadata.xml - send to a dev for analysis"); File badmetadata = new File("badmetadata.xml"); FileAccess.writeByteArray(metadata,badmetadata); //please, please, PLEASE don't just catch them and do nothing! // i know, i just added a TODO as in rest of file because i don't // know what to do if failed... index++; failures = 0; continue; } //check if we have the owner already on the lists String _owner = metaData.getSharer().getUniqueName(); Identity owner; //check friends owner = Core.getFriends().Get(_owner); //if not, check neutral if (owner == null) owner = Core.getNeutral().Get(_owner); //if not, check enemies if (owner == null) owner = Core.getEnemies().Get(_owner); //if still not, use the parsed id if (owner == null) { owner = metaData.getSharer(); owner.noFiles = 0; owner.noMessages =1; Core.getNeutral().Add(owner); } //verify! :) boolean valid = Core.getCrypto().detachedVerify( plaintext, owner.getKey(), metaData.getSig()); //unzip //REDFLAG: encoding byte[] unzippedXml = FileAccess.readZipFileBinary(testMe); FileAccess.writeByteArray(unzippedXml,testMe); //create object try { currentMsg = new VerifyableMessageObject(testMe); } catch(Exception ex) { ex.printStackTrace(); // TODO: file could not be read, mark it invalid not to confuse gui index++; continue; } //then check if the signature was ok if (!valid) { currentMsg.setStatus(VerifyableMessageObject.TAMPERED); Core.getOut().println("TOFDN: message failed verification"); index++; continue; } //make sure the pubkey and from fields in the xml file are the same //as those in the metadata String metaDataHash = mixed.makeFilename(Core.getCrypto().digest( metaData.getSharer().getKey())); String messageHash = mixed.makeFilename(currentMsg.getFrom().substring( currentMsg.getFrom().indexOf("@"), currentMsg.getFrom().length())); if (!metaDataHash.equals(messageHash)) { Core.getOut().println("hash in metadata doesn't match hash in message!"); Core.getOut().println("metadata : "+ metaDataHash+" , message: "+ messageHash); currentMsg.setStatus(VerifyableMessageObject.TAMPERED); index++; continue; } //if it is, we have the user either on the good, bad or neutral lists if (Core.getFriends().containsKey(_owner)) currentMsg.setStatus(VerifyableMessageObject.VERIFIED); else if (Core.getEnemies().containsKey(_owner)) currentMsg.setStatus(VerifyableMessageObject.FAILED); else currentMsg.setStatus(VerifyableMessageObject.PENDING); /* Encryption will be done+handled using private boards */ // verify the message date and time if( currentMsg.isValidFormat( calDL ) == false ) { // TODO: file contains invalid data or time, skip and // mark it to not try it again(?) } File sig = new File(testMe.getPath() + ".sig"); // Is this a valid message? if( currentMsg.isValid() ) { if( TOF.blocked(currentMsg, board) && testMe.length() > 0 ) { board.incBlocked(); Core.getOut().println("\nTOFDN: ########### blocked message for board '"+board.toString()+"' #########\n"); } else { frame1.displayNewMessageIcon(true); // write the NEW message indicator file FileAccess.writeFile("This message is new!", testMe.getPath() + ".lck"); // add new message or notify of arrival TOF.addNewMessageToTable(testMe, board); } } else { FileAccess.writeFile("Empty", testMe); } } else { Core.getOut().println(Thread.currentThread().getName()+": TOFDN: ****** Duplicate Message : " + testMe.getName() + " *****"); FileAccess.writeFile("Empty", testMe); } index++; failures = 0; } else { /* if( !flagNew ) { Core.getOut().println("TOFDN: *** Increased TOF index for board '"+board.toString()+"' ***"); }*/ failures++; index++; } } if( isInterrupted() ) return; }catch(Throwable t) { t.printStackTrace(Core.getOut()); index++; } } // end-of: while } /**Constructor*/ // public MessageDownloadThread(boolean fn, FrostBoardObject boa, int dlHtl, String kpool, String maxmsg) { super(boa); this.flagNew = fn; this.board = boa; this.downloadHtl = dlHtl; this.keypool = kpool; this.maxMessageDownload = Integer.parseInt(maxmsg); } }
43565b19853d1d58a05ee2c92d4c302165eed5e1
eac06e3b1627e3b76b07aea3c1d799fb3f7cb1f1
/android/app/src/main/java/com/rnniubiz/NiubizModule.java
4f9d4e3f8d3d5d2036b400d5cb10024bc5fbf7be
[]
no_license
ksandon/NiubizReactNative
e064fcebd58dc6067d6b2fe32e6464152998afba
ccb10bf26123de63b4f602f936d0b29c775a34ab
refs/heads/master
2023-07-01T11:53:29.727304
2021-07-18T07:43:29
2021-07-18T07:43:29
387,071,703
0
0
null
null
null
null
UTF-8
Java
false
false
3,432
java
package com.rnniubiz; import android.app.Activity; import android.content.Intent; import android.util.Log; import androidx.annotation.NonNull; import com.facebook.react.bridge.ActivityEventListener; import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableMap; import java.util.HashMap; import java.util.Map; import lib.visanet.com.pe.visanetlib.VisaNet; import lib.visanet.com.pe.visanetlib.data.custom.Channel; import lib.visanet.com.pe.visanetlib.presentation.custom.VisaNetViewAuthorizationCustom; public class NiubizModule extends ReactContextBaseJavaModule { private Promise resultPromise; String TAG = "NIUBIZ"; NiubizModule(ReactApplicationContext context) { super(context); context.addActivityEventListener(activityEventListener); } @NonNull @Override public String getName() { return "NiubizModule"; } @ReactMethod public void openNiubizForm(ReadableMap map, Promise promise) { Log.i(TAG, "Android niubiz form"); Map<String, Object> data = new HashMap<>(); data.put(VisaNet.VISANET_CHANNEL, Channel.MOBILE); data.put(VisaNet.VISANET_COUNTABLE, true); data.put(VisaNet.VISANET_SECURITY_TOKEN, map.getString("token")); data.put(VisaNet.VISANET_MERCHANT, map.getString("merchant")); data.put(VisaNet.VISANET_PURCHASE_NUMBER, map.getString("purchase")); data.put(VisaNet.VISANET_AMOUNT, Double.parseDouble(map.getString("amount"))); data.put(VisaNet.VISANET_REGISTER_NAME, map.getString("name")); data.put(VisaNet.VISANET_REGISTER_LASTNAME, map.getString("lastname")); data.put(VisaNet.VISANET_REGISTER_EMAIL, map.getString("email")); data.put(VisaNet.VISANET_ENDPOINT_URL, map.getString("endpoint")); data.put(VisaNet.VISANET_CERTIFICATE_HOST, map.getString("endpoint")); data.put(VisaNet.VISANET_CERTIFICATE_PIN, "sha256/" + map.getString("pin")); VisaNetViewAuthorizationCustom custom = new VisaNetViewAuthorizationCustom(); resultPromise = promise; Log.i(TAG, "Android open niubiz form"); try { VisaNet.authorization(getCurrentActivity(), data, custom); } catch (Exception e) { Log.e(TAG, e.getMessage()); } } private final ActivityEventListener activityEventListener = new ActivityEventListener() { @Override public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { if (requestCode == VisaNet.VISANET_AUTHORIZATION) { if (data != null) { if (resultCode == Activity.RESULT_OK) { Log.i(TAG, "Android result OK"); String response = data.getExtras().getString("keySuccess"); resultPromise.resolve(response); } else { Log.i(TAG, "Android result ERROR"); String response = data.getExtras().getString("keyError"); resultPromise.resolve(response); } } } } @Override public void onNewIntent(Intent intent) {} }; }
5be554c3a50f02d0188534d2c8ac440efc318217
4b42a40e006d88e0159bc607c019b22e2b0fc6ce
/src/CAD.java
73be3e937959c892c1a4e524dff56d4b0207e219
[]
no_license
mclindino/Quine-McCluskey
ae092e4cbc3dd381f3cb264b1bd786cdc95fd9ae
0c3ba57abc195039118a79eb351370f52eaab31d
refs/heads/master
2020-07-31T02:55:56.275334
2019-09-23T22:02:33
2019-09-23T22:02:33
210,460,024
0
0
null
null
null
null
UTF-8
Java
false
false
6,696
java
package FerCAD; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class CAD { public static List<String> getLetters() { List<String> v = new ArrayList<>(); v.add("a"); v.add("b"); v.add("c"); v.add("d"); return v; } public static String decimalToBinario(int n) { if((n == 0) || (n == 1)) { return n + ""; } if((n % 2) == 0) { return decimalToBinario(n / 2) + "0"; } else { return decimalToBinario(n / 2) + "1"; } } public static String setZeros(String bin) { int max = 4 - bin.length(); for(int i = 0; i < max; i++) { bin = "0" + bin; } return bin; } public static boolean confere(String n1, String n2) { int flag = 0; for(int i = 0; i < n1.length(); i++) { if(n1.charAt(i) != n2.charAt(i)) { flag++; } } return (flag == 1); } public static String dontCares(String n1, String n2) { String temp = ""; for(int i = 0; i < n1.length(); i++) { if(n1.charAt(i) != n2.charAt(i)) { temp = temp + "-"; } else { temp = temp + n1.charAt(i); } } return temp; } public static boolean getIgualdade(List<String> n1, String n2) { for(int i = 0; i < n1.size(); i++) { if(n1.get(i).compareTo(n2) == 0) { return true; } } return false; } public static Tabela reduce(List<String> minterms, List<String> valores) { List<String> newminterms = new ArrayList<>(); List<String> newvalores = new ArrayList<>(); int max = minterms.size(); int[] checked = new int[max]; for(int i = 0; i < max; i++) { for(int j = i; j < max; j++) { if(confere(minterms.get(i), minterms.get(j))) { checked[i] = 1; checked[j] = 1; if(!getIgualdade(newminterms, dontCares(minterms.get(i), minterms.get(j)))) { newminterms.add(dontCares(minterms.get(i),minterms.get(j))); String str = valores.get(i) + "," + valores.get(j); newvalores.add(str); } } } } for(int i = 0; i < max; i++) { if((checked[i] != 1) && (!getIgualdade(newminterms, minterms.get(i)))) { newminterms.add(minterms.get(i)); newvalores.add(valores.get(i)); } } Tabela t = new Tabela(newminterms, newvalores); return t; } public static String getValue(String n1) { String temp = ""; List<String> vars = getLetters(); for(int i = 0; i < n1.length(); i++) { if(n1.charAt(i) != '-') { if(n1.charAt(i) == '0') { temp = temp + vars.get(i) + "\'"; } else { temp = temp + vars.get(i); } } } return temp; } public static boolean VectorsEqual(List<String> n1, List<String> n2) { if(n1.size() != n2.size()) { return false; } Collections.sort(n1); Collections.sort(n2); for(int i = 0; i < n1.size(); i++) { if(n1.get(i) != n2.get(i)) { return false; } } return true; } public static List<String> tabelaCobertura(List<String> s, List<String> v_associado, List<String> valores){ String[][] tabela = new String[s.size()][valores.size()]; List<String> reduzido = new ArrayList<>(); String n = null; int count = 0; for(int i = 0; i < s.size(); i++) { String[] str = v_associado.get(i).split(","); for(int k = 0; k < str.length; k++) { for(int j = 0; j < valores.size(); j++) { if(str[k].equals(valores.get(j))) { tabela[i][j] = "X"; } } } } /* for(int i = 0; i < s.size(); i++) { for(int j = 0; j < valores.size(); j++) { if(tabela[i][j] == null) { tabela[i][j] = "-"; } System.out.print(tabela[i][j] + " "); } System.out.print("\n"); } System.out.print("________________\n\n"); */ for(int i = 0; i < s.size(); i++) { for(int j = 0; j < valores.size(); j++) { if(tabela[i][j] == "X") { tabela[i][j] = valores.get(j); } if(tabela[i][j] == "-") { tabela[i][j] = "-"; } } } /* for(int i = 0; i < s.size(); i++) { for(int j = 0; j < valores.size(); j++) { System.out.print(tabela[i][j] + " "); } System.out.print("\n"); } System.out.print("________________\n\n"); */ ;//ACHAR MINTERMOS ESSENCIAIS: for(int i = 0; i < s.size(); i++) { for(int j = 0; j < valores.size(); j++) { if(tabela[i][j] != "*") { if(tabela[i][j] != "-") { n = tabela[i][j]; count = contador(n, tabela, s.size(), valores.size()); if(count == 1) { reduzido.add(s.get(i)); for(int k = 0; k < s.size(); k++) { tabela[k][j] = "*"; } for(int k = 0; k < valores.size(); k++) { tabela[i][k] = "*"; } } } } } } /*for(int i = 0; i < s.size(); i++) { for(int j = 0; j < valores.size(); j++) { System.out.print(tabela[i][j] + " "); } System.out.print("\n"); } System.out.print("________________\n\n"); */ //BUSCA O MINTERMOS QUE COBRE MAIS VALORES while(completo(tabela, s.size(), valores.size())) { int linha = busca(tabela, s.size(), valores.size()); //System.out.println(linha); reduzido.add(s.get(linha)); //System.out.print("________________\n\n"); for(int i = 0; i < valores.size(); i++) { if(tabela[linha][i] != "*") { if(tabela[linha][i] != "-") { for(int j = 0; j < s.size(); j++) { tabela[j][i] = "*"; } } } } } /*for(int i = 0; i < s.size(); i++) { for(int j = 0; j < valores.size(); j++) { System.out.print(tabela[i][j] + " "); } System.out.print("\n"); } */ return reduzido; } public static boolean completo(String[][] aux, int X, int Y) { for(int i = 0; i < X; i++) { for(int j = 0; j < Y; j++) { if(aux[i][j] != "*") { return true; } } } return false; } public static int busca(String[][] aux, int X, int Y) { int linha = 0; int atual = 0; int count; for(int i = 0; i < X; i++) { count = 0; for(int j = 0; j < Y; j++) { if(aux[i][j] != "*") { if(aux[i][j] != "-") { count++; } } } if(count > atual) { atual = count; linha = i; } } return linha; } public static int contador(String n, String[][] aux, int X, int Y) { int count = 0; for(int i = 0; i < X; i++) { for(int j = 0; j < Y; j++) { if(n == aux[i][j]) { count++; } } } return count; } @SuppressWarnings("resource") public static List<Integer> lerDados() { System.out.println("Digite os mintermos separados com vírgula: "); Scanner sc = new Scanner(System.in); String[] entrada = sc.nextLine().split(","); List<Integer> valores = new ArrayList<>(); for(int i = 0; i < entrada.length; i++) { valores.add(Integer.parseInt(entrada[i])); } return valores; } }
3e3dddde0acd7a0eb710bc9fa44cfb4bf7639a95
a5cd88d80d2c6af43528153199c86eacbea22f55
/java/2. Add Two Numbers.java
1880b6aa78c53a057616dc45eba50b07e7563eba
[]
no_license
qingmm/leetcode
c23a674a9051227b26288105482f99ce128abb00
ae2ac905cb6ad216e554332388f1ec37e45ed0df
refs/heads/master
2020-03-11T15:14:55.444601
2018-09-23T13:58:22
2018-09-23T13:58:22
130,078,586
0
0
null
null
null
null
UTF-8
Java
false
false
718
java
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { ListNode cur = new ListNode(0), l3 = cur; int carry = 0; while(l1 != null || l2 != null || carry != 0) { if (l1 != null) { carry += l1.val; l1 = l1.next; } if (l2 != null) { carry += l2.val; l2 = l2.next; } cur.next = new ListNode(carry % 10); cur = cur.next; carry /= 10; } return l3.next; } }
ecde965abef4f0970e7ca0631bb36c8aa0982ca8
d5c16c604fd6c9a7741cdd554fa20373de61832f
/zookeeper_book/src/main/java/book/chapter05/$5_4_1/Get_Children_Sample.java
ef71f0775120b0f668601661a284581fa57d32ea
[]
no_license
sunbaolong/study
0ca132795d85c493746715ff912225a438cf3dac
07ed461e9fc6461811879a841fda27a48887a312
refs/heads/master
2021-09-20T22:58:44.680305
2018-08-16T09:51:59
2018-08-16T09:51:59
109,987,429
0
0
null
null
null
null
UTF-8
Java
false
false
1,138
java
package book.chapter05.$5_4_1; import java.util.List; import book.ConnectUtil; import org.I0Itec.zkclient.IZkChildListener; import org.I0Itec.zkclient.ZkClient; // ZkClient获取子节点列表。 public class Get_Children_Sample { public static void main(String[] args) throws Exception { String path = "/zk-book"; ZkClient zkClient = new ZkClient("192.168.73.101:2181,192.168.73.102:2181,192.168.73.103:2181", 5000); zkClient.subscribeChildChanges(path, new IZkChildListener() { public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception { System.out.println(parentPath + " 's child changed, currentChilds:" + currentChilds); } }); zkClient.createPersistent(path); Thread.sleep( 1000 ); System.out.println(zkClient.getChildren(path)); Thread.sleep( 1000 ); zkClient.createPersistent(path+"/c1"); Thread.sleep( 1000 ); zkClient.delete(path+"/c1"); Thread.sleep( 1000 ); zkClient.delete(path); Thread.sleep( Integer.MAX_VALUE ); } }
8ba5e15d6e38cc5aedc4a51301aa33b224990fde
e88fa8e7a2fc8b91c24922b624a18b68772832de
/v-ol2/src/test/java/org/vaadin/vol/demo/SelectMultipleVectorLayers.java
a615517c9aae64d47621eb565e4cb5838d7a6d3e
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
mstahv/v-ol2
73dd031e7b6a22bcfa7653fe6c98a00abff977e5
1f0f9b270badf7fce691df94afa86691167ba2ab
refs/heads/master
2020-12-03T10:24:50.853688
2016-01-08T15:12:32
2016-01-08T15:12:32
49,279,084
0
0
null
2016-01-08T15:18:21
2016-01-08T15:18:21
null
UTF-8
Java
false
false
4,758
java
package org.vaadin.vol.demo; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Notification; import com.vaadin.ui.VerticalLayout; import org.vaadin.vol.Area; import org.vaadin.vol.Layer; import org.vaadin.vol.OpenLayersMap; import org.vaadin.vol.OpenStreetMapLayer; import org.vaadin.vol.client.Point; import org.vaadin.vol.PointVector; import org.vaadin.vol.client.Style; import org.vaadin.vol.client.StyleMap; import org.vaadin.vol.VectorLayer; import org.vaadin.vol.VectorLayer.VectorSelectedEvent; import org.vaadin.vol.client.VectorLayerState; /** * Demonstrates issue of only last VectorLayer added being able to listen for VectorSelected events. * With fix applied, each VectorLayer can listen to its own VectorSelected events. */ public class SelectMultipleVectorLayers extends AbstractVOLTest { private OpenLayersMap map = new OpenLayersMap(); //private VectorLayer layer1; //private VectorLayer layer2; @Override public String getDescription() { return "Demonstrate listening for VectorSelected events from multiple layers."; } @Override Component getMap() { map.addLayer(new OpenStreetMapLayer()); map.setCenter(-104.9, 38); map.setZoom(6); map.setSizeFull(); HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(createCheckBox("Layer 1", createLayer1())); hl.addComponent(createCheckBox("Layer 2", createLayer2())); Label l1 = new Label("Without fix, only the last vector layer added to a map can handle VectorSelected events"); l1.setSizeUndefined(); Label l2 = new Label("Click checkboxes to add and remove layers"); l2.setSizeUndefined(); VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); vl.addComponent(l1); vl.addComponent(hl); vl.addComponent(l2); vl.addComponent(map); vl.setExpandRatio(map, 1f); return vl; } private Component createCheckBox(String caption, final Layer layer) { CheckBox cb = new CheckBox(caption); cb.setImmediate(true); cb.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { addRemoveLayer((Boolean) event.getProperty().getValue(), layer); } }); return cb; } private void addRemoveLayer(boolean addIt, Layer layer) { if (addIt) { map.addLayer(layer); } else { map.removeLayer(layer); } } private Layer createLayer1() { VectorLayer layer1 = new VectorLayer(); layer1.setSelectionCtrlId("rz"); layer1.addVector(new PointVector(-104.9, 40.8)); layer1.addVector(new PointVector(-105.6, 40.6)); layer1.addVectorSelectedListener(new VectorLayer.VectorSelectedListener() { public void vectorSelected(VectorSelectedEvent event) { Notification.show("Select on Layer1"); } }); layer1.setSelectionMode(VectorLayerState.SelectionMode.SIMPLE); Style s = new Style(); s.setPointRadius(15.0); StyleMap sm = new StyleMap(s); layer1.setStyleMap(sm); return layer1; } private Layer createLayer2() { VectorLayer layer2 = new VectorLayer(); layer2.setSelectionCtrlId("rz"); Point st = new Point(-103.8, 40.2); double dx = 1.5; double dy = 1.25; Point[] r1 = { st, new Point(st.getLon(), st.getLat() - dy), new Point(st.getLon() + dx, st.getLat() - dy), new Point(st.getLon() + dx, st.getLat()), st }; Area a1 = new Area(); a1.setPoints(r1); layer2.addVector(a1); double off = 1.3; Point[]r2 = new Point[r1.length]; for (int i=0; i<r1.length; i++) { r2[i] = new Point(r1[i].getLon() + off, r1[i].getLat() + off); } Area a2 = new Area(); a2.setPoints(r2); layer2.addVector(a2); layer2.addVectorSelectedListener(new VectorLayer.VectorSelectedListener() { public void vectorSelected(VectorSelectedEvent event) { Notification.show("Select on Layer2"); } }); layer2.setSelectionMode(VectorLayerState.SelectionMode.SIMPLE); Style s = new Style(); s.setFillColor("green"); StyleMap sm = new StyleMap(s); layer2.setStyleMap(sm); return layer2; } }
1d072014bdcd4b1e542a7a23f23052826ac13489
af8542364da07adb69b59438cb28011ff4fdc2ab
/src/com/project/controller/TicTacToeView.java
ac963b94c065cdf030e9838c6f2934ce34ca56c8
[]
no_license
prashantbasnet94/JunitTest
8ab8408a4f6d0c59c78b7bd890e2980e0d772b00
6ee62404f3b3f7b2f16463f6e8d065e7010a8d4f
refs/heads/master
2020-12-29T21:13:40.828014
2020-02-21T06:13:37
2020-02-21T06:13:37
238,734,020
0
0
null
null
null
null
UTF-8
Java
false
false
678
java
package com.project.controller; public class TicTacToeView { public static void printBoard( int [][] matrix ){ for( int row = 0; row < matrix.length; row++ ){ for( int col = 0; col < matrix[row].length; col++ ){ // Uses the "global" constants to print out appropriate letter. if( matrix[row][col] == TicTacToeModel.X ) System.out.print("X "); else if(matrix[row][col] == TicTacToeModel.O ) System.out.print("O "); else System.out.print(". "); } // Goes to new line after printing each row System.out.println(""); } } }
6ee38ab7b5d9b3f3397e94c1986a37be0c138014
ffbdbdbbd94592081310541959066d0e3ce96631
/Cell.java
4e1d952de2cd5c30f8dc49649f89a2adf4b80dd8
[]
no_license
GangulyYadav/Java-Programs
977a20ce995acd5a240bd11ad9e4336507ae4035
43768fea85b0b39333caa4593bdb439abf0dea3d
refs/heads/master
2023-08-05T02:26:15.660633
2021-09-18T08:56:55
2021-09-18T08:56:55
407,808,617
0
0
null
null
null
null
UTF-8
Java
false
false
513
java
// Java program to create CellPhone class with methods printing ringing and vibrating methods // CWH practice set 8 question 2 // By Ganguly Yadav // 26th July 2021 class CellPhone{ public void ringing(){ System.out.println("Ringing..."); } public void vibrating(){ System.out.println("Vibrating..."); } } public class Cell { public static void main(String[] args) { CellPhone mobile = new CellPhone(); mobile.ringing(); mobile.vibrating(); } }
b4d2a378472c4ffe3c97b14fcbfb3ca2ed95ea23
9db1ce61724ef2b5d394b7c8dc7968158824b83d
/src/test/java/org/keyko/retirement/domain/PurchaseTest.java
252bde4f8e99802809145ca72cb36f435140d6ae
[]
no_license
kombucha-java/retirement
efee3d2551cc0c9759cafec4d557c8586549f4f9
cf0bc8587c2f5a1e878fe7d436fe4d334af0f5f5
refs/heads/master
2023-04-11T04:08:49.743204
2021-04-26T15:30:23
2021-04-26T15:30:23
361,800,951
0
0
null
null
null
null
UTF-8
Java
false
false
699
java
package org.keyko.retirement.domain; import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; import org.keyko.retirement.web.rest.TestUtil; class PurchaseTest { @Test void equalsVerifier() throws Exception { TestUtil.equalsVerifier(Purchase.class); Purchase purchase1 = new Purchase(); purchase1.setId(1L); Purchase purchase2 = new Purchase(); purchase2.setId(purchase1.getId()); assertThat(purchase1).isEqualTo(purchase2); purchase2.setId(2L); assertThat(purchase1).isNotEqualTo(purchase2); purchase1.setId(null); assertThat(purchase1).isNotEqualTo(purchase2); } }
25872880f685576af9da98501a7fb81cfeb6846d
5b9a04d3c911c16aba63258d48606d6ea364a6da
/distribution_inventory/modules/inventory/app/dto/product_inventory/ProductInventoryDetailDto.java
a28e80213231991d396692d7b2d755e98761844b
[ "Apache-2.0" ]
permissive
yourant/repository1
40fa5ce602bbcad4e6f61ad6eb1330cfe966f780
9ab74a2dfecc3ce60a55225e39597e533975a465
refs/heads/master
2021-12-15T04:22:23.009473
2017-07-28T06:06:35
2017-07-28T06:06:35
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,579
java
package dto.product_inventory; /** * @author longhuashen * @since 2016/12/13 */ public class ProductInventoryDetailDto { private String account; private String sku; private Integer warehouseId; private String warehouseName; private Integer isGift; private Integer expirationDateSort;// 是否需要按照变更时间排序,0:asc,1:desc,null:默认排序 private Integer moreThan; public String getSku() { return sku; } public void setSku(String sku) { this.sku = sku; } public Integer getWarehouseId() { return warehouseId; } public void setWarehouseId(Integer warehouseId) { this.warehouseId = warehouseId; } public String getAccount() { return account; } public void setAccount(String account) { this.account = account; } public String getWarehouseName() { return warehouseName; } public void setWarehouseName(String warehouseName) { this.warehouseName = warehouseName; } public Integer getExpirationDateSort() { return expirationDateSort; } public void setExpirationDateSort(Integer expirationDateSort) { this.expirationDateSort = expirationDateSort; } public Integer getIsGift() { return isGift; } public void setIsGift(Integer isGift) { this.isGift = isGift; } public Integer getMoreThan() { return moreThan; } public void setMoreThan(Integer moreThan) { this.moreThan = moreThan; } }
298b309353345661ea29890dea277ed57d0a4716
99c7920038f551b8c16e472840c78afc3d567021
/aliyun-java-sdk-dts-v5/src/main/java/com/aliyuncs/v5/dts/model/v20200101/DescribeSubscriptionInstanceStatusResponse.java
4ddcee638266c313ba8652e0f731651b5f0b50c1
[ "Apache-2.0" ]
permissive
aliyun/aliyun-openapi-java-sdk-v5
9fa211e248b16c36d29b1a04662153a61a51ec88
0ece7a0ba3730796e7a7ce4970a23865cd11b57c
refs/heads/master
2023-03-13T01:32:07.260745
2021-10-18T08:07:02
2021-10-18T08:07:02
263,800,324
4
2
NOASSERTION
2022-05-20T22:01:22
2020-05-14T02:58:50
Java
UTF-8
Java
false
false
7,371
java
/* * 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.aliyuncs.v5.dts.model.v20200101; import java.util.List; import com.aliyuncs.v5.AcsResponse; import com.aliyuncs.v5.dts.transform.v20200101.DescribeSubscriptionInstanceStatusResponseUnmarshaller; import com.aliyuncs.v5.transform.UnmarshallerContext; /** * @author auto create * @version */ public class DescribeSubscriptionInstanceStatusResponse extends AcsResponse { private String beginTimestamp; private String consumptionCheckpoint; private String consumptionClient; private String endTimestamp; private String errMessage; private String payType; private String requestId; private String status; private String subscribeTopic; private String subscriptionInstanceID; private String subscriptionInstanceName; private String errCode; private String success; private String errorMessage; private String taskId; private List<SynchronousObject> subscriptionObject; private SourceEndpoint sourceEndpoint; private SubscriptionDataType subscriptionDataType; private SubscriptionHost subscriptionHost; public String getBeginTimestamp() { return this.beginTimestamp; } public void setBeginTimestamp(String beginTimestamp) { this.beginTimestamp = beginTimestamp; } public String getConsumptionCheckpoint() { return this.consumptionCheckpoint; } public void setConsumptionCheckpoint(String consumptionCheckpoint) { this.consumptionCheckpoint = consumptionCheckpoint; } public String getConsumptionClient() { return this.consumptionClient; } public void setConsumptionClient(String consumptionClient) { this.consumptionClient = consumptionClient; } public String getEndTimestamp() { return this.endTimestamp; } public void setEndTimestamp(String endTimestamp) { this.endTimestamp = endTimestamp; } public String getErrMessage() { return this.errMessage; } public void setErrMessage(String errMessage) { this.errMessage = errMessage; } public String getPayType() { return this.payType; } public void setPayType(String payType) { this.payType = payType; } public String getRequestId() { return this.requestId; } public void setRequestId(String requestId) { this.requestId = requestId; } public String getStatus() { return this.status; } public void setStatus(String status) { this.status = status; } public String getSubscribeTopic() { return this.subscribeTopic; } public void setSubscribeTopic(String subscribeTopic) { this.subscribeTopic = subscribeTopic; } public String getSubscriptionInstanceID() { return this.subscriptionInstanceID; } public void setSubscriptionInstanceID(String subscriptionInstanceID) { this.subscriptionInstanceID = subscriptionInstanceID; } public String getSubscriptionInstanceName() { return this.subscriptionInstanceName; } public void setSubscriptionInstanceName(String subscriptionInstanceName) { this.subscriptionInstanceName = subscriptionInstanceName; } public String getErrCode() { return this.errCode; } public void setErrCode(String errCode) { this.errCode = errCode; } public String getSuccess() { return this.success; } public void setSuccess(String success) { this.success = success; } public String getErrorMessage() { return this.errorMessage; } public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; } public String getTaskId() { return this.taskId; } public void setTaskId(String taskId) { this.taskId = taskId; } public List<SynchronousObject> getSubscriptionObject() { return this.subscriptionObject; } public void setSubscriptionObject(List<SynchronousObject> subscriptionObject) { this.subscriptionObject = subscriptionObject; } public SourceEndpoint getSourceEndpoint() { return this.sourceEndpoint; } public void setSourceEndpoint(SourceEndpoint sourceEndpoint) { this.sourceEndpoint = sourceEndpoint; } public SubscriptionDataType getSubscriptionDataType() { return this.subscriptionDataType; } public void setSubscriptionDataType(SubscriptionDataType subscriptionDataType) { this.subscriptionDataType = subscriptionDataType; } public SubscriptionHost getSubscriptionHost() { return this.subscriptionHost; } public void setSubscriptionHost(SubscriptionHost subscriptionHost) { this.subscriptionHost = subscriptionHost; } public static class SynchronousObject { private String databaseName; private String wholeDatabase; private List<String> tableList; public String getDatabaseName() { return this.databaseName; } public void setDatabaseName(String databaseName) { this.databaseName = databaseName; } public String getWholeDatabase() { return this.wholeDatabase; } public void setWholeDatabase(String wholeDatabase) { this.wholeDatabase = wholeDatabase; } public List<String> getTableList() { return this.tableList; } public void setTableList(List<String> tableList) { this.tableList = tableList; } } public static class SourceEndpoint { private String instanceID; private String instanceType; public String getInstanceID() { return this.instanceID; } public void setInstanceID(String instanceID) { this.instanceID = instanceID; } public String getInstanceType() { return this.instanceType; } public void setInstanceType(String instanceType) { this.instanceType = instanceType; } } public static class SubscriptionDataType { private Boolean dDL; private Boolean dML; public Boolean getDDL() { return this.dDL; } public void setDDL(Boolean dDL) { this.dDL = dDL; } public Boolean getDML() { return this.dML; } public void setDML(Boolean dML) { this.dML = dML; } } public static class SubscriptionHost { private String privateHost; private String publicHost; private String vPCHost; public String getPrivateHost() { return this.privateHost; } public void setPrivateHost(String privateHost) { this.privateHost = privateHost; } public String getPublicHost() { return this.publicHost; } public void setPublicHost(String publicHost) { this.publicHost = publicHost; } public String getVPCHost() { return this.vPCHost; } public void setVPCHost(String vPCHost) { this.vPCHost = vPCHost; } } @Override public DescribeSubscriptionInstanceStatusResponse getInstance(UnmarshallerContext context) { return DescribeSubscriptionInstanceStatusResponseUnmarshaller.unmarshall(this, context); } }
76cf1dd608e977d6870f07c6d5d432a535c36e54
463562b9797bf0318850bf4714c73b52eb283974
/app/src/main/java/com/wangyh2116/sunnyweather/logic/model/dailyresponse/LifeIndex.java
f98e78fc42c419f5ae348628d8cfdc8723445dc0
[ "Apache-2.0" ]
permissive
Android-keki-Ading/SunnyWeather2
8492af9e9eb4682a3972ff4d1a91774322a52409
143799cd83a68a0ed869338a95ae69aa2fce4d50
refs/heads/main
2023-02-13T16:02:52.088008
2021-01-06T03:32:39
2021-01-06T03:32:39
null
0
0
null
null
null
null
UTF-8
Java
false
false
939
java
package com.wangyh2116.sunnyweather.logic.model.dailyresponse; import java.util.List; public class LifeIndex { private List<LifeDescription> coldRisk; private List<LifeDescription> carWashing; private List<LifeDescription> ultraviolet; private List<LifeDescription> dressing; public LifeIndex(List<LifeDescription> coldRisk, List<LifeDescription> carWashing, List<LifeDescription> ultraviolet, List<LifeDescription> dressing) { this.coldRisk = coldRisk; this.carWashing = carWashing; this.ultraviolet = ultraviolet; this.dressing = dressing; } public List<LifeDescription> getColdRisk() { return coldRisk; } public List<LifeDescription> getCarWashing() { return carWashing; } public List<LifeDescription> getUltraviolet() { return ultraviolet; } public List<LifeDescription> getDressing() { return dressing; } }
af103356662842603d7dcc0356d6a5668e7cb9c4
e0a87d0e197f3c2420289ee6b742e3e1508c549e
/src/main/java/com/example/entity/InvoiceReceiveInfo.java
915127ddf561ea174de4a7450c8e1e7efc1d2fcf
[]
no_license
kongad/engineer0
d8a8961ba0de5eb8b248cf97e0af69bf9e6fbc91
d70d0f7025288c3db479df9c71dee04933dcb7c8
refs/heads/master
2022-12-28T09:45:43.139974
2020-10-05T02:33:43
2020-10-05T02:33:43
303,316,097
1
0
null
null
null
null
UTF-8
Java
false
false
4,095
java
package com.example.entity; import java.io.Serializable; /** * 发票收票登记表(InvoiceReceiveInfo)实体类 * * @author makejava * @since 2020-10-05 10:18:36 */ public class InvoiceReceiveInfo implements Serializable { private static final long serialVersionUID = 808341848716170939L; /** * 编号 */ private Integer id; /** * 项目ID */ private Integer pId; /** * 合同ID */ private Integer cId; /** * 开票类型 */ private String openType; /** * 付款单位 */ private Integer payCompanyId; /** * 收款单位 */ private Integer incomeCompanyId; /** * 发票类型 */ private String invoiceType; /** * 发票号码 */ private String invoiceNo; /** * 发票金额 */ private Double invoiceAmount; /** * 金额大写 */ private String amountUpper; /** * 开户银行 */ private String accountBank; /** * 账号 */ private String accountNum; /** * 纳税人识别号 */ private String taxplayerNo; /** * 电话、地址 */ private String phoneAddress; /** * 填报人 */ private String editer; /** * 日期 */ private Object openDate; /** * 备注 */ private String comment; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Integer getPId() { return pId; } public void setPId(Integer pId) { this.pId = pId; } public Integer getCId() { return cId; } public void setCId(Integer cId) { this.cId = cId; } public String getOpenType() { return openType; } public void setOpenType(String openType) { this.openType = openType; } public Integer getPayCompanyId() { return payCompanyId; } public void setPayCompanyId(Integer payCompanyId) { this.payCompanyId = payCompanyId; } public Integer getIncomeCompanyId() { return incomeCompanyId; } public void setIncomeCompanyId(Integer incomeCompanyId) { this.incomeCompanyId = incomeCompanyId; } public String getInvoiceType() { return invoiceType; } public void setInvoiceType(String invoiceType) { this.invoiceType = invoiceType; } public String getInvoiceNo() { return invoiceNo; } public void setInvoiceNo(String invoiceNo) { this.invoiceNo = invoiceNo; } public Double getInvoiceAmount() { return invoiceAmount; } public void setInvoiceAmount(Double invoiceAmount) { this.invoiceAmount = invoiceAmount; } public String getAmountUpper() { return amountUpper; } public void setAmountUpper(String amountUpper) { this.amountUpper = amountUpper; } public String getAccountBank() { return accountBank; } public void setAccountBank(String accountBank) { this.accountBank = accountBank; } public String getAccountNum() { return accountNum; } public void setAccountNum(String accountNum) { this.accountNum = accountNum; } public String getTaxplayerNo() { return taxplayerNo; } public void setTaxplayerNo(String taxplayerNo) { this.taxplayerNo = taxplayerNo; } public String getPhoneAddress() { return phoneAddress; } public void setPhoneAddress(String phoneAddress) { this.phoneAddress = phoneAddress; } public String getEditer() { return editer; } public void setEditer(String editer) { this.editer = editer; } public Object getOpenDate() { return openDate; } public void setOpenDate(Object openDate) { this.openDate = openDate; } public String getComment() { return comment; } public void setComment(String comment) { this.comment = comment; } }