blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 332 | content_id stringlengths 40 40 | detected_licenses listlengths 0 50 | license_type stringclasses 2
values | repo_name stringlengths 7 115 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 557
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 77.7k | fork_events_count int64 0 48k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 82
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 7 5.41M | extension stringclasses 11
values | content stringlengths 7 5.41M | authors listlengths 1 1 | author stringlengths 0 161 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cbf0d42a1e43d3bb2a14af6915e0119c1097d181 | 5c4c5521f9b53ddf1f5e7b51151b756ea30645c7 | /src/main/java/com/hines/playerscraper/entities/StatsSummary.java | 2f4cebcd29fb231f1a129ccb9d4af504bd4c7bf7 | [] | no_license | jonhines/espn_fbb_player_fetch | 7a5fbde00966ce26200a18101d26c9368dacb007 | 67cbf2a558faadeeb593e3df5a645b12ac172729 | refs/heads/master | 2022-09-22T23:21:01.570791 | 2022-09-20T00:56:14 | 2022-09-20T00:56:14 | 199,556,031 | 0 | 3 | null | null | null | null | UTF-8 | Java | false | false | 331 | java | package com.hines.playerscraper.entities;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StatsSummary{
private String displayName;
private List<StatisticsItem> statistics;
}
| [
"johines@vistaprint.com"
] | johines@vistaprint.com |
7ce9dec2525e79be0ab227793b45bb28cdd2e599 | 4f4338ce002a8b67c01776fe374266ad8b80b9c8 | /api-gateway-service/src/main/java/com/gateway/apigatewayservice/JwtConfig.java | 97646e438cfd59ecbfa335922d84b25ed5b18e52 | [] | no_license | MohamedAmarani/microservices | b4c2ce3761583f805a82e48eeabd63f28e8d6fa4 | ff5886cee55d2445785515b53f7fa30d9df29a4e | refs/heads/main | 2023-08-16T02:33:41.138782 | 2021-09-15T11:54:57 | 2021-09-15T11:54:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,017 | java | package com.gateway.apigatewayservice;
import com.google.common.util.concurrent.AtomicDouble;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Value;
import javax.annotation.PostConstruct;
import java.text.SimpleDateFormat;
import java.util.*;
public class JwtConfig {
@Value("${security.jwt.uri:/auth/**}")
private String Uri;
@Value("${security.jwt.header:Authorization}")
private String header;
@Value("${security.jwt.prefix:Bearer }")
private String prefix;
@Value("${security.jwt.expiration:#{24*60*60}}")
private int expiration;
@Value("${security.jwt.secret:JwtSecretKey}")
private String secret;
public String getUri() {
return Uri;
}
public String getHeader() {
return header;
}
public String getPrefix() {
return prefix;
}
public int getExpiration() {
return expiration;
}
public String getSecret() {
return secret;
}
} | [
"mohamedamarani@inslauro.net"
] | mohamedamarani@inslauro.net |
4462d066c6733657d8c6e475006809ac2e02ecea | c88fe68e5ea5803f66090da00f6362b14b8d6aab | /src/main/java/com/sdmx/support/app/ModelEntity.java | d4d7ba3029226c40473f494f98c71b2bb6cf3577 | [] | no_license | mangadul/sdmx | 59042b49e87328ca11b6730ed0fbc3a9b8590ade | a0f3ae5bfb389ab095b5f0376c9e0850f9e686f5 | refs/heads/master | 2021-05-12T18:39:56.307057 | 2018-01-11T08:24:43 | 2018-01-11T08:24:43 | 114,432,262 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,781 | java | package com.sdmx.support.app;
import com.sdmx.Application;
import com.sdmx.error.exception.FormValidationException;
import com.sdmx.error.exception.HttpException;
import org.thymeleaf.util.StringUtils;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class ModelEntity implements Application {
private ModelEntityFactory factory;
private Class classEntity;
private CriteriaBuilder builder;
public ModelEntity(ModelEntityFactory factory, Class classEntity) {
this.factory = factory;
this.classEntity = classEntity;
}
public ModelEntityFactory getFactory() {
return factory;
}
/** SELECTION */
public Object find(Object id) {
EntityManager em = factory.em();
Object object = em.find(classEntity, id);
em.close();
return object;
}
public Object find(Map<String, Object> param) {
EntityManager em = factory.em();
Object object = em.find(classEntity, param);
em.close();
return object;
}
public Object findOrFail(Object id) {
Object entity = find(id);
if (entity == null) {
throw new HttpException(404);
}
return entity;
}
public List<?> all() {
CriteriaQuery query = query();
query.select(query.from(classEntity));
EntityManager em = factory.em();
List<?> result = em.createQuery(query).getResultList();
em.close();
return result;
}
/** DATA MANIPULATION */
public Object create(Object model) {
try {
EntityManager em = factory.em();
em.getTransaction().begin();
em.persist(model);
em.getTransaction().commit();
em.close();
return model;
}
catch (FormValidationException e) {
throw e;
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
public Object update(Object model) {
try {
EntityManager em = factory.em();
em.getTransaction().begin();
em.merge(model);
em.getTransaction().commit();
em.close();
return model;
}
catch (FormValidationException e) {
throw e;
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
public Object save(Map<String, Object> value) {
try {
EntityManager em = factory.em();
em.getTransaction().begin();
Object model = fill(classEntity.newInstance(), value);
em.persist(model);
em.getTransaction().commit();
em.close();
return model;
}
catch (FormValidationException e) {
throw e;
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
public Object update(Object id, Map<String, Object> value) {
try { return updateOrFail(id, value); } catch (HttpException e) { return null; }
}
public void delete(Object id) {
try { deleteOrFail(id); } catch (HttpException e) { }
}
public Object updateOrFail(Object id, Map<String, Object> value) {
Object entity = fill(findOrFail(id), value);
EntityManager em = factory.em();
em.getTransaction().begin();
em.merge(entity);
em.getTransaction().commit();
em.close();
return entity;
}
public void deleteOrFail(Object id) {
Object entity = findOrFail(id);
EntityManager em = factory.em();
em.getTransaction().begin();
em.remove(em.contains(entity) ? entity : em.merge(entity));
em.getTransaction().commit();
em.close();
}
/** HELPERS */
public Object fill(Object entity, Map<String, Object> value) {
Class<?> entityClass = entity.getClass();
List<String> fillable = null;
Map<String, String> rules = null;
// Fetch Fillable
try {
Field fillableField = entityClass.getDeclaredField("fillable");
fillableField.setAccessible(true);
fillable = Arrays.asList((String[]) fillableField.get(entity));
}
catch (Exception e) { e.printStackTrace(); }
// Fetch Rules
try {
Method rulesMethod = entityClass.getDeclaredMethod("rules");
rulesMethod.setAccessible(true);
rules = (Map<String, String>) rulesMethod.invoke(entity);
}
catch (Exception e) { e.printStackTrace(); }
// Fill Attribute
for (Field field : entityClass.getDeclaredFields()) {
String fieldName = field.getName();
field.setAccessible(true);
// not listed in fillable
// applied only if fillable declared
if (fillable instanceof List && !fillable.contains(fieldName)) {
continue;
}
try {
// auto set updated time
if (field.getType() == Date.class && fieldName == "updated") {
field.set(entity, new Date());
}
// set attribute
else if (value.containsKey(fieldName)) {
String fieldRule;
Validator validator = factory.getValidator();
// fetch attribute rules
if (rules instanceof Map && rules.containsKey(fieldName)) {
fieldRule = rules.get(fieldName);
}
else {
fieldRule = StringUtils.join(validator.guessFieldRule(field), "|");
}
// validate value
validator.validateAttributeOrFail(fieldName, fieldRule, value.get(fieldName));
// set value
field.set(entity, value.get(fieldName));
}
}
catch (Exception e) { e.printStackTrace(); }
}
return entity;
}
public EntityManager createEntityManager() {
return getFactory().em();
}
public CriteriaBuilder builder() {
if (builder == null) {
builder = factory.getEntityManagerFactory().getCriteriaBuilder();
}
return builder;
}
public CriteriaQuery query() {
return builder().createQuery(classEntity);
}
}
| [
"muin.abdul@gmail.com"
] | muin.abdul@gmail.com |
fd8258b4ee0679aed838f90b2f43da838da44e6a | d7edc45168169dcbce00b38d4c40aa7f86563b37 | /src/com/connectionLayer/DAO/PerifericoExternoDAO.java | 8f71e2852c4fbdd93a5edd1fac1481304c1b2d84 | [] | no_license | luxar/OnmiSample__Server | 8a392526ad7ad139a9305c61ed7cfae2b2f2a502 | ce208cc9cc245dde2dbee415b94f99bc681817e5 | refs/heads/master | 2021-05-28T18:56:13.275074 | 2015-07-03T16:29:44 | 2015-07-03T16:29:44 | null | 0 | 0 | null | null | null | null | MacCentralEurope | Java | false | false | 1,759 | java | package com.connectionLayer.DAO;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Collection;
import java.util.Vector;
import com.connectionLayer.DTO.PerifericoDTO;
import com.connectionLayer.connectors.EConnection;
/**
* engloba las funciones que tienen como fin tratar con la base de datos de dispositivos DomoEnd externa.
* @author Lucas Alvarez ArgŁero
*
*/
public class PerifericoExternoDAO {
/**
* Devuelve el dto de todos los perifericos del dispositivo(modelo de base datos externa)
* @param numserie numero de serie del dispositivo
* @return coleccion dto con todos los perifericos del dispositivo y todas sus opciones
*/
public Collection<PerifericoDTO> dispositvo(int numserie) {
Connection con = null;
PreparedStatement pstm = null;
ResultSet rs = null;
try {
con = EConnection.getConnection();
String sql = "";
sql += "SELECT * FROM periferico WHERE numserie=?";
pstm = con.prepareStatement(sql);
pstm.setInt(1, numserie);
rs = pstm.executeQuery();
PerifericoDTO dto = null;
Vector<PerifericoDTO> ret = new Vector<PerifericoDTO>();
while (rs.next()) {
dto=new PerifericoDTO();
dto.setNumserie(rs.getInt("numserie"));
dto.setPosicion(rs.getInt("posicion"));
dto.setBooleano(rs.getBoolean("booleano"));
dto.setEscribible(rs.getBoolean("escribible"));
dto.setPicMax(rs.getInt("picmax"));
dto.setPicMin(rs.getInt("picmin"));
dto.setRealMax(rs.getInt("realmax"));
dto.setRealMin(rs.getInt("realmin"));
dto.setNombreperi(rs.getString("nombreperi"));
ret.add(dto);
}
return ret;
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
}
}
| [
"lucasmecanicapando@gmail.com"
] | lucasmecanicapando@gmail.com |
166377fea6b16c938a1946b2786555ee6cf26a73 | 90ec14d8fc49164c0bb5bbc79e8a4314ab59a4b9 | /src/test/java/hooks/StarterClass.java | ec7e283edf396b0511f15af20c9e08b13d56ad34 | [] | no_license | ssbrahim78/BDD_New_Brahim | a7e3df3e9b79d5406b3790388dfc4944c3da8ef5 | e8d86e1f4dbeb26e0c6cf6e3cac06b538e14c641 | refs/heads/master | 2023-08-03T01:36:17.361038 | 2021-10-05T19:52:14 | 2021-10-05T19:52:14 | 411,893,319 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,544 | java | package hooks;
import io.cucumber.java.After;
import io.cucumber.java.Before;
import io.cucumber.java.Scenario;
import org.openqa.selenium.support.PageFactory;
import utils.Common;
import webPages.AmazonHomePage;
import java.io.IOException;
import java.util.Properties;
public class StarterClass extends Common {
public static AmazonHomePage amazonHomePage;
String PropertiesFilePath = "config.properties";
String secretFilePath = "src/test/resources/secret.properties";
public static Properties prop;
{
try {
prop = loadProperties(PropertiesFilePath);
} catch (IOException e) {
e.printStackTrace();
}
}
public static Properties secretProp;
{
try {
secretProp = loadProperties(secretFilePath);
} catch (IOException e) {
e.printStackTrace();
}
}
String testingEnvironment= prop.getProperty("TestingEnvironment");
Boolean useCloudEnv= Boolean.parseBoolean(prop.getProperty("UseCloudEnv")) ;
String cloudEnvName= prop.getProperty("CloudEnvName");
String os= prop.getProperty("Os");
String os_version = prop.getProperty("Os_version");
String browserName = prop.getProperty("BrowserName");
String browserVersion = prop.getProperty("BrowserVersion");
long implicitlyWaitTime=Long.parseLong(prop.getProperty("ImplicitlyWaitTime").trim());
//long implicitlyWaitTime= implicitlywaitTime.longValue();
String url = secretProp.getProperty(testingEnvironment);
// Read properties from propertie file
public static void Init() {
amazonHomePage = PageFactory.initElements(driver,AmazonHomePage.class);
}
@Before
public void setUp_Init() throws IOException {
setUp( useCloudEnv, cloudEnvName,
os, os_version, browserName,
browserVersion, url,implicitlyWaitTime);
Init();
}
@After
public void tearDown(Scenario scenario) throws IOException {
String scenarioStatus=" is Failed";
//ScreenShot method
if(scenario.isFailed()){
try{
System.out.println(scenario.getName()+" is Failed");
screenShot(scenario);
}catch (Exception e){
e.printStackTrace();
}
}else {
try{
System.out.println(scenario.getName()+" is Passed");
}catch (Exception E){
E.printStackTrace();
}
}
driver.quit();
}
} | [
"63694144+ssbrahim78@users.noreply.github.com"
] | 63694144+ssbrahim78@users.noreply.github.com |
488f3766fb016316a741041025d329204e6d386b | a9de22590675be8ee38163127a2c24a20c248a0b | /src/com/iremote/device/operate/zwavedevice/OperationTranslatorHelper.java | 04b45b61f2f84de4f70916d42fd0dd627809770a | [] | no_license | jessicaallen777/iremote2 | 0943622300286f8d16e9bb4dca349613ffc23bb1 | b27aa81785fc8bf5467a1ffcacd49a04e41f6966 | refs/heads/master | 2023-03-16T03:20:00.746888 | 2019-12-12T04:02:30 | 2019-12-12T04:02:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 716 | java | package com.iremote.device.operate.zwavedevice;
import java.util.List;
import com.iremote.infraredtrans.tlv.CommandTlv;
public class OperationTranslatorHelper
{
public static byte[] createCommand(List<CommandTlv> lst)
{
if ( lst == null || lst.size() == 0 )
return null;
byte b[][] = new byte[lst.size()][];
for ( int i = 0 ; i < lst.size() ; i ++ )
b[i] = lst.get(i).getByte();
int size = 0 ;
for ( int i = 0 ; i < b.length ; i ++ )
size += ( b[i].length - 5 ) ;
byte command[] = new byte[size];
int index = 0 ;
for ( int i = 0 ; i < b.length ; i ++ )
{
System.arraycopy(b[i], 4, command, index, b[i].length - 5);
index += b[i].length - 5;
}
return command ;
}
}
| [
"stevenbluesky@163.com"
] | stevenbluesky@163.com |
5859de34ddc091a7fb39ce8ae0d0411fecc88654 | 3958a76a9d0cb96de0a4392edcf878bfbfe56034 | /library/src/main/java/com/sunday/common/widgets/wheel/WheelView.java | 4416d98519fe4c1e939e37a41110902b7148e1f7 | [] | no_license | MaryDQ/meiboyunRemote | 358d8608f66c4e2b5c549808212692c9235fe27e | b8801633e36d03ec0191844bf68fa2e04a2a89bf | refs/heads/master | 2020-08-03T05:14:28.323814 | 2019-09-29T09:00:14 | 2019-09-29T09:00:14 | 211,634,338 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 23,187 | java | /*
* Android Wheel Control.
* https://code.google.com/p/android-wheel/
*
* Copyright 2011 Yuri Kanivets
*
* 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.sunday.common.widgets.wheel;
import android.content.Context;
import android.database.DataSetObserver;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;
import com.sunday.common.R;
import com.sunday.common.widgets.wheel.adapters.WheelViewAdapter;
import java.util.LinkedList;
import java.util.List;
/**
* Numeric wheel view.
*
* @author Yuri Kanivets
*/
public class WheelView extends View {
/** Top and bottom shadows colors */
/*/ Modified by wulianghuan 2014-11-25
private int[] SHADOWS_COLORS = new int[] { 0xFF111111,
0x00AAAAAA, 0x00AAAAAA };
//*/
private int[] SHADOWS_COLORS = new int[] { 0xefE9E9E9,
0xcfE9E9E9, 0x3fE9E9E9 };
/** Top and bottom items offset (to hide that) */
private static final int ITEM_OFFSET_PERCENT = 0;
/** Left and right padding value */
private static final int PADDING = 10;
/** Default count of visible items */
private static final int DEF_VISIBLE_ITEMS = 5;
// Wheel Values
private int currentItem = 0;
// Count of visible items
private int visibleItems = DEF_VISIBLE_ITEMS;
// Item height
private int itemHeight = 0;
// Center Line
private Drawable centerDrawable;
// Wheel drawables
private int wheelBackground = R.drawable.wheel_bg;
private int wheelForeground = R.drawable.wheel_val;
// Shadows drawables
private GradientDrawable topShadow;
private GradientDrawable bottomShadow;
// Draw Shadows
private boolean drawShadows = true;
// Scrolling
private WheelScroller scroller;
private boolean isScrollingPerformed;
private int scrollingOffset;
// Cyclic
boolean isCyclic = false;
// Items layout
private LinearLayout itemsLayout;
// The number of first item in layout
private int firstItem;
// View adapter
private WheelViewAdapter viewAdapter;
// Recycle
private WheelRecycle recycle = new WheelRecycle(this);
// Listeners
private List<OnWheelChangedListener> changingListeners = new LinkedList<OnWheelChangedListener>();
private List<OnWheelScrollListener> scrollingListeners = new LinkedList<OnWheelScrollListener>();
private List<OnWheelClickedListener> clickingListeners = new LinkedList<OnWheelClickedListener>();
/**
* Constructor
*/
public WheelView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initData(context);
}
/**
* Constructor
*/
public WheelView(Context context, AttributeSet attrs) {
super(context, attrs);
initData(context);
}
/**
* Constructor
*/
public WheelView(Context context) {
super(context);
initData(context);
}
/**
* Initializes class data
* @param context the context
*/
private void initData(Context context) {
scroller = new WheelScroller(getContext(), scrollingListener);
}
// Scrolling listener
WheelScroller.ScrollingListener scrollingListener = new WheelScroller.ScrollingListener() {
@Override
public void onStarted() {
isScrollingPerformed = true;
notifyScrollingListenersAboutStart();
}
@Override
public void onScroll(int distance) {
doScroll(distance);
int height = getHeight();
if (scrollingOffset > height) {
scrollingOffset = height;
scroller.stopScrolling();
} else if (scrollingOffset < -height) {
scrollingOffset = -height;
scroller.stopScrolling();
}
}
@Override
public void onFinished() {
if (isScrollingPerformed) {
notifyScrollingListenersAboutEnd();
isScrollingPerformed = false;
}
scrollingOffset = 0;
invalidate();
}
@Override
public void onJustify() {
if (Math.abs(scrollingOffset) > WheelScroller.MIN_DELTA_FOR_SCROLLING) {
scroller.scroll(scrollingOffset, 0);
}
}
};
/**
* Set the the specified scrolling interpolator
* @param interpolator the interpolator
*/
public void setInterpolator(Interpolator interpolator) {
scroller.setInterpolator(interpolator);
}
/**
* Gets count of visible items
*
* @return the count of visible items
*/
public int getVisibleItems() {
return visibleItems;
}
/**
* Sets the desired count of visible items.
* Actual amount of visible items depends on wheel layout parameters.
* To apply changes and rebuild view call measure().
*
* @param count the desired count for visible items
*/
public void setVisibleItems(int count) {
visibleItems = count;
}
/**
* Gets view adapter
* @return the view adapter
*/
public WheelViewAdapter getViewAdapter() {
return viewAdapter;
}
// Adapter listener
private DataSetObserver dataObserver = new DataSetObserver() {
@Override
public void onChanged() {
invalidateWheel(true);
}
@Override
public void onInvalidated() {
invalidateWheel(true);
}
};
/**
* Sets view adapter. Usually new adapters contain different views, so
* it needs to rebuild view by calling measure().
*
* @param viewAdapter the view adapter
*/
public void setViewAdapter(WheelViewAdapter viewAdapter) {
/* if (this.viewAdapter != null) {
this.viewAdapter.unregisterDataSetObserver(dataObserver);
}*/
this.viewAdapter = viewAdapter;
if (this.viewAdapter != null) {
this.viewAdapter.registerDataSetObserver(dataObserver);
}
invalidateWheel(true);
}
/**
* Adds wheel changing listener
* @param listener the listener
*/
public void addChangingListener(OnWheelChangedListener listener) {
changingListeners.add(listener);
}
/**
* Removes wheel changing listener
* @param listener the listener
*/
public void removeChangingListener(OnWheelChangedListener listener) {
changingListeners.remove(listener);
}
/**
* Notifies changing listeners
* @param oldValue the old wheel value
* @param newValue the new wheel value
*/
protected void notifyChangingListeners(int oldValue, int newValue) {
for (OnWheelChangedListener listener : changingListeners) {
listener.onChanged(this, oldValue, newValue);
}
if(viewAdapter!=null){
viewAdapter.notifyDataChangedEvent();
}
}
/**
* Adds wheel scrolling listener
* @param listener the listener
*/
public void addScrollingListener(OnWheelScrollListener listener) {
scrollingListeners.add(listener);
}
/**
* Removes wheel scrolling listener
* @param listener the listener
*/
public void removeScrollingListener(OnWheelScrollListener listener) {
scrollingListeners.remove(listener);
}
/**
* Notifies listeners about starting scrolling
*/
protected void notifyScrollingListenersAboutStart() {
for (OnWheelScrollListener listener : scrollingListeners) {
listener.onScrollingStarted(this);
}
}
/**
* Notifies listeners about ending scrolling
*/
protected void notifyScrollingListenersAboutEnd() {
for (OnWheelScrollListener listener : scrollingListeners) {
listener.onScrollingFinished(this);
}
}
/**
* Adds wheel clicking listener
* @param listener the listener
*/
public void addClickingListener(OnWheelClickedListener listener) {
clickingListeners.add(listener);
}
/**
* Removes wheel clicking listener
* @param listener the listener
*/
public void removeClickingListener(OnWheelClickedListener listener) {
clickingListeners.remove(listener);
}
/**
* Notifies listeners about clicking
*/
protected void notifyClickListenersAboutClick(int item) {
for (OnWheelClickedListener listener : clickingListeners) {
listener.onItemClicked(this, item);
}
}
/**
* Gets current value
*
* @return the current value
*/
public int getCurrentItem() {
return currentItem;
}
/**
* Sets the current item. Does nothing when index is wrong.
*
* @param index the item index
* @param animated the animation flag
*/
public void setCurrentItem(int index, boolean animated) {
if (viewAdapter == null || viewAdapter.getItemsCount() == 0) {
return; // throw?
}
int itemCount = viewAdapter.getItemsCount();
if (index < 0 || index >= itemCount) {
if (isCyclic) {
while (index < 0) {
index += itemCount;
}
index %= itemCount;
} else{
return; // throw?
}
}
if (index != currentItem) {
if (animated) {
int itemsToScroll = index - currentItem;
if (isCyclic) {
int scroll = itemCount + Math.min(index, currentItem) - Math.max(index, currentItem);
if (scroll < Math.abs(itemsToScroll)) {
itemsToScroll = itemsToScroll < 0 ? scroll : -scroll;
}
}
scroll(itemsToScroll, 0);
} else {
scrollingOffset = 0;
int old = currentItem;
currentItem = index;
notifyChangingListeners(old, currentItem);
invalidate();
}
}
}
/**
* Sets the current item w/o animation. Does nothing when index is wrong.
*
* @param index the item index
*/
public void setCurrentItem(int index) {
setCurrentItem(index, false);
}
/**
* Tests if wheel is cyclic. That means before the 1st item there is shown the last one
* @return true if wheel is cyclic
*/
public boolean isCyclic() {
return isCyclic;
}
/**
* Set wheel cyclic flag
* @param isCyclic the flag to set
*/
public void setCyclic(boolean isCyclic) {
this.isCyclic = isCyclic;
invalidateWheel(false);
}
/**
* Determine whether shadows are drawn
* @return true is shadows are drawn
*/
public boolean drawShadows() {
return drawShadows;
}
/**
* Set whether shadows should be drawn
* @param drawShadows flag as true or false
*/
public void setDrawShadows(boolean drawShadows) {
this.drawShadows = drawShadows;
}
/**
* Set the shadow gradient color
* @param start
* @param middle
* @param end
*/
public void setShadowColor(int start, int middle, int end) {
SHADOWS_COLORS = new int[] {start, middle, end};
}
/**
* Sets the drawable for the wheel background
* @param resource
*/
public void setWheelBackground(int resource) {
wheelBackground = resource;
setBackgroundResource(wheelBackground);
}
/**
* Sets the drawable for the wheel foreground
* @param resource
*/
public void setWheelForeground(int resource) {
wheelForeground = resource;
centerDrawable = getContext().getResources().getDrawable(wheelForeground);
}
/**
* Invalidates wheel
* @param clearCaches if true then cached views will be clear
*/
public void invalidateWheel(boolean clearCaches) {
if (clearCaches) {
recycle.clearAll();
if (itemsLayout != null) {
itemsLayout.removeAllViews();
}
scrollingOffset = 0;
} else if (itemsLayout != null) {
// cache all items
recycle.recycleItems(itemsLayout, firstItem, new ItemsRange());
}
invalidate();
}
/**
* Initializes resources
*/
private void initResourcesIfNecessary() {
if (centerDrawable == null) {
centerDrawable = getContext().getResources().getDrawable(wheelForeground);
}
if (topShadow == null) {
topShadow = new GradientDrawable(Orientation.TOP_BOTTOM, SHADOWS_COLORS);
}
if (bottomShadow == null) {
bottomShadow = new GradientDrawable(Orientation.BOTTOM_TOP, SHADOWS_COLORS);
}
setBackgroundResource(wheelBackground);
}
/**
* Calculates desired height for layout
*
* @param layout
* the source layout
* @return the desired layout height
*/
private int getDesiredHeight(LinearLayout layout) {
if (layout != null && layout.getChildAt(0) != null) {
itemHeight = layout.getChildAt(0).getMeasuredHeight();
}
int desired = itemHeight * visibleItems - itemHeight * ITEM_OFFSET_PERCENT / 50;
return Math.max(desired, getSuggestedMinimumHeight());
}
/**
* Returns height of wheel item
* @return the item height
*/
private int getItemHeight() {
if (itemHeight != 0) {
return itemHeight;
}
if (itemsLayout != null && itemsLayout.getChildAt(0) != null) {
itemHeight = itemsLayout.getChildAt(0).getHeight();
return itemHeight;
}
return getHeight() / visibleItems;
}
/**
* Calculates control width and creates text layouts
* @param widthSize the input layout width
* @param mode the layout mode
* @return the calculated control width
*/
private int calculateLayoutWidth(int widthSize, int mode) {
initResourcesIfNecessary();
// TODO: make it static
itemsLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
itemsLayout.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int width = itemsLayout.getMeasuredWidth();
if (mode == MeasureSpec.EXACTLY) {
width = widthSize;
} else {
width += 2 * PADDING;
// Check against our minimum width
width = Math.max(width, getSuggestedMinimumWidth());
if (mode == MeasureSpec.AT_MOST && widthSize < width) {
width = widthSize;
}
}
itemsLayout.measure(MeasureSpec.makeMeasureSpec(width - 2 * PADDING, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
return width;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
buildViewForMeasuring();
int width = calculateLayoutWidth(widthSize, widthMode);
int height;
if (heightMode == MeasureSpec.EXACTLY) {
height = heightSize;
} else {
height = getDesiredHeight(itemsLayout);
if (heightMode == MeasureSpec.AT_MOST) {
height = Math.min(height, heightSize);
}
}
setMeasuredDimension(width, height);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
layout(r - l, b - t);
}
/**
* Sets layouts width and height
* @param width the layout width
* @param height the layout height
*/
private void layout(int width, int height) {
int itemsWidth = width - 2 * PADDING;
itemsLayout.layout(0, 0, itemsWidth, height);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (viewAdapter != null && viewAdapter.getItemsCount() > 0) {
updateView();
drawItems(canvas);
drawCenterRect(canvas);
}
if (drawShadows) {
drawShadows(canvas);
}
}
/**
* Draws shadows on top and bottom of control
* @param canvas the canvas for drawing
*/
private void drawShadows(Canvas canvas) {
/*/ Modified by wulianghuan 2014-11-25
int height = (int)(1.5 * getItemHeight());
//*/
int height = (int)(3 * getItemHeight());
//*/
topShadow.setBounds(0, 0, getWidth(), height);
topShadow.draw(canvas);
bottomShadow.setBounds(0, getHeight() - height, getWidth(), getHeight());
bottomShadow.draw(canvas);
}
/**
* Draws items
* @param canvas the canvas for drawing
*/
private void drawItems(Canvas canvas) {
canvas.save();
int top = (currentItem - firstItem) * getItemHeight() + (getItemHeight() - getHeight()) / 2;
canvas.translate(PADDING, - top + scrollingOffset);
itemsLayout.draw(canvas);
canvas.restore();
}
/**
* Draws rect for current value
* @param canvas the canvas for drawing
*/
private void drawCenterRect(Canvas canvas) {
int center = getHeight() / 2;
int offset = (int) (getItemHeight() / 2 * 1.2);
/*/ Remarked by wulianghuan 2014-11-27 使用自己的画线,而不是描边
Rect rect = new Rect(left, top, right, bottom)
centerDrawable.setBounds(bounds)
centerDrawable.setBounds(0, center - offset, getWidth(), center + offset);
centerDrawable.draw(canvas);
//*/
Paint paint = new Paint();
paint.setColor(getResources().getColor(R.color.province_line_border));
// 设置线宽
paint.setStrokeWidth((float) 3);
// 绘制上边直线
canvas.drawLine(0, center - offset, getWidth(), center - offset, paint);
// 绘制下边直线
canvas.drawLine(0, center + offset, getWidth(), center + offset, paint);
//*/
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled() || getViewAdapter() == null) {
return true;
}
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
if (getParent() != null) {
getParent().requestDisallowInterceptTouchEvent(true);
}
break;
case MotionEvent.ACTION_UP:
if (!isScrollingPerformed) {
int distance = (int) event.getY() - getHeight() / 2;
if (distance > 0) {
distance += getItemHeight() / 2;
} else {
distance -= getItemHeight() / 2;
}
int items = distance / getItemHeight();
if (items != 0 && isValidItemIndex(currentItem + items)) {
notifyClickListenersAboutClick(currentItem + items);
}
}
break;
default:
break;
}
return scroller.onTouchEvent(event);
}
/**
* Scrolls the wheel
* @param delta the scrolling value
*/
private void doScroll(int delta) {
scrollingOffset += delta;
int itemHeight = getItemHeight();
int count = scrollingOffset / itemHeight;
int pos = currentItem - count;
int itemCount = viewAdapter.getItemsCount();
int fixPos = scrollingOffset % itemHeight;
if (Math.abs(fixPos) <= itemHeight / 2) {
fixPos = 0;
}
if (isCyclic && itemCount > 0) {
if (fixPos > 0) {
pos--;
count++;
} else if (fixPos < 0) {
pos++;
count--;
}
// fix position by rotating
while (pos < 0) {
pos += itemCount;
}
pos %= itemCount;
} else {
//
if (pos < 0) {
count = currentItem;
pos = 0;
} else if (pos >= itemCount) {
count = currentItem - itemCount + 1;
pos = itemCount - 1;
} else if (pos > 0 && fixPos > 0) {
pos--;
count++;
} else if (pos < itemCount - 1 && fixPos < 0) {
pos++;
count--;
}
}
int offset = scrollingOffset;
if (pos != currentItem) {
setCurrentItem(pos, false);
} else {
invalidate();
}
// update offset
scrollingOffset = offset - count * itemHeight;
if (scrollingOffset > getHeight()) {
scrollingOffset = scrollingOffset % getHeight() + getHeight();
}
}
/**
* Scroll the wheel
* @param time scrolling duration
*/
public void scroll(int itemsToScroll, int time) {
int distance = itemsToScroll * getItemHeight() - scrollingOffset;
scroller.scroll(distance, time);
}
/**
* Calculates range for wheel items
* @return the items range
*/
private ItemsRange getItemsRange() {
if (getItemHeight() == 0) {
return null;
}
int first = currentItem;
int count = 1;
while (count * getItemHeight() < getHeight()) {
first--;
count += 2; // top + bottom items
}
if (scrollingOffset != 0) {
if (scrollingOffset > 0) {
first--;
}
count++;
// process empty items above the first or below the second
int emptyItems = scrollingOffset / getItemHeight();
first -= emptyItems;
count += Math.asin(emptyItems);
}
return new ItemsRange(first, count);
}
/**
* Rebuilds wheel items if necessary. Caches all unused items.
*
* @return true if items are rebuilt
*/
private boolean rebuildItems() {
boolean updated = false;
ItemsRange range = getItemsRange();
if (itemsLayout != null) {
int first = recycle.recycleItems(itemsLayout, firstItem, range);
updated = firstItem != first;
firstItem = first;
} else {
createItemsLayout();
updated = true;
}
if (!updated) {
updated = firstItem != range.getFirst() || itemsLayout.getChildCount() != range.getCount();
}
if (firstItem > range.getFirst() && firstItem <= range.getLast()) {
for (int i = firstItem - 1; i >= range.getFirst(); i--) {
if (!addViewItem(i, true)) {
break;
}
firstItem = i;
}
} else {
firstItem = range.getFirst();
}
int first = firstItem;
for (int i = itemsLayout.getChildCount(); i < range.getCount(); i++) {
if (!addViewItem(firstItem + i, false) && itemsLayout.getChildCount() == 0) {
first++;
}
}
firstItem = first;
return updated;
}
/**
* Updates view. Rebuilds items and label if necessary, recalculate items sizes.
*/
private void updateView() {
if (rebuildItems()) {
calculateLayoutWidth(getWidth(), MeasureSpec.EXACTLY);
layout(getWidth(), getHeight());
}
}
/**
* Creates item layouts if necessary
*/
private void createItemsLayout() {
if (itemsLayout == null) {
itemsLayout = new LinearLayout(getContext());
itemsLayout.setOrientation(LinearLayout.VERTICAL);
}
}
/**
* Builds view for measuring
*/
private void buildViewForMeasuring() {
// clear all items
if (itemsLayout != null) {
recycle.recycleItems(itemsLayout, firstItem, new ItemsRange());
} else {
createItemsLayout();
}
// add views
int addItems = visibleItems / 2;
for (int i = currentItem + addItems; i >= currentItem - addItems; i--) {
if (addViewItem(i, true)) {
firstItem = i;
}
}
}
/**
* Adds view for item to items layout
* @param index the item index
* @param first the flag indicates if view should be first
* @return true if corresponding item exists and is added
*/
private boolean addViewItem(int index, boolean first) {
View view = getItemView(index);
if (view != null) {
if (first) {
itemsLayout.addView(view, 0);
} else {
itemsLayout.addView(view);
}
return true;
}
return false;
}
/**
* Checks whether intem index is valid
* @param index the item index
* @return true if item index is not out of bounds or the wheel is cyclic
*/
private boolean isValidItemIndex(int index) {
return viewAdapter != null && viewAdapter.getItemsCount() > 0 &&
(isCyclic || index >= 0 && index < viewAdapter.getItemsCount());
}
/**
* Returns view for specified item
* @param index the item index
* @return item view or empty view if index is out of bounds
*/
private View getItemView(int index) {
if (viewAdapter == null || viewAdapter.getItemsCount() == 0) {
return null;
}
int count = viewAdapter.getItemsCount();
if (!isValidItemIndex(index)) {
return viewAdapter.getEmptyItem(recycle.getEmptyItem(), itemsLayout);
} else {
while (index < 0) {
index = count + index;
}
}
index %= count;
return viewAdapter.getItem(index, recycle.getItem(), itemsLayout);
}
/**
* Stops scrolling
*/
public void stopScrolling() {
scroller.stopScrolling();
}
}
| [
"80731595@qq.com"
] | 80731595@qq.com |
a4673ba09ddda18dc75dd2a967c5835e2bfe7c80 | adeb1ce8a509ad2ae37b8d0c8ff2afa839be9aff | /day02/day02_demo01/src/main/java/com/spring/dao/impl/AccountDaoImpl1.java | 88dec16b1f06b039c585cdae17eaaf9197599df4 | [] | no_license | 1144075799/spring | 6b19e9daf87179f1200bbd628300d43a8e9bcd67 | 2058ea41a0e82ab3ec4f0f26d5918090242f11b9 | refs/heads/master | 2022-07-12T02:57:59.057338 | 2019-08-08T03:40:57 | 2019-08-08T03:40:57 | 201,171,816 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 327 | java | package com.spring.dao.impl;
import com.spring.dao.AccountDao;
import org.springframework.stereotype.Repository;
/**
* 账户的持久层实现类
*/
@Repository("accountDao1")
public class AccountDaoImpl1 implements AccountDao {
public void saveAccount() {
System.out.println("保存了账户1111");
}
}
| [
"1144075799@qq.com"
] | 1144075799@qq.com |
76e6173e18c33dfe7f44be18ad7fb8960f64e2ec | 0a687de2d61470cbe8a6e0984c85bf4aa958b563 | /src/StaticMethods/A.java | 415c0930430a8affc3874ab0c878bc7e9bbd7643 | [] | no_license | brahmaqa1/MyRepo1 | a983a922895197e36206c9852bd345bb0de40faa | 1d8fb0019329153036d9e5620bf94362d55066aa | refs/heads/master | 2020-06-21T11:46:05.195463 | 2019-07-17T18:22:45 | 2019-07-17T18:22:45 | 197,440,448 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 570 | java | package StaticMethods;
class A{
int a=10;//non static inst var
static int b=20;
public static void main(String args[])//static method
{
//Care :: // compile error error Cannot make a static reference to the non-static field a
// System.out.println(a); // note:...error should not use non static var in statci
System.out.println("b="+b);// 20 directly used
A obj=new A();//
obj.a=10;// non static inst var can be used by creating obj
System.out.println(obj.a);//10
//static var - in static method()
}
}
| [
"brahma.qa1@gmail.com"
] | brahma.qa1@gmail.com |
e219f66fe3eadf9f2e0e8ee5d97e313db89d7c84 | 26eee0a7ec01b1e89280374da32d4ee7e9b969ba | /app/src/main/java/com/example/sarav/anew/AddSubjFragment.java | c49bf2d42361c52afab4efa89392b39d530ba481 | [] | no_license | Saravanasan/Bunk_Manager | 664415fac51be295749443fed913d3497f1502bd | 9e5652cd9cf59384e6f21d3d56ccd1cebdee75fe | refs/heads/master | 2020-04-28T11:01:33.197803 | 2019-10-28T08:56:19 | 2019-10-28T08:56:19 | 175,221,617 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,968 | java | package com.example.sarav.anew;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyLog;
import com.android.volley.toolbox.HttpHeaderParser;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class AddSubjFragment extends Fragment {
private EditText cr, asubj;
public Button submit,del;
Activity context = getActivity();
public static final String MyPREFERENCES = "MyPrefs";
public static int id = 1;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_addsubj, container, false);
cr = v.findViewById(R.id.addcredit);
asubj = v.findViewById(R.id.addsubj);
del = v.findViewById(R.id.del);
submit = v.findViewById(R.id.submit);
submit.setOnClickListener((View w) -> {
String subj1 = asubj.getText().toString();
String crd = cr.getText().toString();
if(check(subj1,crd)==0) {
SharedPreferences sharedpreferences = getActivity().getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
String s1 = sharedpreferences.getString("roll", "");
String s = sharedpreferences.getString("token", "");
String subj[] = new String[12];
try {
JSONObject obj = new JSONObject();
obj.put("subject", subj1);
obj.put("credit", crd);
obj.put("roll", s1);
String URL = " https://bunk-manager.herokuapp.com/subjsave";
RequestQueue requestQueue = Volley.newRequestQueue(getContext());
final String mRequestBody = obj.toString();
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, response -> {
Toast.makeText(getContext(), "Successfully Inserted", Toast.LENGTH_SHORT).show();
}, error -> Toast.makeText(getContext(), "Network Error", Toast.LENGTH_SHORT).show()) {
@Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
@Override
public byte[] getBody() throws AuthFailureError {
try {
return mRequestBody.getBytes("utf-8");
} catch (UnsupportedEncodingException uee) {
VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", mRequestBody, "utf-8");
return null;
}
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
headers.put("x-auth", s);
return headers;
}
@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
String responseString = "";
if (response != null) {
try {
responseString = new String(response.data, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
}
};
requestQueue.add(stringRequest);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
del.setOnClickListener((View w) -> {
String subj1 = asubj.getText().toString();
String crd = cr.getText().toString();
if(check(subj1,crd)==0) {
SharedPreferences sharedpreferences = getActivity().getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
String s1 = sharedpreferences.getString("roll", "");
String s = sharedpreferences.getString("token", "");
try {
JSONObject obj = new JSONObject();
obj.put("subject", subj1);
obj.put("roll", s1);
String URL = " https://bunk-manager.herokuapp.com/delete";
RequestQueue requestQueue = Volley.newRequestQueue(getContext());
final String mRequestBody = obj.toString();
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, response -> {
Toast.makeText(getContext(), "Successfully Deleted", Toast.LENGTH_SHORT).show();
}, error -> Toast.makeText(getContext(), "Network Error", Toast.LENGTH_SHORT).show()) {
@Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
@Override
public byte[] getBody() throws AuthFailureError {
try {
return mRequestBody.getBytes("utf-8");
} catch (UnsupportedEncodingException uee) {
VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s", mRequestBody, "utf-8");
return null;
}
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
headers.put("x-auth", s);
return headers;
}
@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
String responseString = "";
if (response != null) {
try {
responseString = new String(response.data, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return Response.success(responseString, HttpHeaderParser.parseCacheHeaders(response));
}
};
requestQueue.add(stringRequest);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
return v;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
public int check(String subj, String cr) {
if (subj.isEmpty()) {
Toast.makeText(getContext(), "Subject cannot be empty", Toast.LENGTH_SHORT).show();
return 1;
}else if (cr.isEmpty()) {
Toast.makeText(getContext(), "Credit cannot be empty", Toast.LENGTH_SHORT).show();
return 1;
}else {
return 0;
}
}
}
| [
"saravanasan06@gmail.com"
] | saravanasan06@gmail.com |
6cc88e1c37b743a4a00f5b5cb76a62cdc5555cc3 | f9631712e73b1e62b0b17c7d209a9a64ad38735c | /app/src/main/java/com/example/gemstudios/myufc_app/data/network/service/IRequestInterface.java | a5ae6eb188c9ac0bdd0417d74019770f27abb975 | [] | no_license | aftabhabib/MyUFC_App | a78498938678d8a6c32e874ff072723d37e5c754 | 946810148d7eb898edbb8ee1ab62e81dc142ded3 | refs/heads/master | 2020-03-28T08:58:18.510809 | 2018-03-22T21:39:17 | 2018-03-22T21:39:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,359 | java | package com.example.gemstudios.myufc_app.data.network.service;
import com.example.gemstudios.myufc_app.data.network.model.Events;
import com.example.gemstudios.myufc_app.data.network.model.EventsDetails;
import com.example.gemstudios.myufc_app.data.network.model.Fighters;
import com.example.gemstudios.myufc_app.data.network.model.Medium;
import com.example.gemstudios.myufc_app.data.network.model.News;
import com.example.gemstudios.myufc_app.data.network.model.OctagonGirl;
import com.example.gemstudios.myufc_app.data.network.model.TitleHolders;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.Path;
/**
* Created by TAE on 09-Feb-18.
*/
public interface IRequestInterface {
/**
* Octagon girls api
*/
@GET(ApiList.OCTAGON_GIRLS)
Observable<List<OctagonGirl>> getOctagonGirl();
@GET(ApiList.MEDIA_URL)
Observable<List<Medium>> getMedia();
@GET(ApiList.EVENT_URL)
Observable<List<Events>> getEvents();
@GET(ApiList.EVENT_DETAILS_URL)
Observable<List<EventsDetails>> getEventsDetails(@Path("id") int id);
@GET(ApiList.NEWS_URL)
Observable<List<News>> getNews();
@GET(ApiList.TITLE_HOLDERS_URL)
Observable<List<TitleHolders>> getTitleHolders();
@GET(ApiList.FIGHTERS_URL)
Observable<List<Fighters>> getFighters();
}
| [
"gaffy_cool@hotmail.com"
] | gaffy_cool@hotmail.com |
e85defb844f6b447e9d7b0998bc8908959d26cee | a3947a242f5c60af8dc30ae3789dba55af917599 | /src/main/java/oaiprovider/driver/ITQLQueryFactory.java | 14581f60002975f40c459b3ca7ea6dd6a9fc05d3 | [] | no_license | qucosa/qucosa-fcrepo-oaiprovider | 56095635bda4be6a3ebc71868a8847271703b76d | 981e3fcf5b1135754d08f629e745a80f8296352d | refs/heads/master | 2021-11-25T19:25:27.525891 | 2021-03-22T10:27:06 | 2021-03-22T10:27:06 | 55,216,906 | 0 | 0 | null | 2021-06-07T17:34:12 | 2016-04-01T08:40:35 | Java | UTF-8 | Java | false | false | 18,696 | java | /*
* Copyright 2016 Saxon State and University Library Dresden (SLUB)
*
* 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 oaiprovider.driver;
import oaiprovider.FedoraMetadataFormat;
import oaiprovider.FedoraRecord;
import oaiprovider.InvocationSpec;
import oaiprovider.QueryFactory;
import oaiprovider.ResultCombiner;
import org.fcrepo.client.FedoraClient;
import org.fcrepo.common.Constants;
import org.fcrepo.utilities.DateUtility;
import org.jrdf.graph.Node;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.trippi.RDFFormat;
import org.trippi.TrippiException;
import org.trippi.TupleIterator;
import proai.MetadataFormat;
import proai.SetInfo;
import proai.driver.RemoteIterator;
import proai.error.RepositoryException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@SuppressWarnings("unused") // dynamically loaded via configuration
public class ITQLQueryFactory
implements QueryFactory, Constants {
private static final Logger logger = LoggerFactory.getLogger(ITQLQueryFactory.class);
private static final String QUERY_LANGUAGE = "itql";
private String m_deleted;
private FedoraClient m_fedora;
private FedoraClient m_queryClient;
private String m_itemSetSpecPath;
private String m_oaiItemID;
private String m_setSpec;
private String m_setSpecName;
public ITQLQueryFactory() {
}
public void init(FedoraClient client,
FedoraClient queryClient,
Properties props) {
m_fedora = client;
m_queryClient = queryClient;
m_oaiItemID =
FedoraOAIDriver.getRequired(props, FedoraOAIDriver.PROP_ITEMID);
m_setSpec =
FedoraOAIDriver
.getOptional(props, FedoraOAIDriver.PROP_SETSPEC);
if (!m_setSpec.equals("")) {
m_setSpecName =
FedoraOAIDriver
.getRequired(props,
FedoraOAIDriver.PROP_SETSPEC_NAME);
m_itemSetSpecPath =
parseItemSetSpecPath(FedoraOAIDriver
.getRequired(props,
FedoraOAIDriver.PROP_ITEM_SETSPEC_PATH));
}
m_deleted =
FedoraOAIDriver
.getOptional(props, FedoraOAIDriver.PROP_DELETED);
}
/**
* Return latest modification date of any OAI relevant record.
*
* If no records match, the current date is returned as a fallback.
*
* @param formats Ignored. All items are queried.
* @return Latest modification date according to Fedora.
*/
public Date latestRecordDate(Iterator<? extends MetadataFormat> formats) throws RepositoryException {
String query =
"select $item $modified from <#ri>\n" +
"where $item <http://www.openarchives.org/OAI/2.0/itemID> $itemID\n" +
"and $item <fedora-view:lastModifiedDate> $modified\n" +
"order by $modified desc\n" +
"limit 1";
TupleIterator it = getTuples(query);
try {
if (it.hasNext()) {
Map<String, Node> t = it.next();
String item = t.get("item").stringValue();
String modified = t.get("modified").stringValue();
return DateUtility.convertStringToDate(modified);
}
} catch (TrippiException e) {
logger.error("Failed to query for latest modification date", e);
}
logger.warn("No OAI relevant elements for obtaining the latest modification date. Fallback to current host time.");
return new Date();
}
public RemoteIterator<SetInfo> listSetInfo(InvocationSpec setInfoSpec) {
if (m_itemSetSpecPath == null) {
// return empty iterator if sets not configured
return new FedoraSetInfoIterator();
} else {
TupleIterator tuples = getTuples(getListSetInfoQuery(setInfoSpec));
return new FedoraSetInfoIterator(m_fedora, tuples);
}
}
/**
* Convert the given Date to a String while also adding or subtracting a
* millisecond. The shift is necessary because the provided dates are
* inclusive, whereas ITQL date operators are exclusive.
*/
private String getExclusiveDateString(Date date, boolean isUntilDate) {
if (date == null) {
return null;
} else {
long time = date.getTime();
if (isUntilDate) {
time++; // add 1ms to make "until" -> "before"
} else {
time--; // sub 1ms to make "from" -> "after"
}
return DateUtility.convertDateToString(new Date(time));
}
}
public RemoteIterator<FedoraRecord> listRecords(Date from,
Date until,
FedoraMetadataFormat format) {
// Construct and get results of one to three queries, depending on conf
// Parse and convert the dates once; they may be used more than once
String afterUTC = getExclusiveDateString(from, false);
String beforeUTC = getExclusiveDateString(until, true);
// do primary query
String primaryQuery =
getListRecordsPrimaryQuery(afterUTC, beforeUTC, format
.getMetadataSpec());
File primaryFile = getCSVResults(primaryQuery);
// do set membership query, if applicable
File setFile = null;
if (m_itemSetSpecPath != null && m_itemSetSpecPath.length() > 0) { // need
// set
// membership
// info
String setQuery =
getListRecordsSetMembershipQuery(afterUTC,
beforeUTC,
format.getMetadataSpec());
setFile = getCSVResults(setQuery);
}
// do about query, if applicable
File aboutFile = null;
if (format.getAboutSpec() != null) { // need
// about
// info
String aboutQuery =
getListRecordsAboutQuery(afterUTC, beforeUTC, format);
aboutFile = getCSVResults(aboutQuery);
}
// Get a FedoraRecordIterator over the combined results
// that automatically cleans up the result files when closed
String mdDissType = format.getMetadataSpec().getDisseminationType();
String aboutDissType = null;
if (format.getAboutSpec() != null) {
aboutDissType = format.getAboutSpec().getDisseminationType();
}
try {
ResultCombiner combiner =
new ResultCombiner(primaryFile, setFile, aboutFile, true);
return new CombinerRecordIterator(format.getPrefix(),
mdDissType,
aboutDissType,
combiner);
} catch (FileNotFoundException e) {
throw new RepositoryException("Programmer error? Query result "
+ "file(s) not found!");
}
}
// FedoraOAIDriver.PROP_DELETED is an optional, object-level (as opposed
// to dissemination-level) property. If present, use it in place of
// Fedora state.
private String getStatePattern() {
if (m_deleted.equals("")) {
return "$item <" + MODEL.STATE + "> $state";
} else {
return "$item <" + m_deleted + "> $state";
}
}
private void appendDateParts(String afterUTC,
String beforeUTC,
boolean alwaysSelectDate,
StringBuilder out) {
if (afterUTC == null && beforeUTC == null && !alwaysSelectDate) {
// we don't have to select the date because
// there are no date constraints and the query doesn't ask for it
return;
} else {
out.append("and $item <" + VIEW.LAST_MODIFIED_DATE
+ "> $date\n");
}
// date constraints are optional
if (afterUTC != null) {
out.append("and $date <" + MULGARA.AFTER + "> '"
+ afterUTC + "'^^<" + RDF_XSD.DATE_TIME + "> in <#xsd>\n");
}
if (beforeUTC != null) {
out.append("and $date <" + MULGARA.BEFORE + "> '"
+ beforeUTC + "'^^<" + RDF_XSD.DATE_TIME + "> in <#xsd>\n");
}
}
// ordering is required for the combiner to work
private void appendOrder(StringBuilder out) {
out.append("order by $itemID asc");
}
// this is common for all listRecords queries
private void appendCommonFromWhereAnd(StringBuilder out) {
out.append("from <#ri>\n");
out.append("where $item <" + m_oaiItemID + "> $itemID\n");
}
private String getListRecordsPrimaryQuery(String afterUTC,
String beforeUTC,
InvocationSpec mdSpec) {
StringBuilder out = new StringBuilder();
String selectString;
String contentDissString;
selectString = "select $item $itemID $date $state\n";
if (mdSpec.isDatastreamInvocation()) {
contentDissString = getDatastreamDissType(mdSpec, "$item", "");
} else {
contentDissString = getServiceDissType(mdSpec, "$item", "");
}
out.append(selectString);
appendCommonFromWhereAnd(out);
out.append("and " + getStatePattern() + "\n");
out.append("and " + contentDissString);
appendDateParts(afterUTC, beforeUTC, true, out);
appendOrder(out);
return out.toString();
}
private String getListRecordsSetMembershipQuery(String afterUTC,
String beforeUTC,
InvocationSpec mdSpec) {
StringBuilder out = new StringBuilder();
out.append("select $itemID $setSpec\n");
appendCommonFromWhereAnd(out);
if (mdSpec.isDatastreamInvocation()) {
out.append("and " + getDatastreamDissType(mdSpec, "$item", ""));
} else {
out.append("and " + getServiceDissType(mdSpec, "$item", ""));
}
appendDateParts(afterUTC, beforeUTC, true, out);
out.append("and " + m_itemSetSpecPath + "\n");
appendOrder(out);
return out.toString();
}
private String getListRecordsAboutQuery(String afterUTC,
String beforeUTC,
FedoraMetadataFormat format) {
StringBuilder out = new StringBuilder();
InvocationSpec mdSpec = format.getMetadataSpec();
InvocationSpec aboutSpec = format.getAboutSpec();
out.append("select $itemID\n");
appendCommonFromWhereAnd(out);
if (mdSpec.isDatastreamInvocation()) {
out.append("and " + getDatastreamDissType(mdSpec, "$item", "_md"));
} else {
out.append("and " + getServiceDissType(mdSpec, "$item", "_md"));
}
appendDateParts(afterUTC, beforeUTC, true, out);
if (aboutSpec.isDatastreamInvocation()) {
out.append("and "
+ getDatastreamDissType(aboutSpec, "$item", "_about"));
} else {
out.append("and "
+ getServiceDissType(aboutSpec, "$item", "_about"));
}
appendOrder(out);
return out.toString();
}
/**
* Get the results of the given itql tuple query as a temporary CSV file.
*/
private File getCSVResults(String queryText) throws RepositoryException {
logger.debug("getCSVResults() called with query:\n" + queryText);
Map<String, String> parameters = new HashMap<>();
parameters.put("lang", QUERY_LANGUAGE);
parameters.put("query", queryText);
File tempFile;
OutputStream out;
try {
tempFile =
File.createTempFile("oaiprovider-listrec-tuples", ".csv");
tempFile.deleteOnExit(); // just in case
out = new FileOutputStream(tempFile);
} catch (IOException e) {
throw new RepositoryException("Error creating temp query result file",
e);
}
try {
TupleIterator tuples = m_queryClient.getTuples(parameters);
logger.debug("Saving query results to disk...");
tuples.toStream(out, RDFFormat.CSV);
logger.debug("Done saving query results");
return tempFile;
} catch (Exception e) {
tempFile.delete();
throw new RepositoryException("Error getting tuples from Fedora: "
+ e.getMessage(), e);
} finally {
try {
out.close();
} catch (Exception ignored) {
}
}
}
private String getServiceDissType(InvocationSpec spec,
String objectVar,
String suffix) {
StringBuilder s = new StringBuilder();
String model = "$model" + suffix;
String sDef = "$SDef" + suffix;
s.append(objectVar + " <" + MODEL.HAS_MODEL + "> " + model
+ "\n");
s.append("and " + model + " <" + MODEL.HAS_SERVICE + "> " + sDef + "\n");
s.append("and " + sDef + " <" + MODEL.DEFINES_METHOD + "> '"
+ spec.method() + "'\n");
if (spec.service() != null) {
s.append(" and " + sDef + " <" + MULGARA.IS + "> <"
+ spec.service().toURI() + ">\n");
}
return s.toString();
}
private String getDatastreamDissType(InvocationSpec spec,
String objectVar,
String suffix) {
return String.format("%s\n and %s\n",
String.format("%s <%s> $diss%s", objectVar, VIEW.DISSEMINATES, suffix),
String.format("$diss%s <%s> <%s>", suffix, VIEW.DISSEMINATION_TYPE, spec.getDisseminationType()));
}
private String getListSetInfoQuery(InvocationSpec setInfoSpec) {
StringBuilder query = new StringBuilder();
String setInfoDissQuery =
" $setDiss <test:noMatch> <test:noMatch>\n";
String target = "$setDiss";
String dissType = "";
String commonWhereClause =
"where $set <" + m_setSpec + "> $setSpec\n" + "and $set <"
+ m_setSpecName + "> $setName\n";
if (setInfoSpec != null) {
dissType = setInfoSpec.getDisseminationType();
if (setInfoSpec.isDatastreamInvocation()) {
setInfoDissQuery =
getDatastreamDissType(setInfoSpec, "$set", "");
target = "$diss";
} else {
setInfoDissQuery = getServiceDissType(setInfoSpec, "$set", "");
target = "$SDef";
}
}
query.append("select $set $setSpec $setName '" + dissType + "'\n"
+ " subquery(" + " select " + target + "\n from <#ri>\n");
query.append(commonWhereClause);
query.append("and " + setInfoDissQuery);
query.append(")\n");
query.append("from <#ri>" + commonWhereClause);
return query.toString();
}
private TupleIterator getTuples(String query) throws RepositoryException {
logger.debug("getTuples() called with query:\n" + query);
Map<String, String> parameters = new HashMap<>();
parameters.put("lang", QUERY_LANGUAGE);
parameters.put("query", query);
parameters.put("stream", "true"); // stream immediately from server
try {
return m_queryClient.getTuples(parameters);
} catch (IOException e) {
throw new RepositoryException("Error getting tuples from Fedora: "
+ e.getMessage(), e);
}
}
/**
* @param itemSetSpecPath
* @return the setSpec, in the form "$item <$predicate> $setSpec"
* @throws RepositoryException
*/
private String parseItemSetSpecPath(String itemSetSpecPath)
throws RepositoryException {
String msg = "Required property, itemSetSpecPath, ";
String[] path = itemSetSpecPath.split("\\s+");
if (!itemSetSpecPath.contains("$item")) {
throw new RepositoryException(msg + "must include \"$item\"");
}
if (!itemSetSpecPath.contains("$setSpec")) {
throw new RepositoryException(msg + "must include \"$setSpec\"");
}
if (!itemSetSpecPath.matches("(\\$\\w+\\s+<\\S+>\\s+\\$\\w+\\s*)+")) {
throw new RepositoryException(msg
+ "must be of the form $item <predicate> $setSpec");
}
if (path.length == 3 && path[1].equals(m_setSpec)) {
throw new RepositoryException(msg
+ "may not use the same predicate as defined in setSpec");
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < path.length; i++) {
if (i != 0) {
sb.append(" ");
if (i % 3 == 0) {
sb.append("and ");
}
}
sb.append(path[i]);
if (path[i].startsWith("$")
&& !(path[i].equals("$item") || path[i].equals("$set") || path[i]
.equals("$setSpec"))) {
sb.append(path[i].hashCode());
}
}
return (sb.toString());
}
}
| [
"ralf.claussnitzer@slub-dresden.de"
] | ralf.claussnitzer@slub-dresden.de |
8e147518df8815ffda54bd45b8b9fccc7115db7c | 6dd4d6425fe484c60eb31c994ed155cd647fa371 | /plugins/org.chromium.debug.ui/src/org/chromium/debug/ui/launcher/PluginVariablesUtil.java | cb4d952b649826930e7eeefb9ef74e8a968af67e | [
"BSD-3-Clause"
] | permissive | anagovitsyn/oss.FCL.sftools.dev.eclipseenv.wrttools | 6206efe3c305b45b400e3a7359f16a166e8fea0e | 2b909321ef1e9c431d17ad0233746b717dcb5fc6 | refs/heads/master | 2021-12-11T08:59:54.238183 | 2010-11-04T22:22:02 | 2010-11-04T22:22:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,316 | java | // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.debug.ui.launcher;
import org.chromium.debug.ui.ChromiumDebugUIPlugin;
import org.eclipse.core.variables.VariablesPlugin;
/**
* Provides convenient access to the variables declared in the
* org.eclipse.core.variables.valueVariables extension point.
*/
class PluginVariablesUtil {
/** The default server port variable id. */
public static final String DEFAULT_PORT =
ChromiumDebugUIPlugin.PLUGIN_ID + ".chromium_debug_port"; //$NON-NLS-1$
/**
* @param variableName to get the value for
* @return the variable value parsed as an integer
* @throws NumberFormatException
* if the value cannot be parsed as an integer
*/
public static int getValueAsInt(String variableName) {
return Integer.parseInt(getValue(variableName));
}
/**
* @param variableName to get the value for
* @return the value of the specified variable
*/
public static String getValue(String variableName) {
return VariablesPlugin.getDefault().getStringVariableManager()
.getValueVariable(variableName).getValue();
}
private PluginVariablesUtil() {
// not instantiable
}
}
| [
"TasneemS@US-TASNEEMS"
] | TasneemS@US-TASNEEMS |
e1bc9e52a7a45e3cb0810995a18bafd125819a9d | 18606c6b3f164a935e571932b3356260b493e543 | /benchmarks/jmeter/src/protocol/http/org/apache/jmeter/protocol/http/modifier/UserParameterModifier.java | 794c2ada25de1e9a75efb69e1b9ad71519c1ba92 | [
"Apache-1.1",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | jackyhaoli/abc | d9a3bd2d4140dd92b9f9d0814eeafa16ea7163c4 | 42071b0dcb91db28d7b7fdcffd062f567a5a1e6c | refs/heads/master | 2020-04-03T09:34:47.612136 | 2019-01-11T07:16:04 | 2019-01-11T07:16:04 | 155,169,244 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,896 | java | /*
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. 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. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache JMeter" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache JMeter", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
* ITS 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jmeter.protocol.http.modifier;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.engine.event.LoopIterationEvent;
import org.apache.jmeter.processor.PreProcessor;
import org.apache.jmeter.protocol.http.sampler.HTTPSampler;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.testelement.TestListener;
import org.apache.jmeter.testelement.property.PropertyIterator;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.log.Hierarchy;
import org.apache.log.Logger;
/************************************************************
* Title: Jakarta-JMeter Description: Copyright: Copyright (c) 2001 Company:
* Apache
*
*<P>This modifier will replace any http sampler's url parameter values with
* parameter values defined in a XML file for each simulated user
*<BR>
*<P>For example if userid and password are defined in the XML parameter file
* for each user (ie thread), then simulated multiple user activity can occur
*@author Mark Walsh
*@created $Date: 2008/02/13 23:32:50 $
*@version 1.0
***********************************************************/
public class UserParameterModifier
extends ConfigTestElement
implements PreProcessor, Serializable, TestListener
{
transient private static Logger log =
Hierarchy.getDefaultHierarchy().getLoggerFor("jmeter.protocol.http");
private static final String XMLURI = "UserParameterModifier.xmluri";
//-------------------------------------------
// Constants and Data Members
//-------------------------------------------
private UserSequence allAvailableUsers;
//-------------------------------------------
// Constructors
//-------------------------------------------
/**
* Default constructor
*/
public UserParameterModifier()
{
} //end constructor
/**
* Runs before the start of every test. Reload the Sequencer with the
* latest parameter data for each user
*/
public void testStarted()
{
// try to populate allUsers, if fail, leave as any empty set
List allUsers = new LinkedList();
try
{
UserParameterXMLParser readXMLParameters = new UserParameterXMLParser();
allUsers = readXMLParameters.getXMLParameters(getXmlUri());
}
catch (Exception e)
{
// do nothing, now object allUsers contains an empty set
log.error("Unable to read parameters from xml file " + getXmlUri());
log.error(
"No unique values for http requests will be substituted for each thread",
e);
}
allAvailableUsers = new UserSequence(allUsers);
}
public void testEnded()
{
}
public void testStarted(String host)
{
testStarted();
}
public void testEnded(String host)
{
}
/*----------------------------------------------------------------------------------------------
* Methods implemented from interface org.apache.jmeter.config.Modifier
*--------------------------------------------------------------------------------------------*/
/**
* Modifies an entry object to replace the value of any url parameter that matches a parameter
* name in the XML file.
*
* @param entry Entry object containing information about the current test
* @return <code>True</code> if modified, else <code>false</code>
*/
public void process()
{
Sampler entry = JMeterContextService.getContext().getCurrentSampler();
if (!(entry instanceof HTTPSampler))
{
return;
}
HTTPSampler config = (HTTPSampler) entry;
Map currentUser = allAvailableUsers.getNextUserMods();
PropertyIterator iter = config.getArguments().iterator();
while (iter.hasNext())
{
Argument arg = (Argument) iter.next().getObjectValue();
// if parameter name exists in http request
// then change its value
// (Note: each jmeter thread (ie user) gets to have unique values)
if (currentUser.containsKey(arg.getName()))
{
arg.setValue((String)currentUser.get(arg.getName()));
}
}
}
/*----------------------------------------------------------------------------------------------
* Methods (used by UserParameterModifierGui to get/set the name of XML parameter file)
*--------------------------------------------------------------------------------------------*/
/**
* return the current XML file name to be read to obtain the parameter data for all users
* @return the name of the XML file containing parameter data for each user
*/
public String getXmlUri()
{
return this.getPropertyAsString(XMLURI);
}
/**
* From the GUI screen, set file name of XML to read
* @param the name of the XML file containing the HTTP name value pair parameters per user
*/
public void setXmlUri(String xmlURI)
{
setProperty(XMLURI, xmlURI);
}
/* (non-Javadoc)
* @see org.apache.jmeter.testelement.TestListener#testIterationStart(LoopIterationEvent)
*/
public void testIterationStart(LoopIterationEvent event)
{}
/* (non-Javadoc)
* @see java.lang.Object#clone()
*/
public Object clone()
{
UserParameterModifier clone = (UserParameterModifier) super.clone();
clone.allAvailableUsers = allAvailableUsers;
return clone;
}
} | [
"xiemaisi@40514614-586c-40e6-bf05-bf7e477dc3e6"
] | xiemaisi@40514614-586c-40e6-bf05-bf7e477dc3e6 |
1e64d118119c9acdadf3c6dfdfbc9156b8390968 | 35964c1e51b1655e5a435ccd0c4c199e4103ea6b | /authentication-service/src/main/java/com/jams/authentication/security/JWTTokenEnhancer.java | f38125466e820cae4ab018ae3de935bce863f61b | [] | no_license | hcz2000/workspace | c043b774252e5674a9f894824d104afe8645b08a | 92efc574626ffb64991f24e3267b4a72432ada18 | refs/heads/master | 2023-08-17T01:50:58.825890 | 2023-08-13T14:36:50 | 2023-08-13T14:36:50 | 134,142,146 | 0 | 0 | null | 2023-06-01T03:53:29 | 2018-05-20T10:49:22 | C++ | UTF-8 | Java | false | false | 827 | java | package com.jams.authentication.security;
import java.util.HashMap;
import java.util.Map;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
public class JWTTokenEnhancer implements TokenEnhancer {
@Override
public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
Map<String, Object> additionalInfo = new HashMap<String,Object>();
additionalInfo.put("organizationId", "org-"+authentication.getName());
((DefaultOAuth2AccessToken)accessToken).setAdditionalInformation(additionalInfo);
return accessToken;
}
}
| [
"huangchangzhan@hotmail.com"
] | huangchangzhan@hotmail.com |
fe672d815676b275c8b4990750a471c82d09ffed | 19de1c1438d9def7cdcc61a4a58c65bbcb143642 | /project_folder/src/dp/막대기.java | 542aeaf096b4383407580fc3e97794cb7f5a06b8 | [
"MIT"
] | permissive | stevejhkang/algorithm-quiz | aa977586796976492e312ee68b7e2a79147065fc | 066f528f3993ab8ad956774b0216712fee4b124d | refs/heads/master | 2021-07-16T06:08:44.732274 | 2020-06-06T03:51:04 | 2020-06-06T03:51:04 | 168,269,370 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 353 | java | package dp;
import java.util.Scanner;
public class 막대기 {
static int[] dp;
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
int n = sc.nextInt();
dp = new int[n+1];
dp[0] =1;
dp[1]= 1;
dp[2] = 2;
for(int i=3;i<=n;i++) {
dp[i] = dp[i-1]+dp[i-2]+dp[i-3];
}
System.out.println(dp[n]);
}
}
| [
"steve.jh.kang@gmail.com"
] | steve.jh.kang@gmail.com |
23a13ace03da9a8038eadd887db568a9ec023080 | 17eec5a820d0299bcd4879745109ea943d490eab | /ubk_Spider_50/src/com/unbank/robotspider/action/filter/CnComChinawuliu.java | e1da985761b4fc3dee33d7bd9d0ebb301cfb09bb | [] | no_license | un-knower/ubk_Spider_50 | 5dcf1ed21088788b692a437e95a99f8ac3ff8283 | 675693c9e51542d8435630cd6c9f6b9f95e50def | refs/heads/master | 2020-03-17T22:52:53.663468 | 2017-06-08T09:24:39 | 2017-06-08T09:24:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,354 | java | package com.unbank.robotspider.action.filter;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.springframework.stereotype.Service;
import com.unbank.robotspider.action.model.normal.BaseFilter;
import com.unbank.robotspider.action.model.normal.FilterLocator;
@Service
public class CnComChinawuliu extends BaseFilter {
private String domain = "www.chinawuliu.com.cn";
public CnComChinawuliu() {
FilterLocator.getInstance().register(domain, this);
}
@Override
public Element removeNoNeedHtmlElement(String url, Document document,
String title) {
Element element = document.select("#mainContent").first();
removeNoNeedElement(element, "script");
removeNoNeedElement(element, "style");
return element;
}
@Override
public void formatElements(Element maxTextElement) {
super.formatElements(maxTextElement);
}
@Override
public void saveImage(Element maxTextElement, String url) {
super.saveImage(maxTextElement, url);
}
@Override
public String replaceStockCode(String content) {
return super.replaceStockCode(content);
}
@Override
public String replaceSpechars(String content) {
String str = super.replaceSpechars(content);
return str;
}
@Override
public String addTag(String content) {
return super.addTag(content);
}
}
| [
"1378022176@qq.com"
] | 1378022176@qq.com |
d49c1a6ebd9bc46f881e0f37e13fde21e10a546e | 7469cddf89625c9761e96388876c0f08d3b63844 | /src/main/java/com/wkcheng/disruptor/DisruptorTest.java | 916014ed55e1eb25a238a43579e09f543cfa54fb | [] | no_license | ksymmy/application | 3bb106efd4cb4994bfa5b8ef69e444177dbd1118 | 03dfb5b7838798302d7c6252e3faf62086dadda2 | refs/heads/master | 2021-06-13T06:42:31.087595 | 2018-10-23T07:00:32 | 2018-10-23T07:00:32 | 132,310,074 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,054 | java | package com.wkcheng.disruptor;
import com.lmax.disruptor.EventFactory;
import com.lmax.disruptor.RingBuffer;
import com.lmax.disruptor.YieldingWaitStrategy;
import com.lmax.disruptor.dsl.Disruptor;
import com.lmax.disruptor.dsl.ProducerType;
import org.testng.annotations.Test;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @author created by wkcheng@iflytek.com at 2018/9/18 20:57
* @desc
*/
public class DisruptorTest {
// WaitStrategy BLOCKING_WAIT = new BlockingWaitStrategy();
// WaitStrategy SLEEPING_WAIT = new SleepingWaitStrategy();
// WaitStrategy YIELDING_WAIT = new YieldingWaitStrategy();
@Test
private void test() {
EventFactory<LongEvent> eventFactory = new LongEventFactory();
ExecutorService executors = Executors.newSingleThreadExecutor();
int ringBufferSize = 1024 * 1024; // RingBuffer 大小,必须是 2 的 N 次方;
//创建一个disruptor,指定ringbuffer的size和处理数据的factory
Disruptor<LongEvent> disruptor = new Disruptor<>(eventFactory, ringBufferSize, executors, ProducerType.SINGLE, new YieldingWaitStrategy());
//disruptor里面设置一个处理方式
disruptor.handleEventsWith(new LongEventHandler());
disruptor.start();
RingBuffer<LongEvent> ringBuffer = disruptor.getRingBuffer();
for (long i = 0; i < 1000; i++) {
//下一个可以用的序列号
long seq = ringBuffer.next();
try {
//这个序列号的slot 放入数据
LongEvent valueEvent = ringBuffer.get(seq);
valueEvent.setValue(i);
} finally {
//发布通知,并且这一步一定要放在finally中,因为调用了ringBuffer.next(),就一定要发布,否则会导致disruptor状态的错乱
ringBuffer.publish(seq);
}
}
// Translator.publishEvent2(disruptor);
disruptor.shutdown();
executors.shutdown();
}
}
| [
"ksymmy@163.com"
] | ksymmy@163.com |
f99f0333f913f46b256f529a93c2f409b83b6cbe | 92483c4605d2e9f3a8448cc60afe86b67c4ad826 | /algorithms-and-programming-II/AppAgenda/AbstractContato.java | 0bc0701311d0d26c71446c8c910a3584b9f5c3ec | [] | no_license | asgabe/ads-senacRS | af76ba306580a1e8708816bb2682ce33b4dbeb43 | 7966364a4ce6cf2536c52f636b15fa689aa16c2f | refs/heads/master | 2020-04-12T00:36:30.859458 | 2018-05-10T19:59:49 | 2018-05-10T19:59:49 | 41,645,142 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 674 | java |
/**
*
* @author gabriel
*/
import java.util.ArrayList;
abstract class AbstractContato {
protected String nome;
protected ArrayList<Telefone> telefones;
public AbstractContato(String nome) {
this.nome = nome;
telefones = new ArrayList();
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public void setTelefone(Telefone tf) {
telefones.add(tf);
}
public String getDados() {
String ret = nome + "\n";
for (Telefone t : telefones) {
ret += t.getTelefone() + "\n";
}
return ret;
}
}
| [
"gabe.crs@gmail.com"
] | gabe.crs@gmail.com |
3e2f90ac00c2f622fdb6d10e8f47bad038a064e6 | 8c851d359f65a087c5220884d09d25fddb6d6187 | /src/main/java/src/main/java/mammba/core/service/impl/LoginServiceImpl.java | f2b9ee854cd9e93101ab859932bf69c9aa87f992 | [] | no_license | mammba01012018/mammbaapi | b89afc9341244226cf4142c3b7b1d68c7c024229 | a1794e3de27786bd2a27a151ce4cee94b5718bc9 | refs/heads/master | 2021-06-05T03:03:42.148649 | 2019-12-14T17:49:01 | 2019-12-14T17:49:01 | 142,634,345 | 1 | 2 | null | 2019-12-14T17:49:02 | 2018-07-28T00:30:22 | null | UTF-8 | Java | false | false | 2,774 | java | /**
* LoginServiceImpl.java - MAMMBA Application
* 2018 All rights reserved.
*
*/
package src.main.java.mammba.core.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import src.main.java.mammba.core.dao.MammbaUserDao;
import src.main.java.mammba.core.dao.SecurityQuestionDao;
import src.main.java.mammba.core.exception.DaoException;
import src.main.java.mammba.core.exception.ServiceException;
import src.main.java.mammba.core.service.LoginService;
import src.main.java.mammba.core.util.ErrorMessage;
import src.main.java.mammba.core.util.ObjectUtility;
import src.main.java.mammba.model.LoginModel;
import src.main.java.mammba.model.MammbaUser;
/**
* Implements the LoginService interface.
*
* @author Mardolfh Del Rosario
*
*/
@Service
public class LoginServiceImpl implements LoginService {
@Autowired
@Qualifier("userDao")
private MammbaUserDao userDao;
@Autowired
private ObjectUtility utility;
@Autowired
private SecurityQuestionDao securityQuestionDao;
/**
* Checks and validates user credentials.
*
* @param loginModel LoginModel reference.
* @return true/false.
* @throws ServiceException business error logic.
*/
@Override
public boolean isLoginValid(LoginModel loginModel) throws ServiceException {
try {
return this.userDao.isLoginValid(loginModel);
} catch(DaoException e) {
throw new ServiceException(ErrorMessage.LOG_ERR_INVLD_LOGIN, e);
}
}
@Override
public String getUserType(String userName) throws ServiceException {
try {
MammbaUser user = this.userDao.getUserDetails(userName);
if (!this.utility.isNullOrEmpty(user)) {
return user.getUserType();
}
} catch(DaoException e) {
throw new ServiceException(ErrorMessage.PROFILE_ERR_ACS_DTA, e);
}
return null;
}
@Override
public void updatePassword(int userId, String pwd) throws ServiceException {
try {
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String hashedPassword = passwordEncoder.encode(pwd);
this.securityQuestionDao.updateUserPwd(userId, hashedPassword);
this.securityQuestionDao.updateUserStatus(userId, 1);
} catch(DaoException e) {
throw new ServiceException(ErrorMessage.LOG_ERR_UPDT_PWD, e);
}
}
}
| [
"mdelrosario14@gmail.com"
] | mdelrosario14@gmail.com |
11244232cec1a0963474c7ffd75ea72c66bed3a4 | f2c0e67f79592156e98c3d8c05955e6b98f44be5 | /src/main/java/com/dandan/dto/OrderDto.java | 5a0ca7a1aee18462e5e9f28847a32db24253acc6 | [] | no_license | hellohahello/eatmeal-ten | 0011caf650656f2e899a980d596396cd4cc497d4 | c7f1c58c38d640f8ced5035dc95696ccc73ad143 | refs/heads/master | 2020-04-09T07:12:19.399412 | 2018-12-03T06:48:28 | 2018-12-03T06:48:28 | 160,145,320 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,392 | java | package com.dandan.dto;
import com.dandan.Enum.OrderStatusEnum;
import com.dandan.Enum.PayStatusEnum;
import com.dandan.entity.OrderDetail;
import com.dandan.utils.EnumUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author 一笑奈何
* @create 2018-11-28 19:59
* @desc
**/
@Data
public class OrderDto {
private String orderId;
/*
买家姓名
*/
private String buyerName;
/*
买家电话
*/
private String buyerPhone;
/*
地址
*/
private String buyerAddress;
/*
买家openId
*/
private String buyerOpenid;
/*
订单总额
*/
private BigDecimal orderAmount;
/*
订单状态,默认0新订单
*/
private Integer orderStatus;
/*
支付状态,默认0未支付
*/
private Integer payStatus;
/*
创建时间
*/
private Date createTime;
/*
更新时间
*/
private Date updateTime;
/*
订单详情
*/
private List<OrderDetail> orderDetailList;
@JsonIgnore
public OrderStatusEnum getOrderMessage() {
return EnumUtils.getMessage(orderStatus, OrderStatusEnum.class);
}
@JsonIgnore
public PayStatusEnum getPayMessage(){
return EnumUtils.getMessage(orderStatus,PayStatusEnum.class);
}
}
| [
"1291482971@qq.com"
] | 1291482971@qq.com |
84e9a83c8c77f8ee681feefc4c40c136a420ebf7 | 7e891a680d1ab1453bda69470fc5cee52534b768 | /onesignal/src/main/java/com/onesignal/NotificationPayloadProcessorHMS.java | 2dc625860d9043e7a7cded74a90f788753d0d6fc | [] | no_license | hamedmobarakehi1/notif-iran-android | c2310b6fcabf38ea26a734be54f6259144d5a319 | ca525849da1eb3fd26eafaf6f5659ad56a1089d6 | refs/heads/master | 2023-01-31T10:31:42.714748 | 2020-12-19T21:18:02 | 2020-12-19T21:18:02 | 322,750,538 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,440 | java | package com.onesignal;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import static com.onesignal.GenerateNotification.BUNDLE_KEY_ACTION_ID;
class NotificationPayloadProcessorHMS {
static void handleHMSNotificationOpenIntent(@NonNull Activity activity, @Nullable Intent intent) {
OneSignal.setAppContext(activity);
if (intent == null)
return;
JSONObject jsonData = covertHMSOpenIntentToJson(intent);
if (jsonData == null)
return;
handleProcessJsonOpenData(activity, jsonData);
}
// Takes in a Notification Open Intent fired from HMS Core and coverts it to an OS formatted JSONObject
// Returns null if it is NOT a notification sent from OneSignal's backend
private static @Nullable JSONObject covertHMSOpenIntentToJson(@Nullable Intent intent) {
// Validate Intent to prevent any side effects or crashes
// if triggered outside of OneSignal for any reason.
if (!OSNotificationFormatHelper.isOneSignalIntent(intent))
return null;
Bundle bundle = intent.getExtras();
JSONObject jsonData = NotificationBundleProcessor.bundleAsJSONObject(bundle);
reformatButtonClickAction(jsonData);
return jsonData;
}
// Un-nests JSON, key actionId, if it exists under custom
// Example:
// From this:
// { custom: { actionId: "exampleId" } }
// To this:
// { custom: { }, actionId: "exampleId" } }
private static void reformatButtonClickAction(@NonNull JSONObject jsonData) {
try {
JSONObject custom = NotificationBundleProcessor.getCustomJSONObject(jsonData);
String actionId = (String)custom.remove(BUNDLE_KEY_ACTION_ID);
if (actionId == null)
return;
jsonData.put(BUNDLE_KEY_ACTION_ID, actionId);
} catch (JSONException e) {
e.printStackTrace();
}
}
private static void handleProcessJsonOpenData(@NonNull Activity activity, @NonNull JSONObject jsonData) {
if (NotificationOpenedProcessor.handleIAMPreviewOpen(activity, jsonData))
return;
OneSignal.handleNotificationOpen(
activity,
new JSONArray().put(jsonData),
false,
OSNotificationFormatHelper.getOSNotificationIdFromJson(jsonData)
);
}
public static void processDataMessageReceived(@NonNull Context context, @Nullable String data) {
OneSignal.setAppContext(context);
if (data == null)
return;
Bundle bundle = OSUtils.jsonStringToBundle(data);
if (bundle == null)
return;
NotificationBundleProcessor.ProcessedBundleResult processedResult = NotificationBundleProcessor.processBundleFromReceiver(context, bundle);
// Return if the notification will NOT be handled by normal GcmIntentService display flow.
if (processedResult.processed())
return;
// TODO: 4.0.0 or after - What is in GcmBroadcastReceiver should be split into a shared class to support FCM, HMS, and ADM
GcmBroadcastReceiver.startGCMService(context, bundle);
}
}
| [
"56935314+hamedmobarakehi@users.noreply.github.com"
] | 56935314+hamedmobarakehi@users.noreply.github.com |
d69e23e33c119970b78caa0198672cc7007f34fa | 9afd9ef7bd751ae683c43b2ccaf660a32945cb55 | /src/FEP_Frame_viewer/src/com/hzjbbis/fas/protocol/zj/parse/Parser07.java | 67e55d53a2d5387517569044ec0b75fcc3a25425 | [] | no_license | road4918/jbbis | 0c2c4b25395ee199a5acafb6d5ac13b9a946fa98 | a04469a669f2cae31aa07021821f15463618717d | refs/heads/master | 2020-06-07T16:25:18.130912 | 2014-10-22T12:35:17 | 2014-10-22T12:35:17 | null | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 2,112 | java | package com.hzjbbis.fas.protocol.zj.parse;
import com.hzjbbis.exception.MessageEncodeException;
/**
* 时间解析及组帧 MM-DD hh:mm
* @author yangdinghuan
*
*/
public class Parser07 {
/**
* 解析
* @param data 数据帧
* @param loc 解析开始位置
* @param len 解析长度
* @param fraction 解析后小数位数
* @return 数据值
*/
public static Object parsevalue(byte[] data,int loc,int len,int fraction){
Object rt=null;
try{
boolean ok=true;
/*if((data[loc] & 0xff)==0xff){
ok=ParseTool.isValid(data,loc,len);
}*/
ok=ParseTool.isValidBCD(data,loc,len);
if(ok){
StringBuffer sb=new StringBuffer();
sb.append(ParseTool.ByteToHex(data[loc+3]));
sb.append("-");
sb.append(ParseTool.ByteToHex(data[loc+2]));
sb.append(" ");
sb.append(ParseTool.ByteToHex(data[loc+1]));
sb.append(":");
sb.append(ParseTool.ByteToHex(data[loc]));
rt=sb.toString();
}
}catch(Exception e){
e.printStackTrace();
}
return rt;
}
/**
* 组帧
* @param frame 存放数据的帧
* @param value 数据值(前后不能有多余空字符)
* @param loc 存放开始位置
* @param len 组帧长度
* @param fraction 数据中包含的小数位数
* @return
*/
public static int constructor(byte[] frame,String value,int loc,int len,int fraction){
try{
//check
for(int i=0;i<value.length();i++){
char c=value.charAt(i);
if(c==' '){
continue;
}
if(c==':'){
continue;
}
if(c=='-'){
continue;
}
if(c>='0' && c<='9'){
continue;
}
throw new MessageEncodeException("错误的 MM-DD HH:mm 组帧参数:"+value);
}
String[] para=value.split(" ");
String[] date=para[0].split("-");
String[] time=para[1].split(":");
frame[loc]=ParseTool.StringToBcd(time[1]);
frame[loc+1]=ParseTool.StringToBcd(time[0]);
frame[loc+2]=ParseTool.StringToBcd(date[1]);
frame[loc+3]=ParseTool.StringToBcd(date[0]);
}catch(Exception e){
throw new MessageEncodeException("错误的 MM-DD hh:mm 组帧参数:"+value);
}
return len;
}
}
| [
"road4918@163.com"
] | road4918@163.com |
ca24b3dfdfcb8ee6b18a47b9acb50d4b32e0bd8c | 81b3984cce8eab7e04a5b0b6bcef593bc0181e5a | /android/CarlifeSource/app/src/main/java/me/objectyan/screensharing/view/RadioPlayerCircleProgressView.java | 116f3d4480dcfeee45c438635de1c1d1c28abac0 | [] | no_license | ausdruck/Demo | 20ee124734d3a56b99b8a8e38466f2adc28024d6 | e11f8844f4852cec901ba784ce93fcbb4200edc6 | refs/heads/master | 2020-04-10T03:49:24.198527 | 2018-07-27T10:14:56 | 2018-07-27T10:14:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,873 | java | package com.baidu.carlife.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Cap;
import android.graphics.Paint.Style;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
import com.baidu.carlife.R;
import com.baidu.carlife.core.CarlifeScreenUtil;
import com.baidu.carlife.util.C2188r;
public class RadioPlayerCircleProgressView extends View {
/* renamed from: a */
private int f7210a;
/* renamed from: b */
private Paint f7211b = new Paint();
/* renamed from: c */
private final int f7212c = CarlifeScreenUtil.m4331a().m4343c(2);
/* renamed from: d */
private RectF f7213d;
/* renamed from: e */
private int f7214e = 100;
public void setProgress(int progress) {
this.f7210a = progress;
invalidate();
}
public void setMax(int value) {
this.f7214e = value;
}
public RadioPlayerCircleProgressView(Context context, AttributeSet attrs) {
super(context, attrs);
this.f7211b.setAntiAlias(true);
this.f7211b.setFlags(1);
this.f7211b.setStyle(Style.STROKE);
this.f7211b.setColor(C2188r.m8328a((int) R.color.cl_progress_radio_player));
this.f7211b.setStrokeWidth((float) this.f7212c);
this.f7211b.setStrokeCap(Cap.SQUARE);
this.f7213d = new RectF();
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int center = getWidth() / 2;
if (center != 0) {
this.f7213d.set((float) (this.f7212c / 2), (float) (this.f7212c / 2), (float) ((center * 2) - (this.f7212c / 2)), (float) ((center * 2) - (this.f7212c / 2)));
canvas.drawArc(this.f7213d, -90.0f, 360.0f * (((float) this.f7210a) / ((float) this.f7214e)), false, this.f7211b);
}
}
}
| [
"objectyan@gmail.com"
] | objectyan@gmail.com |
483faa40f64e76a43af0b14ed74592466c905ee1 | 6e2e383a00778d826c451a4d9274fc49e0cff41c | /hackerrank/src/Leecode/Prob_64.java | 7246dfbfaf110eebc89e7d7902cf90ff0df4e941 | [] | no_license | kenvifire/AlgorithmPractice | d875df9d13a76a02bce9ce0b90a8fad5ba90f832 | e16315ca2ad0476f65f087f608cc9424710e0812 | refs/heads/master | 2022-12-17T23:45:37.784637 | 2020-09-22T14:45:46 | 2020-09-22T14:45:46 | 58,105,208 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 828 | java | package Leecode;
import utils.PrintUtils;
public class Prob_64 {
public int minPathSum(int[][] grid) {
int[][] dp = new int[grid.length][grid[0].length];
for (int i = 0; i < grid.length; i++) {
for (int j = 0; j < grid[0].length; j++) {
if(i == 0 && j == 0) {
dp[i][j] = grid[i][j];
continue;
}
dp[i][j] = Math.min(i - 1 >= 0 ? dp[i-1][j] : Integer.MAX_VALUE,
j - 1 >= 0 ? dp[i][j-1] : Integer.MAX_VALUE) + grid[i][j];
}
}
return dp[grid.length - 1][grid[0].length - 1];
}
public static void main(String[] args) {
Prob_64 prob = new Prob_64();
System.out.println(prob.minPathSum(new int[][]{{1,3,1},{1,5,1},{4,2,1}}));
}
}
| [
"mrwhite@163.com"
] | mrwhite@163.com |
f284da742a1529b8a2d1a3bc23d99803214354a4 | ace1241b5653e327026a3a41db3a66f200828e91 | /src/test/java/mel/Tests/Admin/BlogsTest.java | bc53e5102aa538935bc9afeafc24f7c59894fb33 | [] | no_license | Danil21/autotest-mel | d434fa9fcc0b91b9c3af944de7bfa04a4ced6e07 | 614895fab041298a543eea036c9f489e30c33334 | refs/heads/master | 2023-07-20T09:38:37.835385 | 2023-07-15T10:44:50 | 2023-07-15T10:44:50 | 220,287,215 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,543 | java | package mel.Tests.Admin;
import mel.AdminTestClasses.AdminBlogs;
import mel.AdminTestClasses.AdminFrontPage;
import mel.AdminTestClasses.AdminLogin;
import mel.Helper.AdditionalMethods;
import mel.Helper.GetUrl;
import mel.Helper.SetDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Set;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.sleep;
import static com.codeborne.selenide.WebDriverRunner.getWebDriver;
public class BlogsTest extends SetDriver {
private AdditionalMethods methods = new AdditionalMethods();
private GetUrl getUrl = new GetUrl();
private AdminLogin adminLogin = new AdminLogin();
private AdminFrontPage frontPage = new AdminFrontPage();
private AdminBlogs blogs = new AdminBlogs();
@AfterClass
public void browserLogs() throws IOException {
methods = new AdditionalMethods();
ArrayList errors = new ArrayList();
errors.add("yandex");
errors.add("yadro");
errors.add("tracker.rareru");
errors.add("relap.io");
errors.add("aidata");
methods.getBrowserLogs(errors, "BlogsTest");
}
@Test
public void checkBlogs() {
getUrl.driverGetAdminUrl();
adminLogin.adminAuthorisation("test@example.com", "123qwe11");
sleep(2000);
blogs.clickInBlogsButton();
String parentWindowId = getWebDriver().getWindowHandle();
final Set<String> oldWindowsSet = getWebDriver().getWindowHandles();
// запись в строку заголовка блога в админке
sleep(200);
String blogInAdmin = methods.getTextInsideElement(blogs.blogTitleInAdmin);
String blogId = blogs.getBlogId();
sleep(3000);
// нажатие на кнопку открытия на сайте публикации
blogs.clickInOpenAtSiteButton();
sleep(3000);
methods.moveFocusToTheNewWindow(oldWindowsSet);
// запись в строку заголовка блога на сайте
String blogInSite = methods.getTextInsideElement(blogs.blogTitleInSite);
// blogInSite = blogInSite.replace("—", "–")
// .replace("«", "")
// .replace("»", ""); //executes only if post has "-" or "«,", »" in title
// blogInAdmin = blogInAdmin.replace("\"", "");
blogs.comprasionTitleBlogs(blogInAdmin, blogInSite);
// переход на окно в адмикне
getWebDriver().switchTo().window(parentWindowId);
sleep(1000);
// нажатие на выпадающее меню в зависимости добавлена ли запись на первую полосу
if (!blogs.checkFlagAddToFrontPage()) {
blogs.clickInDropDownMenu();
} else {
blogs.clickInDropDownMenu();
blogs.clickInPostFutureButton();
blogs.clickInDropDownMenu();
}
sleep(1000);
// нажатие на кнопку блокировки публикации
blogs.clickInPostBlockingButton();
sleep(1000);
// проверка отображения значка блорировки
org.testng.Assert.assertTrue($(blogs.iconImgHiddenBlog).isDisplayed());
blogs.clickInDropDownMenu();
// разблокировка публикации
$(blogs.postBlockingButton).click();
sleep(1000);
blogs.clickInDropDownMenu();
sleep(1000);
// нажатие на кнокпку добавление на первую полосу
blogs.clickInPostFutureButton();
sleep(2000);
// проверка отображения флага
org.testng.Assert.assertTrue($(blogs.flagAddToFrontPage).isDisplayed());
// переход на первую полосу
getUrl.driverGetCurrentAdminUrl("frontpage");
sleep(5000);
for (int i = 1; i < 15; i++) {
By blogInFirstPage = By.cssSelector(".b-order-manager__switcher-list-container > div > div:nth-child(" + i + ")");
String compareId = $(blogInFirstPage).getAttribute("data-params").substring(6, 10);
if (compareId.equals(blogId)) {
By firstPageONButton = By.cssSelector(".b-order-manager__switcher-list-container > div > div:nth-child(" + i + ") > div > div.b-switcher__icon > div");
String actualAttribute = $(firstPageONButton).getAttribute("data-params");
String expectedAttribute = "{\"type\":\"off\"}";
// нажатие на кнопку добавления блога на первую полосу
if (actualAttribute.equals(expectedAttribute) == true) {
By switcher = By.cssSelector(".b-order-manager__switcher-list-container > div > div:nth-child(" + i + ") > div > div.b-switcher__icon > div");
$(switcher).click();
sleep(2000);
break;
}
break;
}
break;
}
for (int i = 1; i < 15; i++) {
By blogInFirstPage = By.cssSelector(".b-order-manager__switcher-list-container > div > div:nth-child(" + i + ")");
String compareId = $(blogInFirstPage).getAttribute("data-params").substring(6, 10);
if (compareId.equals(blogId)) {
WebElement switcher = $(By.cssSelector(".b-order-manager__switcher-list-container > div > div:nth-child(" + i + ") > div > div.b-switcher__drag-handle"));
int yOffset;
if (i == 1) {
yOffset = 0;
} else {
yOffset = i * 65;
}
new Actions(getWebDriver())
.dragAndDropBy(switcher, 0, -yOffset) // смещение в пикселях
.build()
.perform();
break;
}
}
sleep(1000);
frontPage.clickInFrontPageSaveButton();
// проверка на соответствия данных созданного блога и блога, отображающегося на сайте
sleep(5000);
getUrl.driverGet();
sleep(1000);
if (methods.getDisplayedElement(blogs.mainPagePublicationTitle)) {
Assert.assertEquals(methods.getTextFromSelector(blogs.mainPagePublicationTitle)
.replace("«", "")
.replace("»", ""), blogInSite);
} else if (methods.getDisplayedElement(blogs.mainPageBlogTitle)) {
Assert.assertEquals(methods.getTextFromSelector(blogs.mainPageBlogTitle)
.replace("«", "")
.replace("»", ""), blogInSite);
}
if (methods.getDisplayedElement(blogs.mainPagePublicationCoverTag)) {
Assert.assertEquals(methods.getTextFromSelector(blogs.mainPagePublicationCoverTag), "БЛОГИ");
} else if (methods.getDisplayedElement(blogs.mainPageBlogCoverTag)) {
Assert.assertEquals(methods.getTextFromSelector(blogs.mainPageBlogCoverTag), "БЛОГИ");
}
}
}
| [
"vagin.2012@mail.ru"
] | vagin.2012@mail.ru |
600d42d493e1ed4cdffc25d329080347777ae101 | be4416cc059f63e5f078988f3dc5eaf77c394a7a | /Week2_String_Assignments/Assignment2/Part3.java | df0f53ff55cb2160426f5e6707941ea066fcaca2 | [] | no_license | hezitaooOO/Coursera_Java_Programming_Solving_Problems_with_Software_Assignments | 242b6e8e20097fda2a3fe5c128695e257c0a001c | c3efd2fde87e3787e23c0932676ff50fbbd26a65 | refs/heads/main | 2023-01-23T00:19:13.173996 | 2020-12-12T04:11:18 | 2020-12-12T04:11:18 | 320,738,716 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,069 | java | /**
* Coursera Course: Java Programming: Solving Problems with Software.
* Week 2
* Assignment 2: Find all genes in DNA strand.
* Part 3
*
* @Zitao He
* @version 1
*/
public class Part3 {
public int findStopCodon(String dna, int startIndex, String stopCodon){
//String dnaNew = dna.substring(startIndex);
int stopIndex = dna.indexOf(stopCodon, startIndex);
// if there is no valid DNA, return the length of original dna strand.
if (stopIndex == -1 ||
(stopIndex != -1 && (stopIndex - startIndex) % 3 != 0))
{
return dna.length();
}
return stopIndex;
}
public String findGene(String dna){
String startCodon = "ATG";
int startIndex = 0;
int stopIndexTAA = 0;
int stopIndexTAG = 0;
int stopIndexTGA = 0;
int stopIndexFinal = 0;
startIndex = dna.indexOf(startCodon);
if (startIndex == -1){return "";}
stopIndexTAA = findStopCodon(dna, startIndex, "TAA");
stopIndexTAG = findStopCodon(dna, startIndex, "TAG");
stopIndexTGA = findStopCodon(dna, startIndex, "TGA");
//If there is no valid stop codon, return an empty string
if (stopIndexTAA == dna.length() && stopIndexTAG == dna.length() && stopIndexTGA == dna.length()){return "";}
//Find the stop codon that is closest to the start codon
int[] stopIndexList = {stopIndexTAA, stopIndexTAG, stopIndexTGA};
int temp = dna.length();
for (int index : stopIndexList){
if (index != -1){temp = Math.min(temp, index);}
}
stopIndexFinal = temp;
return dna.substring(startIndex, stopIndexFinal + 3);
}
public void printAllGenes(String dna){
int startIndex = 0;
int newStartIndex = 0;
while (true){
String gene = findGene(dna);
if (gene.isEmpty()){
break;
}
System.out.println("Found a valid gene: " + gene);
newStartIndex = dna.indexOf(gene) + gene.length();
dna = dna.substring(newStartIndex);
}
System.out.println("Gene search finished. All valid genes are printed. Check your DNA if there aren't any genes printed.");
}
public int countGenes(String dna){
int startIndex = 0;
int newStartIndex = 0;
int count = 0;
while (true){
String gene = findGene(dna);
if (gene.isEmpty()){
break;
}
newStartIndex = dna.indexOf(gene) + gene.length();
dna = dna.substring(newStartIndex);
count ++;
}
return count;
}
public void testCountGenes(){
String dna = "ATGTAAGATGCCCTAGT";
System.out.println(countGenes(dna));
}
}
| [
"noreply@github.com"
] | noreply@github.com |
1966bb96c8bf5abacce95f3cd62bcbdcf11d1382 | 71a74f2ea9b33c91a98d5933e1442452f1d6eb03 | /system_demo/src/cn/wistron/utils/JSONUtils.java | d18e30b2886bb9b2a190e6ceb17572bb115bc625 | [] | no_license | androidlgy/learning | 04407478015691288ce43defa8ffe2f70932c4ba | 93344cbb5e3e8c8e9ad0b7e3654c1c4561c7aa48 | refs/heads/master | 2021-01-12T07:51:49.869714 | 2017-05-10T01:43:38 | 2017-05-10T01:43:38 | 77,045,424 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 12,375 | java | package cn.wistron.utils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.beanutils.BeanUtils;
public class JSONUtils
{
/**
*
* @author wangwei JSON工具类
* @param
*
*/
/***
* 将List对象序列化为JSON文本
*/
public static <T> String toJSONString(List<T> list)
{
JSONArray jsonArray = JSONArray.fromObject(list);
return jsonArray.toString();
}
/***
* 将对象序列化为JSON文本
* @param object
* @return
*/
public static String toJSONString(Object object)
{
JSONArray jsonArray = JSONArray.fromObject(object);
return jsonArray.toString();
}
/***
* 将JSON对象数组序列化为JSON文本
* @param jsonArray
* @return
*/
public static String toJSONString(JSONArray jsonArray)
{
return jsonArray.toString();
}
/***
* 将JSON对象序列化为JSON文本
* @param jsonObject
* @return
*/
public static String toJSONString(JSONObject jsonObject)
{
return jsonObject.toString();
}
/***
* 将对象转换为List对象
* @param object
* @return
*/
public static List toArrayList(Object object)
{
List arrayList = new ArrayList();
JSONArray jsonArray = JSONArray.fromObject(object);
Iterator it = jsonArray.iterator();
while (it.hasNext())
{
JSONObject jsonObject = (JSONObject) it.next();
Iterator keys = jsonObject.keys();
while (keys.hasNext())
{
Object key = keys.next();
Object value = jsonObject.get(key);
arrayList.add(value);
}
}
return arrayList;
}
/***
* 将对象转换为Collection对象
* @param object
* @return
*/
public static Collection toCollection(Object object)
{
JSONArray jsonArray = JSONArray.fromObject(object);
return JSONArray.toCollection(jsonArray);
}
/***
* 将对象转换为JSON对象数组
* @param object
* @return
*/
public static JSONArray toJSONArray(Object object)
{
return JSONArray.fromObject(object);
}
/***
* 将对象转换为JSON对象
* @param object
* @return
*/
public static JSONObject toJSONObject(Object object)
{
return JSONObject.fromObject(object);
}
/***
* 将对象转换为HashMap
* @param object
* @return
*/
public static HashMap toHashMap(Object object)
{
HashMap<String, Object> data = new HashMap<String, Object>();
JSONObject jsonObject = JSONUtils.toJSONObject(object);
Iterator it = jsonObject.keys();
while (it.hasNext())
{
String key = String.valueOf(it.next());
Object value = jsonObject.get(key);
data.put(key, value);
}
return data;
}
/***
* 将对象转换为List>
* @param object
* @return
*/
// 返回非实体类型(Map)的List
public static List<Map<String, Object>> toList(Object object)
{
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
JSONArray jsonArray = JSONArray.fromObject(object);
for (Object obj : jsonArray)
{
JSONObject jsonObject = (JSONObject) obj;
Map<String, Object> map = new HashMap<String, Object>();
Iterator it = jsonObject.keys();
while (it.hasNext())
{
String key = (String) it.next();
Object value = jsonObject.get(key);
map.put((String) key, value);
}
list.add(map);
}
return list;
}
/***
* 将JSON对象数组转换为传入类型的List
* @param
* @param jsonArray
* @param objectClass
* @return
*/
public static <T> List<T> toList(JSONArray jsonArray, Class<T> objectClass)
{
return JSONArray.toList(jsonArray, objectClass);
}
/***
* 将对象转换为传入类型的List
* @param
* @param jsonArray
* @param objectClass
* @return
*/
public static <T> List<T> toList(Object object, Class<T> objectClass)
{
JSONArray jsonArray = JSONArray.fromObject(object);
return JSONArray.toList(jsonArray, objectClass);
}
/***
* 将JSON对象转换为传入类型的对象
* @param
* @param jsonObject
* @param beanClass
* @return
*/
public static <T> T toBean(JSONObject jsonObject, Class<T> beanClass)
{
return (T) JSONObject.toBean(jsonObject, beanClass);
}
/***
* 将将对象转换为传入类型的对象
* @param
* @param object
* @param beanClass
* @return
*/
public static <T> T toBean(Object object, Class<T> beanClass)
{
JSONObject jsonObject = JSONObject.fromObject(object);
return (T) JSONObject.toBean(jsonObject, beanClass);
}
/***
* 将JSON文本反序列化为主从关系的实体
* @param 泛型T 代表主实体类型
* @param 泛型D 代表从实体类型
* @param jsonString JSON文本
* @param mainClass 主实体类型
* @param detailName 从实体类在主实体类中的属性名称
* @param detailClass 从实体类型
* @return
*/
public static <T, D> T toBean(String jsonString, Class<T> mainClass,
String detailName, Class<D> detailClass)
{
JSONObject jsonObject = JSONObject.fromObject(jsonString);
JSONArray jsonArray = (JSONArray) jsonObject.get(detailName);
T mainEntity = JSONUtils.toBean(jsonObject, mainClass);
List<D> detailList = JSONUtils.toList(jsonArray, detailClass);
try
{
BeanUtils.setProperty(mainEntity, detailName, detailList);
}
catch (Exception ex)
{
throw new RuntimeException("主从关系JSON反序列化实体失败!");
}
return mainEntity;
}
/***
* 将JSON文本反序列化为主从关系的实体
* @param 泛型T 代表主实体类型
* @param 泛型D1 代表从实体类型
* @param 泛型D2 代表从实体类型
* @param jsonString JSON文本
* @param mainClass 主实体类型
* @param detailName1 从实体类在主实体类中的属性
* @param detailClass1 从实体类型
* @param detailName2 从实体类在主实体类中的属性
* @param detailClass2 从实体类型
* @return
*/
public static <T, D1, D2> T toBean(String jsonString, Class<T> mainClass,
String detailName1, Class<D1> detailClass1, String detailName2,
Class<D2> detailClass2)
{
JSONObject jsonObject = JSONObject.fromObject(jsonString);
JSONArray jsonArray1 = (JSONArray) jsonObject.get(detailName1);
JSONArray jsonArray2 = (JSONArray) jsonObject.get(detailName2);
T mainEntity = JSONUtils.toBean(jsonObject, mainClass);
List<D1> detailList1 = JSONUtils.toList(jsonArray1, detailClass1);
List<D2> detailList2 = JSONUtils.toList(jsonArray2, detailClass2);
try
{
BeanUtils.setProperty(mainEntity, detailName1, detailList1);
BeanUtils.setProperty(mainEntity, detailName2, detailList2);
}
catch (Exception ex)
{
throw new RuntimeException("主从关系JSON反序列化实体失败!");
}
return mainEntity;
}
/***
* 将JSON文本反序列化为主从关系的实体
* @param 泛型T 代表主实体类型
* @param 泛型D1 代表从实体类型
* @param 泛型D2 代表从实体类型
* @param jsonString JSON文本
* @param mainClass 主实体类型
* @param detailName1 从实体类在主实体类中的属性
* @param detailClass1 从实体类型
* @param detailName2 从实体类在主实体类中的属性
* @param detailClass2 从实体类型
* @param detailName3 从实体类在主实体类中的属性
* @param detailClass3 从实体类型
* @return
*/
public static <T, D1, D2, D3> T toBean(String jsonString,
Class<T> mainClass, String detailName1, Class<D1> detailClass1,
String detailName2, Class<D2> detailClass2, String detailName3,
Class<D3> detailClass3)
{
JSONObject jsonObject = JSONObject.fromObject(jsonString);
JSONArray jsonArray1 = (JSONArray) jsonObject.get(detailName1);
JSONArray jsonArray2 = (JSONArray) jsonObject.get(detailName2);
JSONArray jsonArray3 = (JSONArray) jsonObject.get(detailName3);
T mainEntity = JSONUtils.toBean(jsonObject, mainClass);
List<D1> detailList1 = JSONUtils.toList(jsonArray1, detailClass1);
List<D2> detailList2 = JSONUtils.toList(jsonArray2, detailClass2);
List<D3> detailList3 = JSONUtils.toList(jsonArray3, detailClass3);
try
{
BeanUtils.setProperty(mainEntity, detailName1, detailList1);
BeanUtils.setProperty(mainEntity, detailName2, detailList2);
BeanUtils.setProperty(mainEntity, detailName3, detailList3);
}
catch (Exception ex)
{
throw new RuntimeException("主从关系JSON反序列化实体失败!");
}
return mainEntity;
}
/***
* 将JSON文本反序列化为主从关系的实体
* @param 主实体类型
* @param jsonString JSON文本
* @param mainClass 主实体类型
* @param detailClass 存放了多个从实体在主实体中属性名称和类型
* @return
*/
public static <T> T toBean(String jsonString, Class<T> mainClass,
HashMap<String, Class> detailClass)
{
JSONObject jsonObject = JSONObject.fromObject(jsonString);
T mainEntity = JSONUtils.toBean(jsonObject, mainClass);
for (Object key : detailClass.keySet())
{
try
{
Class value = (Class) detailClass.get(key);
BeanUtils.setProperty(mainEntity, key.toString(), value);
}
catch (Exception ex)
{
throw new RuntimeException("主从关系JSON反序列化实体失败!");
}
}
return mainEntity;
}
} | [
"andy@andy-PC"
] | andy@andy-PC |
d243ff980cb12baa4263270ac0e706a5e03a3fb0 | 1b21418b1e42dd07507353649bcb062a07dd3e1c | /CalhandarWeb/src/it/polimi/db2/controllers/GoToCommitmentTypePage.java | 6fc138a597d7c0de29b85d39e31112d33c049d05 | [] | no_license | silvialocarno/Calhandar | 89ec17e78372e8c916cccc5fa7c5263d15febc8f | 0c6cc95d1575dc309e629ee1b3fd6658af060aef | refs/heads/main | 2023-05-07T11:26:56.267795 | 2021-06-04T11:39:19 | 2021-06-04T11:39:19 | 373,574,308 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,386 | java | package it.polimi.db2.controllers;
import it.polimi.db2.calhandar.entities.Commitment;
import it.polimi.db2.calhandar.entities.Professor;
import it.polimi.db2.calhandar.services.ProfessorService;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.WebContext;
import org.thymeleaf.templatemode.TemplateMode;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;
import javax.ejb.EJB;
import javax.servlet.ServletContext;
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 java.io.IOException;
import java.time.LocalDate;
import java.util.List;
@WebServlet("/CommitmentType")
public class GoToCommitmentTypePage extends HttpServlet {
private static final long serialVersionUID = 1L;
private TemplateEngine templateEngine;
public GoToCommitmentTypePage() {
super();
}
public void init() throws ServletException {
ServletContext servletContext = getServletContext();
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(servletContext);
templateResolver.setTemplateMode(TemplateMode.HTML);
this.templateEngine = new TemplateEngine();
this.templateEngine.setTemplateResolver(templateResolver);
templateResolver.setSuffix(".html");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// If the user is not logged in (not present in session) redirect to the login
String loginpath = getServletContext().getContextPath() + "/index.html";
HttpSession session = request.getSession();
if (session.isNew() || session.getAttribute("user") == null) {
response.sendRedirect(loginpath);
return;
}
// Redirect to the Home page and add missions to the parameters
String path = "/WEB-INF/CommitmentType.html";
ServletContext servletContext = getServletContext();
final WebContext ctx = new WebContext(request, response, servletContext, request.getLocale());
templateEngine.process(path, ctx, response.getWriter());
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
public void destroy() {
}
}
| [
"silvia.locarno@mail.polimi.it"
] | silvia.locarno@mail.polimi.it |
b445f19f37d8305b322617822064b2679100b482 | 6b34e9f52ebd095dc190ee9e89bcb5c95228aed6 | /l2gw-core/highfive/gameserver/java/ru/l2gw/gameserver/skills/effects/i_harvesting.java | 933249a22208b0a40382c6b1ac9702ea45f5b084 | [] | no_license | tablichka/play4 | 86c057ececdb81f24fc493c7557b7dbb7260218d | b0c7d142ab162b7b37fe79d203e153fcf440a8a6 | refs/heads/master | 2022-04-25T17:04:32.244384 | 2020-04-27T12:59:45 | 2020-04-27T12:59:45 | 259,319,030 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,858 | java | package ru.l2gw.gameserver.skills.effects;
import ru.l2gw.gameserver.Config;
import ru.l2gw.commons.arrays.GArray;
import ru.l2gw.extensions.multilang.CustomMessage;
import ru.l2gw.gameserver.cache.Msg;
import ru.l2gw.gameserver.model.L2Character;
import ru.l2gw.gameserver.model.L2Player;
import ru.l2gw.gameserver.model.instances.L2ItemInstance;
import ru.l2gw.gameserver.model.instances.L2MonsterInstance;
import ru.l2gw.gameserver.serverpackets.SystemMessage;
import ru.l2gw.gameserver.skills.Env;
import ru.l2gw.commons.math.Rnd;
/**
* @author rage
* @date 26.11.2009 8:59:15
*/
public class i_harvesting extends i_effect
{
public i_harvesting(EffectTemplate template)
{
super(template);
}
@Override
public void doEffect(L2Character cha, GArray<Env> targets, int ss, boolean counter)
{
L2Player player = cha.getPlayer();
if(player == null)
return;
for(Env env : targets)
if(env.target.isMonster())
{
L2MonsterInstance monster = (L2MonsterInstance) env.target;
// Не посеяно
if(!monster.isSeeded())
{
player.sendPacket(Msg.THE_HARVEST_FAILED_BECAUSE_THE_SEED_WAS_NOT_SOWN);
continue;
}
if(!monster.isSeeded(player))
{
player.sendPacket(Msg.YOU_ARE_NOT_AUTHORIZED_TO_HARVEST);
continue;
}
double SuccessRate = Config.MANOR_HARVESTING_BASIC_SUCCESS;
int diffPlayerTarget = Math.abs(player.getLevel() - monster.getLevel());
// Штраф, на разницу уровней между мобом и игроком
// 5% на каждый уровень при разнице >5 - по умолчанию
if(diffPlayerTarget > Config.MANOR_DIFF_PLAYER_TARGET)
SuccessRate -= (diffPlayerTarget - Config.MANOR_DIFF_PLAYER_TARGET) * Config.MANOR_DIFF_PLAYER_TARGET_PENALTY;
// Минимальный шанс успеха всегда 1%
if(SuccessRate < 1)
SuccessRate = 1;
if(Config.SKILLS_SHOW_CHANCE)
player.sendMessage(new CustomMessage("ru.l2gw.gameserver.skills.skillclasses.Harvesting.Chance", player).addNumber((int) SuccessRate));
if(!Rnd.chance(SuccessRate))
{
player.sendPacket(Msg.THE_HARVEST_HAS_FAILED);
monster.takeHarvest();
continue;
}
L2ItemInstance[] items = monster.takeHarvest();
if(items == null)
continue;
for(L2ItemInstance item : items)
{
long itemCount = item.getCount();
item = player.getInventory().addItem("Harvest", item, player, monster);
SystemMessage sm = new SystemMessage(SystemMessage.S1_HARVESTED_S3_S2_S).addString(player.getName()).addNumber(itemCount).addItemName(item.getItemId());
player.sendPacket(sm);
if(player.isInParty())
player.getParty().broadcastToPartyMembers(player, sm);
}
}
}
}
| [
"ubuntu235@gmail.com"
] | ubuntu235@gmail.com |
8606fb26f63d4678425af6ed7433b51853f03f0d | 9e3b0735ce9fc649a7fcb972cb48201adcfe29f5 | /src/com/starmapper/android/celestial/Constellation.java | e9946a4bb36b343f2c62ea296edcd47ae0865ad4 | [] | no_license | jodonnell07/StarMapper_Android | 4084c5e30c77348d2d95322218fae5eaf443a14b | 79b958cfcc9759c79d6e40ac63810de73051aa74 | refs/heads/master | 2016-09-05T23:58:19.378527 | 2013-11-08T23:49:03 | 2013-11-08T23:49:03 | 13,197,117 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 959 | java | package com.starmapper.android.celestial;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.ArrayList;
public class Constellation {
private String name;
// Stars in constellation
private Set<Star> StarSet;
// Constellation Lines (separate lines each connecting two stars)
private ArrayList<ConstLine> ConstLines;
// Constructors
public Constellation() {
StarSet = new LinkedHashSet<Star>();
ConstLines = new ArrayList<ConstLine>();
}
public void addName(String argName) {
name = argName;
}
public void addStar(Star argStar) {
StarSet.add(argStar);
}
public int getNumStars() {
return StarSet.size();
}
public Set<Star> getStars() {
return StarSet;
}
public void addLine(ConstLine line) {
ConstLines.add(line);
}
public ArrayList<ConstLine> getLines() {
return ConstLines;
}
public int getNumLines() {
return ConstLines.size();
}
public String getName() {
return name;
}
}
| [
"jodonnell07@gmail.com"
] | jodonnell07@gmail.com |
d56f0dd44cf008ccf62b1df1d0908b83c4581e3b | 089482a0dec2c77110d2c87cdbc2bb651011bb97 | /src/main/java/com/gwg/demo/mapper/SysOperationLogMapper.java | 26ce05f669c98861dfa2dd513eb75e4d91a4894d | [] | no_license | gaoweigang/springboot-asyncLogger-baseOnAspect | 450b50426f614272d2e26f2574a5dc0648e80da2 | 1463065bbd45a04d32b8fa4e9465db73ad602424 | refs/heads/master | 2020-03-31T21:28:49.991294 | 2018-10-15T06:21:18 | 2018-10-15T06:21:18 | 152,582,212 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 968 | java | package com.gwg.demo.mapper;
import com.gwg.demo.domain.SysOperationLog;
import com.gwg.demo.domain.SysOperationLogExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SysOperationLogMapper {
int countByExample(SysOperationLogExample example);
int deleteByExample(SysOperationLogExample example);
int deleteByPrimaryKey(Integer id);
int insert(SysOperationLog record);
int insertSelective(SysOperationLog record);
List<SysOperationLog> selectByExample(SysOperationLogExample example);
SysOperationLog selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") SysOperationLog record, @Param("example") SysOperationLogExample example);
int updateByExample(@Param("record") SysOperationLog record, @Param("example") SysOperationLogExample example);
int updateByPrimaryKeySelective(SysOperationLog record);
int updateByPrimaryKey(SysOperationLog record);
} | [
"13817191469@163.com"
] | 13817191469@163.com |
96e2d9565c01a8f808d447065db12cb8c05ff3c1 | 84c8b02b53c131ed8b1ead0b7de1194f5d527c30 | /src/test/java/mfrolov/test/ChildParentDto.java | 0ab06ee58ecebe4540f4152a8a3915b05633420b | [] | no_license | wrungel/eclipselink-archiving | 05ef7c450d7d29e629092b218f8f983d963fecd8 | c2b4e5ba23873f51450f08f55989a07f6a9fd8de | refs/heads/master | 2020-12-24T10:52:29.587017 | 2016-11-07T22:35:40 | 2016-11-07T22:35:40 | 73,127,276 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,457 | java | package mfrolov.test;
import java.util.Objects;
public class ChildParentDto {
private final String childDescription;
private final String parentDescription;
public ChildParentDto(String childDescription, String parentDescription) {
this.childDescription = childDescription;
this.parentDescription = parentDescription;
}
public String getChildDescription() {
return childDescription;
}
public String getParentDescription() {
return parentDescription;
}
@Override
public String toString() {
return String.format("%s:%s", childDescription, parentDescription);
}
@Override
public int hashCode() {
return Objects.hash(childDescription, parentDescription);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof ChildParentDto)) {
return false;
}
ChildParentDto other = (ChildParentDto) obj;
return Objects.equals(this.childDescription, other.childDescription)
&& Objects.equals(this.parentDescription, other.parentDescription);
}
/**
* @param description e.g <code>C5:P2</code>
*/
public static ChildParentDto childParentDto(String description) {
String[] descriptions = description.split(":");
return new ChildParentDto(descriptions[0], descriptions[1]);
}
}
| [
"Maxim.Frolov-External@hamburgsud.com"
] | Maxim.Frolov-External@hamburgsud.com |
f493e0d404c427dec294caec40006e5fd389708d | c31140a66db40fd1cd0df4ebeccbf187c11aee66 | /java8/src/baekjoon/bj17000/BJ17300.java | 9685dd9f4c7e4ff550cc187634370ed5f211cbd7 | [] | no_license | puzzledPublic/firstRepository | 4a00e51f3748e389277c6409d19e011e33bb4cdc | 8eb4ccf6f2fa45bd10e5ecbf7f3461c07db44c4e | refs/heads/master | 2021-05-24T04:50:34.973158 | 2020-08-30T13:18:54 | 2020-08-30T13:18:54 | 43,477,374 | 1 | 0 | null | 2016-06-13T07:15:59 | 2015-10-01T03:54:41 | Java | UTF-8 | Java | false | false | 2,220 | java | package baekjoon.bj17000;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
//패턴
public class BJ17300 {
static int[][] pos = {{0, 0}, {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {1, 2}, {2, 0}, {2, 1}, {2, 2}}; //3x3행렬에서 i의 좌표
static int[][] screen = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; //3x3행렬
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int N = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int[] arr = new int[10];
boolean[] chk = new boolean[11]; //이미 수열에 들었는지 표시하는 배열
for(int i = 0; i < N; i++) {
arr[i] = Integer.parseInt(st.nextToken());
}
boolean can = true;
chk[arr[0]] = true; //첫번째 숫자 표시
for(int i = 1; i < N; i++) {
if(chk[arr[i]]) { //이미 나온 숫자라면 패턴 불가
can = false;
break;
}
int len1 = Math.abs(pos[arr[i - 1]][0] - pos[arr[i]][0]); //이전 숫자와 현재 숫자 좌표 차이의 절대값.
int len2 = Math.abs(pos[arr[i - 1]][1] - pos[arr[i]][1]);
//좌표 절대값이 (2, 0), (0, 2), (2, 2)가 아니라면 바로 갈 수 있는 곳이므로 체크
if(!((len1 == 2 && len2 == 0) || (len1 == 0 && len2 == 2) || (len1 == 2 && len2 == 2))) {
chk[arr[i]] = true;
}else {
//좌표 절대값이 (2, 0), (0, 2), (2, 2)라면 중간에 숫자 하나를 건너 뛴 셈이고 ex)1 -> 9 or 1 -> 3 or 1 -> 7...
//중간 숫자 좌표를 계산하여 해당 좌표의 숫자가 체크 되어있다면 현재 숫자로 갈 수 있다.
int x = (pos[arr[i - 1]][0] + pos[arr[i]][0]) / 2;
int y = (pos[arr[i - 1]][1] + pos[arr[i]][1]) / 2;
if(chk[screen[x][y]]) {
chk[arr[i]] = true;
}else {
can = false;
break;
}
}
}
bw.write(can ? "YES" : "NO");
bw.flush();
bw.close();
br.close();
}
} | [
"puzzledPublic@gmail.com"
] | puzzledPublic@gmail.com |
1d5d851fe9005e525c8008c2d7090a4cc5c926db | 88b0125fc8c5e4f9ecfdb22aebaa74ac25f5aa14 | /app/src/main/java/heroesapi/ImageResponse.java | f0aa30a0c7b049a444a2e69fe9438333ed9a4ea7 | [] | no_license | sujanshrestha08/FileDataAPI | 96b3f145f4b9af75372de0e8aa0c05dcabd8e980 | c977ca0bbf15008cbce3d41c65fabe303cbe4b5c | refs/heads/master | 2020-05-24T19:38:58.725941 | 2019-05-24T02:52:18 | 2019-05-24T02:52:18 | 187,439,062 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 146 | java | package heroesapi;
public class ImageResponse {
private String filename;
public String getFilename() {
return filename;
}
}
| [
"softwarica@softwarica.com"
] | softwarica@softwarica.com |
936a6ee89426bb2a72781f8d07ebeb8f6099c473 | b336307902d9d74b19ec22c91a99f4d65a1c434f | /java/src/main/java/多线程/notify/Consumer.java | 481dbf745d33e00703b7a459bd01fd0f4388b4cf | [] | no_license | shejiewei/sjw-all | f529159a87defda6373b3322a89788565c16e302 | 25e03eacc268dded130476d0492ed4990101f256 | refs/heads/master | 2022-09-22T16:28:45.539089 | 2021-03-14T09:35:43 | 2021-03-14T09:35:43 | 166,673,906 | 4 | 0 | null | 2022-09-17T00:05:57 | 2019-01-20T15:00:25 | Java | UTF-8 | Java | false | false | 668 | java | package 多线程.notify;
/**
* Created by shejiewei on 2019/3/10.
*/
public class Consumer extends Thread{
// 每次消费的产品数量
private int num;
// 所在放置的仓库
private AbstractStorage abstractStorage1;
// 构造函数,设置仓库
public Consumer(AbstractStorage abstractStorage1)
{
this.abstractStorage1 = abstractStorage1;
}
// 线程run函数
public void run()
{
consume(num);
}
// 调用仓库Storage的生产函数
public void consume(int num)
{
abstractStorage1.consume(num);
}
public void setNum(int num){
this.num = num;
}
}
| [
"2284872818@qq.com"
] | 2284872818@qq.com |
1710b3c1b62bbd5acaec2c86ef2dc4023f85f478 | 2e26a961726b6adf6359cacbae9688d0b89d6a0d | /pear-utils/src/main/java/com/pear/commons/tools/base/exception/DecoderException.java | 8344f29ebdda21ffcd74e6d947a8ba2a6ff542f9 | [] | no_license | littlehui/Pear | 27a15456fe68483a90f728a8c8f34b76f2bee4dc | 600f739a644e81da1d90963f1715fb7eccc4c9bf | refs/heads/master | 2021-01-24T20:53:03.290741 | 2018-07-10T04:00:40 | 2018-07-10T04:00:40 | 123,261,551 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,721 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.pear.commons.tools.base.exception;
/**
* Thrown when there is a failure condition during the decoding process. This exception is thrown when a {@link Decoder}
* encounters a decoding specific exception such as invalid data, or characters outside of the expected range.
*
* @author Apache Software Foundation
* @version $Id: DecoderException.java 1157192 2011-08-12 17:27:38Z ggregory $
*/
public class DecoderException extends Exception {
/**
* Declares the Serial Version Uid.
*
* @see <a href="http://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always Declare Serial Version Uid</a>
*/
private static final long serialVersionUID = 1L;
/**
* Constructs a new exception with <code>null</code> as its detail message. The cause is not initialized, and may
* subsequently be initialized by a call to {@link #initCause}.
*
* @since 1.4
*/
public DecoderException() {
super();
}
/**
* Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently
* be initialized by a call to {@link #initCause}.
*
* @param message
* The detail message which is saved for later retrieval by the {@link #getMessage()} method.
*/
public DecoderException(String message) {
super(message);
}
/**
* Constructsa new exception with the specified detail message and cause.
*
* <p>
* Note that the detail message associated with <code>cause</code> is not automatically incorporated into this
* exception's detail message.
* </p>
*
* @param message
* The detail message which is saved for later retrieval by the {@link #getMessage()} method.
* @param cause
* The cause which is saved for later retrieval by the {@link #getCause()} method. A <code>null</code>
* value is permitted, and indicates that the cause is nonexistent or unknown.
* @since 1.4
*/
public DecoderException(String message, Throwable cause) {
super(message, cause);
}
/**
* Constructs a new exception with the specified cause and a detail message of <code>(cause==null ?
* null : cause.toString())</code> (which typically contains the class and detail message of <code>cause</code>).
* This constructor is useful for exceptions that are little more than wrappers for other throwables.
*
* @param cause
* The cause which is saved for later retrieval by the {@link #getCause()} method. A <code>null</code>
* value is permitted, and indicates that the cause is nonexistent or unknown.
* @since 1.4
*/
public DecoderException(Throwable cause) {
super(cause);
}
}
| [
"aod2011@163.com"
] | aod2011@163.com |
9b2acba0c5608a0a831fa780f9eb7b1ce5563313 | 6e768aae8b77d3f9d89287abfcea69549d1ad224 | /persistence-modules/spring-data-jpa-repo-3/src/main/java/com/baeldung/spring/data/jpa/listrepositories/entity/Person.java | 0f58e403abdec4633d1e695670b5d6e9fea7a533 | [
"MIT"
] | permissive | press0/baeldung-tutorials | 6d06552f7208e336bbca76337449d621948257e6 | 8ffca600fcf7f62d7978e735ea495d33e2d22a81 | refs/heads/master | 2023-08-16T23:17:46.001847 | 2023-08-14T17:03:59 | 2023-08-14T17:03:59 | 52,390,032 | 5 | 9 | MIT | 2023-03-01T01:35:59 | 2016-02-23T20:40:02 | Java | UTF-8 | Java | false | false | 677 | java | package com.baeldung.spring.data.jpa.listrepositories.entity;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
@Entity
public class Person {
@Id
private int id;
private String firstName;
private String lastName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
f2ba0c89bc202a7976cf5a121e1771eb61e42fb7 | 346adfeabd9c67698cc6e7aee39393b244c23c44 | /ssm022/src/main/java/com/emp/service/impl/EmpServiceImpl.java | 6cfb2f2883724a1586a5af04ed7ad9aa8a4ef8e5 | [] | no_license | lijixi888/rep_1903 | 6199b8d9f476386d38c8bd803937d1e79e80feae | 09bc6a29af6f300e78b20d2b2fea8c7e63dff7a8 | refs/heads/master | 2022-12-24T15:16:34.910374 | 2019-09-04T03:12:31 | 2019-09-04T03:12:31 | 206,033,131 | 0 | 0 | null | 2022-12-16T12:13:25 | 2019-09-03T08:55:11 | Java | GB18030 | Java | false | false | 2,164 | java | package com.emp.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import com.emp.dao.EmpDao;
import com.emp.entity.Emp;
import com.emp.service.EmpService;
import com.emp.utils.PageBean;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@Service
public class EmpServiceImpl implements EmpService{
//注入员工Dao
@Resource
private EmpDao empDao;
//分页查询 配置分页助手
public PageBean<Emp> queryBypage(Integer pageNo, Integer pageSize) {
PageHelper.startPage(pageNo,pageSize);
List<Emp> list = empDao.queryAll();
PageInfo<Emp> pageInfo = new PageInfo<Emp>(list);
//创建一个PageBean对象
PageBean<Emp> pageBean=new PageBean<Emp>();
pageBean.setPageNo(pageNo);
pageBean.setPageSize(pageSize);
pageBean.setList(pageInfo.getList());
pageBean.setTotalCount((int)(pageInfo.getTotal()));
return pageBean;
}
@Override//条件分页
public PageBean<Emp> queryByCondition(Integer pageNo, Integer pageSize, String ename) {
PageHelper.startPage(pageNo,pageSize);
List<Emp> list = empDao.queryListName(ename);
PageInfo<Emp> pageInfo = new PageInfo<Emp>(list);
//创建一个PageBean对象
PageBean<Emp> pageBean=new PageBean<Emp>();
pageBean.setPageNo(pageNo);
pageBean.setPageSize(pageSize);
pageBean.setList(pageInfo.getList());
pageBean.setTotalCount((int)(pageInfo.getTotal()));
return pageBean;
}
@Override//依据编号查询员工
public Emp queryEmpById(@PathVariable("empno")String empno) {
Emp emp = empDao.queryById(empno);
return emp;
}
@Override//添加员工
public void addEmp(Emp emp) {
empDao.addEmp(emp);
System.out.println("添加成功");
}
@Override//修改员工
public void updateEmp(Emp emp) {
empDao.updateEmp(emp);
System.out.println("更新成功");
}
@Override//删除员工
public void deleteEmp(String empno) {
empDao.deleteEmp(empno);
System.out.println("删除成功");
}
@Override
public List<Emp> queryMgrs() {
List<Emp> mgrs = empDao.queryMgrs();
return mgrs;
}
}
| [
"569223567@qq.com"
] | 569223567@qq.com |
2d0ea7cce6e0c61adf95c1201f0d301738d8b82d | badbfd900624cb8d9368d5ea7884cd4469ce6043 | /src/main/java/com/burnie/filter/CorsFilter.java | 6dc094794aa525cd68044ac236df102635e2908c | [] | no_license | BoningLiang/metro | eb4af9e2759f69e4b2f905031ce78a7e22cb7b6f | 42f5a2fda4be6949d4019c941e01a63822ae7c7f | refs/heads/master | 2022-12-28T22:57:14.260607 | 2019-09-15T08:43:55 | 2019-09-15T08:43:55 | 195,986,634 | 0 | 0 | null | 2022-12-10T05:42:20 | 2019-07-09T10:26:24 | Java | UTF-8 | Java | false | false | 1,941 | java | package com.burnie.filter;
import org.springframework.context.annotation.Configuration;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
/**
* @author liangboning
* @date 2019/7/22 17:45
*/
@Configuration
public class CorsFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = HttpServletRequest.class.cast(servletRequest);
HttpServletResponse httpServletResponse = HttpServletResponse.class.cast(servletResponse);
Set<String> allowOrigins = new HashSet<>(Arrays.asList(
"http://localhost:8081",
"http://localhost:8082",
"http://localhost:8083",
"http://localhost:8084",
"http://localhost:8085"));
Enumeration<String> origins = httpServletRequest.getHeaders("Origin");
httpServletResponse.setHeader("Access-Control-Allow-Headers", "*");
httpServletResponse.setHeader("Access-Control-Max-Age", "3600");
httpServletResponse.setHeader("Access-Control-Allow-Credentials", "true");
httpServletResponse.setHeader("Access-Control-Allow-Methods", "*");
if (origins.hasMoreElements()) {
String origin = origins.nextElement();
if (allowOrigins.contains(origin)) {
httpServletResponse.setHeader("Access-Control-Allow-Origin", origin);
}
}
filterChain.doFilter(servletRequest, servletResponse);
}
@Override
public void destroy() {
}
}
| [
"liangboning@cjbdi.com"
] | liangboning@cjbdi.com |
00ce4a52ade73529f5f59f1c64d7c36e752ca1a4 | 7b384c16eb417b5d3024edc666066cd2a8186bc5 | /src/test/java/us/xwhite/dvd/controller/FilmControllerTest.java | 7a88e2bde43fb68fa06214d95fa3127d1dd425aa | [
"Apache-2.0"
] | permissive | mtbkeith/SpringBootDocker | 1ddb4f3a042e9b9b6c2884f521df55691292b1b9 | f737cd5fffc6bbecb25b92ad09a35dea7d4ea0bf | refs/heads/master | 2021-05-16T03:47:15.448959 | 2017-10-03T05:52:46 | 2017-10-03T05:52:46 | 105,618,293 | 0 | 0 | null | 2017-10-03T05:52:47 | 2017-10-03T05:44:04 | Java | UTF-8 | Java | false | false | 2,818 | java | /*
* Copyright 2017
*
* 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 us.xwhite.dvd.controller;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.verify;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import us.xwhite.dvd.db.FilmRepository;
import us.xwhite.dvd.domain.base.Film;
/**
*
* @author Joel Crosswhite <joel.crosswhite@ix.netcom.com>
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class FilmControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private FilmRepository filmRepository;
@Test
public void getFilmDetailByTitle() throws Exception {
String title = "ACADEMY DINOSAUR";
Film expectedResult = new Film();
expectedResult.setFilmId((short) 1);
expectedResult.setTitle(title);
given(filmRepository.findOneByName(title))
.willReturn(expectedResult);
mockMvc.perform(MockMvcRequestBuilders.get("/api/films?title=" + title).accept(MediaType.APPLICATION_JSON))
// .andDo(print())
.andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(header().string(HttpHeaders.ETAG, "\"0a51c18e62c2d9473092ba17e839a7a82\""));
verify(filmRepository, atLeast(1)).findOneByName(title);
}
}
| [
"joel.crosswhite@ix.netcom.com"
] | joel.crosswhite@ix.netcom.com |
a807580ddda3c61d7b324b6d6301de4c9433626d | be3cf81bda41e13d90af53016bcdd18506f6c88c | /src/icity/app/icity/search/SearchConsultingListJob.java | 7718df948b104b574c1f853c2f4703666e124900 | [] | no_license | nobodybut/wangban | 943c00f635c4c089838d65dc499c368375077145 | a5346fc5f6e4cf438f880251a5fd35a04ae2f25a | refs/heads/master | 2021-06-27T00:20:15.627780 | 2017-09-15T08:08:59 | 2017-09-15T08:08:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 674 | java | package app.icity.search;
import com.icore.core.ThreadPoolBean;
import com.icore.core.ThreadPoolManager;
import com.inspur.StateType;
import com.inspur.base.BaseQueryCommand;
import com.inspur.bean.DataSet;
import com.inspur.bean.ParameterSet;
import com.inspur.util.Command;
public class SearchConsultingListJob extends BaseQueryCommand {
public DataSet execute(ParameterSet pset) {
DataSet ds = new DataSet();
try {
Command cmd = new Command("app.icity.search.SearchGenCmd");
ds = cmd.execute("getConsultingList");
if (ds.getState() == StateType.SUCCESS) {
}
} catch (Exception e) {
e.printStackTrace();
}
return ds;
}
} | [
"664284292@qq.com"
] | 664284292@qq.com |
bda140c82c52f94821fc38b220aed3752a6d238f | 125dd7aac3d882650ed08a8a038fdfb3b69c55c0 | /FruitLoops.java | 86d1bc74fcc19c8d813977b11d5cfc5e9efcc275 | [] | no_license | joeyoneill/csce247.project4 | 7ff9035f8f71effbf057635a87221d84dd0816a5 | 80e7bff654f0c2d8480acb21753a1a4fda6d4466 | refs/heads/master | 2021-01-02T13:35:23.051645 | 2020-02-11T00:52:08 | 2020-02-11T00:52:08 | 239,645,206 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 492 | java | package csce247project4;
public class FruitLoops extends Cereal {
/**
* Default constructor
*/
public FruitLoops() {
this.name = "Fruit Loops";
this.price = 1.89;
}
/**
* Displays the preperation of the cereal
*/
@Override
public void prepare() {
super.prepare();
System.out.println(" - Gather the grain");
System.out.println(" - Shape into circles");
System.out.println(" - Randomly color circles");
System.out.println(" - Let circles dry");
}
}
| [
"o39joey@gmail.com"
] | o39joey@gmail.com |
ddd31788410a1b0949afb963f77ad965591e3042 | 9299d420e3a06b14ddaeb14e3f8ca3611a2d521a | /src/neutron/Logic/Interfaces/Player.java | 5a322584910f74e5d220ef62af1004e055613d65 | [] | no_license | jkitaj/Neutron | 9ed025e613848a1720dc3ed800e8ed4dbc871adb | 5b67250a73ee5fdfe19c623274b6eb13d9cf79f1 | refs/heads/master | 2021-01-18T04:03:17.722396 | 2012-05-23T17:48:37 | 2012-05-23T17:48:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 106 | java | package neutron.Logic.Interfaces;
/**
* @author Marcin
*/
public enum Player {
Player,
Enemy
}
| [
"M.Kaczynski@stud.elka.pw.edu.pl"
] | M.Kaczynski@stud.elka.pw.edu.pl |
c88bb541abdd6a53d24053e02158890bd7b9f36b | 86a8030efba44bc53848eafbf83b81fa558c008f | /src/Models/Fuego.java | 1ea8a5f0b43a54ad45ff4acc95af2013ebdf2a40 | [
"Unlicense"
] | permissive | HenryOrtizAjcuc/testGame | 20f9c4aa83a5a959e0c96ec23d98eab4ca17ba46 | 3e4ce2f3d15a2d5fdd4524ea5b56e2f21917dda4 | refs/heads/main | 2023-06-07T12:46:26.207167 | 2021-06-20T02:41:39 | 2021-06-20T02:41:39 | 378,527,035 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 437 | java | package src.Models;
import src.Interfaces.Inicio;
//Laser
public class Fuego extends Accion {
protected static final int DISPARO_SPEED = 3;
public Fuego(Inicio inicio) {
super(inicio);
setSpriteNames(new String[]{"src/images/fue0.png"});
setFrameSpeed(10);
}
public void act() {
super.act();
y += DISPARO_SPEED;
if (y > Inicio.PLAY_HEIGHT)
remove();
}
} | [
"heoa100@gmail.com"
] | heoa100@gmail.com |
19da18d0786f950f8e06f0a3e2724221cca02321 | 02ae2fbaa266c2ef591786b624be780e5ac6ee92 | /tikv-client/src/main/java/com/pingcap/tikv/parser/AstBuilder.java | 011aaa417a1b32e25e27898891841a2e70862e74 | [
"Apache-2.0",
"GPL-1.0-or-later"
] | permissive | pingcap/tispark | 95952888b421be98e55ea81e11040189204966fb | 0446309396d540d191d2574ca86c3b31f0c93883 | refs/heads/master | 2023-08-29T14:14:52.449423 | 2023-08-01T07:28:07 | 2023-08-01T07:28:07 | 90,061,538 | 904 | 278 | Apache-2.0 | 2023-08-30T06:59:47 | 2017-05-02T17:48:30 | Scala | UTF-8 | Java | false | false | 9,178 | java | /*
* Copyright 2020 PingCAP, Inc.
*
* 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.pingcap.tikv.parser;
import static com.pingcap.tikv.types.IntegerType.BOOLEAN;
import com.pingcap.tikv.expression.ArithmeticBinaryExpression;
import com.pingcap.tikv.expression.ColumnRef;
import com.pingcap.tikv.expression.ComparisonBinaryExpression;
import com.pingcap.tikv.expression.Constant;
import com.pingcap.tikv.expression.Expression;
import com.pingcap.tikv.expression.FuncCallExpr;
import com.pingcap.tikv.expression.FuncCallExpr.Type;
import com.pingcap.tikv.expression.LogicalBinaryExpression;
import com.pingcap.tikv.meta.TiTableInfo;
import com.pingcap.tikv.parser.MySqlParser.ExpressionContext;
import com.pingcap.tikv.parser.MySqlParser.FunctionNameBaseContext;
import com.pingcap.tikv.types.IntegerType;
import com.pingcap.tikv.types.RealType;
import com.pingcap.tikv.types.StringType;
import java.nio.charset.StandardCharsets;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.tikv.common.exception.UnsupportedSyntaxException;
import org.tikv.shade.com.google.common.primitives.Doubles;
// AstBuilder will convert ParseTree into Ast Node.
// In tikv java client, we only need to parser expression
// which is used by partition pruning.
public class AstBuilder extends MySqlParserBaseVisitor<Expression> {
protected TiTableInfo tableInfo;
public AstBuilder() {}
public AstBuilder(TiTableInfo tableInfo) {
this.tableInfo = tableInfo;
}
public Expression visitSimpleId(MySqlParser.SimpleIdContext ctx) {
if (ctx.ID() != null) {
return createColRef(ctx.ID().getSymbol().getText());
}
if (ctx.functionNameBase() != null) {
return createColRef(ctx.functionNameBase().getText());
}
throw new UnsupportedSyntaxException(ctx.getParent().toString() + ": it is not supported");
}
protected Expression createColRef(String id) {
if (tableInfo != null) {
return ColumnRef.create(id, tableInfo);
} else {
return ColumnRef.create(id);
}
}
@Override
public Expression visitUid(MySqlParser.UidContext ctx) {
if (ctx.REVERSE_QUOTE_ID() != null) {
return createColRef(ctx.REVERSE_QUOTE_ID().getSymbol().getText());
}
return visitSimpleId(ctx.simpleId());
}
@Override
public Expression visitScalarFunctionCall(MySqlParser.ScalarFunctionCallContext ctx) {
FunctionNameBaseContext fnNameCtx = ctx.scalarFunctionName().functionNameBase();
if (fnNameCtx != null) {
if (fnNameCtx.YEAR() != null) {
Expression args = visitFunctionArgs(ctx.functionArgs());
return new FuncCallExpr(args, Type.YEAR);
}
if (fnNameCtx.TO_DAYS() != null) {
Expression args = visitFunctionArgs(ctx.functionArgs());
return new FuncCallExpr(args, Type.TO_DAYS);
}
}
return visitChildren(ctx);
}
@Override
public Expression visitFullColumnName(MySqlParser.FullColumnNameContext ctx) {
return visitUid(ctx.uid());
}
protected Expression parseIntOrLongOrDec(String val) {
try {
return Constant.create(Integer.parseInt(val), IntegerType.INT);
} catch (Exception e) {
try {
return Constant.create(Long.parseLong(val), IntegerType.BIGINT);
} catch (Exception e2) {
return Constant.create(Double.parseDouble(val), RealType.DOUBLE);
}
}
}
@Override
public Expression visitDecimalLiteral(MySqlParser.DecimalLiteralContext ctx) {
if (ctx.ONE_DECIMAL() != null) {
String val = ctx.ONE_DECIMAL().getSymbol().getText();
return parseIntOrLongOrDec(val);
}
if (ctx.TWO_DECIMAL() != null) {
String val = ctx.TWO_DECIMAL().getSymbol().getText();
return parseIntOrLongOrDec(val);
}
if (ctx.DECIMAL_LITERAL() != null) {
String val = ctx.DECIMAL_LITERAL().getSymbol().getText();
return parseIntOrLongOrDec(val);
}
if (ctx.ZERO_DECIMAL() != null) {
String val = ctx.ZERO_DECIMAL().getSymbol().getText();
return parseIntOrLongOrDec(val);
}
throw new UnsupportedSyntaxException(ctx.toString() + ": it is not supported.");
}
@Override
public Expression visitBooleanLiteral(MySqlParser.BooleanLiteralContext ctx) {
if (ctx.FALSE() != null) {
return Constant.create(0);
}
return Constant.create(1, BOOLEAN);
}
@Override
public Expression visitStringLiteral(MySqlParser.StringLiteralContext ctx) {
if (ctx.STRING_LITERAL() != null) {
StringBuilder sb = new StringBuilder();
for (TerminalNode str : ctx.STRING_LITERAL()) {
sb.append(str.getSymbol().getText());
}
return Constant.create(sb.toString().replace("\"", ""));
}
throw new UnsupportedSyntaxException(ctx.toString() + " is not supported yet");
}
@Override
public Expression visitHexadecimalLiteral(MySqlParser.HexadecimalLiteralContext ctx) {
if (ctx.HEXADECIMAL_LITERAL() != null) {
String text = ctx.HEXADECIMAL_LITERAL().getSymbol().getText();
text = text.substring(2, text.length() - 1);
try {
// use String to compare with hexadecimal literal.
return Constant.create(
new String(Hex.decodeHex(text), StandardCharsets.UTF_8), StringType.VARCHAR);
} catch (DecoderException e) {
throw new RuntimeException(e);
}
} else {
throw new UnsupportedSyntaxException(ctx.toString() + " is not supported yet");
}
}
@Override
public Expression visitConstant(MySqlParser.ConstantContext ctx) {
if (ctx.nullLiteral != null) {
return Constant.create(null);
}
if (ctx.booleanLiteral() != null) {
return visitBooleanLiteral(ctx.booleanLiteral());
}
if (ctx.decimalLiteral() != null) {
return visitDecimalLiteral(ctx.decimalLiteral());
}
if (ctx.stringLiteral() != null) {
return visitStringLiteral(ctx.stringLiteral());
}
if (ctx.REAL_LITERAL() != null) {
return Constant.create(
Doubles.tryParse(ctx.REAL_LITERAL().getSymbol().getText()), RealType.REAL);
}
if (ctx.hexadecimalLiteral() != null) {
return visitHexadecimalLiteral(ctx.hexadecimalLiteral());
}
throw new UnsupportedSyntaxException(ctx.toString() + "not supported constant");
}
@Override
public Expression visitConstantExpressionAtom(MySqlParser.ConstantExpressionAtomContext ctx) {
return visitChildren(ctx);
}
@Override
public Expression visitBinaryComparisonPredicate(
MySqlParser.BinaryComparisonPredicateContext ctx) {
Expression left = visitChildren(ctx.left);
Expression right = visitChildren(ctx.right);
switch (ctx.comparisonOperator().getText()) {
case "<":
return ComparisonBinaryExpression.lessThan(left, right);
case "<=":
return ComparisonBinaryExpression.lessEqual(left, right);
case "=":
return ComparisonBinaryExpression.equal(left, right);
case ">":
return ComparisonBinaryExpression.greaterThan(left, right);
case ">=":
return ComparisonBinaryExpression.greaterEqual(left, right);
}
throw new UnsupportedSyntaxException(
ctx.toString() + ": it is not possible reach to this line of code");
}
public Expression visitLogicalExpression(MySqlParser.LogicalExpressionContext ctx) {
ExpressionContext left = ctx.expression(0);
ExpressionContext right = ctx.expression(1);
switch (ctx.logicalOperator().getText()) {
case "and":
return LogicalBinaryExpression.and(visitChildren(left), visitChildren(right));
case "or":
return LogicalBinaryExpression.or(visitChildren(left), visitChildren(right));
case "xor":
return LogicalBinaryExpression.xor(visitChildren(left), visitChildren(right));
}
throw new UnsupportedSyntaxException(
ctx.toString() + ": it is not possible reach to this line of code");
}
@Override
public Expression visitMathExpressionAtom(MySqlParser.MathExpressionAtomContext ctx) {
Expression left = visitChildren(ctx.left);
Expression right = visitChildren(ctx.right);
switch (ctx.mathOperator().getText()) {
case "+":
return ArithmeticBinaryExpression.plus(left, right);
case "-":
return ArithmeticBinaryExpression.minus(left, right);
case "*":
return ArithmeticBinaryExpression.multiply(left, right);
case "/":
case "div":
return ArithmeticBinaryExpression.divide(left, right);
}
throw new UnsupportedSyntaxException(ctx.toString() + ": it is not supported right now");
}
}
| [
"noreply@github.com"
] | noreply@github.com |
cf2c1e99f23ac2b6e58d4f52ddd6e793b29deffe | efd387c8ca49aebc41e3b37b14604abdcd1c9a4f | /src/ReentrantLockExample.java | 2507213d44b1664ca30ef522011d89cf68891063 | [] | no_license | Xzzz918/Java-MultiThreading | fff4a95ee38248bcaaa60bea498efcb15955effe | e1088cdeae4285f932247ed87a7e93d564c71da3 | refs/heads/master | 2023-04-17T09:19:05.424009 | 2021-04-29T09:09:57 | 2021-04-29T09:09:57 | 356,502,236 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 666 | java | import java.util.concurrent.locks.ReentrantLock;
/**
* @author gemini
* Created in 2021/4/12 19:56
* Java并发编程的艺术Page 50
* 锁内存语义的实现
*/
public class ReentrantLockExample {
int a = 0;
ReentrantLock lock = new ReentrantLock();
public void writer(){
lock.lock(); //获取锁
try {
a++;
}finally {
lock.unlock(); //释放锁
}
}
public void reader(){
lock.lock(); //获取锁
try{
int i = a;
}finally {
lock.unlock(); //释放锁
}
}
public static void main(String[] args) {
}
}
| [
"884146241@qq.com"
] | 884146241@qq.com |
e4378297a9d0117922b16f560829c87be72b76c5 | 1120fa73f99d865ef8815e3a1c961da196f06e60 | /LarwarApp-Android-master2/Login/app/src/main/java/login/studio/com/br/login/SegundaActivity.java | 70315a31ee0d21fe21d2961f4b1a80badc503e0d | [] | no_license | Larwargrjr1/app-celular1 | 5e97971ea663bbee405fd027cb1fc4d2a6730983 | 29c6072c3149775f363138cdbefe4f179bbc6cfb | refs/heads/master | 2023-04-25T23:32:30.798210 | 2021-06-11T19:28:38 | 2021-06-11T19:28:38 | 376,118,578 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 344 | java | package login.studio.com.br.login;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class SegundaActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_segunda);
}
}
| [
"larwargrjr5@gmail.com"
] | larwargrjr5@gmail.com |
a55d1a601e3e2f95c0baa713ae297b2aeb8fafa6 | b58c4e1a2bdd64135f44b64f2b69036b5e7fb10f | /src/test/java/com/paytm/PAYTM/PaytmApplicationTests.java | 965f6a9a2e786cf0f621294d0eebd0f816252086 | [] | no_license | mittulmandhan/PAYTM | b9209b904aa23c6e33f560cea4174fa2f600aae5 | 958f5a3c8042d3e66edd1737e063e19e32627d73 | refs/heads/master | 2020-05-02T15:22:00.343416 | 2019-03-27T18:12:46 | 2019-03-27T18:12:46 | 178,038,987 | 0 | 0 | null | 2019-03-27T17:56:45 | 2019-03-27T17:00:53 | Java | UTF-8 | Java | false | false | 331 | java | package com.paytm.PAYTM;
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 PaytmApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"conanmittul@gmail.com"
] | conanmittul@gmail.com |
ffff6d9cea6e1c684cc459847ea75166dbaeb518 | 79afb8a9fa7d11a69c16d2cbaf9235b7c5210159 | /epidemic/app/src/main/java/com/songyuan/epidemic/base/mvvm/databanding/command/BindingCommand.java | fb438ef181a0319082a442f7ceac8d928f3bc41c | [] | no_license | NiLuogege/epidemic | 2555b8c57ca22527ddbc0275fe8703ef7a162814 | d221a1666a3c2e09c7c801e17d3598fd40ee9951 | refs/heads/master | 2021-01-02T00:45:32.857298 | 2020-02-17T03:03:50 | 2020-02-17T03:03:50 | 239,417,819 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,185 | java | package com.songyuan.epidemic.base.mvvm.databanding.command;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
/**
* About : kelin的ReplyCommand
* 执行的命令回调, 用于ViewModel与xml之间的数据绑定
*/
public class BindingCommand<T> {
private Action execute0;
private Consumer<T> execute1;
public BindingCommand(Action execute) {
this.execute0 = execute;
}
/**
* @param execute 带泛型参数的命令绑定
*/
public BindingCommand(Consumer<T> execute) {
this.execute1 = execute;
}
/**
* 执行Action命令
*/
public void execute() {
if (execute0 != null) {
try {
execute0.run();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 执行带泛型参数的命令
*
* @param parameter 泛型参数
*/
public void execute(T parameter) {
if (execute1 != null) {
try {
execute1.accept(parameter);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
| [
"hank.luo@xianghuanji.com"
] | hank.luo@xianghuanji.com |
08b637e5c67118021765eb885570b136d5dad47c | 0c1c0f6393b102c592c7ce124e0f9b378da5e02a | /04-springboot尚硅谷/spring-boot-logging/src/main/java/com/example/springbootlogging/SpringBootLoggingApplication.java | 0a0f5bfbef32baab0fa5d06c8ee6c42d4472e404 | [] | no_license | JackyZhuYK/maven-test | e551585c93336be821e68476f8c9366fc101ac2e | cab325e5a4bc712f9b7ebe3ce0b123ef20fff7dd | refs/heads/master | 2023-01-02T06:45:04.070920 | 2020-10-25T07:31:49 | 2020-10-25T07:31:49 | 296,860,965 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 357 | java | package com.example.springbootlogging;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootLoggingApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootLoggingApplication.class, args);
}
}
| [
"834386401@qq.com"
] | 834386401@qq.com |
766f28f9f32434cdc91931a13190d980ee504d9f | c2aa6319b44efbfe3ce3acaa08a7b09bb18daac8 | /checker-framework/checkers/src/checkers/units/UnitsAnnotatedTypeFactory.java | 160e5aa1f4544403f59f766b4764b3af9f6ea6cf | [] | no_license | checklt/checklt | 132d34258157731b178f1e9fd5bf9ca7819f6ea4 | 14f8d05868cdaa3cd9da8691fb68c01fa3a94811 | refs/heads/master | 2016-09-06T11:53:38.395733 | 2015-10-02T15:42:49 | 2015-10-02T15:42:49 | 10,589,368 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,769 | java | package checkers.units;
import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import checkers.basetype.BaseTypeChecker;
import checkers.quals.Bottom;
import checkers.types.AnnotatedTypeMirror;
import checkers.types.BasicAnnotatedTypeFactory;
import checkers.types.TreeAnnotator;
import checkers.units.quals.MixedUnits;
import checkers.units.quals.Prefix;
import checkers.units.quals.UnitsMultiple;
import checkers.util.AnnotationBuilder;
import checkers.util.AnnotationUtils;
import com.sun.source.tree.BinaryTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.CompoundAssignmentTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.Tree;
/**
* Annotated type factory for the Units Checker.
*
* Handles multiple names for the same unit, with different prefixes,
* e.g. @kg is the same as @g(Prefix.kilo).
*
* Supports relations between units, e.g. if "m" is a variable of type "@m" and
* "s" is a variable of type "@s", the division "m/s" is automatically annotated
* as "mPERs", the correct unit for the result.
*/
public class UnitsAnnotatedTypeFactory extends
BasicAnnotatedTypeFactory<UnitsChecker> {
protected final AnnotationMirror mixedUnits;
public UnitsAnnotatedTypeFactory(UnitsChecker checker,
CompilationUnitTree root) {
// use true for flow inference
super(checker, root, false);
mixedUnits = AnnotationUtils.fromClass(elements, MixedUnits.class);
AnnotationMirror BOTTOM = AnnotationUtils.fromClass(elements, Bottom.class);
this.treeAnnotator.addTreeKind(Tree.Kind.NULL_LITERAL, BOTTOM);
this.typeAnnotator.addTypeName(java.lang.Void.class, BOTTOM);
this.postInit();
}
private final Map<String, AnnotationMirror> aliasMap = new HashMap<String, AnnotationMirror>();
@Override
public AnnotationMirror aliasedAnnotation(AnnotationMirror a) {
String aname = a.getAnnotationType().toString();
if (aliasMap.containsKey(aname)) {
return aliasMap.get(aname);
}
for (AnnotationMirror aa : a.getAnnotationType().asElement().getAnnotationMirrors() ) {
// TODO: Is using toString the best way to go?
if (aa.getAnnotationType().toString().equals(UnitsMultiple.class.getCanonicalName())) {
@SuppressWarnings("unchecked")
Class<? extends Annotation> theclass = (Class<? extends Annotation>)
AnnotationUtils.getElementValueClass(aa, "quantity", true);
Prefix prefix = AnnotationUtils.getElementValueEnum(aa, "prefix", Prefix.class, true);
AnnotationBuilder builder = new AnnotationBuilder(processingEnv, theclass);
builder.setValue("value", prefix);
AnnotationMirror res = builder.build();
aliasMap.put(aname, res);
return res;
}
}
return super.aliasedAnnotation(a);
}
@Override
protected TreeAnnotator createTreeAnnotator(UnitsChecker checker) {
return new UnitsTreeAnnotator(checker);
}
/**
* A class for adding annotations based on tree
*/
private class UnitsTreeAnnotator extends TreeAnnotator {
UnitsTreeAnnotator(BaseTypeChecker checker) {
super(checker, UnitsAnnotatedTypeFactory.this);
}
@Override
public Void visitBinary(BinaryTree node, AnnotatedTypeMirror type) {
AnnotatedTypeMirror lht = getAnnotatedType(node.getLeftOperand());
AnnotatedTypeMirror rht = getAnnotatedType(node.getRightOperand());
Tree.Kind kind = node.getKind();
AnnotationMirror bestres = null;
for (UnitsRelations ur : checker.unitsRel.values()) {
AnnotationMirror res = useUnitsRelation(kind, ur, lht, rht);
if (bestres != null && res != null && !bestres.equals(res)) {
// TODO: warning
System.out.println("UnitsRelation mismatch, taking neither! Previous: "
+ bestres + " and current: " + res);
return null; // super.visitBinary(node, type);
}
if (res!=null) {
bestres = res;
}
}
if (bestres!=null) {
type.addAnnotation(bestres);
} else {
// Handle the binary operations that do not produce a UnitsRelation.
switch(kind) {
case MINUS:
case PLUS:
if (lht.getAnnotations().equals(rht.getAnnotations())) {
// The sum or difference has the same units as both
// operands.
type.addAnnotations(lht.getAnnotations());
break;
} else {
type.addAnnotation(mixedUnits);
break;
}
case DIVIDE:
if (lht.getAnnotations().equals(rht.getAnnotations())) {
// If the units of the division match,
// do not add an annotation to the result type, keep it
// unqualified.
break;
}
case MULTIPLY:
if (noUnits(lht)) {
type.addAnnotations(rht.getAnnotations());
break;
}
if (noUnits(rht)) {
type.addAnnotations(lht.getAnnotations());
break;
}
type.addAnnotation(mixedUnits);
break;
// Placeholders for unhandled binary operations
case REMAINDER:
// The checker disallows the following:
// @Length int q = 10 * UnitTools.m;
// @Length int r = q % 3;
// This seems wrong because it allows this:
// @Length int r = q - (q / 3) * 3;
// TODO: We agreed to treat remainder like division.
break;
}
}
return null; // super.visitBinary(node, type);
}
private boolean noUnits(AnnotatedTypeMirror t) {
Set<AnnotationMirror> annos = t.getAnnotations();
return annos.isEmpty() ||
(annos.size()==1 && AnnotatedTypeMirror.isUnqualified(annos.iterator().next()));
}
@Override
public Void visitCompoundAssignment(CompoundAssignmentTree node, AnnotatedTypeMirror type) {
ExpressionTree var = node.getVariable();
AnnotatedTypeMirror varType = getAnnotatedType(var);
type.clearAnnotations();
type.addAnnotations(varType.getAnnotations());
return super.visitCompoundAssignment(node, type);
}
private AnnotationMirror useUnitsRelation(Tree.Kind kind, UnitsRelations ur,
AnnotatedTypeMirror lht, AnnotatedTypeMirror rht) {
AnnotationMirror res = null;
if (ur!=null) {
switch(kind) {
case DIVIDE:
res = ur.division(lht, rht);
break;
case MULTIPLY:
res = ur.multiplication(lht, rht);
break;
}
}
return res;
}
}
}
| [
"jsinglet@gmail.com"
] | jsinglet@gmail.com |
d4019ba568f850d805dd61660e9e87cbbb4defa6 | 11f065c8882721e1877561e663fd271509f3ece9 | /Chapter_17/src/StringComparison/SortString.java | 555798951ab526ecbb77f6d07bfa37647d90cf6b | [] | no_license | Anjali-225/Java-Adv-Herb-Book | 445260dbab6254de66c8a4ff1c2f1ea35164888a | 7286782f8e97594efc7e36e1c55d640ede7d14eb | refs/heads/master | 2023-02-22T23:54:35.268985 | 2021-01-22T09:16:05 | 2021-01-22T09:16:05 | 314,249,384 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 650 | java | package StringComparison;
// A bubble sort for Strings.
public class SortString {
static String arr[] = {
"Now", "is", "the", "time", "for", "all", "good", "men",
"to", "come", "to", "the", "aid", "of", "their", "country"
};
public static void main(String args[]) {
for(int j = 0; j < arr.length; j++) {
for(int i = j + 1; i < arr.length; i++) {
if(arr[i].compareTo(arr[j]) < 0) {
String t = arr[j];
arr[j] = arr[i];
arr[i] = t;
}
}
System.out.println(arr[j]);
}
}
} | [
"anjali.payal69@gmail.com"
] | anjali.payal69@gmail.com |
2e8c0f0df316329273c64065ef28b45dfebffd2b | 250bf9a6895b5d54ad40e1d8883a6da7be143395 | /springcloud-project-dept-80/src/main/java/com/gao/dept/configBeans/ConfigBean.java | 849699ac6dcea5e2ef816fac6f5533dc1123b35c | [] | no_license | jinyulinlang/springcloud-project-04 | 189b3cabb57612099c6582c2f1989eca2bb8dd8d | e83f5bfc95cb473cf4ad29bf5e2cf6788fbb8078 | refs/heads/master | 2020-04-25T17:16:39.895348 | 2019-03-09T12:26:27 | 2019-03-09T12:26:27 | 172,941,593 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 340 | java | package com.gao.dept.configBeans;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
public class ConfigBean {
@Bean
public RestTemplate getRestTemplate() {
return new RestTemplate ();
}
}
| [
"jinyulinlang@126.com"
] | jinyulinlang@126.com |
54e2615035207d146242dc521d049df95872e0c1 | dc6089ebd0fa440f037a3373e6a3ebfadafcfc6b | /BackEnd/src/main/java/test/UserApplicationRepository.java | 0f342d03edd886a86abf61ddcc4fcc02d72ffc54 | [] | no_license | Shubhamizm/E-Voter | 4a0838326b48e57b47ebb32d2a1e0e5a1b643e6f | 1ae02a12c8b106adb9e0c787fb7824f33aa975d5 | refs/heads/master | 2023-01-09T08:19:18.892139 | 2020-01-26T19:03:47 | 2020-01-26T19:03:47 | 236,345,453 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 477 | java | package test;
import javax.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Transactional
@Repository
public interface UserApplicationRepository extends JpaRepository<UserApplication, Integer> {
@Query(value = "select * from user_application where userid=?1",nativeQuery = true)
UserApplication findbyuserid(int userid);
}
| [
"shubham.gupta513@gmail.com"
] | shubham.gupta513@gmail.com |
8503696c844a00c80364e911ee50b4deb1b274c2 | ff65b6d94fc9d45b8599aa61fbe35cff243c14c1 | /src/test/java/ch/rasc/extclassgenerator/ModelGeneratorBeanWithAnnotationsAndValidationTest.java | e06ef51e11083deb828bda8357cf09f7d7da40f4 | [
"Apache-2.0"
] | permissive | akingde/extclassgenerator | 3a1896f4f7cb12bfc50c24fe4be7fc4bb819a909 | 3e99bd985ec58b8c3a5f80c486dd36742602f2b9 | refs/heads/master | 2020-05-27T06:21:06.133060 | 2019-05-16T07:44:26 | 2019-05-16T07:44:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,924 | java | /**
* Copyright 2013-2018 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 ch.rasc.extclassgenerator;
import static org.assertj.core.api.Assertions.assertThat;
import java.math.BigDecimal;
import org.junit.Before;
import org.junit.Test;
import ch.rasc.extclassgenerator.bean.BeanWithAnnotations;
import ch.rasc.extclassgenerator.validation.EmailValidation;
import ch.rasc.extclassgenerator.validation.FormatValidation;
import ch.rasc.extclassgenerator.validation.LengthValidation;
import ch.rasc.extclassgenerator.validation.PresenceValidation;
import ch.rasc.extclassgenerator.validation.RangeValidation;
public class ModelGeneratorBeanWithAnnotationsAndValidationTest {
@Before
public void clearCaches() {
ModelGenerator.clearCaches();
}
@Test
public void testWithQuotes() {
GeneratorTestUtil.testGenerateJavascript(BeanWithAnnotations.class,
"BeanWithAnnotationsValidation", true, IncludeValidation.BUILTIN, false);
}
@Test
public void testWithoutQuotes() {
GeneratorTestUtil.testWriteModelBuiltinValidation(BeanWithAnnotations.class,
"BeanWithAnnotationsValidation");
GeneratorTestUtil.testGenerateJavascript(BeanWithAnnotations.class,
"BeanWithAnnotationsValidation", false, IncludeValidation.BUILTIN, false);
}
@Test
public void testCreateModel() {
OutputConfig oc = new OutputConfig();
oc.setIncludeValidation(IncludeValidation.BUILTIN);
oc.setOutputFormat(OutputFormat.EXTJS5);
ModelBean modelBean = ModelGenerator.createModel(BeanWithAnnotations.class, oc);
assertThat(modelBean.getReadMethod()).isEqualTo("read");
assertThat(modelBean.getCreateMethod()).isEqualTo("create");
assertThat(modelBean.getUpdateMethod()).isEqualTo("update");
assertThat(modelBean.getDestroyMethod()).isEqualTo("destroy");
assertThat(modelBean.getIdProperty()).isEqualTo("aInt");
assertThat(modelBean.getVersionProperty()).isNull();
assertThat(modelBean.isPaging()).isTrue();
assertThat(modelBean.getName()).isEqualTo("Sch.Bean");
assertThat(modelBean.getFields()).hasSize(29);
assertThat(BeanWithAnnotations.expectedFields).hasSize(29);
for (ModelFieldBean expectedField : BeanWithAnnotations.expectedFields) {
ModelFieldBean field = modelBean.getFields().get(expectedField.getName());
assertThat(field).isEqualToComparingFieldByField(expectedField);
}
assertThat(modelBean.getValidations()).hasSize(6);
assertThat(modelBean.getValidations().get(0))
.isInstanceOf(PresenceValidation.class);
assertThat(modelBean.getValidations().get(0).getType()).isEqualTo("presence");
assertThat(modelBean.getValidations().get(0).getField()).isEqualTo("aBigInteger");
assertThat(modelBean.getValidations().get(1)).isInstanceOf(RangeValidation.class);
assertThat(modelBean.getValidations().get(1).getType()).isEqualTo("range");
assertThat(modelBean.getValidations().get(1).getField()).isEqualTo("aBigInteger");
RangeValidation rv = (RangeValidation) modelBean.getValidations().get(1);
assertThat(rv.getMin()).isNull();
assertThat(rv.getMax()).isEqualTo(new BigDecimal("500000"));
assertThat(modelBean.getValidations().get(2))
.isInstanceOf(PresenceValidation.class);
assertThat(modelBean.getValidations().get(2).getType()).isEqualTo("presence");
assertThat(modelBean.getValidations().get(2).getField()).isEqualTo("aDouble");
assertThat(modelBean.getValidations().get(3)).isInstanceOf(EmailValidation.class);
assertThat(modelBean.getValidations().get(3).getType()).isEqualTo("email");
assertThat(modelBean.getValidations().get(3).getField()).isEqualTo("aString");
assertThat(modelBean.getValidations().get(4))
.isInstanceOf(LengthValidation.class);
LengthValidation lengthValidation = (LengthValidation) modelBean.getValidations()
.get(4);
assertThat(lengthValidation.getType()).isEqualTo("length");
assertThat(lengthValidation.getField()).isEqualTo("aString");
assertThat(lengthValidation.getMax()).isEqualTo(255L);
assertThat(modelBean.getValidations().get(5))
.isInstanceOf(FormatValidation.class);
FormatValidation formatValidation = (FormatValidation) modelBean.getValidations()
.get(5);
assertThat(formatValidation.getType()).isEqualTo("format");
assertThat(formatValidation.getField()).isEqualTo("aString");
assertThat(formatValidation.getMatcher())
.isEqualTo("/\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\]/");
}
}
| [
"ralphschaer@gmail.com"
] | ralphschaer@gmail.com |
64f76482506ecf2997b603b7c8df2e131993511d | df28e762c598d468bd93bb8065f9e881dd41a88d | /src/main/java/com/shdatabank/puruan/model/MyDeal.java | 4818b328b109cebeefa135dcace5d2afeec28c90 | [] | no_license | sunniers/puran | 5bad05aeaf2a492648525ae0c87058cb060c9a82 | fd0b01526a6564cd4a2473c774f7c67e4751cce4 | refs/heads/master | 2020-05-27T10:35:00.320322 | 2017-02-20T14:15:03 | 2017-02-20T14:15:03 | 82,542,619 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,717 | java | package com.shdatabank.puruan.model;
import java.sql.Timestamp;
public class MyDeal {
/** 资源id */
private Long id;
/** 类型 */
private Integer sign;
/** 资源名称 */
private String name;
/** 资源描述 */
private String description;
/** 成交时间 */
private String startTime;
/** 成交时间 */
private Timestamp time;
/** 成交时间 */
private String endTime;
/** 成交时间映射 */
private String timeMaping;
/** 成交数量 */
private Float number;
/** 成交状态 */
private String transactionStatus;
/** 用户ID */
private Long userId;
/** 创意需求实体类 */
private ProjectRequirement projectRequirement;
/** 创意人才需求实体类 */
private TalentRequirement talentRequirement;
/** 创意资源实体类 */
private CreativeResourceFront creativeResourceFront;
/** 人才交易实体类 */
private TalentTransaction talentTransaction;
/** 项目承接实体类 */
private ProjectRequirementUndertake projectRequirementUndertake;
/** 资源交易实体类 */
private CeativeResourceTransaction ceativeResourceTransaction;
/** 创意人才实体类 */
private UserCreativeTalent userCreativeTalent;
/** 页码 */
private int page;
/** 每页显示数量 */
private int pageSize;
public UserCreativeTalent getUserCreativeTalent() {
return userCreativeTalent;
}
public void setUserCreativeTalent(UserCreativeTalent userCreativeTalent) {
this.userCreativeTalent = userCreativeTalent;
}
public Timestamp getTime() {
return time;
}
public void setTime(Timestamp time) {
this.time = time;
}
public ProjectRequirement getProjectRequirement() {
return projectRequirement;
}
public void setProjectRequirement(ProjectRequirement projectRequirement) {
this.projectRequirement = projectRequirement;
}
public TalentRequirement getTalentRequirement() {
return talentRequirement;
}
public void setTalentRequirement(TalentRequirement talentRequirement) {
this.talentRequirement = talentRequirement;
}
public CreativeResourceFront getCreativeResourceFront() {
return creativeResourceFront;
}
public void setCreativeResourceFront(CreativeResourceFront creativeResourceFront) {
this.creativeResourceFront = creativeResourceFront;
}
public TalentTransaction getTalentTransaction() {
return talentTransaction;
}
public void setTalentTransaction(TalentTransaction talentTransaction) {
this.talentTransaction = talentTransaction;
}
public ProjectRequirementUndertake getProjectRequirementUndertake() {
return projectRequirementUndertake;
}
public void setProjectRequirementUndertake(ProjectRequirementUndertake projectRequirementUndertake) {
this.projectRequirementUndertake = projectRequirementUndertake;
}
public CeativeResourceTransaction getCeativeResourceTransaction() {
return ceativeResourceTransaction;
}
public void setCeativeResourceTransaction(CeativeResourceTransaction ceativeResourceTransaction) {
this.ceativeResourceTransaction = ceativeResourceTransaction;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getSign() {
return sign;
}
public void setSign(Integer sign) {
this.sign = sign;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getTimeMaping() {
return timeMaping;
}
public void setTimeMaping(String timeMaping) {
this.timeMaping = timeMaping;
}
public Float getNumber() {
return number;
}
public void setNumber(Float number) {
this.number = number;
}
public String getTransactionStatus() {
return transactionStatus;
}
public void setTransactionStatus(String transactionStatus) {
this.transactionStatus = transactionStatus;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
}
| [
"zhoujunlei012@163.com"
] | zhoujunlei012@163.com |
22c04cc19d02debe8a88fb82663bbff0b0029b0a | 2565ff0e94375306bbb5b94d204b954343e7eb96 | /src/main/java/transfer/rest/LoggingRouteDefinition.java | b82e82c1b6b3752c2f2b8f29e6eb61f13f795459 | [] | no_license | VictorMarcinschi/money-transfer | a453006a131e48b7c72b73962259a252b4bed906 | f77c6cd04f082687fa1d91e42a17536843374a9f | refs/heads/master | 2022-11-19T15:24:32.682007 | 2020-02-12T18:29:34 | 2020-02-12T18:29:34 | 238,254,282 | 0 | 0 | null | 2022-11-16T00:43:49 | 2020-02-04T16:40:53 | Java | UTF-8 | Java | false | false | 633 | java | package transfer.rest;
import lombok.extern.slf4j.Slf4j;
import transfer.server.SparkRouteDefinition;
import static spark.Spark.after;
import static spark.Spark.before;
@Slf4j
class LoggingRouteDefinition implements SparkRouteDefinition {
@Override
public void define() {
before((req, res) -> {
log.info("Received request {} {} with params {}\n{}", req.requestMethod(), req.pathInfo(),
req.params(), req.body());
});
after((req, res) -> {
log.info("Sending response for {} {}\n{}", req.requestMethod(), req.pathInfo(), res.body());
});
}
}
| [
"victor.marcinschi@endava.com"
] | victor.marcinschi@endava.com |
91fb622d71afd7e45ec442d2e9a93ce6ea85ef09 | 7309365244d6001bb80893163433b936712f646a | /app/src/main/java/com/modesty/quickdevelop/anim/evaluator/CharEvaluator.java | 5854235f0b82c2cc203e975c47a03ad5b2c581df | [] | no_license | shengjinbing/QuickDevelop | 3df000381a9108f8e50c1741e7645b63a1a3fbef | a0ac9c8bc37abe01ec1fe7101ee2f9e26dfa7aeb | refs/heads/master | 2021-06-14T12:07:33.216347 | 2021-03-17T07:27:45 | 2021-03-17T07:27:45 | 160,311,790 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 447 | java | package com.modesty.quickdevelop.anim.evaluator;
import android.animation.TypeEvaluator;
public class CharEvaluator implements TypeEvaluator<Character> {
@Override
public Character evaluate(float fraction, Character startValue, Character endValue) {
int startInt = (int) startValue;
int endInt = (int) endValue;
int curInt = (int) (startInt + fraction * (endInt - startInt));
return (char)curInt;
}
}
| [
"675196450qq.com"
] | 675196450qq.com |
0f4de21bb640a5f61da0c5adf5ab0f520e062ff8 | 642d4fbdc189a13440c70339bc8b417ba7dd4908 | /relestimation/src/main/java/edu/aspen/capstone/estimation/relative/dao/DevelopmentGroupDAOImpl.java | 2ea6ac2c6793cbbc28baf5af291e4f91560bbf5c | [] | no_license | jaiishankar/estools | e2c8e7490890e15605a0fefeb141985aaddcc67b | e8526197a892a1cf6a20c0e82a769f2cbaef87ff | refs/heads/master | 2021-01-25T05:28:06.266836 | 2014-09-16T06:28:17 | 2014-09-16T06:28:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,349 | java | /*
*
*
*
*/
package edu.aspen.capstone.estimation.relative.dao;
import edu.aspen.capstone.estimation.relative.entity.DevelopmentGroup;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
/**
*
* @author jaiishankar
*/
@Repository("DevelopmentGroupDAO")
@Transactional
public class DevelopmentGroupDAOImpl implements DevelopmentGroupDAO {
@Autowired
private SessionFactory sessionFactory;
@Override
public DevelopmentGroup addGroup(DevelopmentGroup grp) {
try {
sessionFactory.getCurrentSession().saveOrUpdate(grp);
sessionFactory.getCurrentSession().flush();
sessionFactory.getCurrentSession().refresh(grp);
return grp;
} catch (HibernateException hbe) {
hbe.printStackTrace();
return null;
}
}
@Override
public List<DevelopmentGroup> listAll() {
try {
return (List<DevelopmentGroup>) sessionFactory.getCurrentSession().createQuery("from "
+ DevelopmentGroup.class.getName()).list();
} catch (HibernateException hbe) {
hbe.printStackTrace();
return null;
}
}
@Override
public DevelopmentGroup getGroup(Integer id) {
try {
return (DevelopmentGroup) sessionFactory.getCurrentSession().get(DevelopmentGroup.class, id);
} catch (HibernateException hbe) {
hbe.printStackTrace();
return null;
}
}
@Override
public DevelopmentGroup updateGroup(DevelopmentGroup grp) {
try {
return this.addGroup(grp);
} catch (HibernateException hbe) {
hbe.printStackTrace();
return null;
}
}
@Override
public Boolean deleteGroup(Integer id) {
try {
sessionFactory.getCurrentSession().delete(this.getGroup(id));
return true;
} catch (HibernateException hbe) {
hbe.printStackTrace();
return false;
}
}
}
//try{return null;} catch(HibernateException hbe){hbe.printStackTrace();return null;}
| [
"jaiishankar@gmail.com"
] | jaiishankar@gmail.com |
65a810f4b4c689f21df12e82774833a18e736008 | b4c49e86ca2b6eb82d10d5cb57539b5f50432ed7 | /perun-engine/src/main/java/cz/metacentrum/perun/engine/scheduling/impl/SchedulingPoolImpl.java | c782b49d61d3243985d308e9f7c53fe547e01669 | [
"BSD-2-Clause"
] | permissive | ondrocks/perun | 7bfe4c0d79b24a99dadb745bd9c11724e3a40c3a | 12a9111259dd3ecb763fa3b35e72a4af4fc149bc | refs/heads/master | 2021-01-18T13:06:08.392732 | 2015-09-11T11:44:12 | 2015-09-11T11:44:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,674 | java | package cz.metacentrum.perun.engine.scheduling.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PreDestroy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import cz.metacentrum.perun.core.api.Destination;
import cz.metacentrum.perun.core.api.Facility;
import cz.metacentrum.perun.core.api.exceptions.InternalErrorException;
import cz.metacentrum.perun.engine.model.Pair;
import cz.metacentrum.perun.engine.scheduling.SchedulingPool;
import cz.metacentrum.perun.engine.scheduling.TaskResultListener;
import cz.metacentrum.perun.taskslib.model.ExecService;
import cz.metacentrum.perun.taskslib.model.Task;
import cz.metacentrum.perun.taskslib.model.Task.TaskStatus;
import cz.metacentrum.perun.taskslib.model.TaskResult;
import cz.metacentrum.perun.taskslib.service.TaskManager;
@org.springframework.stereotype.Service(value = "schedulingPool")
// Spring 3.0 default...
@Scope(value = "singleton")
public class SchedulingPoolImpl implements SchedulingPool, TaskResultListener {
private final static Logger log = LoggerFactory.getLogger(SchedulingPoolImpl.class);
private Map<TaskStatus, List<Task>> pool = new EnumMap<TaskStatus, List<Task>>(TaskStatus.class);
private Map<Integer, Task> taskIdMap = new ConcurrentHashMap<Integer, Task>();
@Autowired
private TaskManager taskManager;
/*
* private BufferedWriter out = null; private FileWriter fstream = null;
*
* @Autowired private TaskExecutor taskExecutorSchedulingPoolSerializer;
* private boolean writerInitialized = false;
*/
public SchedulingPoolImpl() {
for (TaskStatus status : TaskStatus.class.getEnumConstants()) {
pool.put(status, new ArrayList<Task>());
}
}
@Override
public int addToPool(Task task) {
synchronized (pool) {
if (taskIdMap.containsKey(task.getId())) {
log.warn("Task already is in the pool " + task.toString());
return this.getSize();
}
taskIdMap.put(task.getId(), task);
TaskStatus status = task.getStatus();
if (status == null) {
task.setStatus(TaskStatus.NONE);
}
if (!pool.get(task.getStatus()).contains(task.getId())) {
pool.get(task.getStatus()).add(task);
}
}
// XXX should this be synchronized too?
task.setSchedule(new Date(System.currentTimeMillis()));
try {
taskManager.insertTask(task, 0);
log.debug("adding task " + task.toString() + " to database");
} catch (InternalErrorException e) {
log.error("Error storing task into database: " + e.getMessage());
}
return this.getSize();
}
@Override
public List<Task> getPlannedTasks() {
return new ArrayList<Task>(pool.get(TaskStatus.PLANNED));
}
@Override
public List<Task> getNewTasks() {
return new ArrayList<Task>(pool.get(TaskStatus.NONE));
}
@Override
public List<Task> getProcessingTasks() {
return new ArrayList<Task>(pool.get(TaskStatus.PROCESSING));
}
@Override
public List<Task> getErrorTasks() {
return new ArrayList<Task>(pool.get(TaskStatus.ERROR));
}
@Override
public List<Task> getDoneTasks() {
return new ArrayList<Task>(pool.get(TaskStatus.DONE));
}
@Override
public void setTaskStatus(Task task, TaskStatus status) {
TaskStatus old = task.getStatus();
task.setStatus(status);
// move task to the appropriate place
if (!old.equals(status)) {
pool.get(old).remove(task);
pool.get(status).add(task);
}
taskManager.updateTask(task, 0);
}
@Override
public int getSize() {
/*
* int size = 0; for(TaskStatus status :
* TaskStatus.class.getEnumConstants()) { size +=
* pool.get(status).size(); } return size;
*/
return taskIdMap.size();
}
@Override
public Task getTaskById(int id) {
return taskIdMap.get(id);
}
@Override
public void removeTask(Task task) {
synchronized (pool) {
for (TaskStatus status : TaskStatus.class.getEnumConstants()) {
// remove from everywhere, just to be sure
List<Task> tasklist = pool.get(status /* task.getStatus() */);
if (tasklist != null) {
tasklist.remove(task);
}
}
taskIdMap.remove(task.getId());
}
taskManager.removeTask(task.getId(), 0);
}
@Override
@Deprecated
public int addToPool(Pair<ExecService, Facility> pair) {
/*
* if (!writerInitialized) { initializeWriter(); writerInitialized =
* true; } pool.add(pair); serialize(pair);
*/
return this.getSize();
}
@Override
@Deprecated
public List<Pair<ExecService, Facility>> emptyPool() {
/*
* List<Pair<ExecService, Facility>> toBeReturned = new
* ArrayList<Pair<ExecService, Facility>>(pool);
* log.debug(toBeReturned.size() + " pairs to be returned");
* pool.clear(); close(); initializeWriter(); return toBeReturned;
*/
return null;
}
/*
* private void serialize(Pair<ExecService, Facility> pair) {
* taskExecutorSchedulingPoolSerializer.execute(new Serializator(pair)); }
*
* private void initializeWriter() { try { //Do not append, truncate the
* file instead. //You just have to make sure the former content have been
* loaded... fstream = new FileWriter("SchedulingPool.txt", false); } catch
* (IOException e) { log.error(e.toString(), e); } out = new
* BufferedWriter(fstream); }
*/
@PreDestroy
@Override
@Deprecated
public void close() {
/*
* log.debug("Closing file writer..."); try { if (out != null) {
* out.flush(); out.close(); } } catch (IOException e) {
* log.error(e.toString(), e); }
*/
}
@Override
public void reloadTasks(int engineID) {
this.clearPool();
for (Task task : taskManager.listAllTasks(engineID)) {
TaskStatus status = task.getStatus();
if (status == null) {
task.setStatus(TaskStatus.NONE);
}
if (!pool.get(task.getStatus()).contains(task.getId())) {
pool.get(task.getStatus()).add(task);
}
// XXX should this be synchronized too?
taskIdMap.put(task.getId(), task);
}
}
private void clearPool() {
pool = new EnumMap<TaskStatus, List<Task>>(TaskStatus.class);
taskIdMap = new ConcurrentHashMap<Integer, Task>();
for (TaskStatus status : TaskStatus.class.getEnumConstants()) {
pool.put(status, new ArrayList<Task>());
}
}
// implementation of TaskResultListener interface
// - meant for GEN tasks
// - does not take into account destinations, once the method is called, the
// task status is set accordingly
@Override
public void onTaskDestinationDone(Task task, Destination destination,
TaskResult result) {
this.setTaskStatus(task, TaskStatus.DONE);
}
@Override
public void onTaskDestinationError(Task task, Destination destination,
TaskResult result) {
this.setTaskStatus(task, TaskStatus.ERROR);
}
/*
* class Serializator implements Runnable { private Pair<ExecService,
* Facility> pair = null;
*
* public Serializator(Pair<ExecService, Facility> pair) { super();
* this.pair = pair; }
*
* public void run() { if (pair != null && pair.getLeft() != null &&
* pair.getRight() != null) { try { out.write(System.currentTimeMillis() +
* " " + pair.getLeft().getId() + " " + pair.getRight().getId() + "\n");
* out.flush(); } catch (IOException e) { log.error(e.toString(), e); } } }
* }
*/
/*
* public TaskExecutor getTaskExecutorSchedulingPoolSerializer() { return
* taskExecutorSchedulingPoolSerializer; }
*
* public void setTaskExecutorSchedulingPoolSerializer(TaskExecutor
* taskExecutorSchedulingPoolSerializer) {
* this.taskExecutorSchedulingPoolSerializer =
* taskExecutorSchedulingPoolSerializer; }
*/
}
| [
"michal.vocu@gmail.com"
] | michal.vocu@gmail.com |
4472899af9c3c50dc555b3b939d161e81fbbaea9 | f18a24763357bfa879e7e4d69f66a962ed06162c | /Conscientia/C3003.java | a854af561cc6188f2504ddeabd162d7fbd1d683b | [] | no_license | nikhilbhardwaj/Codechef | cf50380f4e1406d3d2485ff79d8ba2d9bcdccb58 | 4a71071502dfdb311318e39fd0d09554b4034498 | refs/heads/master | 2021-01-15T19:40:09.638800 | 2013-10-13T06:11:53 | 2013-10-13T06:11:53 | 2,930,781 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,304 | java | import java.io.*;
import java.util.*;
public class C3003
{
public static void main(String [] args)
throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
String input_string, waste_chars;
StringTokenizer strtok = new StringTokenizer(line);
input_string = strtok.nextToken();
waste_chars = strtok.nextToken();
TreeMap<Character,Integer> charCountMap = new TreeMap<Character,Integer>();
for(int i = 0; i < input_string.length(); ++i)
{
char current_char = input_string.charAt(i);
if(charCountMap.containsKey(current_char))
{
int newVal = (int)(charCountMap.get(current_char)) + 1;
charCountMap.put(current_char,newVal);
}
else
{
charCountMap.put(current_char,1);
}
}
for(int i = 0; i < waste_chars.length(); ++i)
{
char current_char = waste_chars.charAt(i);
if(charCountMap.containsKey(current_char))
{
charCountMap.remove(current_char);
}
}
Iterator entries = charCountMap.entrySet().iterator();
while(entries.hasNext())
{
Map.Entry t = (Map.Entry)entries.next();
System.out.print(t.getKey()+""+t.getValue());
}
System.out.println("");
}
}
| [
"root@nikhilbhardwaj.in"
] | root@nikhilbhardwaj.in |
7889d64a85bae5d2be29bacf138dc8c3af061b7f | 3da543657e7418122b14094eb7da8d8640eb14da | /github.com/Nirmalajothi/nirmala.git/Java/src/Getset/Main.java | 7fb4038b3c957017c6f4d669e089baac0b6b7c4c | [] | no_license | Nirmalajothi/java | a8b629f5a5f5e15ada3f8b6d96b2fc18e9f5d98c | 65345b65e5223876cbcbbcd9ddfca56a99bb92c0 | refs/heads/master | 2020-11-29T20:19:19.011457 | 2020-01-06T11:52:36 | 2020-01-06T11:52:36 | 230,207,998 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 338 | java | package Getset;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String teamname=sc.next();
String cityrep=sc.next();
Set Set=new Set(teamname,cityrep);
System.out.println(Set.getteamname());
System.out.println(Set.getcity());
}
}
| [
"krishnasamynirmala@gmail.com"
] | krishnasamynirmala@gmail.com |
3352d9ce1dab258bc6cab5ba3a72d83bf6b78207 | 4bbdb5970eed5c4974dd1d921272f303cc18b99e | /src/csc612m/integrating/project/MainFrame.java | 8cf86d87ace0fc6b695c404cedd34eb2f4885b72 | [
"Apache-2.0"
] | permissive | mjcortejo/CSC612M-Integrating-Project | 48328d9a8e5795fb3a5d6b4d8250cf5bd4b29f9f | 62217d756441a4019814f20b679a2318af061336 | refs/heads/master | 2023-05-13T06:49:59.552971 | 2021-06-04T07:07:32 | 2021-06-04T07:07:32 | 360,903,997 | 0 | 0 | Apache-2.0 | 2021-05-25T07:25:42 | 2021-04-23T14:04:15 | Java | UTF-8 | Java | false | false | 30,496 | 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 csc612m.integrating.project;
import java.awt.Color;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JTextPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
/**
*
* @author mark
*/
public class MainFrame extends javax.swing.JFrame {
/**
* Creates new form MainFrame
*/
Pipeline pipeline;
InstructionExtractor instruction_extractor;
Opcode opcode;
OutputPane outputpane;
DefaultTableModel memory_table;
DefaultTableModel program_table;
DefaultTableModel pipeline_map_table;
HashMap<String, Integer> register_alias_map;
HashMap<String, int[]> data_segment_map;
HashMap<Integer, int[]> address_location_map;
SimpleAttributeSet attributeSet;
Document textpane;
HashMap<String, String[]> instruction_parse_map;
public MainFrame() {
initComponents();
outputpane = new OutputPane(jTextOutput);
data_segment_map = new HashMap<String, int[]>();
address_location_map = new HashMap<Integer, int[]>();
instruction_parse_map = new HashMap<String, String[]>();
register_alias_map = new HashMap<String, Integer>() {{ //this is used when the instruction is invoking the alias name which will point to a row number (the integer value)
put("t0", 5);
put("t1", 6);
put("t2", 7);
put("s0", 8);
put("s1", 9);
put("a0", 10);
put("a1", 11);
put("a2", 12);
put("a3", 13);
put("a4", 14);
put("a5", 15);
put("a6", 16);
put("a7", 17);
put("s2", 18);
put("s3", 19);
put("s4", 20);
put("s5", 21);
put("s6", 22);
put("s7", 23);
put("s8", 24);
put("s9", 25);
put("s10", 26);
put("s11", 27);
put("t3", 28);
put("t4", 29);
put("t5", 30);
put("t6", 31);
}};
pipeline = new Pipeline(jTableRegister, jTableProgram, jTablePipelineMap, jTablePipelineRegister, jTableMemory, register_alias_map);
pipeline.outputpane = outputpane;
PopulateDataSegmentAddress();
// attributeSet = new SimpleAttributeSet();
//
// attributeSet = new SimpleAttributeSet();
// StyleConstants.setItalic(attributeSet, true);
// StyleConstants.setForeground(attributeSet, Color.BLACK);
// StyleConstants.setBackground(attributeSet, Color.white);
//
// textpane = jTextOutput.getDocument();
}
/***
* Populates the Data Segment addresses with default hex values
*/
public void PopulateDataSegmentAddress()
{
this.memory_table = (DefaultTableModel)jTableMemory.getModel();
for (int i = 0; i < 2048; i+=32)
{
Vector cell = new Vector(); //this stores the value of each 'cell' per address row
int[] decimal_to_binary = Convert.IntDecimalToBinary(i, 12); //12 bits == 2048 (according to specs)
String binary_to_hex = Convert.BinaryToHex(decimal_to_binary);
cell.add(binary_to_hex); //this is just the label
int address_row_location = 0;
if (i % 32 == 0) address_row_location = i / 32;
else address_row_location = (i + 1) / 32;
for (int j = 0; j < 28; j+=4) //add half bytes
{
binary_to_hex = Convert.BinaryToHex(Convert.IntDecimalToBinary(0, 12));
cell.add(binary_to_hex);
String memory_hex = Convert.BinaryToHex(Convert.IntDecimalToBinary(i+j, 12));
int address_col_location = 0;
if (j % 4 == 0) address_col_location = j / 4;
else address_col_location = (j+1) / 4;
System.out.println(i+j);
address_location_map.put(i+j, new int[]{ address_row_location, address_col_location + 1});
// data_segment_map.put(memory_hex, binary_to_hex);
}
this.memory_table.addRow(cell);
}
for (int i = 0; i < 2048; i+=32) // to test memory cells
{
int address_row_location = 0;
if (i % 32 == 0) address_row_location = i / 32;
else address_row_location = (i + 1) / 32;
for (int j = 0; j < 28; j+=4) //add half bytes
{
int address_col_location = 0;
if (j % 4 == 0) address_col_location = (j / 4) + 1;
else address_col_location = ((j+1) / 4) + 1;
this.memory_table.getValueAt(address_row_location, address_col_location);
}
}
pipeline.address_location_map = address_location_map;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jScrollPane2 = new javax.swing.JScrollPane();
jTableRegister = new javax.swing.JTable();
jTabbedPane2 = new javax.swing.JTabbedPane();
jScrollPane4 = new javax.swing.JScrollPane();
jEditorPane1 = new javax.swing.JEditorPane();
jTabbedPane3 = new javax.swing.JTabbedPane();
jScrollPane1 = new javax.swing.JScrollPane();
jTableProgram = new javax.swing.JTable();
jScrollPane3 = new javax.swing.JScrollPane();
jTableMemory = new javax.swing.JTable();
jTabbedPane4 = new javax.swing.JTabbedPane();
jScrollPane6 = new javax.swing.JScrollPane();
jTablePipelineMap = new javax.swing.JTable();
jScrollPane8 = new javax.swing.JScrollPane();
jTablePipelineRegister = new javax.swing.JTable();
jBtnRun = new javax.swing.JButton();
jBtnNextLine = new javax.swing.JButton();
jBtnPrevLine = new javax.swing.JButton();
jBtnAssemble = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jScrollPane5 = new javax.swing.JScrollPane();
jTextOutput = new javax.swing.JTextPane();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTableRegister.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{"x0", "zero", "00000000"},
{"x1", "ra", "00000000"},
{"x2", "sp", "00000000"},
{"x3", "gp", "00000000"},
{"x4", "tp", "00000000"},
{"x5", "t0", "00000000"},
{"x6", "t1", "00000000"},
{"x7", "t2", "00000000"},
{"x8", "s0", "00000000"},
{"x9", "s1", "00000000"},
{"x10", "a0", "00000000"},
{"x11", "a1", "00000000"},
{"x12", "a2", "00000000"},
{"x13", "a3", "00000000"},
{"x14", "a4", "00000000"},
{"x15", "a5", "00000000"},
{"x16", "a6", "00000000"},
{"x17", "a7", "00000000"},
{"x18", "s2", "00000000"},
{"x19", "s3", "00000000"},
{"x20", "s4", "00000000"},
{"x21", "s5", "00000000"},
{"x22", "s6", "00000000"},
{"x23", "s7", "00000000"},
{"x24", "s8", "00000000"},
{"x25", "s9", "00000000"},
{"x26", "s10", "00000000"},
{"x27", "s11", "00000000"},
{"x28", "t3", "00000000"},
{"x29", "t4", "00000000"},
{"x30", "t5", "00000000"},
{"x31", "t6", "00000000"},
{null, "pc", "0x00000000"}
},
new String [] {
"Name", "Alias", "Value"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false, true
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jTableRegister.setColumnSelectionAllowed(true);
jTableRegister.getTableHeader().setReorderingAllowed(false);
jScrollPane2.setViewportView(jTableRegister);
jTableRegister.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
if (jTableRegister.getColumnModel().getColumnCount() > 0) {
jTableRegister.getColumnModel().getColumn(0).setResizable(false);
jTableRegister.getColumnModel().getColumn(1).setResizable(false);
jTableRegister.getColumnModel().getColumn(2).setResizable(false);
}
jTabbedPane1.addTab("Registers", jScrollPane2);
jScrollPane4.setViewportView(jEditorPane1);
jTabbedPane2.addTab("Source Code", jScrollPane4);
jTableProgram.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Address", "Opcode", "Instruction", "Stage"
}
) {
boolean[] canEdit = new boolean [] {
false, false, false, false
};
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(jTableProgram);
if (jTableProgram.getColumnModel().getColumnCount() > 0) {
jTableProgram.getColumnModel().getColumn(0).setPreferredWidth(1);
}
jTabbedPane3.addTab("Program", jScrollPane1);
jTableMemory.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Address", "Value (+0)", "Value (+4)", "Value (+8)", "Value (+10)", "Value (+14)", "Value (+18)", "Value (+1c)"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false, false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jTableMemory.getTableHeader().setReorderingAllowed(false);
jScrollPane3.setViewportView(jTableMemory);
if (jTableMemory.getColumnModel().getColumnCount() > 0) {
jTableMemory.getColumnModel().getColumn(0).setResizable(false);
jTableMemory.getColumnModel().getColumn(1).setResizable(false);
jTableMemory.getColumnModel().getColumn(2).setResizable(false);
jTableMemory.getColumnModel().getColumn(3).setResizable(false);
jTableMemory.getColumnModel().getColumn(4).setResizable(false);
jTableMemory.getColumnModel().getColumn(5).setResizable(false);
jTableMemory.getColumnModel().getColumn(6).setResizable(false);
jTableMemory.getColumnModel().getColumn(7).setResizable(false);
}
jTabbedPane3.addTab("Memory", jScrollPane3);
jTabbedPane2.addTab("Execution", jTabbedPane3);
jTablePipelineMap.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Instruction", "Address"
}
));
jScrollPane6.setViewportView(jTablePipelineMap);
jTabbedPane4.addTab("Map", jScrollPane6);
jTablePipelineRegister.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{"IF/ID.IR", "00000000"},
{"IF/ID.NPC", "00001000"},
{"PC", "00001000"},
{"ID/EX.A", "00000000"},
{"ID/EX.B", "00000000"},
{"ID/EX.IMM", "00000000"},
{"ID/EX.IR", "00000000"},
{"ID/EX.NPC", "00000000"},
{"EX/MEM.ALUoutput", "00000000"},
{"EX/MEM.IR", "00000000"},
{"EX/MEM.B", "00000000"},
{"EX/MEM.COND", "00000000"},
{"MEM/WB.LMD", "00000000"},
{"MEM/WB.IR", "00000000"},
{"MEM/WB.ALUoutput", "00000000"},
{"MEM[EX/MEM.ALUoutput]", "00000000"}
},
new String [] {
"Name", "Value"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.Object.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
jScrollPane8.setViewportView(jTablePipelineRegister);
jTabbedPane4.addTab("Registers", jScrollPane8);
jTabbedPane2.addTab("Pipelining", jTabbedPane4);
jBtnRun.setText("Run");
jBtnRun.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jBtnRunActionPerformed(evt);
}
});
jBtnNextLine.setText("Next");
jBtnNextLine.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jBtnNextLineActionPerformed(evt);
}
});
jBtnPrevLine.setText("Prev");
jBtnPrevLine.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jBtnPrevLineActionPerformed(evt);
}
});
jBtnAssemble.setText("Assemble");
jBtnAssemble.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jBtnAssembleActionPerformed(evt);
}
});
jLabel1.setText("Output");
jScrollPane5.setViewportView(jTextOutput);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(17, 17, 17)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jBtnAssemble, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jBtnPrevLine)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jBtnRun)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jBtnNextLine))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 1135, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 1147, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 286, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 672, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jBtnAssemble)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jBtnRun)
.addComponent(jBtnNextLine)
.addComponent(jBtnPrevLine))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* This methods loads all the instruction lines in memory, and also checks for errors
* @param evt
*/
private void jBtnAssembleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnAssembleActionPerformed
// TODO add your handling code here:
try
{
lines = jEditorPane1.getText().split("\n");
this.memory_table = (DefaultTableModel)jTableMemory.getModel();
int current_parse_line = 0;
int sourcecode_section_state = 0;
if (sourcecode_section_state == 0)//initial state
{
for (int i = 0; i < lines.length; i++)
{
String current = lines[i];
if(current.contains(".data"))
{
sourcecode_section_state = 1;
current_parse_line = i;
break;
}
else if (current.contains(".text"))
{
sourcecode_section_state = 2;
current_parse_line = i;
}
}
}
int current_memory_row = 0;
int current_memory_col = 1;
String pattern = "(\\w+:) (.\\w+) (0x[a-z0-9]+|\\d+)";
Pattern variable_pattern = Pattern.compile(pattern);
if (sourcecode_section_state == 1) //currently in .data section
{
for (int i = current_parse_line; i < lines.length; i++)
{
String current = lines[i];
if(current.contains(".text"))
{
sourcecode_section_state = 2;
current_parse_line = i;
break;
}
Matcher m = variable_pattern.matcher(current);
if(m.find())
{
try
{
String var_name = m.group(1);
String data_type = m.group(2);
String value = m.group(3);
int value_int = ExtractImmediateValueToDecimal(value);
if (current_memory_col > 7)
{
current_memory_row++;
current_memory_col = 1;
}
data_segment_map.put(var_name.replace(":", ""), new int[]{current_memory_row, current_memory_col, value_int});
current_memory_col++;
}
catch(Exception ex)
{
outputpane.Print("Invalid line at "+(current_parse_line + 1) + " with instruction "+lines[i]);
}
}
current_parse_line = i;
}
for (Map.Entry<String, int[]> pair: data_segment_map.entrySet())
{
int row = pair.getValue()[0];
int column = pair.getValue()[1];
int value = pair.getValue()[2];
int[] data_value_binary = Convert.IntDecimalToBinary(value, 32);
String data_value_hex = Convert.BinaryToHex(data_value_binary);
memory_table.setValueAt(data_value_hex, row, column);
}
sourcecode_section_state = 2;
}
if (sourcecode_section_state == 2)//final state
{
pipeline.data_segment_map = data_segment_map;
PopulateProgramTextSegmentAddress(current_parse_line);
}
outputpane.Print("Finish Compiling");
}
catch(Exception ex)
{
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
outputpane.Print(ex.getMessage());
}
}//GEN-LAST:event_jBtnAssembleActionPerformed
public static int ExtractImmediateValueToDecimal(String imm_value)
{
int int_value = 0;
if (imm_value.contains("0x"))
{
imm_value = imm_value.replace("0x", "");
int_value = Convert.HexToDecimal(imm_value);
}
else
{
int_value = Integer.parseInt(imm_value);
}
return int_value;
}
/***
* Populates the jTableProgram table from the source code
* @param current_parse_line
*/
public void PopulateProgramTextSegmentAddress(int current_parse_line)
{
opcode = new Opcode(jTableRegister, jTableProgram, jTableMemory, data_segment_map);
opcode.outputpane = outputpane;
instruction_extractor = new InstructionExtractor(jTableProgram, data_segment_map);
instruction_extractor.outputpane = outputpane;
lines = jEditorPane1.getText().split("\n");
this.program_table = (DefaultTableModel)jTableProgram.getModel();
this.pipeline_map_table = (DefaultTableModel)jTablePipelineMap.getModel();
for (int i = 4096, j = current_parse_line + 1; j < lines.length && i < 8192; i+=4, j++)
{
Vector cell = new Vector(); //this stores the value of each 'cell' per address row
int[] decimal_to_binary = Convert.IntDecimalToBinary(i, 13); //13 bits == 4096 (according to specs)
String binary_to_hex = Convert.BinaryToHex(decimal_to_binary);
cell.add(binary_to_hex);
cell.add(""); //empty opcodes column for now
cell.add(lines[j]);
Vector pipeline_cell = new Vector();
pipeline_cell.add(binary_to_hex);
pipeline_cell.add(lines[j]);
this.program_table.addRow(cell);
this.pipeline_map_table.addRow(pipeline_cell);
}
DefaultTableModel program_model = (DefaultTableModel)jTableProgram.getModel();
instruction_parse_map = instruction_extractor.ExtractParams();
//assign opcodes after loading the instructions in memory
for (int i = current_parse_line + 1, j = 0; i < lines.length; i++, j++)
{
String full_opcode = opcode.GenerateOpcode(lines[i], j);
program_model.setValueAt(full_opcode, j, 1);
}
pipeline.instruction_parse_map = instruction_parse_map;
outputpane.Print("Finished Generating Opcodes");
}
private void jBtnNextLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnNextLineActionPerformed
try {
// TODO add your handling code here:
boolean cycling = ReadCurrentLine();
if(!cycling)
{
outputpane.Print("No More Iterations");
}
} catch (Exception ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
outputpane.Print(ex.getMessage());
}
}//GEN-LAST:event_jBtnNextLineActionPerformed
/**
* To be removed
* @param evt
*/
private void jBtnPrevLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnPrevLineActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jBtnPrevLineActionPerformed
private void jBtnRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnRunActionPerformed
// TODO add your handling code here:
boolean is_ok = true;
while (is_ok)
{
try {
boolean cycling = ReadCurrentLine();
if (!cycling)
{
is_ok = false;
break;
}
} catch (Exception ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
outputpane.Print("Error at line "+(pipeline.currently_visited_program_number) + ex.getMessage());
break;
}
}
}//GEN-LAST:event_jBtnRunActionPerformed
String[] lines;
int current_line;
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainFrame().setVisible(true);
}
});
}
public boolean ReadCurrentLine() throws Exception
{
//parse or read line here
// opcode.GenerateOpcode(lines[current_line], jTableRegister);
return pipeline.Cycle();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jBtnAssemble;
private javax.swing.JButton jBtnNextLine;
private javax.swing.JButton jBtnPrevLine;
private javax.swing.JButton jBtnRun;
private javax.swing.JEditorPane jEditorPane1;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JScrollPane jScrollPane8;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTabbedPane jTabbedPane2;
private javax.swing.JTabbedPane jTabbedPane3;
private javax.swing.JTabbedPane jTabbedPane4;
private javax.swing.JTable jTableMemory;
private javax.swing.JTable jTablePipelineMap;
private javax.swing.JTable jTablePipelineRegister;
private javax.swing.JTable jTableProgram;
private javax.swing.JTable jTableRegister;
private javax.swing.JTextPane jTextOutput;
// End of variables declaration//GEN-END:variables
}
| [
"mark_jethro27@yahoo.com"
] | mark_jethro27@yahoo.com |
af09335535b96697a3afe35c77ed933260c3f661 | 94790ca100dfb5b8150a914279ed3162190774b4 | /app/src/main/java/com/assistne/dribbble/stepper/StepperView.java | 616d562fdbbaad1ab4637c2f76dadf98d30b2839 | [] | no_license | hamzahadjtaieb/Dribbble | 8f899aea18405960ba83eb9c26f6224a61aa929d | 6c87939751edadfe649f84dca386d0c2078c4c59 | refs/heads/master | 2020-12-11T14:35:19.151117 | 2017-03-30T03:14:00 | 2017-03-30T03:14:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,197 | java | package com.assistne.dribbble.stepper;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.text.DynamicLayout;
import android.text.Layout;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.facebook.rebound.SimpleSpringListener;
import com.facebook.rebound.Spring;
import com.facebook.rebound.SpringSystem;
/**
* Created by assistne on 17/3/28.
*/
public class StepperView extends View {
private static final String TAG = "#StepperView";
private static final int BG_COLOR = Color.argb(51, 255, 255, 255);
private static final int CIRCLE_COLOR = Color.WHITE;
private static final int MARK_COLOR = Color.WHITE;
private static final int CIRCLE_SHADOW_COLOR = Color.argb(51, 15, 46, 81);
private static final int TEXT_COLOR = Color.rgb(109, 114, 255);
private int mCircleCenterX;
private Paint mBgPaint;
private Paint mCirclePaint;
private Paint mMarkPaint;
private Path mBgPath;
private Layout mNumberLayout;
private SpannableStringBuilder mNumberSpannable;
private int mNumber;
private boolean mCanIncrease;
private float mMinusScale = 1f;
private float mPlusScale = 1f;
private float mLastX;
private boolean mPlusScaling;
private ValueAnimator mPlusRunningAnimator;
private boolean mMinusScaling;
private ValueAnimator mMinusRunningAnimator;
private Spring mSpring;
public StepperView(Context context) {
this(context, null);
}
public StepperView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public StepperView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBgPaint.setStyle(Paint.Style.FILL);
mBgPaint.setColor(BG_COLOR);
mMarkPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mMarkPaint.setColor(MARK_COLOR);
mMarkPaint.setStyle(Paint.Style.STROKE);
mCirclePaint = new Paint(mBgPaint);
mCirclePaint.setColor(CIRCLE_COLOR);
mCirclePaint.setShadowLayer(24, 0, 0, CIRCLE_SHADOW_COLOR);
// 为了绘制阴影
setLayerType(LAYER_TYPE_SOFTWARE, mCirclePaint);
mNumberSpannable = new SpannableStringBuilder(String.valueOf(mNumber));
initSpring();
}
private void initSpring() {
SpringSystem springSystem = SpringSystem.create();
mSpring = springSystem.createSpring();
mSpring.addListener(new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
mCircleCenterX = (int) spring.getCurrentValue();
invalidate();
}
});
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mLastX = event.getX();
if (isInCircle(event)) {
mCanIncrease = true;
return true;
} else {
mCanIncrease = false;
return false;
}
case MotionEvent.ACTION_MOVE:
if (isInControlSpan(event)) {
final int threshold = getMeasuredHeight() / 6;
final int middle = getMeasuredWidth() / 2;
mCircleCenterX += (event.getX() - mLastX) * 0.4f;
mSpring.setCurrentValue(mCircleCenterX);
mLastX = event.getX();
invalidate();
int delta = (int) (event.getX() - middle);
if (delta >= 0) {// 在右侧
if (event.getX() - middle > threshold) {
scalePlusMark();
} else {
restorePlusMark();
}
} else {
if (-delta > threshold) {
scaleMinusMark();
} else {
restoreMinusMark();
}
}
return true;
} else {
onReleaseCircle();
return false;
}
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
onReleaseCircle();
mCanIncrease = false;
return true;
}
return false;
}
private void scalePlusMark() {
if (!mPlusScaling) {
if (mPlusRunningAnimator != null && mPlusRunningAnimator.isRunning()) {
mPlusRunningAnimator.cancel();
}
mPlusRunningAnimator = ValueAnimator.ofFloat(mPlusScale, 1.2f);
mPlusRunningAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mPlusScale = (float) animation.getAnimatedValue();
invalidate();
}
});
mPlusRunningAnimator.start();
mPlusScaling = true;
}
}
private void restorePlusMark() {
if (mPlusScaling) {
if (mPlusRunningAnimator != null && mPlusRunningAnimator.isRunning()) {
mPlusRunningAnimator.cancel();
}
mPlusRunningAnimator = ValueAnimator.ofFloat(mPlusScale, 1f);
mPlusRunningAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mPlusScale = (float) animation.getAnimatedValue();
invalidate();
}
});
mPlusRunningAnimator.start();
mPlusScaling = false;
}
}
private void scaleMinusMark() {
if (!mMinusScaling && mNumber > 0) {
if (mMinusRunningAnimator != null && mMinusRunningAnimator.isRunning()) {
mMinusRunningAnimator.cancel();
}
mMinusRunningAnimator = ValueAnimator.ofFloat(mMinusScale, 1.2f);
mMinusRunningAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mMinusScale = (float) animation.getAnimatedValue();
invalidate();
}
});
mMinusRunningAnimator.start();
mMinusScaling = true;
}
}
private void restoreMinusMark() {
if (mMinusScaling) {
if (mMinusRunningAnimator != null && mMinusRunningAnimator.isRunning()) {
mMinusRunningAnimator.cancel();
}
mMinusRunningAnimator = ValueAnimator.ofFloat(mMinusScale, 1f);
mMinusRunningAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mMinusScale = (float) animation.getAnimatedValue();
invalidate();
}
});
mMinusRunningAnimator.start();
mMinusScaling = false;
}
}
private void resetCircle() {
mSpring.setEndValue(getMeasuredWidth() / 2);
}
private boolean isInCircle(MotionEvent event) {
int circleCenterY = getMeasuredHeight() / 2;
return circleCenterY * circleCenterY >= Math.pow(event.getX() - mCircleCenterX, 2) + Math.pow(event.getY() - circleCenterY, 2);
}
private boolean isInControlSpan(MotionEvent event) {
int circleCenterY = getMeasuredHeight() / 2;
return circleCenterY * circleCenterY * 1.5f >= Math.pow(event.getX() - mCircleCenterX, 2) + Math.pow(event.getY() - circleCenterY, 2);
}
private void onReleaseCircle() {
restoreMinusMark();
restorePlusMark();
resetCircle();
increaseNumber();
}
private void increaseNumber() {
if (mCanIncrease) {
final int threshold = getMeasuredHeight() / 6;
if (mCircleCenterX - getMeasuredWidth() / 2 >= threshold) {
mNumber += 1;
mNumberSpannable.replace(0, mNumberSpannable.length(), String.valueOf(mNumber));
mCanIncrease = false;
} else if (mCircleCenterX - getMeasuredWidth() / 2 <= - threshold && mNumber > 0) {
mNumber -= 1;
mNumberSpannable.replace(0, mNumberSpannable.length(), String.valueOf(mNumber));
mCanIncrease = false;
}
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
mCircleCenterX = getMeasuredWidth() / 2;
mMarkPaint.setStrokeWidth(getMeasuredHeight() / 30);
if (mNumberLayout == null) {
TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setColor(TEXT_COLOR);
textPaint.setTextSize(getMeasuredHeight() * 0.45f);
mNumberLayout = new DynamicLayout(mNumberSpannable, mNumberSpannable, textPaint, getMeasuredHeight(), Layout.Alignment.ALIGN_CENTER, 1, 0, true);
}
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
drawBackground(canvas);
drawMinus(canvas);
drawPlus(canvas);
drawCircle(canvas);
}
private void drawBackground(Canvas canvas) {
if (mBgPath == null) {
int r = getMeasuredHeight() / 2;
int lineLen = getMeasuredWidth() - getMeasuredHeight();
mBgPath = new Path();
mBgPath.addRect(r, 0, getMeasuredWidth() - r, getMeasuredHeight(), Path.Direction.CW);
RectF rectF = new RectF(lineLen, 0, getMeasuredWidth(), getMeasuredHeight());
mBgPath.addArc(rectF, -90, 180);
rectF.offsetTo(0, 0);
mBgPath.addArc(rectF, 90, 180);
}
canvas.drawPath(mBgPath, mBgPaint);
}
private void drawCircle(Canvas canvas) {
int r = getMeasuredHeight() / 2;
canvas.save();
canvas.clipPath(mBgPath);
canvas.translate(mCircleCenterX - r, 0);
canvas.drawCircle(r, r , r, mCirclePaint);
canvas.translate(0, (getMeasuredHeight() - mNumberLayout.getHeight()) / 2);
mNumberLayout.draw(canvas);
canvas.restore();
}
private void drawPlus(Canvas canvas) {
mMarkPaint.setColor(MARK_COLOR);
int container = getMeasuredHeight() / 3;
int padding = container / 5;
int lineLen = container - 2 * padding;
canvas.save();
canvas.translate(getMeasuredWidth() - getMeasuredHeight() / 2, (getMeasuredHeight() - container) / 2);
canvas.scale(mPlusScale, mPlusScale, container / 2, container / 2);
canvas.drawLine(padding, container / 2, padding + lineLen, container / 2, mMarkPaint);
canvas.drawLine(container / 2, padding, container / 2, padding + lineLen, mMarkPaint);
canvas.restore();
}
private void drawMinus(Canvas canvas) {
if (mNumber == 0) {
mMarkPaint.setAlpha(51);
} else {
mMarkPaint.setColor(MARK_COLOR);
}
int padding = getMeasuredHeight() / 15;
int startX = getMeasuredHeight() / 6 + padding;
int startY = getMeasuredHeight() / 2;
int lineLen = getMeasuredHeight() / 5;
canvas.save();
canvas.scale(mMinusScale, mMinusScale, startX + lineLen / 2, startY);
canvas.drawLine(startX, startY, startX + lineLen, startY, mMarkPaint);
canvas.restore();
}
}
| [
"ljiaquan929@gmail.com"
] | ljiaquan929@gmail.com |
619301d89f58f236d431b117f8fb640f946c1c08 | d2fdab73112081f9823854a834d8bc17f2af67ae | /src/main/java/com/sda/myapp/contrlollers/PersonMapper.java | 941717bd754631c22e0753141ecd087fe467733c | [] | no_license | ravebog/spring | 53172010c88b73ec5d1a59dc114e6dbd54f774e8 | 264cf8aa11667f5f81761358d4835d4bead64566 | refs/heads/master | 2023-01-23T18:02:47.978035 | 2020-12-08T15:00:32 | 2020-12-08T15:00:32 | 311,727,337 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 701 | java | package com.sda.myapp.contrlollers;
import com.sda.myapp.contrlollers.jsons.PersonJson;
import com.sda.myapp.contrlollers.jsons.PersonJsonProjection;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class PersonMapper {
public List<PersonJsonProjection> map(List<PersonJson> all) {
return all.stream().map(e->from(e)).collect(Collectors.toList());
}
public static PersonJsonProjection from (PersonJson json){
PersonJsonProjection projection = new PersonJsonProjection();
projection.setCnp(json.getCnp());
projection.setName(json.getName());
return projection;
}
}
| [
"ravebog@gmail.com"
] | ravebog@gmail.com |
21e578c83e0950910dd69d63e975151dc1fc24a4 | c941ff9e43a93bbaf9901fcb8c3c75d7ebdaa0a5 | /src/hari2/kuis.java | 540f243086671980217ec8667d3bb8896aba2e37 | [] | no_license | iamsyahidi/logicGen2 | b4de6b9980c11c6c1352cf280f653640fbedcf48 | 4d45d320b158bf7d97d7ea21a004a436c66cb480 | refs/heads/master | 2022-11-12T04:27:36.557239 | 2020-07-06T02:09:17 | 2020-07-06T02:09:17 | 277,420,488 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 741 | java | package hari2;
import java.util.Scanner;
public class kuis {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
System.out.print("Masukkan nilai N : ");
System.out.println();
int n = scanner.nextInt();
if (n%2==0) {
System.out.print("N Genap, masukkan bilangan Ganjil");
}
else {
System.out.print("N sudah bilangan Ganjil");
System.out.println();
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i==j) {
System.out.print((i*2)+1);
}else if (i+j==n-1) {
System.out.print((j*2)+2);
}else {
System.out.print(" ");
}
}
System.out.println();
}
}
scanner.close();
}
}
| [
"ilhamsyahidi66@gmail.com"
] | ilhamsyahidi66@gmail.com |
217dda2602d5c66a3c82fcc8438c4b466ad6332a | 11c2e5a69ebf31f9de23bb7fdd624d711f397e94 | /src/main/java/com/pan/entity/TProjectServerEntity.java | 724777df97330ef23994249d7cf897f402dfcb63 | [] | no_license | tangp666/QuickDeployment | e461c3833541acd639a0d4a2d9e3b952ecebe96f | d0e2ca8f131d30919a1e51930d2f6e3d653d4380 | refs/heads/master | 2022-12-23T15:54:07.895016 | 2020-10-02T12:13:55 | 2020-10-02T12:13:55 | 295,958,119 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 823 | java | package com.pan.entity;
import javax.persistence.Column;
import javax.persistence.Table;
import java.io.Serializable;
/**
* 项目和服务器关联关系
* @author tangpan
*/
@Table(name = "t_project_server")
public class TProjectServerEntity extends BaseEntity implements Serializable {
private static final long serializable = 1l;
/* 项目主键 */
@Column(name = "project_id")
private long projectId;
/* 服务器主键 */
@Column(name = "server_id")
private long serverId;
public long getProjectId() {
return projectId;
}
public void setProjectId(long projectId) {
this.projectId = projectId;
}
public long getServerId() {
return serverId;
}
public void setServerId(long serverId) {
this.serverId = serverId;
}
}
| [
"137889800@qq.com"
] | 137889800@qq.com |
f2e44c6bbc8779bfafe90c260353860e2bbfd49e | 8540efa7e6cfbf76dedaa239d175336a92a60f5f | /sipservice/src/main/java/org/pjsip/pjsua2/pjsip_cred_data_type.java | 01563bd544c598e389e968f0f90a397a5928408b | [] | no_license | wblt/wephone | cc7c705604f9926b890c1fe1a178fc6b4d76b41c | 7e9ea2e5f1422294261babb1b999658ce0c04528 | refs/heads/master | 2020-04-16T13:34:26.843227 | 2019-01-16T07:03:47 | 2019-01-16T07:03:47 | 165,633,298 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,212 | java | /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 2.0.10
*
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
package org.pjsip.pjsua2;
public final class pjsip_cred_data_type {
public final static pjsip_cred_data_type PJSIP_CRED_DATA_PLAIN_PASSWD = new pjsip_cred_data_type("PJSIP_CRED_DATA_PLAIN_PASSWD", pjsua2JNI.PJSIP_CRED_DATA_PLAIN_PASSWD_get());
public final static pjsip_cred_data_type PJSIP_CRED_DATA_DIGEST = new pjsip_cred_data_type("PJSIP_CRED_DATA_DIGEST", pjsua2JNI.PJSIP_CRED_DATA_DIGEST_get());
public final static pjsip_cred_data_type PJSIP_CRED_DATA_EXT_AKA = new pjsip_cred_data_type("PJSIP_CRED_DATA_EXT_AKA", pjsua2JNI.PJSIP_CRED_DATA_EXT_AKA_get());
public final int swigValue() {
return swigValue;
}
public String toString() {
return swigName;
}
public static pjsip_cred_data_type swigToEnum(int swigValue) {
if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
return swigValues[swigValue];
for (int i = 0; i < swigValues.length; i++)
if (swigValues[i].swigValue == swigValue)
return swigValues[i];
throw new IllegalArgumentException("No enum " + pjsip_cred_data_type.class + " with value " + swigValue);
}
private pjsip_cred_data_type(String swigName) {
this.swigName = swigName;
this.swigValue = swigNext++;
}
private pjsip_cred_data_type(String swigName, int swigValue) {
this.swigName = swigName;
this.swigValue = swigValue;
swigNext = swigValue+1;
}
private pjsip_cred_data_type(String swigName, pjsip_cred_data_type swigEnum) {
this.swigName = swigName;
this.swigValue = swigEnum.swigValue;
swigNext = this.swigValue+1;
}
private static pjsip_cred_data_type[] swigValues = { PJSIP_CRED_DATA_PLAIN_PASSWD, PJSIP_CRED_DATA_DIGEST, PJSIP_CRED_DATA_EXT_AKA };
private static int swigNext = 0;
private final int swigValue;
private final String swigName;
}
| [
"940422068@qq.com"
] | 940422068@qq.com |
6ac85c30cd72a377aa3932d9e7d158d7edf897e5 | 1dff987515b41d6a3587ae8a280d0a56e835a7d3 | /src/main/java/com/shsxt/crm/vo/User.java | 860a206278b950f7ca862b0d023abedc76ac8d62 | [] | no_license | TryForget/CRM | 4a02f242cd745fc2426124ed1398ebb997ca14e3 | bb9c1c8f05cf4ea212fb53f0a10135c68398444a | refs/heads/master | 2022-12-08T10:29:30.029306 | 2020-08-28T02:31:23 | 2020-08-28T02:31:23 | 290,765,844 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,196 | java | package com.shsxt.crm.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
public class User {
private Integer id;
private String userName;
private String userPwd;
private String trueName;
private String email;
private String phone;
private Integer isValid;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateDate;
private String roleIds; // 用户角色ID
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName == null ? null : userName.trim();
}
public String getUserPwd() {
return userPwd;
}
public void setUserPwd(String userPwd) {
this.userPwd = userPwd == null ? null : userPwd.trim();
}
public String getTrueName() {
return trueName;
}
public void setTrueName(String trueName) {
this.trueName = trueName == null ? null : trueName.trim();
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email == null ? null : email.trim();
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}
public Integer getIsValid() {
return isValid;
}
public void setIsValid(Integer isValid) {
this.isValid = isValid;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getUpdateDate() {
return updateDate;
}
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
public String getRoleIds() {
return roleIds;
}
public void setRoleIds(String roleIds) {
this.roleIds = roleIds;
}
} | [
"805023334@qq.com"
] | 805023334@qq.com |
4405c078bc5dffcdbe6b7b1f61095c65f51e33d4 | 60887725e1ff5df4394c8f523cc78eb7d609eeb1 | /src/main/java/cn/xilikeli/skyblog/common/enumeration/LeaveMessageLevelEnum.java | c7b00f55f1b98bd6b4a0b71149e52cd3c0bb48cc | [
"MIT"
] | permissive | 270686992/sky-blog-server | 53465cc1c920a43d6d37b4e2ad8379d88fc0ad62 | 34e1a82de3fb3a0da0234765eb1cdd2de775a847 | refs/heads/master | 2023-02-02T10:43:36.928083 | 2020-10-06T11:42:48 | 2020-10-06T11:48:21 | 291,402,924 | 1 | 1 | MIT | 2020-10-06T11:48:22 | 2020-08-30T04:57:53 | Java | UTF-8 | Java | false | false | 1,067 | java | package cn.xilikeli.skyblog.common.enumeration;
/**
* <p>
* 留言级别枚举类
* </p>
*
* @author 踏雪彡寻梅
* @version 1.0
* @date 2020/8/23 - 17:30
* @since JDK1.8
*/
public enum LeaveMessageLevelEnum {
/**
* 一级留言
*/
ROOT(1, "一级留言"),
/**
* 二级留言
*/
NOT_ROOT(0, "二级留言");
/**
* 枚举值
*/
private Integer value;
/**
* 枚举描述
*/
private String description;
/**
* 构造函数
*
* @param value 枚举值
* @param description 枚举描述
*/
LeaveMessageLevelEnum(Integer value, String description) {
this.value = value;
this.description = description;
}
public void setValue(Integer value) {
this.value = value;
}
public Integer getValue() {
return this.value;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return this.description;
}
} | [
"1743291847@qq.com"
] | 1743291847@qq.com |
d1657846fe2ae83c3b30a2621f0253acfb407b45 | 33738b7dd03ab0277bdf7a1d83bdd8d08094771f | /sff/src/main/java/com/lti/entity/Bid.java | 0c6a8559cdb0c1bbe18f2a5490b3172b7ff41cbe | [] | no_license | SowmyaS98/sff | fb73f5066de1e384f90d1dfe914d7a6eb802d8b0 | 12df492a0360fdbcf5dbc1d4fa9797d8804ac7b9 | refs/heads/master | 2023-02-09T20:53:34.748755 | 2021-01-08T14:32:21 | 2021-01-08T14:32:21 | 327,927,529 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,637 | java | package com.lti.entity;
import java.time.LocalDate;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
@Entity
public class Bid {
@Id
@SequenceGenerator(name="seq_bid",initialValue=500,allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="seq_bid")
long bidId;
double bidAmount;
LocalDate bidDate;
String bidApprove;
String bidSold;
@ManyToOne (fetch=FetchType.EAGER)
@JoinColumn(name="cropId")
Crop crop;
@ManyToOne
@JoinColumn(name="bidderId")
Bidder bidder;
public long getBidId() {
return bidId;
}
public void setBidId(long bidId) {
this.bidId = bidId;
}
public double getBidAmount() {
return bidAmount;
}
public void setBidAmount(double bidAmount) {
this.bidAmount = bidAmount;
}
public LocalDate getBidDate() {
return bidDate;
}
public void setBidDate(LocalDate bidDate) {
this.bidDate = bidDate;
}
public String getBidApprove() {
return bidApprove;
}
public void setBidApprove(String bidApprove) {
this.bidApprove = bidApprove;
}
public String getBidSold() {
return bidSold;
}
public void setBidSold(String bidSold) {
this.bidSold = bidSold;
}
public Crop getCrop() {
return crop;
}
public void setCrop(Crop crop) {
this.crop = crop;
}
public Bidder getBidder() {
return bidder;
}
public void setBidder(Bidder bidder) {
this.bidder = bidder;
}
}
| [
"sowmyselvaraj.ssk@gmail.com"
] | sowmyselvaraj.ssk@gmail.com |
fcf088a0d98d8abb64f8812ac9a3040306cc25f8 | 438da6e7a37d303804e29c4ff33d3e232ade01d6 | /Calc.java | 4387d8facbb41bb09ccbf53975315eabf98d3a6e | [] | no_license | bj04/MyCalcRepo | f1d3a138c3917e9559917ac3f5f28c160e9bd341 | a548a797e4be893fd765dd12ffb37ce261e1d76e | refs/heads/main | 2023-01-04T10:04:55.840014 | 2020-10-20T05:48:04 | 2020-10-20T05:48:04 | 305,360,307 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 347 | java | class Calc{
public static int add(int a, int b){
return a+b;
}
public static int sub(int a, int b){
return a-b;
}
public static int prod(int a, int b){
return a*b;
}
public static void main(String[] args){
System.out.println(add(10,20));
System.out.println(sub(10,20));
System.out.println(prod(10,20));
}
}
| [
"noreply@github.com"
] | noreply@github.com |
73de3111a0647482a4f9d679dab4ab7a272239c0 | ae5eb1a38b4d22c82dfd67c86db73592094edc4b | /project426/src/main/java/org/gradle/test/performance/largejavamultiproject/project426/p2130/Production42617.java | 4de344bf9f8b41ac2d250242a25f4bcbf0337be3 | [] | no_license | big-guy/largeJavaMultiProject | 405cc7f55301e1fd87cee5878a165ec5d4a071aa | 1cd6a3f9c59e9b13dffa35ad27d911114f253c33 | refs/heads/main | 2023-03-17T10:59:53.226128 | 2021-03-04T01:01:39 | 2021-03-04T01:01:39 | 344,307,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,890 | java | package org.gradle.test.performance.largejavamultiproject.project426.p2130;
public class Production42617 {
private String property0;
public String getProperty0() {
return property0;
}
public void setProperty0(String value) {
property0 = value;
}
private String property1;
public String getProperty1() {
return property1;
}
public void setProperty1(String value) {
property1 = value;
}
private String property2;
public String getProperty2() {
return property2;
}
public void setProperty2(String value) {
property2 = value;
}
private String property3;
public String getProperty3() {
return property3;
}
public void setProperty3(String value) {
property3 = value;
}
private String property4;
public String getProperty4() {
return property4;
}
public void setProperty4(String value) {
property4 = value;
}
private String property5;
public String getProperty5() {
return property5;
}
public void setProperty5(String value) {
property5 = value;
}
private String property6;
public String getProperty6() {
return property6;
}
public void setProperty6(String value) {
property6 = value;
}
private String property7;
public String getProperty7() {
return property7;
}
public void setProperty7(String value) {
property7 = value;
}
private String property8;
public String getProperty8() {
return property8;
}
public void setProperty8(String value) {
property8 = value;
}
private String property9;
public String getProperty9() {
return property9;
}
public void setProperty9(String value) {
property9 = value;
}
} | [
"sterling.greene@gmail.com"
] | sterling.greene@gmail.com |
d529e452812b20c26fde7697e5b69362e5db4992 | ebd026e5aaa494f4bed4c8ae989dcfa49d93b921 | /src/main/java/com/yahoo/sketches/theta/AnotB.java | cb3aeac7cf4a4f5f78c8ae682c97a73125e49ad6 | [
"Apache-2.0"
] | permissive | Chanpaul/sketches-core | 936150b271a2b74986a0b95464d94a9a3721b3c9 | 75e66344829d707679579e79b64e07a180256b98 | refs/heads/master | 2021-01-18T10:48:13.468247 | 2016-07-06T22:45:51 | 2016-07-06T22:45:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,778 | java | /*
* Copyright 2015-16, Yahoo! Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*/
package com.yahoo.sketches.theta;
import com.yahoo.sketches.memory.Memory;
/**
* The API for the set difference operation <i>A and not B</i> operations.
* This is a stateless operation. However, to make the API
* more consistent with the other set operations the intended use is:
* <pre><code>
* AnotB aNotB = SetOperationBuilder.buildAnotB();
* aNotB.update(SketchA, SketchB); //Called only once.
* CompactSketch result = aNotB.getResult();
* </code></pre>
*
* Calling the update function a second time essentially clears the internal state and updates with
* the new pair of sketches.
*
* @author Lee Rhodes
*/
public interface AnotB {
/**
* Perform A-and-not-B set operation on the two given sketches.
* A null sketch is interpreted as an empty sketch.
*
* @param a The incoming sketch for the first argument
* @param b The incoming sketch for the second argument
*/
void update(Sketch a, Sketch b);
/**
* Gets the result of this operation as a CompactSketch of the chosen form
* @param dstOrdered
* <a href="{@docRoot}/resources/dictionary.html#dstOrdered">See Destination Ordered</a>
*
* @param dstMem
* <a href="{@docRoot}/resources/dictionary.html#dstMem">See Destination Memory</a>.
*
* @return the result of this operation as a CompactSketch of the chosen form
*/
CompactSketch getResult(boolean dstOrdered, Memory dstMem);
/**
* Gets the result of this operation as an ordered CompactSketch on the Java heap
* @return the result of this operation as an ordered CompactSketch on the Java heap
*/
CompactSketch getResult();
}
| [
"lrhodes@yahoo-inc.com"
] | lrhodes@yahoo-inc.com |
39189c8ebdbc1e577b08c133887ac323d26c2e7f | 18b60fd47e20aa0c38806243bed8081c9ef3cd86 | /jupiter-rpc/src/main/java/org/jupiter/rpc/load/balance/WeightArray.java | 94f4382fcf6e3aec6b0a6ab6068b11fff69413b5 | [
"Apache-2.0"
] | permissive | kongzhidea/Jupiter | 9ddbdf8f652e46e1c751c23098af424a60fb382b | 9b9234891ba03b21c71da9d69a6e0904216cb094 | refs/heads/master | 2021-10-01T15:39:43.719113 | 2018-11-27T11:32:45 | 2018-11-27T11:32:45 | 110,490,308 | 1 | 0 | NOASSERTION | 2018-11-27T11:32:46 | 2017-11-13T02:27:29 | Java | UTF-8 | Java | false | false | 1,360 | java | /*
* Copyright (c) 2015 The Jupiter Project
*
* 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.jupiter.rpc.load.balance;
/**
* jupiter
* org.jupiter.rpc.load.balance
*
* @author jiachun.fjc
*/
final class WeightArray {
private final int[] array;
private final int length;
private int gcd;
WeightArray(int[] array, int length) {
this.array = array;
this.length = (array != null ? array.length : length);
}
int get(int index) {
if (index >= array.length) {
throw new ArrayIndexOutOfBoundsException(index);
}
return array[index];
}
int length() {
return length;
}
int gcd() {
return gcd;
}
void gcd(int gcd) {
this.gcd = gcd;
}
boolean isAllSameWeight() {
return array == null;
}
}
| [
"jiachun.fjc@alibaba-inc.com"
] | jiachun.fjc@alibaba-inc.com |
aa0fbbb910665b1abbe6e0c983b59ed6fda68bdc | 122891c561459c030b0dc4846e6f41b87dca0595 | /src/test/nio/SeekServer.java | 47670e389f2f7b061199df22bce209c649de7f04 | [] | no_license | firefoxmmx2/niosocket_test | 16a2b01a8489862ac0287a3678627d9d3e855649 | 04bad18d81d42e7a83caef216758f16104c1b7b8 | refs/heads/master | 2021-01-18T21:38:36.731810 | 2016-03-31T08:23:20 | 2016-03-31T08:23:20 | 20,720,555 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,811 | java | package test.nio;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.logging.Logger;
/**
* Created by hooxin on 14-6-23.
*/
public class SeekServer extends Thread{
Logger logger=Logger.getLogger(SeekServer.class.getName());
private final int ACCEPT_PORT=10086;
private final int TIME_OUT=3600;
private Selector mSelector=null;
private ServerSocketChannel mSocketChannel=null;
private ServerSocket mServerSocket=null;
private InetSocketAddress mAddress=null;
public SeekServer(){
long sign=System.currentTimeMillis();
try{
mSocketChannel=ServerSocketChannel.open();
if(mSocketChannel==null){
System.out.println("cant open server socket");
}
mServerSocket=mSocketChannel.socket();
mAddress=new InetSocketAddress(ACCEPT_PORT);
mServerSocket.bind(mAddress);
logger.info("server bind port is "+ACCEPT_PORT);
mSelector=Selector.open();
mSocketChannel.configureBlocking(false);
SelectionKey key=mSocketChannel.register(mSelector,SelectionKey.OP_ACCEPT);
key.attach(new Acceptor());
logger.info("Seek server startup in "+(System.currentTimeMillis()-sign)+"ms!");
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void run() {
logger.info("server is listening... ");
while (!Thread.interrupted()){
try{
if(mSelector.select(TIME_OUT)>0){
logger.info("find a new selection key");
for(SelectionKey key : mSelector.selectedKeys()){
Runnable at=(Runnable)key.attachment();
if(at!=null){
at.run();
}
// mSelector.selectedKeys().clear();
}
}
} catch (IOException e) {
e.printStackTrace();
logger.warning(e.getMessage());
}
}
}
class Acceptor implements Runnable{
@Override
public void run() {
SocketChannel sc= null;
try {
sc = mSocketChannel.accept();
new Handler(mSelector,sc);
} catch (IOException e) {
e.printStackTrace();
logger.warning(e.getMessage());
}
}
}
class Handler {
public Handler(Selector selector,SocketChannel socketChannel) {
}
}
}
| [
"firefoxmmx@gmail.com"
] | firefoxmmx@gmail.com |
86b3de1a0a9b3a68e822c46a455ddff4df64bdf5 | f440e05b074fc9043409067d8d704b40ea18c763 | /src/Day21/HashMapExercises.java | 026a6779557bbbfa07e60f8d968b1367ed4571c4 | [] | no_license | MuharremUstun/TechnoStudyOnlineJavaClasses.Day21andAfter | bfbfa20059b9e11e04189f420a9b51b65e923d81 | 3d00e2504c68a906ec8dd1d7033f0a8e7aa9fe2b | refs/heads/master | 2020-12-04T09:01:02.781909 | 2020-04-30T04:04:58 | 2020-04-30T04:04:58 | 231,704,380 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,863 | java | package Day21;
//https://beginnersbook.com/2013/12/hashmap-in-java-with-example/
import java.util.HashMap;
import java.util.Map;
public class HashMapExercises {
public static void main(String[] args) {
//1. Write a Java program to associate the specified value with the specified key in a HashMap.
System.out.println("Task 1 --------------------------------");
HashMap<String, Integer> map = new HashMap<>();
map.put("Max", 54);
map.put("Sergey", 100);
map.put("Maxim", 78);
map.put("Mahmut", 100);
System.out.println(map.entrySet());
//2. Write a Java program to count the number of key-value (size) mappings in a map.
System.out.println("\nTask 2 --------------------------------");
int size = map.size();
System.out.println("Map size is: " + size);
//3. Write a Java program to copy all of the mappings from the specified map to another map.
System.out.println("\nTask 3 --------------------------------");
// 1. way: during declaration:
HashMap<String, Integer> map2 = new HashMap(map);
// 2. way: putAll
HashMap<String, Integer> map3 = new HashMap<>();
map3.putAll(map);
// 3. way: loop
HashMap<String, Integer> map4 = new HashMap<>();
for (Map.Entry<String, Integer> entry : map.entrySet()) {
String key = entry.getKey();
Integer value = entry.getValue();
map4.put(key, value);
}
System.out.println("1. map: " + map.entrySet());
System.out.println("2. map: " + map2.entrySet());
System.out.println("3. map: " + map3.entrySet());
System.out.println("4. map: " + map4.entrySet());
//4. Write a Java program to remove all of the mappings from a map.
System.out.println("\nTask 4 --------------------------------");
map2.clear();
System.out.println(map2.entrySet());
//5. Write a Java program to check whether a map contains key-value mappings (empty) or not.
System.out.println("\nTask 5 --------------------------------");
boolean isEmpty = map.isEmpty();
boolean isEmpty2 = map2.isEmpty();
System.out.println("Map is empty?: " + isEmpty);
System.out.println("Map2 is empty?: " + isEmpty2);
//6. Write a Java program to get a shallow copy of a HashMap instance.
System.out.println("\nTask 6 --------------------------------");
HashMap<String, Integer> shallowCopy = new HashMap<>();
shallowCopy = map;
System.out.println("Original map: " + map.entrySet());
System.out.println("Shallow copy: " + shallowCopy.entrySet());
//7. Write a Java program to test if a map contains a mapping for the specified key.
System.out.println("\nTask 7 --------------------------------");
for (Map.Entry<String, Integer> entry : map.entrySet()) {
boolean ifContains = map.containsKey(entry.getKey());
if (ifContains) {
System.out.println("The map contains: " + entry.getValue());
} else System.out.println("The map does not contain: " + map.get(entry.getKey()));
}
//8. Write a Java program to test if a map contains a mapping for the specified value.
System.out.println("\nTask 8 --------------------------------");
int value = 100;
if (map.containsValue(value)) System.out.println("The map has " + value);
else System.out.println("The map does not have a value of " + value);
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == value) System.out.println("You have " + value + " on " + entry.getKey());
}
//9. Write a Java program to create a set view of the mappings contained in a map.
System.out.println("\nTask 9 --------------------------------");
System.out.println(map);
//10. Write a Java program to get the value of a specified key in a map.
System.out.println("\nTask 10 --------------------------------");
for (Map.Entry<String, Integer> entry : map.entrySet()) {
System.out.println("Value of " + entry.getKey() + " is " + entry.getValue());
}
//11. Write a Java program to get a set view of the keys contained in this map.
System.out.println("\nTask 11 --------------------------------");
System.out.println(map.keySet());
for (Map.Entry<String, Integer> entry : map.entrySet()) {
System.out.print(entry.getKey() + ", ");
}
System.out.println();
//12. Write a Java program to get a collection view of the values contained in this map.
System.out.println("\nTask 12 --------------------------------");
System.out.println(map.values());
//13. Create a map of at least 5 entries and calculate the sum of the vlues.
System.out.println("\nTask 13 --------------------------------");
HashMap<String, Double> prices = new HashMap<>();
prices.put("Apple", 4.2);
prices.put("Orange", 3.1);
prices.put("Banana", 0.7);
prices.put("Pear", 1.9);
prices.put("Pineapple", 5.5);
double sum = 0;
for (Double entry : prices.values()) {
sum += entry;
}
System.out.println(prices.entrySet());
System.out.println("Sum of the values of prices is: $" + sum);
//14. Print list of the keys and list of the values without the brackets [ ] and commas.
System.out.println("\nTask 14 --------------------------------");
for (String fruit : prices.keySet()) {
System.out.print(fruit + " ");
}
System.out.println();
for (Double price : prices.values()) {
System.out.print(price + " ");
}
System.out.println();
//15. Print list of the keys and list of the values without the brackets [ ] and commas LINE BY LINE.
System.out.println("\nTask 15 --------------------------------");
for (Map.Entry<String, Double> e : prices.entrySet()) {
System.out.println(e.getKey() + " " + e.getValue());
}
//16. Change the values of first two entries
System.out.println("\nTask 16 --------------------------------");
System.out.println(prices);
double appleValue = prices.get("Apple");
double orangeValue = prices.get("Orange");
prices.put("Apple", orangeValue);
prices.put("Orange", appleValue);
System.out.println(prices);
//17. Count each letter in a string array and record them in a map.
System.out.println("\nTask 17 --------------------------------");
String arr = "BECOME A SOFTWARE TEST ENGINEER IN 6 MONTHS!";
HashMap<Character, Integer> numsOfChars = new HashMap<>();
for (int i = 0; i < arr.length(); i++) {
if (numsOfChars.containsKey(arr.charAt(i))) {
int val = numsOfChars.get(arr.charAt(i));
val++;
numsOfChars.put(arr.charAt(i), val);
} else {
numsOfChars.put(arr.charAt(i), 1);
}
}
System.out.println(numsOfChars);
// 2. way ---------------------------------
HashMap<Character, Integer> numsOfChars2 = new HashMap<>();
for( int i = 0; i < arr.length(); i++) {
char ch = arr.charAt(i);
if (!numsOfChars2.containsKey(ch)) {
int charCounter = 0;
for (int j = i; j < arr.length(); j++) {
if (arr.charAt(j) == ch) charCounter++;
}
numsOfChars2.put(ch, charCounter);
}
}
System.out.println(numsOfChars2);
}
}
| [
"56238963+MuharremUstun@users.noreply.github.com"
] | 56238963+MuharremUstun@users.noreply.github.com |
4bc20c2eb377a0efe92454e988f04652bea061d5 | 37aa8d586ac59ccc403c17810d28ee307dbf7ba4 | /sandbox/src/main/java/sand/collection/behavioral/strategy/Sleeping.java | 8d8261ba64347ac23f1fd3d99a44ff7f33b88be4 | [
"Apache-2.0"
] | permissive | Dluhoviskiy/java_start1 | 1e48dc97f796dcaf7a992d01f2749a52b0fe8564 | 905ee8c8f09abc1278b53c68c01f0cb9b6ff6639 | refs/heads/master | 2022-09-28T20:17:18.625121 | 2022-09-28T09:41:05 | 2022-09-28T09:41:05 | 130,637,839 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 189 | java | package sand.collection.behavioral;
public class Sleeping implements Activity{
@Override
public void justDoIt() {
System.out.println("developer is sleeping ... ");
}
}
| [
"dm.luhoviskiy@gmail.com"
] | dm.luhoviskiy@gmail.com |
d34167b6753d4f99dd9c93de96e273a128b0533a | dbd405eed0f4a621d2ebcf5d8a879aaee69136e8 | /main/user-refs/src/main/java/org/osforce/connect/entity/system/ProjectCategory.java | 166f92451a0569e3a968f9357f19e861a9ecfaf2 | [] | no_license | shengang1978/AA | a39fabd54793d0c77a64ad94d8e3dda3f0cd6951 | d7b98b8998d33b48f60514457a873219776d9f38 | refs/heads/master | 2022-12-24T02:42:04.489183 | 2021-04-28T03:26:09 | 2021-04-28T03:26:09 | 33,310,666 | 0 | 1 | null | 2022-12-16T02:29:57 | 2015-04-02T13:36:05 | Java | UTF-8 | Java | false | false | 2,791 | java | package org.osforce.connect.entity.system;
import java.util.List;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.validator.constraints.NotBlank;
import org.osforce.connect.entity.support.SiteEntity;
import org.osforce.spring4me.commons.collection.CollectionUtil;
/**
*
* @author gavin
* @since 1.0.0
* @create Nov 4, 2010 - 11:48:55 AM
* <a href="http://www.opensourceforce.org">开源力量</a>
*/
@Entity
@Table(name="project_categories")
@Cacheable
public class ProjectCategory extends SiteEntity{
private static final long serialVersionUID = 6939240938778471219L;
@NotBlank
private String code;
@NotBlank
private String label;
private Integer level = 0;
private Boolean sensitive = false;
private Boolean enabled = true;
// helper
private Integer count = 0;
private Long parentId;
// refer
private ProjectCategory parent;
private List<ProjectCategory> children = CollectionUtil.newArrayList();
public ProjectCategory() {
}
public ProjectCategory(String label, String code) {
this.label = label;
this.code = code;
}
@Column(nullable=false)
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Column(nullable=false)
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Boolean getSensitive() {
return sensitive;
}
public void setSensitive(Boolean sensitive) {
this.sensitive = sensitive;
}
public Boolean getEnabled() {
return enabled;
}
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
/**
* 返回当前分类的 Project 个数
* @return size
*/
@Transient
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
@Transient
public Long getParentId() {
if(parentId==null && parent!=null) {
parentId = parent.getId();
}
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="parent_id")
public ProjectCategory getParent() {
return parent;
}
public void setParent(ProjectCategory parent) {
this.parent = parent;
}
@OneToMany(mappedBy="parent")
public List<ProjectCategory> getChildren() {
return children;
}
public void setChildren(List<ProjectCategory> children) {
this.children = children;
}
}
| [
"shengang1978@hotmail.com"
] | shengang1978@hotmail.com |
4667667a8a20e51d68eab4508778379d21553322 | ce5a0e41ef1779b6b6aae12e6e9773c49edbca67 | /src/main/java/com/zwf/cms/util/BinaryUploaderFtp.java | f3967c5b65db14de71ae6572b564e33897657264 | [] | no_license | zhwfybcx/zwfcms | 2a4413895b63f5712a236e1df2572facafde1942 | d4d3fda97e59d1788ba307677185ebdaa4768858 | refs/heads/master | 2021-06-17T14:36:02.403619 | 2017-06-12T06:08:05 | 2017-06-12T06:08:05 | 57,208,560 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,512 | java | package com.zwf.cms.util;
import com.baidu.ueditor.PathFormat;
import com.baidu.ueditor.define.AppInfo;
import com.baidu.ueditor.define.BaseState;
import com.baidu.ueditor.define.FileType;
import com.baidu.ueditor.define.State;
import com.baidu.ueditor.upload.StorageManager;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Created by dell on 2017/3/26.
*/
public class BinaryUploaderFtp {
public static final State save(HttpServletRequest request,
Map<String, Object> conf) {
boolean isAjaxUpload = request.getHeader("X_Requested_With") != null;
if (!ServletFileUpload.isMultipartContent(request)) {
return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT);
}
ServletFileUpload upload = new ServletFileUpload(
new DiskFileItemFactory());
if (isAjaxUpload) {
upload.setHeaderEncoding("UTF-8");
}
try {
/*MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile file = multipartRequest.getFile("upfile");*/
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Iterator iter = multipartRequest.getFileNames();
MultipartFile file = null;
while (iter.hasNext()) {
file=multipartRequest.getFile(iter.next().toString());
}
// FileItemIterator iter = multipartRequest.getFileNames();
// FileItemIterator iterator = upload.getItemIterator(request);
//
// while (iterator.hasNext()) {
// fileStream = iterator.next();
//
// if (!fileStream.isFormField())
// break;
// fileStream = null;
// }
//
// if (fileStream == null) {
// return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
// }
String savePath = (String) conf.get("savePath");
String originFileName = file.getOriginalFilename();
String suffix = FileType.getSuffixByFilename(originFileName);
originFileName = originFileName.substring(0,
originFileName.length() - suffix.length());
savePath = savePath + suffix;
long maxSize = ((Long) conf.get("maxSize")).longValue();
if (!validType(suffix, (String[]) conf.get("allowFiles"))) {
return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
}
savePath = PathFormat.parse(savePath, originFileName);
String physicalPath = (String) conf.get("rootPath") + savePath;
InputStream is = file.getInputStream();
State storageState = StorageManager.saveFileByInputStream(is,
physicalPath, maxSize);
is.close();
FTPService ftemp = new FTPService();
String s = ftemp.uploadFile(System.currentTimeMillis()+ suffix, physicalPath);
// 删除上传本地文件(暂时这样写)
File fileDel = new File(physicalPath);
File fileParent = new File(fileDel.getParent());
fileDel.delete();
fileParent.delete();
//判定是否上传成功
PropertyPlaceholder propertyPlaceholder = new PropertyPlaceholder();
if (storageState.isSuccess()) {
/*storageState.putInfo("url", "http://files.maidoupo.com/ccfile/" + s);*/
storageState.putInfo("url", propertyPlaceholder.getProperty("cms.ftp")+ s);
storageState.putInfo("type", suffix);
storageState.putInfo("original", originFileName + suffix);
}
return storageState;
} catch (IOException e) {
return new BaseState(false, AppInfo.IO_ERROR);
}
}
private static boolean validType(String type, String[] allowTypes) {
List<String> list = Arrays.asList(allowTypes);
return list.contains(type);
}
}
| [
"zhwf.ybcx.chn@gmail.com"
] | zhwf.ybcx.chn@gmail.com |
5d368c6e8375fe6548843c70b52640c9381184f3 | accff7fe3dfff09ce904bc3bbe185b41f4a57f71 | /src/main/java/org/chinalbs/logistics/cache/DictMapper.java | 9723b47412353db02afca3f4fc84b81de8be6f4b | [] | no_license | wangyiran125/huaxing | 6fae74b3c0e27863e6675dc9e3e68a70ce84cf56 | 2b531aa58d713306fae49ba09d5c9fc483bc73bc | refs/heads/master | 2021-01-10T01:37:50.095847 | 2015-05-29T02:36:30 | 2015-05-29T02:36:30 | 36,478,552 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,403 | java | package org.chinalbs.logistics.cache;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.chinalbs.logistics.service.DictService;
import org.springframework.stereotype.Component;
@Component
public class DictMapper {
private static DictService dictService;
@Resource
public void setDictService(DictService dictService) {
DictMapper.dictService = dictService;
}
public static DictService getDictService() {
return dictService;
}
private static DictMapper instance;
private Map<String, List<?>> dictContent;
private long lastUpdateTime;
private DictMapper() {
}
public static synchronized DictMapper getInstance() {
if (null == instance) {
instance = new DictMapper();
instance.init();
}
return instance;
}
public void init() {
if (dictContent == null) {
//DictService dictService = SpringFactory.getBean("dictService");
dictContent = dictService.findAllDict();
setLastUpdateTime(new Date().getTime());
}
}
public Map<String, List<?>> getDictContent() {
return dictContent;
}
public void setDictContent(Map<String, List<?>> dictContent) {
this.dictContent = dictContent;
}
public long getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(long lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
}
| [
"wangyiran125@icloud.com"
] | wangyiran125@icloud.com |
6fbe11fdcec4a94fee092d9016b40a6157e26b01 | deb2a0db1646ce35bfe653d449675bc637314b9c | /app/src/main/java/com/alaa/efhmhaw3eshha/AboutusApp.java | 83c0d1faf14cd32dd1f5075ac1e8ef8734f0ee8e | [] | no_license | alaaramadan996/EfhmhaW3eshha | 2bea1d70404ebd94d57407c61de227e7cdaab286 | aa350da4527b78f8e72be73a339b9f3b632a7e1b | refs/heads/master | 2020-08-02T21:17:59.417086 | 2019-10-05T09:37:30 | 2019-10-05T09:37:30 | 211,510,416 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,606 | java | package com.alaa.efhmhaw3eshha;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link AboutusApp.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link AboutusApp#newInstance} factory method to
* create an instance of this fragment.
*/
public class AboutusApp extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public AboutusApp() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment AboutusApp.
*/
// TODO: Rename and change types and number of parameters
public static AboutusApp newInstance(String param1, String param2) {
AboutusApp fragment = new AboutusApp();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_aboutus_app, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
| [
"alaaramadan996@gmail.com"
] | alaaramadan996@gmail.com |
f6b06d8c57574fc0aa42e6e1e187649bc363327a | cf207a23f3c258d1d514d901b38874ee67319fac | /src/model/operation/Sing.java | 1c0d75464cd7eb2015c56abe6021e2705d63856c | [] | no_license | Vectorrrr/JavaFirst | e0936345f4b7709ae1ad28052fafcd869f011b02 | b8011d4f235b424fdca3e98548c29eae95d0ab4f | refs/heads/master | 2016-08-12T10:20:46.265044 | 2016-02-24T11:23:45 | 2016-02-24T11:23:45 | 51,815,167 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 357 | java | package model.operation;
/**
* Created by igladush on 17.02.16.
* Interface for all sings which whant to be recognized in
* input stream in CalculationService
* @see logic.service.CalcService
* @author Gladush Ivan
*/
public interface Sing {
int MAX_PRIORY = 100000;
int MIN_PRIORY = -100000;
int getPriory();
String getSing();
}
| [
"gladush97@gmail.com"
] | gladush97@gmail.com |
ec4c74fcdc171941dd3249d7092dc66ac4af645e | d85028f6a7c72c6e6daa1dd9c855d4720fc8b655 | /io/netty/handler/ssl/ReferenceCountedOpenSslClientContext.java | 62017383bf37a4632b0374c8751b53ffd70fc4b2 | [] | no_license | RavenLeaks/Aegis-src-cfr | 85fb34c2b9437adf1631b103f555baca6353e5d5 | 9815c07b0468cbba8d1efbfe7643351b36665115 | refs/heads/master | 2022-10-13T02:09:08.049217 | 2020-06-09T15:31:27 | 2020-06-09T15:31:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,467 | java | /*
* Decompiled with CFR <Could not determine version>.
*
* Could not load the following classes:
* io.netty.internal.tcnative.CertificateCallback
* io.netty.internal.tcnative.CertificateVerifier
* io.netty.internal.tcnative.SSLContext
*/
package io.netty.handler.ssl;
import io.netty.handler.ssl.ApplicationProtocolConfig;
import io.netty.handler.ssl.CipherSuiteFilter;
import io.netty.handler.ssl.ClientAuth;
import io.netty.handler.ssl.OpenSsl;
import io.netty.handler.ssl.OpenSslCachingX509KeyManagerFactory;
import io.netty.handler.ssl.OpenSslEngineMap;
import io.netty.handler.ssl.OpenSslKeyMaterialManager;
import io.netty.handler.ssl.OpenSslKeyMaterialProvider;
import io.netty.handler.ssl.OpenSslSessionContext;
import io.netty.handler.ssl.OpenSslX509KeyManagerFactory;
import io.netty.handler.ssl.ReferenceCountedOpenSslClientContext;
import io.netty.handler.ssl.ReferenceCountedOpenSslContext;
import io.netty.internal.tcnative.CertificateCallback;
import io.netty.internal.tcnative.CertificateVerifier;
import io.netty.internal.tcnative.SSLContext;
import io.netty.util.internal.SuppressJava6Requirement;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSessionContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509ExtendedTrustManager;
import javax.net.ssl.X509TrustManager;
public final class ReferenceCountedOpenSslClientContext
extends ReferenceCountedOpenSslContext {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(ReferenceCountedOpenSslClientContext.class);
private static final Set<String> SUPPORTED_KEY_TYPES = Collections.unmodifiableSet(new LinkedHashSet<String>(Arrays.asList("RSA", "DH_RSA", "EC", "EC_RSA", "EC_EC")));
private final OpenSslSessionContext sessionContext;
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
ReferenceCountedOpenSslClientContext(X509Certificate[] trustCertCollection, TrustManagerFactory trustManagerFactory, X509Certificate[] keyCertChain, PrivateKey key, String keyPassword, KeyManagerFactory keyManagerFactory, Iterable<String> ciphers, CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, String[] protocols, long sessionCacheSize, long sessionTimeout, boolean enableOcsp, String keyStore) throws SSLException {
super(ciphers, (CipherSuiteFilter)cipherFilter, (ApplicationProtocolConfig)apn, (long)sessionCacheSize, (long)sessionTimeout, (int)0, (Certificate[])keyCertChain, (ClientAuth)ClientAuth.NONE, (String[])protocols, (boolean)false, (boolean)enableOcsp, (boolean)true);
boolean success = false;
try {
this.sessionContext = ReferenceCountedOpenSslClientContext.newSessionContext((ReferenceCountedOpenSslContext)this, (long)this.ctx, (OpenSslEngineMap)this.engineMap, (X509Certificate[])trustCertCollection, (TrustManagerFactory)trustManagerFactory, (X509Certificate[])keyCertChain, (PrivateKey)key, (String)keyPassword, (KeyManagerFactory)keyManagerFactory, (String)keyStore);
success = true;
return;
}
finally {
if (!success) {
this.release();
}
}
}
@Override
public OpenSslSessionContext sessionContext() {
return this.sessionContext;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
static OpenSslSessionContext newSessionContext(ReferenceCountedOpenSslContext thiz, long ctx, OpenSslEngineMap engineMap, X509Certificate[] trustCertCollection, TrustManagerFactory trustManagerFactory, X509Certificate[] keyCertChain, PrivateKey key, String keyPassword, KeyManagerFactory keyManagerFactory, String keyStore) throws SSLException {
if (key == null) {
if (keyCertChain != null) throw new IllegalArgumentException((String)"Either both keyCertChain and key needs to be null or none of them");
}
if (key != null && keyCertChain == null) {
throw new IllegalArgumentException((String)"Either both keyCertChain and key needs to be null or none of them");
}
OpenSslKeyMaterialProvider keyMaterialProvider = null;
try {
Object ks;
try {
if (!OpenSsl.useKeyManagerFactory()) {
if (keyManagerFactory != null) {
throw new IllegalArgumentException((String)"KeyManagerFactory not supported");
}
if (keyCertChain != null) {
ReferenceCountedOpenSslClientContext.setKeyMaterial((long)ctx, (X509Certificate[])keyCertChain, (PrivateKey)key, (String)keyPassword);
}
} else {
if (keyManagerFactory == null && keyCertChain != null) {
char[] keyPasswordChars = ReferenceCountedOpenSslClientContext.keyStorePassword((String)keyPassword);
ks = ReferenceCountedOpenSslClientContext.buildKeyStore((X509Certificate[])keyCertChain, (PrivateKey)key, (char[])keyPasswordChars, (String)keyStore);
keyManagerFactory = ((KeyStore)ks).aliases().hasMoreElements() ? new OpenSslX509KeyManagerFactory() : new OpenSslCachingX509KeyManagerFactory((KeyManagerFactory)KeyManagerFactory.getInstance((String)KeyManagerFactory.getDefaultAlgorithm()));
keyManagerFactory.init((KeyStore)ks, (char[])keyPasswordChars);
keyMaterialProvider = ReferenceCountedOpenSslClientContext.providerFor((KeyManagerFactory)keyManagerFactory, (String)keyPassword);
} else if (keyManagerFactory != null) {
keyMaterialProvider = ReferenceCountedOpenSslClientContext.providerFor((KeyManagerFactory)keyManagerFactory, (String)keyPassword);
}
if (keyMaterialProvider != null) {
OpenSslKeyMaterialManager materialManager = new OpenSslKeyMaterialManager((OpenSslKeyMaterialProvider)keyMaterialProvider);
SSLContext.setCertificateCallback((long)ctx, (CertificateCallback)new OpenSslClientCertificateCallback((OpenSslEngineMap)engineMap, (OpenSslKeyMaterialManager)materialManager));
}
}
}
catch (Exception e) {
throw new SSLException((String)"failed to set certificate and key", (Throwable)e);
}
SSLContext.setVerify((long)ctx, (int)1, (int)10);
try {
if (trustCertCollection != null) {
trustManagerFactory = ReferenceCountedOpenSslClientContext.buildTrustManagerFactory((X509Certificate[])trustCertCollection, (TrustManagerFactory)trustManagerFactory, (String)keyStore);
} else if (trustManagerFactory == null) {
trustManagerFactory = TrustManagerFactory.getInstance((String)TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init((KeyStore)((KeyStore)null));
}
X509TrustManager manager = ReferenceCountedOpenSslClientContext.chooseTrustManager((TrustManager[])trustManagerFactory.getTrustManagers());
ReferenceCountedOpenSslClientContext.setVerifyCallback((long)ctx, (OpenSslEngineMap)engineMap, (X509TrustManager)manager);
}
catch (Exception e) {
if (keyMaterialProvider == null) throw new SSLException((String)"unable to setup trustmanager", (Throwable)e);
keyMaterialProvider.destroy();
throw new SSLException((String)"unable to setup trustmanager", (Throwable)e);
}
OpenSslClientSessionContext context = new OpenSslClientSessionContext((ReferenceCountedOpenSslContext)thiz, (OpenSslKeyMaterialProvider)keyMaterialProvider);
keyMaterialProvider = null;
ks = context;
return ks;
}
finally {
if (keyMaterialProvider != null) {
keyMaterialProvider.destroy();
}
}
}
@SuppressJava6Requirement(reason="Guarded by java version check")
private static void setVerifyCallback(long ctx, OpenSslEngineMap engineMap, X509TrustManager manager) {
if (ReferenceCountedOpenSslClientContext.useExtendedTrustManager((X509TrustManager)manager)) {
SSLContext.setCertVerifyCallback((long)ctx, (CertificateVerifier)new ExtendedTrustManagerVerifyCallback((OpenSslEngineMap)engineMap, (X509ExtendedTrustManager)((X509ExtendedTrustManager)manager)));
return;
}
SSLContext.setCertVerifyCallback((long)ctx, (CertificateVerifier)new TrustManagerVerifyCallback((OpenSslEngineMap)engineMap, (X509TrustManager)manager));
}
static /* synthetic */ InternalLogger access$000() {
return logger;
}
static /* synthetic */ Set access$100() {
return SUPPORTED_KEY_TYPES;
}
}
| [
"emlin2021@gmail.com"
] | emlin2021@gmail.com |
6039760012b112c79b855d4cedabc980261da3df | 2a2fac022e627c36a6e772747ae2da1e63a4ab6c | /src/main/java/co/kenrg/mega/backend/compilation/subcompilers/BooleanInfixExpressionCompiler.java | b99abde03d1a75ef71f89ebd932b1340c8385837 | [] | no_license | kengorab/mega-jvm | 81114904c67601b4278617dd75c6bc41a4ed58d1 | 83e9802bcf96b9686764bcedf7910e366b4c013a | refs/heads/master | 2021-09-07T16:22:19.604078 | 2018-02-26T02:28:44 | 2018-02-26T02:28:44 | 114,555,665 | 1 | 0 | null | 2018-02-21T01:03:46 | 2017-12-17T17:33:16 | Java | UTF-8 | Java | false | false | 10,582 | java | package co.kenrg.mega.backend.compilation.subcompilers;
import static co.kenrg.mega.backend.compilation.TypesAndSignatures.getInternalName;
import static co.kenrg.mega.backend.compilation.TypesAndSignatures.jvmDescriptor;
import static org.objectweb.asm.Opcodes.FCMPG;
import static org.objectweb.asm.Opcodes.FCMPL;
import static org.objectweb.asm.Opcodes.GOTO;
import static org.objectweb.asm.Opcodes.I2F;
import static org.objectweb.asm.Opcodes.ICONST_0;
import static org.objectweb.asm.Opcodes.ICONST_1;
import static org.objectweb.asm.Opcodes.IFEQ;
import static org.objectweb.asm.Opcodes.IFGE;
import static org.objectweb.asm.Opcodes.IFGT;
import static org.objectweb.asm.Opcodes.IFLE;
import static org.objectweb.asm.Opcodes.IFLT;
import static org.objectweb.asm.Opcodes.IFNE;
import static org.objectweb.asm.Opcodes.IF_ICMPEQ;
import static org.objectweb.asm.Opcodes.IF_ICMPGE;
import static org.objectweb.asm.Opcodes.IF_ICMPGT;
import static org.objectweb.asm.Opcodes.IF_ICMPLE;
import static org.objectweb.asm.Opcodes.IF_ICMPLT;
import static org.objectweb.asm.Opcodes.IF_ICMPNE;
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
import java.util.function.Consumer;
import co.kenrg.mega.backend.compilation.scope.Scope;
import co.kenrg.mega.frontend.ast.expression.InfixExpression;
import co.kenrg.mega.frontend.ast.iface.Node;
import co.kenrg.mega.frontend.typechecking.types.MegaType;
import co.kenrg.mega.frontend.typechecking.types.PrimitiveTypes;
import org.objectweb.asm.Label;
/**
* Represents a "sub-compiler" which is specialized to generate JVM bytecode for Boolean Infix Expressions
* (such as && and ||) as well as Comparison Expressions (e.g. <, <=, >, >=, ==, and !=).
*/
public class BooleanInfixExpressionCompiler {
public static void compileConditionalAndExpression(InfixExpression node, Scope scope, Consumer<Node> compileNode) {
Label condEndLabel = new Label();
Label condFalseLabel = new Label();
compileNode.accept(node.left);
scope.focusedMethod.writer.visitJumpInsn(IFEQ, condFalseLabel);
compileNode.accept(node.right);
scope.focusedMethod.writer.visitJumpInsn(IFEQ, condFalseLabel);
scope.focusedMethod.writer.visitInsn(ICONST_1);
scope.focusedMethod.writer.visitJumpInsn(GOTO, condEndLabel);
scope.focusedMethod.writer.visitLabel(condFalseLabel);
scope.focusedMethod.writer.visitInsn(ICONST_0);
scope.focusedMethod.writer.visitLabel(condEndLabel);
}
public static void compileConditionalOrExpression(InfixExpression node, Scope scope, Consumer<Node> compileNode) {
Label condEndLabel = new Label();
Label condTrueLabel = new Label();
Label condFalseLabel = new Label();
compileNode.accept(node.left);
scope.focusedMethod.writer.visitJumpInsn(IFNE, condTrueLabel);
compileNode.accept(node.right);
scope.focusedMethod.writer.visitJumpInsn(IFEQ, condFalseLabel);
scope.focusedMethod.writer.visitLabel(condTrueLabel);
scope.focusedMethod.writer.visitInsn(ICONST_1);
scope.focusedMethod.writer.visitJumpInsn(GOTO, condEndLabel);
scope.focusedMethod.writer.visitLabel(condFalseLabel);
scope.focusedMethod.writer.visitInsn(ICONST_0);
scope.focusedMethod.writer.visitLabel(condEndLabel);
}
public static void compileComparisonExpression(InfixExpression node, Scope scope, Consumer<Node> compileNode) {
MegaType leftType = node.left.getType();
assert leftType != null;
MegaType rightType = node.right.getType();
assert rightType != null;
if (PrimitiveTypes.NUMBER.isEquivalentTo(leftType) && PrimitiveTypes.NUMBER.isEquivalentTo(rightType)) {
if (leftType == PrimitiveTypes.INTEGER && rightType == PrimitiveTypes.INTEGER) {
pushIntegerComparison(node, scope, compileNode);
} else if (leftType == PrimitiveTypes.FLOAT || rightType == PrimitiveTypes.FLOAT) {
pushFloatComparison(node, scope, compileNode);
}
} else if (leftType == PrimitiveTypes.BOOLEAN && rightType == PrimitiveTypes.BOOLEAN) {
pushIntegerComparison(node, scope, compileNode);
} else {
pushComparableComparison(node, scope, compileNode);
}
}
private static void pushIntegerComparison(InfixExpression node, Scope scope, Consumer<Node> compileNode) {
Label trueLabel = new Label();
Label endLabel = new Label();
compileNode.accept(node.left);
compileNode.accept(node.right);
switch (node.operator) {
case "<":
scope.focusedMethod.writer.visitJumpInsn(IF_ICMPLT, trueLabel);
break;
case "<=":
scope.focusedMethod.writer.visitJumpInsn(IF_ICMPLE, trueLabel);
break;
case ">":
scope.focusedMethod.writer.visitJumpInsn(IF_ICMPGT, trueLabel);
break;
case ">=":
scope.focusedMethod.writer.visitJumpInsn(IF_ICMPGE, trueLabel);
break;
case "==":
scope.focusedMethod.writer.visitJumpInsn(IF_ICMPEQ, trueLabel);
break;
case "!=":
scope.focusedMethod.writer.visitJumpInsn(IF_ICMPNE, trueLabel);
break;
}
scope.focusedMethod.writer.visitInsn(ICONST_0);
scope.focusedMethod.writer.visitJumpInsn(GOTO, endLabel);
scope.focusedMethod.writer.visitLabel(trueLabel);
scope.focusedMethod.writer.visitInsn(ICONST_1);
scope.focusedMethod.writer.visitLabel(endLabel);
}
private static void pushFloatComparison(InfixExpression node, Scope scope, Consumer<Node> compileNode) {
MegaType leftType = node.left.getType();
assert leftType != null;
compileNode.accept(node.left);
if (!leftType.isEquivalentTo(PrimitiveTypes.FLOAT)) {
scope.focusedMethod.writer.visitInsn(I2F);
}
MegaType rightType = node.right.getType();
assert rightType != null;
compileNode.accept(node.right);
if (!rightType.isEquivalentTo(PrimitiveTypes.FLOAT)) {
scope.focusedMethod.writer.visitInsn(I2F);
}
Label trueLabel = new Label();
Label endLabel = new Label();
switch (node.operator) {
case "<":
scope.focusedMethod.writer.visitInsn(FCMPL);
scope.focusedMethod.writer.visitJumpInsn(IFLT, trueLabel);
break;
case "<=":
scope.focusedMethod.writer.visitInsn(FCMPL);
scope.focusedMethod.writer.visitJumpInsn(IFLE, trueLabel);
break;
case ">":
scope.focusedMethod.writer.visitInsn(FCMPG);
scope.focusedMethod.writer.visitJumpInsn(IFGT, trueLabel);
break;
case ">=":
scope.focusedMethod.writer.visitInsn(FCMPG);
scope.focusedMethod.writer.visitJumpInsn(IFGE, trueLabel);
break;
case "==":
scope.focusedMethod.writer.visitInsn(FCMPL);
scope.focusedMethod.writer.visitJumpInsn(IFEQ, trueLabel);
break;
case "!=":
scope.focusedMethod.writer.visitInsn(FCMPL);
scope.focusedMethod.writer.visitJumpInsn(IFNE, trueLabel);
break;
}
scope.focusedMethod.writer.visitInsn(ICONST_0);
scope.focusedMethod.writer.visitJumpInsn(GOTO, endLabel);
scope.focusedMethod.writer.visitLabel(trueLabel);
scope.focusedMethod.writer.visitInsn(ICONST_1);
scope.focusedMethod.writer.visitLabel(endLabel);
}
private static void pushComparableComparison(InfixExpression node, Scope scope, Consumer<Node> compileNode) {
compileNode.accept(node.left);
compileNode.accept(node.right);
MegaType leftType = node.left.getType(); // Left type chosen arbitrarily
assert leftType != null;
String jvmDescriptor = jvmDescriptor(leftType, false);
String signature = String.format("(%s)I", jvmDescriptor);
String className = getInternalName(leftType);
if (className == null) {
System.out.printf("Expected type %s to have a class name\n", leftType);
className = getInternalName(PrimitiveTypes.ANY);
}
Label trueLabel = new Label();
Label endLabel = new Label();
switch (node.operator) {
case "<":
scope.focusedMethod.writer.visitMethodInsn(INVOKEVIRTUAL, className, "compareTo", signature, false);
scope.focusedMethod.writer.visitJumpInsn(IFLT, trueLabel);
break;
case "<=":
scope.focusedMethod.writer.visitMethodInsn(INVOKEVIRTUAL, className, "compareTo", signature, false);
scope.focusedMethod.writer.visitJumpInsn(IFLE, trueLabel);
break;
case ">":
scope.focusedMethod.writer.visitMethodInsn(INVOKEVIRTUAL, className, "compareTo", signature, false);
scope.focusedMethod.writer.visitJumpInsn(IFGT, trueLabel);
break;
case ">=":
scope.focusedMethod.writer.visitMethodInsn(INVOKEVIRTUAL, className, "compareTo", signature, false);
scope.focusedMethod.writer.visitJumpInsn(IFGE, trueLabel);
break;
case "==":
// The `equals` method places a boolean on the top of the stack; call the method and return early
scope.focusedMethod.writer.visitMethodInsn(INVOKEVIRTUAL, className, "equals", "(Ljava/lang/Object;)Z", false);
return;
case "!=":
// If the comparison is (!=), call the `equals` method. If `equals` returns 0 (false), negate
// by jumping to the true label.
scope.focusedMethod.writer.visitMethodInsn(INVOKEVIRTUAL, className, "equals", "(Ljava/lang/Object;)Z", false);
scope.focusedMethod.writer.visitJumpInsn(IFEQ, trueLabel);
break;
}
scope.focusedMethod.writer.visitInsn(ICONST_0);
scope.focusedMethod.writer.visitJumpInsn(GOTO, endLabel);
scope.focusedMethod.writer.visitLabel(trueLabel);
scope.focusedMethod.writer.visitInsn(ICONST_1);
scope.focusedMethod.writer.visitLabel(endLabel);
}
}
| [
"ken.gorab@gmail.com"
] | ken.gorab@gmail.com |
122dfe9f1f2914c7da6be0cffcd22c55656d9fb5 | 1f0065c8607a75742af862cf052d7af13fe10161 | /Test/src/com/pankaj/pattern/Pattern3.java | 1b1b03a3b7e39f93f1134319c051d91793231061 | [] | no_license | pathdf/POCs | f222ea82e9f88c29cd4e6cc765c37dad8091fd97 | 428ed65372725e4319e42677eaf2d461d3545a8d | refs/heads/master | 2020-03-28T10:23:56.018014 | 2018-10-02T03:59:23 | 2018-10-02T04:02:06 | 148,105,201 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 774 | java | package com.pankaj.pattern;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Pattern3 {
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int testCase = Integer.parseInt(br.readLine());
for(int t=1;t<=testCase;t++)
{
String[] arguments = br.readLine().split(" ");
int n1 = Integer.parseInt(arguments[0]);
int n2 = Integer.parseInt(arguments[1]);
for(int i=0;i<n1*3+1;i++)
{
for(int j=0;j<n2*3+1;j++)
{
if(i%3==0 || j%3==0)
System.out.print("*");
else
System.out.print(".");
}
System.out.println();
}
}
}
}
| [
"emailpankajchauhan@gmail.com"
] | emailpankajchauhan@gmail.com |
b46ad0e398488a08598596df68ab5c482cf993a1 | a5ec63b862a6d76547f2457ec26f394ed679b503 | /src/main/java/com/kilopo/kosshop/service/OrderProductService.java | 96efc3941da3dcf7b78c39860fd53f9de1de8f76 | [] | no_license | kilopowq/7520studie | e2ecbb2791a894d07ab4b808a6d5fee88773af79 | a678cc533905ca9989aeddffc87dc41a4e9b8f4e | refs/heads/develop | 2022-12-21T22:25:16.787477 | 2019-08-03T17:55:26 | 2019-09-25T20:00:18 | 110,587,341 | 0 | 9 | null | 2022-12-16T04:51:37 | 2017-11-13T18:46:24 | Java | UTF-8 | Java | false | false | 78 | java | package com.kilopo.kosshop.service;
public interface OrderProductService {
}
| [
"33636001+Pasha7520@users.noreply.github.com"
] | 33636001+Pasha7520@users.noreply.github.com |
9a9ab12e25d3d2f0d6c8f6be091ff4f646405180 | 703f1652e0f16420647161cc39ba5a196b9ef318 | /jafu/src/test/java/org/springframework/fu/jafu/r2dbc/R2dbcDslTest.java | 9e4c3844e1005b18a5384ef3c60fdd0421441e52 | [
"Apache-2.0"
] | permissive | spring-projects-experimental/spring-fu | 8531f6899a17a2f90890ee88f473c0e14de4bae2 | c41806b1429dc31f75e2cb0f69ddd51a0bd8e9da | refs/heads/main | 2023-08-19T00:51:15.424795 | 2022-04-05T14:43:48 | 2022-04-05T14:43:48 | 134,733,282 | 703 | 93 | Apache-2.0 | 2023-08-07T08:40:32 | 2018-05-24T15:16:16 | Java | UTF-8 | Java | false | false | 7,897 | java | package org.springframework.fu.jafu.r2dbc;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.query.Criteria;
import org.springframework.data.relational.core.query.Query;
import org.springframework.r2dbc.core.DatabaseClient;
import org.springframework.transaction.reactive.TransactionalOperator;
import org.testcontainers.containers.GenericContainer;
import org.wildfly.common.Assert;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.UUID;
import static org.springframework.fu.jafu.Jafu.application;
import static org.springframework.fu.jafu.r2dbc.R2dbcDsl.r2dbc;
class R2dbcDslTest {
@Test
public void enableR2dbcWithH2Embedded(@TempDir Path tempDir) throws IOException {
var dbPath = tempDir.resolve("test.db");
Files.createFile(dbPath);
var app = application(a -> {
a.enable(r2dbc(r2dbcDsl -> r2dbcDsl.url("r2dbc:h2:file:///" + dbPath.toAbsolutePath())));
a.beans(beans -> beans.bean(R2dbcTestDataRepository.class));
});
var context = app.run();
var repository = context.getBean(R2dbcTestDataRepository.class);
StepVerifier.create(
repository.getClient().sql("CREATE TABLE users (id UUID PRIMARY KEY, name VARCHAR(255));").then()
.then(repository.save(dataUser))
.then(repository.findOne(dataUser.id)))
.expectNext(dataUser)
.verifyComplete();
context.close();
}
@Test
public void enableR2dbcWithH2EmbeddedWithTransaction(@TempDir Path tempDir) throws IOException {
var dbPath = tempDir.resolve("test.db");
Files.createFile(dbPath);
var app = application(a -> {
a.enable(r2dbc(r2dbcDsl -> {
r2dbcDsl.url("r2dbc:h2:file:///" + dbPath.toAbsolutePath());
r2dbcDsl.transactional(true);
}));
a.beans(beans -> beans.bean(R2dbcTestDataRepository.class));
});
var context = app.run();
var repository = context.getBean(R2dbcTestDataRepository.class);
var transactional = context.getBean(TransactionalOperator.class);
Assertions.assertNotNull(transactional);
StepVerifier.create(
transactional.transactional(
repository.getClient().sql("CREATE TABLE users (id UUID PRIMARY KEY, name VARCHAR(255));").then()
.then(repository.save(dataUser))
.then(repository.findOne(dataUser.id))))
.expectNext(dataUser)
.verifyComplete();
context.close();
}
@Test
public void enableR2dbcWithPostgres() throws IOException {
var pg = new GenericContainer("postgres:13")
.withExposedPorts(5432)
.withEnv("POSTGRES_USER", "jo")
.withEnv("POSTGRES_PASSWORD", "pwd")
.withEnv("POSTGRES_DB", "db");
pg.start();
var app = application(a -> {
a.enable(r2dbc(r2dbcDsl -> {
r2dbcDsl.url("r2dbc:postgresql://" + pg.getContainerIpAddress() + ":" + pg.getFirstMappedPort() + "/db");
r2dbcDsl.username("jo");
r2dbcDsl.password("pwd");
}));
a.beans(beans -> beans.bean(R2dbcTestDataRepository.class));
});
var context = app.run();
var repository = context.getBean(R2dbcTestDataRepository.class);
Assert.assertNotNull(repository);
StepVerifier.create(
repository.getClient().sql("CREATE TABLE users (id UUID PRIMARY KEY, name VARCHAR(255));").then()
.then(repository.save(dataUser))
.then(repository.findOne(dataUser.id)))
.expectNext(dataUser)
.verifyComplete();
context.close();
pg.close();
}
@Test
public void enableR2dbcWithPostgresWithTransaction() throws IOException {
var pg = new GenericContainer("postgres:13")
.withExposedPorts(5432)
.withEnv("POSTGRES_USER", "jo")
.withEnv("POSTGRES_PASSWORD", "pwd")
.withEnv("POSTGRES_DB", "db");
pg.start();
var app = application(a -> {
a.enable(r2dbc(r2dbcDsl -> {
r2dbcDsl.url("r2dbc:postgresql://" + pg.getContainerIpAddress() + ":" + pg.getFirstMappedPort() + "/db");
r2dbcDsl.username("jo");
r2dbcDsl.password("pwd");
r2dbcDsl.transactional(true);
}));
a.beans(beans -> beans.bean(R2dbcTestDataRepository.class));
});
var context = app.run();
var repository = context.getBean(R2dbcTestDataRepository.class);
var transactional = context.getBean(TransactionalOperator.class);
Assert.assertNotNull(transactional);
StepVerifier.create(
transactional.transactional(
repository.getClient().sql("CREATE TABLE users (id UUID PRIMARY KEY, name VARCHAR(255));").then()
.then(repository.save(dataUser))
.then(repository.findOne(dataUser.id))))
.expectNext(dataUser)
.verifyComplete();
context.close();
pg.close();
}
private static TestData dataUser = new TestData(UUID.randomUUID(), "foo");
public static class R2dbcTestDataRepository {
private final DatabaseClient client;
public R2dbcTestDataRepository(DatabaseClient client) {
this.client = client;
}
public DatabaseClient getClient() {
return client;
}
public Mono<Integer> save(TestData newUser) {
return client.sql("INSERT INTO users(id, name) VALUES(:id, :name)")
.bind("id", newUser.id)
.bind("name", newUser.name)
.fetch()
.rowsUpdated();
}
public Mono<TestData> findOne(UUID id) {
return client.sql("SELECT * FROM users WHERE id = :id")
.bind("id", id)
.map(row -> new TestData(row.get("id", UUID.class), row.get("name", String.class)))
.one();
}
}
private static class TestData {
@Id
private UUID id;
private String name;
public TestData() {
}
public TestData(UUID id, String name) {
this.id = id;
this.name = name;
}
public UUID getId() {
return id;
}
public TestData setId(UUID id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public TestData setName(String name) {
this.name = name;
return this;
}
@Override
public String toString() {
return "TestDataUser{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TestData that = (TestData) o;
return Objects.equals(id, that.id) &&
Objects.equals(name, that.name);
}
@Override
public int hashCode() {
return Objects.hash(id, name);
}
}
} | [
"francois.teychene@gmail.com"
] | francois.teychene@gmail.com |
dcedafd78a2497b17208aed5d3939924833ecd4f | 9b91a5411844b471a47a7409a900809316fdf572 | /hadoop-demo/hdfs_api/src/main/java/online/tengxing/hdfs/URLCat.java | 016d5f9055e8f02f1bfef606de3573424b2400b9 | [] | no_license | tengxing/hadoop | a0cda5d9b25959d79c13602d4f21e91a2dedec4a | c34cba211fa14ce92e747196c8c27f99789e32be | refs/heads/master | 2020-07-03T09:36:56.132599 | 2016-11-19T01:58:56 | 2016-11-19T01:58:56 | 74,180,413 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 881 | java | package online.tengxing.hdfs;
import org.apache.hadoop.fs.FsUrlStreamHandlerFactory;
import org.apache.hadoop.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.StringTokenizer;
/**
*使用Hadoop URL读取数据
*
* Created by tengxing on 16-11-15.
* mail tengxing7452@163.com
*/
public class URLCat {
static {
URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
}
public static void readHdfs(String url) throws Exception {
InputStream in = null;
try {
in = new URL(url).openStream();
IOUtils.copyBytes(in, System.out, 4096, false);
} finally {
IOUtils.closeStream(in);
}
}
public static void main(String[] args) throws Exception {
readHdfs("hdfs://localhost:9000/user/tengxing/input/dd");
}
}
| [
"tengxing7452@163.com"
] | tengxing7452@163.com |
6f9e1c3137791b16d90c5bc4a0c31bb2c04a9a61 | f24f61c5053ec9198fd00e7745d0556b82505143 | /src/logic/servlet/AddEvaluationServlet.java | 2480c0d6bbe21bc9a2f56553626aaaec5e3003b2 | [] | no_license | g3lbin/Netbooks | 770cb11fc184c213a8ea5e602beb03206523cf26 | 57efad17277aad63d2800e7f25a07d750372cf89 | refs/heads/master | 2023-03-21T03:13:25.561861 | 2020-06-08T20:15:32 | 2020-06-08T20:15:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,206 | java | package logic.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import logic.bean.BookBean;
import logic.bean.BookEvaluationBean;
import logic.bean.ReaderBean;
import logic.controller.buybooksystem.BuyBookSystem;
import logic.exception.PersistencyException;
import logic.exception.WrongSyntaxException;
import logic.util.WebUtilities;
/**
* Servlet utilizata per l'aggiunta di una valutazione di un libro.<br>
*
* Tipo di richiesta: <b>POST</b>
* @author Simone Tiberi (M. 0252795)
*
*/
@WebServlet("/AddEvaluationServlet")
public class AddEvaluationServlet extends HttpServlet {
private static final long serialVersionUID = 3511019712143005757L;
public AddEvaluationServlet() {
super();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (request.getSession().getAttribute("currUser") == null) {
response.sendRedirect(WebUtilities.LOGIN_PAGE_URL.substring(1));
return;
}
try {
BookEvaluationBean evalBean = new BookEvaluationBean();
BookBean bookBean = new BookBean();
evalBean.setRate(Integer.valueOf(request.getParameter("rate")));
evalBean.setTitle(request.getParameter("revTitle"));
evalBean.setBody(request.getParameter("revBody"));
bookBean.setIsbn(request.getParameter("isbn"));
BuyBookSystem.getInstance().addNewEvaluation(evalBean, bookBean, new ReaderBean((String) request.getSession().getAttribute("currUser")));
request.setAttribute("result", "success");
request.getRequestDispatcher(WebUtilities.EVALUATE_BOOK_PAGE_URL).forward(request, response);
} catch (PersistencyException e) {
WebUtilities.redirectToErrorPage(request, response, e.getMessage());
} catch (WrongSyntaxException e) {
request.setAttribute("wrongsyntax", e.getMessage());
request.getRequestDispatcher(WebUtilities.ADD_EVALUATION_PAGE_URL).forward(request, response);
}
}
}
| [
"56643248+tibwere@users.noreply.github.com"
] | 56643248+tibwere@users.noreply.github.com |
2b54c95b4855aea6f593805ed92ee1326fa30086 | 8389cc9dc26cd9e4292608d93877b0686884049e | /Queues and Lists/DynamicListMain.java | 5f9db3983f0f1d70fbf0f7567d73b48b14da1ed1 | [] | no_license | juancoariza/Data-Structures | 2644da8f98c3fb59c94122ed1d70d313c4f5f941 | f61ff58023f71d0b6d63b6290b9010b9cb584939 | refs/heads/master | 2020-04-28T23:27:08.077843 | 2019-03-14T16:25:37 | 2019-03-14T16:25:37 | 175,655,631 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,583 | java | /**
* DynamicListMain.java Juan Ariza 2/20/2019 Main class and tester for DynamicList and DynamicNode
* classes
*/
package Test2;
public class DynamicListMain {
public static void main(String args[]) {
DynamicList newList1 = new DynamicList();
newList1.insertFirst(7);
newList1.insertFirst(2);
newList1.insertFirst(1);
System.out.println("List 1:");
newList1.print();
DynamicList newList2 = new DynamicList();
newList2.insertFirst(5);
newList2.insertFirst(4);
System.out.println("List 2:");
newList2.print();
DynamicList newList3 = new DynamicList();
newList3.insertFirst('f');
newList3.insertFirst('d');
newList3.insertFirst('s');
newList3.insertFirst('a');
newList3.insertFirst('q');
// KNOWN BUG: appended lists do not parse correctly through the deleteMind() method
System.out.println("Appending List 2 to List 1...");
newList1.appendList(newList2);
newList2.reverse(newList2);
System.out.println("Deleting mid of list 1...");
newList1.deleteMid();
newList3.print();
newList3.swap(1, 3);
/*
System.out.println("Deleting mid of list 3...");
newList3.deleteMid();
*/
// empty list demonstration
DynamicList emptyList = new DynamicList();
System.out.println("Empty list:");
emptyList.print();
System.out.println("Displaying 3rd element...");
newList3.displayNth(3);
System.out.println("Reversing empty list...");
emptyList.reverse(emptyList);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
be3b82bd4a9896dd28c4b7591c5dfa78b87f7bbc | 7365486ccb6a868ef7fbe5591a0f83927f8c8448 | /UCF/Practice2015/09122015/JV/greetings.java | 2312ee819b2545022730396edb80339b77d9f2d1 | [] | no_license | Mario0419/Competitive-Programming-Problems | 6b9d14b947ecf9ff1c3ff48a10c712cb34c38f12 | a65d0d11997d70d9e1cfb662a71980e9121195ed | refs/heads/master | 2021-01-23T15:07:53.106947 | 2015-10-06T02:51:41 | 2015-10-06T02:51:41 | 42,023,963 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,365 | java | import java.util.*;
public class greetings{
greetings(){
Scanner input = new Scanner(System.in);
int T = input.nextInt();
for(int cse = 0; cse < T; cse++){
int B = input.nextInt();
int E = input.nextInt();
int[] b = new int[B];
int[] e = new int[E];
int sumB = 0;
int sumE = 0;
for(int i = 0; i < b.length; i++){
int temp = input.nextInt();
String d = input.next();
if(d.equals("L"))
temp *= -1;
b[i] = temp;
sumB += Math.abs(b[i]);
}
for(int i = 0; i < e.length; i++){
int temp = input.nextInt();
String d = input.next();
if(d.equals("L"))
temp *= -1;
e[i] = temp;
sumE += Math.abs(e[i]);
}
int max = Math.max(sumB, sumE);
b = getTime(b, max);
e = getTime(e, max);
int ans = 0;
for(int i = 1; i < e.length && i < b.length; i++){
if(b[i] == e[i] && b[i-1] != e[i-1])
ans++;
}
System.out.println(ans);
}
}
int[] getTime(int[] array, int value){
int[] arr = new int[value + 1];
int index = 1;
for(int i = 0; i < array.length; i++){
int step = array[i] > 0 ? 1 : -1;
for(int j = 0; j < Math.abs(array[i]); j++, index++)
arr[index] = arr[index-1] + step;
}
while(index < arr.length){
arr[index] = arr[index-1];
index++;
}
return arr;
}
public static void main(String[] args){
new greetings();
}
} | [
"mario.massad@gmail.com"
] | mario.massad@gmail.com |
f9fa635d7e2bc582cfb08addbed259aaf9dcb271 | 6cd4bc0cc0152339ddb62673ba2ef265d49b87f3 | /src/it/algos/base/campo/logica/CLElenco.java | 91a3f4e614d439bb03aa5fed2d608ed840f3b99e | [] | no_license | algos-soft/cinquestelle | aa45513dc881e1f416d9a9478aa7b84e16862ffb | ae73ac4e925ae0fea5d975c875c885b35fa3ad6d | refs/heads/master | 2023-06-08T12:44:33.534035 | 2021-07-01T16:58:34 | 2021-07-01T16:58:34 | 382,099,945 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,119 | java | /**
* Title: CLElenco.java
* Package: it.algos.base.campo.logica
* Description:
* Copyright: Copyright (c) 2003
* Company: Algos s.r.l.
* @author Guido Andrea Ceresa & Alessandro Valbonesi / gac
* @version 1.0 /
* Creato: il 22 luglio 2003 alle 19.48
*/
package it.algos.base.campo.logica;
import it.algos.base.campo.base.Campo;
import it.algos.base.campo.dati.CampoDati;
import it.algos.base.campo.db.CDBLinkato;
import it.algos.base.errore.Errore;
import java.util.ArrayList;
/**
* Questa classe concreta e' responsabile di: <br>
* A - Regolare le funzionalita dei rapporti interni dei Campi <br>
* B - Viene usata insieme alla classe CDElenco <br>
*
* @author Guido Andrea Ceresa & Alessandro Valbonesi / gac
* @version 1.0 / 22 luglio 2003 ore 19.48
*/
public final class CLElenco extends CLBase {
/**
* Costruttore base senza parametri <br>
* Indispensabile anche se non viene utilizzato
* (anche solo per compilazione in sviluppo) <br>
* Rimanda al costruttore completo utilizzando eventuali valori di default
*/
public CLElenco() {
/** rimanda al costruttore di questa classe */
this(null);
} /* fine del metodo costruttore base */
/**
* Costruttore completo
*
* @param unCampoParente campo 'contenitore' di questo oggetto
*/
public CLElenco(Campo unCampoParente) {
/** rimanda al costruttore della superclasse */
super(unCampoParente);
/** regolazioni iniziali di riferimenti e variabili */
try { // prova ad eseguire il codice
this.inizia();
} catch (Exception unErrore) { // intercetta l'errore
/** messaggio di errore */
Errore.crea(unErrore);
} /* fine del blocco try-catch */
} /* fine del metodo costruttore completo */
/**
* Regolazioni iniziali di riferimenti e variabili <br>
* Metodo chiamato direttamente dal costruttore <br>
*
* @throws Exception unaEccezione
*/
private void inizia() throws Exception {
} /* fine del metodo inizia */
/**
* Regolazioni iniziali <i>una tantum</i>.
* </p>
* Metodo chiamato dalla classe che crea questo oggetto <br>
* Viene eseguito una sola volta <br>
*/
public void inizializza() {
/* invoca il metodo sovrascritto della superclasse */
super.inizializza();
} /* fine del metodo */
/**
* Regolazioni di avvio, ogni volta che questo oggetto deve 'ripartire', per
* essere sicuri che sia 'pulito' <br>
* Metodo chiamato da altre classi <br>
* Viene eseguito tutte le volte che necessita <br>
*/
public void avvia() {
/** invoca il metodo sovrascritto della superclasse */
super.avvia();
} /* fine del metodo */
/**
* carica dal database una lista di valori e la mette nel modello dati
*
* @deprecated
*/
private void caricaLista() {
/** variabili e costanti locali di lavoro */
ArrayList unaLista = null;
CampoDati unCampoDati = null;
CDBLinkato unCampoDBLinkato = null;
//@todo da cancellare
try { // prova ad eseguire il codice
/* recupera il campo DB specializzato */
unCampoDBLinkato = (CDBLinkato)unCampoParente.getCampoDB();
/* recupera la lista dal campo DB */
unaLista = unCampoDBLinkato.caricaLista();
/* recupera il campo dati */
unCampoDati = unCampoParente.getCampoDati();
/* registra i valori nel modello dei dati del campo */
if (unaLista != null) {
unCampoDati.setValoriInterni(unaLista);
// unCampoDatiElenco.regolaElementiAggiuntivi();
} /* fine del blocco if */
} catch (Exception unErrore) { // intercetta l'errore
/* mostra il messaggio di errore */
Errore.crea(unErrore);
} /* fine del blocco try-catch */
} /* fine del metodo */
}// fine della classe
| [
"algos12"
] | algos12 |
29fd22c3d246b461d3d609e3c7d3fd2d5ca07db2 | 10a3195436f2ec8fc3509d7d0b526d24e213f5de | /src/com/trilead/ssh2/DHGexParameters.java | 1afe9be0ae638ef2a6cf412bbab1c4c86e685c0b | [] | no_license | balangandio/java-http-injector | afb3c469019953015d2d06f6e8ea2b5a57a75c2f | 5a83f0d72520f81b7a6ad8e30ad689de9ed28de1 | refs/heads/master | 2021-07-12T04:57:05.624111 | 2020-08-06T21:00:17 | 2020-08-06T21:00:17 | 177,001,530 | 3 | 3 | null | null | null | null | UTF-8 | Java | false | false | 3,614 | java | package com.trilead.ssh2;
/**
* A <code>DHGexParameters</code> object can be used to specify parameters for
* the diffie-hellman group exchange.
* <p>
* Depending on which constructor is used, either the use of a
* <code>SSH_MSG_KEX_DH_GEX_REQUEST</code> or
* <code>SSH_MSG_KEX_DH_GEX_REQUEST_OLD</code> can be forced.
*
* @see Connection#setDHGexParameters(DHGexParameters)
* @author Christian Plattner, plattner@trilead.com
* @version $Id: DHGexParameters.java,v 1.1 2007/10/15 12:49:56 cplattne Exp $
*/
public class DHGexParameters {
private final int min_group_len;
private final int pref_group_len;
private final int max_group_len;
private static final int MIN_ALLOWED = 1024;
private static final int MAX_ALLOWED = 8192;
/**
* Same as calling {@link #DHGexParameters(int, int, int)
* DHGexParameters(1024, 1024, 4096)}. This is also the default used by the
* Connection class.
*
*/
public DHGexParameters() {
this(1024, 1024, 4096);
}
/**
* This constructor can be used to force the sending of a
* <code>SSH_MSG_KEX_DH_GEX_REQUEST_OLD</code> request. Internally, the
* minimum and maximum group lengths will be set to zero.
*
* @param pref_group_len
* has to be >= 1024 and <= 8192
*/
public DHGexParameters(int pref_group_len) {
if ((pref_group_len < MIN_ALLOWED) || (pref_group_len > MAX_ALLOWED))
throw new IllegalArgumentException("pref_group_len out of range!");
this.pref_group_len = pref_group_len;
this.min_group_len = 0;
this.max_group_len = 0;
}
/**
* This constructor can be used to force the sending of a
* <code>SSH_MSG_KEX_DH_GEX_REQUEST</code> request.
* <p>
* Note: older OpenSSH servers don't understand this request, in which case
* you should use the {@link #DHGexParameters(int)} constructor.
* <p>
* All values have to be >= 1024 and <= 8192. Furthermore,
* min_group_len <= pref_group_len <= max_group_len.
*
* @param min_group_len
* @param pref_group_len
* @param max_group_len
*/
public DHGexParameters(int min_group_len, int pref_group_len,
int max_group_len) {
if ((min_group_len < MIN_ALLOWED) || (min_group_len > MAX_ALLOWED))
throw new IllegalArgumentException("min_group_len out of range!");
if ((pref_group_len < MIN_ALLOWED) || (pref_group_len > MAX_ALLOWED))
throw new IllegalArgumentException("pref_group_len out of range!");
if ((max_group_len < MIN_ALLOWED) || (max_group_len > MAX_ALLOWED))
throw new IllegalArgumentException("max_group_len out of range!");
if ((pref_group_len < min_group_len)
|| (pref_group_len > max_group_len))
throw new IllegalArgumentException(
"pref_group_len is incompatible with min and max!");
if (max_group_len < min_group_len)
throw new IllegalArgumentException(
"max_group_len must not be smaller than min_group_len!");
this.min_group_len = min_group_len;
this.pref_group_len = pref_group_len;
this.max_group_len = max_group_len;
}
/**
* Get the maximum group length.
*
* @return the maximum group length, may be <code>zero</code> if
* SSH_MSG_KEX_DH_GEX_REQUEST_OLD should be requested
*/
public int getMax_group_len() {
return max_group_len;
}
/**
* Get the minimum group length.
*
* @return minimum group length, may be <code>zero</code> if
* SSH_MSG_KEX_DH_GEX_REQUEST_OLD should be requested
*/
public int getMin_group_len() {
return min_group_len;
}
/**
* Get the preferred group length.
*
* @return the preferred group length
*/
public int getPref_group_len() {
return pref_group_len;
}
}
| [
"universo42.01@gmail.com"
] | universo42.01@gmail.com |
da49e4064f77dc38f5ea7be5c81126aa55465672 | 4d6457b70cb87424814ed9632e4e5d954f58854c | /Framework4/src/dataBaseTest/SelectDataBase.java | 7a70bc48fbd48c9695115d13abc18bba8210e03e | [] | no_license | bandisreekanth/MyProjects | 812b38ff4dc471f0dd0be473ab56b41624e17680 | 586f6c3268f3d689d3e5c97b80bc34ae793ce1b0 | refs/heads/master | 2020-03-12T21:30:17.509190 | 2018-04-25T05:39:58 | 2018-04-25T05:39:58 | 130,829,522 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 931 | java | package dataBaseTest;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class SelectDataBase {
public String select_db(String query) throws SQLException
{
String dbURL = "jdbc:sqlserver://192.168.84.78;integratedSecurity=true;databaseName=icici_shg";
String user = "KARVY\\sreekath.bandi";
String pass = "";
String abc="";
String query_field[]=query.split("-");
System.out.println("Query is :"+query_field[0]);
System.out.println("Field is :"+query_field[1]);
Connection conn = DriverManager.getConnection(dbURL,user,pass);
if (conn != null) {
System.out.println("Connected");
}
else
{
System.out.println("Not Connected");
}
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery(query_field[0]);
while(rs.next())
{
abc=rs.getString(query_field[1]);
}
return abc;
}
}
| [
"bandi.sreekanth@gmail.com"
] | bandi.sreekanth@gmail.com |
947a987865362f7bf2e1207e9bd4dae99caa9b64 | 37e8bf8bc67516720e528fe8f2e4485fe3a24050 | /app/src/main/java/net/jspiner/knowyourkid/ui/food/FoodActivity.java | cb2ea23a80ed314f628b6c6e832c3d580fc94059 | [] | no_license | smith-prnd/know-your-kids | 52890e678fa42e0abbacce183a1a275715eabf54 | 7da1048f3c1579c9552b921aab6840a0a4b75e1a | refs/heads/master | 2021-07-20T18:18:32.405133 | 2017-10-30T08:18:49 | 2017-10-30T08:18:49 | 108,821,727 | 1 | 0 | null | 2017-10-30T08:22:34 | 2017-10-30T08:22:34 | null | UTF-8 | Java | false | false | 784 | java | package net.jspiner.knowyourkid.ui.food;
import android.os.Bundle;
import android.support.annotation.Nullable;
import net.jspiner.knowyourkid.R;
import net.jspiner.knowyourkid.databinding.ActivityFoodBinding;
import net.jspiner.knowyourkid.ui.base.BaseActivity;
public class FoodActivity extends BaseActivity<ActivityFoodBinding> {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_food);
init();
}
private void init() {
setSupportActionBar(binding.toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setTitle("Food");
}
}
| [
"jspiner@naver.com"
] | jspiner@naver.com |
ecead74a336e91b6828b75b3f051db2d87fa3c1e | 4c57b8e6a89d44d41a63b32b820d63a7706e3a3f | /src/main/java/org/IPCcoinj/core/listeners/AbstractPeerDataEventListener.java | 4a09bb01a35674c69b49f83103e5ef128caa2e4b | [] | no_license | Rui2guo/ipccoinj | 5f360e74397e9a009459a37950a7f0ed6c07cfb3 | c03f6c68793d3182cf7d7875c36bed6e5a67dde4 | refs/heads/master | 2022-12-07T12:04:54.118382 | 2018-10-29T07:30:59 | 2018-10-29T07:30:59 | 155,169,776 | 0 | 0 | null | 2022-11-16T04:50:22 | 2018-10-29T07:29:33 | Java | UTF-8 | Java | false | false | 1,432 | java | /*
* Copyright 2011 Google Inc.
*
* 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.IPCcoinj.core.listeners;
import org.IPCcoinj.core.*;
import javax.annotation.*;
import java.util.*;
/**
* Deprecated: implement the more specific event listener interfaces instead to fill out only what you need
*/
@Deprecated
public abstract class AbstractPeerDataEventListener implements PeerDataEventListener {
@Override
public void onBlocksDownloaded(Peer peer, Block block, @Nullable FilteredBlock filteredBlock, int blocksLeft) {
}
@Override
public void onChainDownloadStarted(Peer peer, int blocksLeft) {
}
@Override
public Message onPreMessageReceived(Peer peer, Message m) {
// Just pass the message right through for further processing.
return m;
}
@Override
public List<Message> getData(Peer peer, GetDataMessage m) {
return null;
}
}
| [
"guorui.an@okcoin.com"
] | guorui.an@okcoin.com |
330e7a15c7348e84e4b0db8043dc676cd63126a1 | 82c996fe7a45f3de39cabed2563db6f5333da992 | /src/test/java/com/private_void/core/entities/plates/CurvedPlateTest.java | a580356b28b5eb344c53832d8abc6b2d0048d4a3 | [] | no_license | eakurnikov/CapStruct | da58e6f4e837100e46f08bc243e41bf9a06c5511 | 99a89a42fe0bb37084b77c68a522953c6fd9b682 | refs/heads/master | 2021-09-20T19:44:27.326263 | 2018-08-14T18:27:12 | 2018-08-14T18:27:12 | 90,776,080 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,806 | java | package com.private_void.core.entities.plates;
import com.private_void.core.math.geometry.space_3D.coordinates.Point3D;
import com.private_void.core.math.geometry.space_3D.coordinates.SphericalPoint;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class CurvedPlateTest {
@Test
public void isCapillarCoordinateValid() {
double capillarRadius = 7.0;
double curvRadius = 1_000.0;
double pointRadius = Math.atan(capillarRadius / curvRadius);
Point3D[] coordinates = new Point3D[5];
coordinates[0] = new SphericalPoint(curvRadius, 0.0, 0.0); //false
coordinates[1] = new SphericalPoint(curvRadius, pointRadius, 0.0); //false
coordinates[2] = new SphericalPoint(curvRadius, 2.0 * pointRadius, 0.0); //true
coordinates[3] = new SphericalPoint(curvRadius, 2.0 * pointRadius, 2.0 * pointRadius); //true
coordinates[4] = new SphericalPoint(curvRadius, Math.PI, Math.PI); //true
Point3D coordinate = new SphericalPoint(curvRadius, 0.0, 0.0);
boolean[] result = {false, false, true, true, true};
int i = 0;
while (i < coordinates.length && coordinates[i] != null) {
boolean isPointValid = true;
if ((coordinate.getQ2() - coordinates[i].getQ2()) * (coordinate.getQ2() - coordinates[i].getQ2())
+ (coordinate.getQ3() - coordinates[i].getQ3()) * (coordinate.getQ3() - coordinates[i].getQ3())
< 4.0 * pointRadius * pointRadius) {
isPointValid = false;
}
result[i] = isPointValid;
i++;
}
assertTrue(!result[0]);
assertTrue(!result[1]);
assertTrue(result[2]);
assertTrue(result[3]);
assertTrue(result[4]);
}
} | [
"e.kurnikov94@gmail.com"
] | e.kurnikov94@gmail.com |
e6515c2781d7fc220b90cf2f968aa3da3484b465 | d9d7bf3d0dca265c853cb58c251ecae8390135e0 | /gcld/src/com/reign/kf/comm/entity/kfwd/response/KfwdOK.java | a1639ca84bf970b2791a261aa8d81be95a224046 | [] | no_license | Crasader/workspace | 4da6bd746a3ae991a5f2457afbc44586689aa9d0 | 28e26c065a66b480e5e3b966be4871b44981b3d8 | refs/heads/master | 2020-05-04T21:08:49.911571 | 2018-11-19T08:14:27 | 2018-11-19T08:14:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 452 | java | package com.reign.kf.comm.entity.kfwd.response;
import java.io.*;
public class KfwdOK implements Serializable
{
private static final long serialVersionUID = 1L;
private String info;
public KfwdOK() {
}
public KfwdOK(final String info) {
this.info = info;
}
public String getInfo() {
return this.info;
}
public void setInfo(final String info) {
this.info = info;
}
}
| [
"359569198@qq.com"
] | 359569198@qq.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.