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
c0be4b793fa21e81db6edf2e93496b410c56127e
d4a43908d161b258da8dcaf8a157a640cddd46bb
/src/test/java/cz/jollysoft/songenricher/AppTest.java
35a6f618ef33854fc75477544f1d63f421c44807
[]
no_license
evaapavel/songenricher
ad755c4dc4ecd000c02344fdbd5e73838728d4b8
1182da27f9abc1a575c8d76a8b861348e5c88020
refs/heads/master
2021-07-23T17:27:56.786743
2019-12-20T17:12:32
2019-12-20T17:12:32
223,108,942
0
0
null
2020-10-13T17:37:38
2019-11-21T06:57:50
Java
UTF-8
Java
false
false
653
java
package cz.jollysoft.songenricher; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Unit test for simple App. */ public class AppTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ public AppTest( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( AppTest.class ); } /** * Rigourous Test :-) */ public void testApp() { assertTrue( true ); } }
[ "pfoltyn@newps.cz" ]
pfoltyn@newps.cz
7abe2be5154091fdeb86ebbd09695e59c640348f
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/15/15_ec2d39e514429f676d3a7cb4ad623396213f319e/UICallBackManager/15_ec2d39e514429f676d3a7cb4ad623396213f319e_UICallBackManager_s.java
c634a5a3b0333086d95f87abbf27081d191b8af4
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
6,730
java
/******************************************************************************* * Copyright (c) 2007, 2011 Innoopract Informationssysteme GmbH. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Innoopract Informationssysteme GmbH - initial API and implementation * EclipseSource - ongoing development ******************************************************************************/ package org.eclipse.rwt.internal.lifecycle; import java.io.IOException; import java.util.HashSet; import java.util.Set; import javax.servlet.http.HttpServletResponse; import org.eclipse.rwt.SessionSingletonBase; import org.eclipse.rwt.internal.service.ContextProvider; import org.eclipse.rwt.internal.util.SerializableLock; import org.eclipse.rwt.service.*; import org.eclipse.swt.internal.SerializableCompatibility; public final class UICallBackManager implements SerializableCompatibility { private static final int DEFAULT_REQUEST_CHECK_INTERVAL = 30000; private static final String FORCE_UI_CALLBACK = UICallBackManager.class.getName() + "#forceUICallBack"; private static class UnblockSessionStoreListener implements SessionStoreListener, SerializableCompatibility { private transient final Thread currentThread; private UnblockSessionStoreListener( Thread currentThread ) { this.currentThread = currentThread; } public void beforeDestroy( SessionStoreEvent event ) { currentThread.interrupt(); } } public static UICallBackManager getInstance() { return ( UICallBackManager )SessionSingletonBase.getInstance( UICallBackManager.class ); } private final IdManager idManager; // synchronization object to control access to the runnables List final SerializableLock lock; // contains a reference to the callback request thread that is currently // blocked. private final Set<Thread> blockedCallBackRequests; // Flag that indicates whether a request is processed. In that case no // notifications are sent to the client. private boolean uiThreadRunning; // Flag that indicates that a notification was sent to the client. If the new // callback thread returns earlier than the UI Thread the callback thread // must be blocked although the runnables are not empty private boolean waitForUIThread; // indicates whether the display has runnables to execute private boolean hasRunnables; private boolean wakeCalled; private int requestCheckInterval; private UICallBackManager() { lock = new SerializableLock(); idManager = new IdManager(); blockedCallBackRequests = new HashSet<Thread>(); uiThreadRunning = false; waitForUIThread = false; wakeCalled = false; requestCheckInterval = DEFAULT_REQUEST_CHECK_INTERVAL; } public boolean isCallBackRequestBlocked() { synchronized( lock ) { return !blockedCallBackRequests.isEmpty(); } } public void wakeClient() { synchronized( lock ) { if( !uiThreadRunning ) { releaseBlockedRequest(); } } } public void releaseBlockedRequest() { synchronized( lock ) { wakeCalled = true; lock.notifyAll(); } } public void setHasRunnables( boolean hasRunnables ) { synchronized( lock ) { this.hasRunnables = hasRunnables; } if( hasRunnables && isUICallBackActive() ) { ContextProvider.getStateInfo().setAttribute( FORCE_UI_CALLBACK, Boolean.TRUE ); } } public void setRequestCheckInterval( int requestCheckInterval ) { this.requestCheckInterval = requestCheckInterval; } void notifyUIThreadStart() { synchronized( lock ) { uiThreadRunning = true; waitForUIThread = false; } } void notifyUIThreadEnd() { synchronized( lock ) { uiThreadRunning = false; if( hasRunnables ) { wakeClient(); } } } boolean hasRunnables() { synchronized( lock ) { return hasRunnables; } } void blockCallBackRequest() { synchronized( lock ) { if( blockedCallBackRequests.isEmpty() && mustBlockCallBackRequest() ) { Thread currentThread = Thread.currentThread(); SessionStoreListener listener = new UnblockSessionStoreListener( currentThread ); ISessionStore sessionStore = ContextProvider.getSession(); sessionStore.addSessionStoreListener( listener ); blockedCallBackRequests.add( currentThread ); try { boolean keepWaiting = true; wakeCalled = false; while( !wakeCalled && keepWaiting ) { lock.wait( requestCheckInterval ); keepWaiting = mustBlockCallBackRequest() && isConnectionAlive( ContextProvider.getResponse() ); } } catch( InterruptedException ie ) { Thread.interrupted(); // Reset interrupted state, see bug 300254 } finally { blockedCallBackRequests.remove( currentThread ); sessionStore.removeSessionStoreListener( listener ); } } waitForUIThread = true; } } private static boolean isConnectionAlive( HttpServletResponse response ) { boolean result; try { JavaScriptResponseWriter responseWriter = new JavaScriptResponseWriter( response ); responseWriter.write( " " ); result = !responseWriter.checkError(); } catch( IOException ioe ) { result = false; } return result; } boolean mustBlockCallBackRequest() { boolean prevent = !waitForUIThread && !uiThreadRunning && hasRunnables; boolean isActive = !idManager.isEmpty(); return isActive && !prevent; } boolean isUICallBackActive() { return !idManager.isEmpty(); } public void activateUICallBacksFor( final String id ) { idManager.add( id ); } public void deactivateUICallBacksFor( final String id ) { int size = idManager.remove( id ); if( size == 0 ) { releaseBlockedRequest(); } } public boolean needsActivation() { boolean result; if( isCallBackRequestBlocked() ) { result = false; } else { result = isUICallBackActive() || forceUICallBackForPendingRunnables(); } return result; } private static boolean forceUICallBackForPendingRunnables() { return Boolean.TRUE.equals( ContextProvider.getStateInfo().getAttribute( FORCE_UI_CALLBACK ) ); } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
5db68404b5a029b263f5747dd346fc39ad062c96
7809ae469c47873ae0f292a6a52ae9dd391dc9dd
/ah3/src/se/sics/ah3/old/History.java
1e2fdd64d5d0f893d2ab977ca3742d5846afd6f2
[]
no_license
YixianChen/affectivehealthy
6ef39adc97a21c860c31a473c96e560cb1f916eb
0af0bb43e02ee4430b88596631c739ff1f595f3c
refs/heads/master
2016-09-08T02:06:02.649161
2014-06-09T15:00:18
2014-06-09T15:00:18
null
0
0
null
null
null
null
UTF-8
Java
false
false
22,061
java
package se.sics.ah3.old; import java.util.Date; import java.util.GregorianCalendar; import se.sics.ah3.Error; import android.content.ContentValues; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.graphics.Color; import android.util.Log; public class History implements IColorProvider, IMovementProvider, IBioDataProvider{ public static final String TABLE_NAME = "bioHistory"; //Column names public static final String ID = "id"; public static final String TIME = "timestamp"; public static final String AROUSAL = "arousal"; public static final String MOVEMENT = "movment"; public static final String PULSE = "pulse"; public static final String SYNC = "sync_status"; public static final String[] SERVER_VALS= {ID,TIME,AROUSAL,MOVEMENT,PULSE}; private static final float NO_DATA = 0; private static final long SECONDS_GRANULARITY = 1000; private static final float NO_COLOR = 0; public enum Channels {CAROUSAL, CMOVEMENT, CPULSE}; long mId; long mTimestamp; short mArousal; short mMovement; short mPulse; int mBufferSize; int mBufferPos; short[] mArousalBuffer; short[] mMovementBuffer; short[] mPulseBuffer; byte mSyncStatus; private boolean isInit; Date d; ColorMapper colorMapper = null; public History(DataStore _dataStore) { // TODO Auto-generated constructor stub isInit = false; colorMapper = new ColorMapper(); init(_dataStore.getWritableDatabase()); mBufferSize = 100; mMovementBuffer = new short[mBufferSize]; mArousalBuffer = new short[mBufferSize]; mPulseBuffer = new short[mBufferSize]; mBufferPos = 0; d = new Date(); mTimestamp = d.getTime(); mSyncStatus = 0; } public History(DataStore _dataStore, long id) { // TODO Auto-generated constructor stub isInit = false; colorMapper = new ColorMapper(); init(_dataStore.getWritableDatabase()); } public void setUpdateValue(short val, Channels chan) { switch(chan) { case CAROUSAL: mArousal = val; break; case CMOVEMENT: mMovement = val; break; case CPULSE: mPulse = val; break; default: break; } } public void setUpdateValues(short arousal, short movment, short pulse) { mTimestamp = d.getTime(); mArousal = arousal; mMovement = movment; mPulse = pulse; mSyncStatus = 0; } public void setCreateValues(GregorianCalendar date, short arousal2, short movement2, short pulse2) { mId = -1; d = date.getTime(); mTimestamp = date.getTimeInMillis(); mArousal = arousal2; mPulse = pulse2; mMovement = movement2; } public void setBufferdCreateValues(short arousal, short movment, short pulse, DataStore helper) { mId = -1; mTimestamp += 1000; mArousalBuffer[mBufferPos] = arousal; mMovementBuffer[mBufferPos] = movment; mPulseBuffer[mBufferPos] = pulse; mBufferPos++; if(mBufferPos == mBufferSize) saveBufferedToDb(helper); } void init(SQLiteDatabase db) { createTable(db); isInit = true; } public static int updateToDbByTime(DataStore helper,long timeStamp, short val, Channels chan) { ContentValues values = new ContentValues(); switch(chan) { case CAROUSAL: values.put(AROUSAL, val); break; case CMOVEMENT: values.put(MOVEMENT, val); break; case CPULSE: values.put(PULSE, val); break; default: break; } SQLiteDatabase db = helper.getWritableDatabase(); String whereStatement = TIME+"=?"; String[] whereArgs = {(""+timeStamp)}; int success = db.update(TABLE_NAME, values, whereStatement, whereArgs); if(success == 0) { //create new entry values.put(TIME, timeStamp); db.insert(TABLE_NAME, null, values); } return success; } public void saveToDb(DataStore helper) { ContentValues values = new ContentValues(); values.put(TIME, ""+getNowTimeStamp()); values.put(AROUSAL, mArousal); values.put(MOVEMENT, mMovement); values.put(PULSE, mPulse); SQLiteDatabase db = helper.getWritableDatabase(); if(!isInit)init(db); if(mId >= 0) { String[] whereArgs = {(""+mId)}; //try to update an existing trip int success = db.update(TABLE_NAME, values, "ID = ?", whereArgs); if(success > 0) return; } mId = db.insert(TABLE_NAME, null, values); } private long getNowTimeStamp() { Date d = new Date(); //get rid of milliseconds//commented out because we current algorithm can handle milliseconds; /*long timeInMilliSec = d.getTime()/1000; return timeInMilliSec*1000;*/ return d.getTime(); } public void saveBufferedToDb(DataStore helper) { mBufferPos = 0; SQLiteDatabase db = helper.getWritableDatabase(); if(!isInit) { init(db); } ContentValues values = new ContentValues(); for(int i = 0; i < mBufferSize; i++) { values.put(TIME, mTimestamp); values.put(AROUSAL, mArousal); values.put(MOVEMENT, mMovement); values.put(PULSE, mPulse); db.insert(TABLE_NAME, null, values); } } public void setValuesFromDbByTime(DataStore dataStore, long timeStamp) { SQLiteDatabase db = dataStore.getWritableDatabase(); String table = TABLE_NAME; String limitString = "1"; String whereClause = TIME + " = " + timeStamp ; Cursor c = db.query(table,null,whereClause,null,null,null,null,limitString); int numRows = c.getCount(); c.moveToFirst(); for(int i = 0; i < numRows; i ++) { mId = c.getLong(c.getColumnIndex(ID)); mMovement = c.getShort(c.getColumnIndex(MOVEMENT)); mArousal = c.getShort(c.getColumnIndex(AROUSAL)); mPulse = c.getShort(c.getColumnIndex(PULSE)); mSyncStatus = (byte)c.getInt(c.getColumnIndex(SYNC)); c.moveToNext(); } } @Override public float[] fillMovementBuffer(DataStore dataStore, int dataPos, int length) { SQLiteDatabase db = dataStore.getWritableDatabase(); float[] movement = new float[length*1*1]; //History.checkFill(length,db); String table = TABLE_NAME; String limitString = "" +(length); //String whereClause = ID + ">" + (dataPos-1) ; String whereClause = TIME + ">" + (dataPos-1) ; Cursor c = db.query(table,null,whereClause,null,null,null,null,limitString); int numRows = c.getCount(); //int numCols = c.getColumnCount(); int movementRaw = 0; float movementMapped = 0; c.moveToFirst(); for(int i = 0; i < numRows; i ++) { movementRaw = c.getInt(c.getColumnIndex(MOVEMENT)); movementMapped = NumberMapper.mapToFactor(movementRaw); movement[i] = movementMapped; //movement[i*2+1] = (float) (Color.green(color)/255.0); c.moveToNext(); } //fill rest of buffer with place holder for(int i = numRows; i < length; i++) { movement[i] = 0.0f; } c.close(); return movement; } @Override public float[] fillMovementBuffer(DataStore dataStore, int bufferLength, GregorianCalendar startTime, long granularity) { GregorianCalendar end = new GregorianCalendar(); end.setTimeInMillis(startTime.getTimeInMillis()+(bufferLength*granularity)); Log.d("AHBuffer", "filling movement buffer from: "+ startTime.getTime().toGMTString()+ " \n \t to: " + end.getTime().toGMTString()); return fillMovementBuffer(dataStore, bufferLength, startTime, end, granularity); } public float[] fillMovementBuffer(DataStore dataStore, int bufferLength, GregorianCalendar startTime, GregorianCalendar endTime, long granularity) { SQLiteDatabase db = dataStore.getWritableDatabase(); float[] movement = new float[bufferLength*1*1]; //History.checkFill(length,db); String table = TABLE_NAME; String limitString = "" +(bufferLength*5); //String whereClause = ID + ">" + (dataPos-1) ; String whereClause = TIME + " < " + endTime.getTimeInMillis() + " AND " + TIME + " >= " + startTime.getTimeInMillis(); String orderClause = TIME + " DESC" ; //TODO: find out why the where statement does not work! Cursor c = db.query(table,null,whereClause,null,null,null,orderClause,limitString); int numRows = c.getCount(); //int numCols = c.getColumnCount(); int movementRaw = 0; float movementMapped = 0; long timeStamp; int insertPosition = 0; c.moveToFirst(); for(int i = 0; i < numRows; i ++) { movementRaw = c.getInt(c.getColumnIndex(MOVEMENT)); movementMapped = NumberMapper.mapToFactor(movementRaw); timeStamp = c.getLong(c.getColumnIndex(TIME)); insertPosition = calculateInverseTimeDistance(endTime,timeStamp,SECONDS_GRANULARITY);//calculateTimeDistance(start,timeStamp,SECONDS_GRANULARITY); if(insertPosition >= 0 && insertPosition < bufferLength) movement[insertPosition] = movementMapped; //movement[i*2+1] = (float) (Color.green(color)/255.0); c.moveToNext(); } //fill rest of buffer with place holder for(int i = numRows; i < bufferLength; i++) { movement[i] = 0.0f; } c.close(); return movement; } @Override public boolean fillBioBuffer(DataStore dataStore, GregorianCalendar start, GregorianCalendar end, float[] arousalBuffer, float[] movementBuffer, float[] pulseBuffer) { int length = movementBuffer.length; SQLiteDatabase db = dataStore.getWritableDatabase(); String table = TABLE_NAME; String whereClause = TIME + " < " + end.getTimeInMillis() + " AND " + TIME + " >= " + start.getTimeInMillis(); String orderClause = TIME + " DESC" ; Cursor c = db.query(table,null,whereClause,null,null,null,orderClause,null); int numRows = c.getCount(); c.moveToFirst(); int bufferPosition = 0; int insertPosition = 0; long timeStamp = 0; Date date; int movementRaw = 0; float movementMapped = 0; int arousalRaw = 0; int arousalColor = 0; c.moveToFirst(); ColorMapper cm = new ColorMapper();//TODO: check if this should be a instance variable or a Singleton to speed up for(int i = 0; i < numRows; i ++) { movementRaw = c.getInt(c.getColumnIndex(MOVEMENT)); movementMapped = NumberMapper.mapToFactor(movementRaw); arousalRaw = c.getShort(c.getColumnIndex(AROUSAL)); arousalColor = cm.getErrorMapping(Error.NO_DATA); timeStamp = c.getLong(c.getColumnIndex(TIME)); insertPosition = calculateTimeDistance(start,timeStamp,SECONDS_GRANULARITY); for(; bufferPosition < insertPosition; bufferPosition++) { movementBuffer[bufferPosition] = NO_DATA; arousalBuffer[bufferPosition*8 + 0] = NO_COLOR; arousalBuffer[bufferPosition*8 + 1] = NO_COLOR; arousalBuffer[bufferPosition*8 + 2] = NO_COLOR; arousalBuffer[bufferPosition*8 + 3] = 1.0f; arousalBuffer[bufferPosition*8 + 4] = NO_COLOR; arousalBuffer[bufferPosition*8 + 5] = NO_COLOR; arousalBuffer[bufferPosition*8 + 6] = NO_COLOR; arousalBuffer[bufferPosition*8 + 7] = 0.5f; } movementBuffer[bufferPosition] = movementMapped; arousalBuffer[bufferPosition*8 + 0] = (float) (Color.red(arousalColor)/255.0); arousalBuffer[bufferPosition*8 + 1] = (float) (Color.green(arousalColor)/255.0); arousalBuffer[bufferPosition*8 + 2] = (float) (Color.blue(arousalColor)/255.0); arousalBuffer[bufferPosition*8 + 3] = 1.0f; arousalBuffer[bufferPosition*8 + 4] = (float) (Color.red(arousalColor)/255.0); arousalBuffer[bufferPosition*8 + 5] = (float) (Color.green(arousalColor)/255.0); arousalBuffer[bufferPosition*8 + 6] = (float) (Color.blue(arousalColor)/255.0); arousalBuffer[bufferPosition*8 + 7] = 1.0f; /*mArousal = c.getShort(c.getColumnIndex(AROUSAL)); mPulse = c.getShort(c.getColumnIndex(PULSE)); mSyncStatus = (byte)c.getInt(c.getColumnIndex(SYNC));*/ date = new Date(mTimestamp); c.moveToNext(); } //fill rest of buffer with place holder for(int i = insertPosition; i < length; i++) { movementBuffer[i] = NO_DATA; arousalBuffer[i*8 + 0] = NO_COLOR; arousalBuffer[i*8 + 1] = NO_COLOR; arousalBuffer[i*8 + 2] = NO_COLOR; arousalBuffer[i*8 + 3] = NO_COLOR; arousalBuffer[i*8 + 4] = NO_COLOR; arousalBuffer[i*8 + 5] = NO_COLOR; arousalBuffer[i*8 + 6] = NO_COLOR; arousalBuffer[i*8 + 7] = NO_COLOR; } c.close(); return true; } private int calculateTimeDistance(GregorianCalendar earlyTime, long timeStamp,long granularity) { long difference = timeStamp - earlyTime.getTimeInMillis(); int res = (int)(difference/granularity); return res; } private int calculateInverseTimeDistance(GregorianCalendar latestTime, long timeStamp,long granularity) { long difference = latestTime.getTimeInMillis()- timeStamp; int res = (int)(difference/granularity); return res; } public float[] fillArousalColorBuffer(DataStore dataStore, int dataPos, int length) { SQLiteDatabase db = dataStore.getWritableDatabase(); float[] colors = new float[length*4*2]; /* //History.checkFill(length,db); String table = TABLE_NAME; //String[] columns = Trip.ALL_COLUMNS; String limitString = "" +(length); String whereClause = ID + ">" + (dataPos-1) ; Cursor c = db.query(table,null,whereClause,null,null,null,null,limitString); int numRows = c.getCount(); //int numCols = c.getColumnCount(); int arousal = 0 ,g =0 ,b = 0; int color = 0; c.moveToFirst(); ColorMapper cm = new ColorMapper();//TODO: check if this should be a instance variable or a Singleton to speed up for(int i = 0; i < numRows; i ++) { arousal= c.getInt(c.getColumnIndex(AROUSAL)); color = cm.mapToColor(arousal);*/ /*for(int j = 0; j < numCols;j++) { if(c.getColumnName(j).equals(RED)) r = c.getInt(j); if(c.getColumnName(j).equals(GREEN)) g = c.getInt(j); if(c.getColumnName(j).equals(BLUE)) b = c.getInt(j); }*/ /* colors[i*8+0] = (float) (Color.red(color)/255.0); colors[i*8+1] = (float) (Color.green(color)/255.0); colors[i*8+2] = (float) (Color.blue(color)/255.0); colors[i*8+3] = 1.0f; colors[i*8+4] = (float) (Color.red(color)/255.0); colors[i*8+5] = (float) (Color.green(color)/255.0); colors[i*8+6] = (float) (Color.blue(color)/255.0); colors[i*8+7] = 1.0f; c.moveToNext(); } for(int i = numRows; i < length; i++) { color = cm.getErrorMapping(Error.NO_DATA); colors[i*8+0] = (float) (Color.red(color)/255.0); colors[i*8+1] = (float) (Color.green(color)/255.0); colors[i*8+2] = (float) (Color.blue(color)/255.0); colors[i*8+3] = 1.0f; colors[i*8+4] = (float) (Color.red(color)/255.0); colors[i*8+5] = (float) (Color.green(color)/255.0); colors[i*8+6] = (float) (Color.blue(color)/255.0); colors[i*8+7] = 1.0f; } c.close();*/ return colors; } public float[] fillArousalColorBuffer(DataStore dataStore, int length, GregorianCalendar earliestTime, long granularity) { GregorianCalendar latestTime = new GregorianCalendar(); latestTime.setTimeInMillis(earliestTime.getTimeInMillis()+(length*granularity)); Log.d("AHBuffer", "filling buffer from: "+ earliestTime.getTime().toGMTString()+ " \n \t to: " + latestTime.getTime().toGMTString()); return fillArousalColorBuffer(dataStore, length, earliestTime, latestTime, granularity); } public float[] fillArousalColorBuffer(DataStore dataStore, int length, long granularity, GregorianCalendar latestTime) { GregorianCalendar earliestTime = new GregorianCalendar(); earliestTime.setTimeInMillis(latestTime.getTimeInMillis()-(length*granularity)); Log.d("AHBuffer", "filling buffer from: "+ earliestTime.getTime().toGMTString()+ " \n \t to: " + latestTime.getTime().toGMTString()); return fillArousalColorBuffer(dataStore, length, earliestTime, latestTime, granularity); } public float[] mockFillArousalColorBuffer(DataStore dataStore, int length, GregorianCalendar earliestTime, GregorianCalendar latestTime, long granularity) { SQLiteDatabase db = dataStore.getWritableDatabase(); float[] colors = new float[length*4*2]; String table = TABLE_NAME; String whereClause = TIME + " < " + latestTime.getTimeInMillis() + " AND " + TIME + " >= " + earliestTime.getTimeInMillis(); String orderClause = TIME + " DESC" ; Cursor c = db.query(table,null,whereClause,null,null,null,orderClause,null); int numRows = c.getCount(); long timeStamp; int bufferPosition = 0; int insertPosition = 0; int arousal = 0 ,g =0 ,b = 0; int color = 0; c.moveToFirst(); ColorMapper cm = new ColorMapper();//TODO: check if this should be a instance variable or a Singleton to speed up for(int i = 0; i < numRows; i ++) { arousal= c.getInt(c.getColumnIndex(AROUSAL)); color = cm.mapToColor(arousal); timeStamp = c.getLong(c.getColumnIndex(TIME)); Date debug_d = new Date(timeStamp); String gmt = debug_d.toGMTString(); insertPosition = calculateInverseTimeDistance(latestTime, timeStamp, SECONDS_GRANULARITY); if(insertPosition < length) { bufferPosition++; } else { insertPosition = bufferPosition; } c.moveToNext(); } //debug mark start and end colors[0*8+0] = 1.0f; colors[0*8+1] = 0.0f; colors[0*8+2] = 0.0f; colors[0*8+3] = 1.0f; colors[(length-1)*8+2] = 1.0f; colors[(length-1)*8+3] = 1.0f; c.close(); return colors; } public float[] fillArousalColorBuffer(DataStore dataStore, int length, GregorianCalendar earliestTime, GregorianCalendar latestTime, long granularity) { SQLiteDatabase db = dataStore.getWritableDatabase(); float[] colors = new float[length*4*2]; String table = TABLE_NAME; String whereClause = TIME + " < " + latestTime.getTimeInMillis() + " AND " + TIME + " >= " + earliestTime.getTimeInMillis(); String orderClause = TIME + " DESC" ; Cursor c = db.query(table,null,whereClause,null,null,null,orderClause,null); int numRows = c.getCount(); long timeStamp; int bufferPosition = 0; int insertPosition = 0; int arousal = 0 ,g =0 ,b = 0; int color = 0; c.moveToFirst(); ColorMapper cm = new ColorMapper();//TODO: check if this should be a instance variable or a Singleton to speed up for(int i = 0; i < numRows; i ++) { arousal= c.getInt(c.getColumnIndex(AROUSAL)); color = cm.mapToColor(arousal); timeStamp = c.getLong(c.getColumnIndex(TIME)); //Date debug_d = new Date(timeStamp); //Log.d("AHColor", debug_d.toGMTString()+ " : " + color); //insertPosition = calculateInverseTimeDistance(end,timeStamp,SECONDS_GRANULARITY);//calculateTimeDistance(start,timeStamp,SECONDS_GRANULARITY); insertPosition = calculateInverseTimeDistance(latestTime, timeStamp, SECONDS_GRANULARITY); //Log.d("AHColor", debug_d.toGMTString()+ " : " + color + " : " + insertPosition + " / " + calculateInverseTimeDistance(end,timeStamp,SECONDS_GRANULARITY)); if(insertPosition < length) { /*for(; bufferPosition < insertPosition-1; bufferPosition++) { colors[bufferPosition*8 + 0] = NO_COLOR; colors[bufferPosition*8 + 1] = NO_COLOR; colors[bufferPosition*8 + 2] = NO_COLOR; colors[bufferPosition*8 + 3] = 0.5f; colors[bufferPosition*8 + 4] = NO_COLOR; colors[bufferPosition*8 + 5] = NO_COLOR; colors[bufferPosition*8 + 6] = NO_COLOR; colors[bufferPosition*8 + 7] = 0.5f; } Log.d("AHColor","r: "+(float) (Color.red(color)/255.0)+";" +"g: "+(float) (Color.green(color)/255.0)+";" +"b: "+(float) (Color.blue(color)/255.0));*/ colors[insertPosition*8+0] = (float) (Color.red(color)/255.0); colors[insertPosition*8+1] = (float) (Color.green(color)/255.0); colors[insertPosition*8+2] = (float) (Color.blue(color)/255.0); colors[insertPosition*8+3] = 1.0f; colors[insertPosition*8+4] = (float) (Color.red(color)/255.0); colors[insertPosition*8+5] = (float) (Color.green(color)/255.0); colors[insertPosition*8+6] = (float) (Color.blue(color)/255.0); colors[insertPosition*8+7] = 1.0f; /*colors[insertPosition*8+0] = 0.0f; colors[insertPosition*8+1] = 0.0f; colors[insertPosition*8+2] = 0.0f; colors[insertPosition*8+3] = 1.0f; colors[insertPosition*8+4] = (float) (Color.red(color)/255.0); colors[insertPosition*8+5] = (float) (Color.green(color)/255.0); colors[insertPosition*8+6] = (float) (Color.blue(color)/255.0); colors[insertPosition*8+7] = 1.0f;*/ bufferPosition++; } else { insertPosition = bufferPosition; } c.moveToNext(); } /*for(int i = insertPosition; i < length; i++) { color = cm.getErrorMapping(Error.NO_DATA); colors[i*8+0] = (float) (Color.red(color)/255.0); colors[i*8+1] = (float) (Color.green(color)/255.0); colors[i*8+2] = (float) (Color.blue(color)/255.0); colors[i*8+3] = 1.0f; colors[i*8+4] = (float) (Color.red(color)/255.0); colors[i*8+5] = (float) (Color.green(color)/255.0); colors[i*8+6] = (float) (Color.blue(color)/255.0); colors[i*8+7] = 1.0f; }*/ //debug mark start and end colors[0*8+0] = 1.0f; colors[0*8+1] = 0.0f; colors[0*8+2] = 0.0f; colors[0*8+3] = 1.0f; colors[(length-1)*8+2] = 1.0f; colors[(length-1)*8+3] = 1.0f; c.close(); return colors; } ///////////////// //DB related //////////////// public static void createTable(SQLiteDatabase db) { createTable(TABLE_NAME, db); } public static void createTable(String tableName, SQLiteDatabase db) { db.execSQL("CREATE TABLE IF NOT EXISTS " + tableName + " (" + ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + TIME + " TEXT, " + AROUSAL + " INTEGER, " + MOVEMENT + " INTEGER, " + PULSE +" INTEGER, " + SYNC + " INTEGER " +");"); } public static void clean(SQLiteDatabase db) { db.delete(TABLE_NAME, null, null); } public static Channels determinChannel(String fileName) { //standard AH2 naming scheme String[] tokens = fileName.split("_"); //token 0 should be AHHistory //token 1 should be Year //token 2 should be Month //token 3 should be Day //token 4 should be Channel //token 5 should be Granularity int channel = 0; if(tokens.length == 6) { channel = Integer.parseInt(tokens[4]); switch(channel) { //EAHHeartRate = 64, //EAHArousal = 128, //EAHArousalS = 136, //EAHMovement = 192, case 64: return History.Channels.CPULSE; case 128: return History.Channels.CAROUSAL; case 192: return History.Channels.CMOVEMENT; } } return null; } }
[ "chenyixian0423@gmail.com" ]
chenyixian0423@gmail.com
33c9da20ed38612985f1cc110369f5d632564192
5f8ea6554816cd298bc32e4cba5d5a61397b5d6a
/src/main/java/de/jfranz/homepage/service/MenuItemService.java
4bb0e3bd132facc89d799a60de77ad20db8b1462
[ "Apache-2.0" ]
permissive
jensfranz/homepageWickd
66921b71b90a212fa748d8749aba16c43660831a
a0868a9fb611219df459cf3db7aa43dc19ed5dbd
refs/heads/master
2021-01-01T05:49:59.547771
2013-04-23T16:50:50
2013-04-23T16:50:50
null
0
0
null
null
null
null
UTF-8
Java
false
false
181
java
package de.jfranz.homepage.service; import java.util.List; import de.jfranz.homepage.panel.menu.MenuItem; public interface MenuItemService { public List<MenuItem> getItems(); }
[ "jens@jens-X201EP" ]
jens@jens-X201EP
5dfc608aa7827df2ee6c2ef782054e38352d5d58
7c23d558b392bc8141135a7375a7387d7061fab0
/app/src/main/java/com/example/ryan/roomrep/LandlordFragments/LandlordListingsFragment.java
b412335a4902a7144bf5bfc7917e13e5c1530ed5
[]
no_license
rodrigoHM/RoomR
ee66e15ffee3f2cc39c06d31a5946c788514208f
b63525ac4fb39771e96e7458a62b49c64f872232
refs/heads/master
2020-12-22T21:26:57.085515
2020-06-09T21:56:25
2020-06-09T21:56:25
236,936,732
1
0
null
null
null
null
UTF-8
Java
false
false
5,896
java
package com.example.ryan.roomrep.LandlordFragments; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; import com.example.ryan.roomrep.Adapters.HouseRecyclerviewAdapter; import com.example.ryan.roomrep.Adapters.ItemClickListener; import com.example.ryan.roomrep.Adapters.LandlordListingsRecyclerviewAdapter; import com.example.ryan.roomrep.Adapters.LongClickItemListener; import com.example.ryan.roomrep.Classes.House.House; import com.example.ryan.roomrep.Classes.Iterator.JSONArrayIterator; import com.example.ryan.roomrep.Classes.Landlord.Landlord; import com.example.ryan.roomrep.Classes.Network.FragmentEventListener; import com.example.ryan.roomrep.Classes.Network.Network; import com.example.ryan.roomrep.Classes.Router.LandlordRouterAction; import com.example.ryan.roomrep.R; import com.google.gson.Gson; import org.json.JSONArray; import org.json.JSONException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class LandlordListingsFragment extends Fragment implements ItemClickListener, AddListingDialogActionListener, LongClickItemListener { RecyclerView rcyLandlordListings; Button btnPostListing; TextView txtNoListings; private LandlordRouterAction routerActionListener; private List<House> houses; private List<House> listedHouses; private LandlordListingsRecyclerviewAdapter adapter; private Landlord landlord; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_landlord_listings, container, false); rcyLandlordListings = view.findViewById(R.id.rcyLandlordListings); txtNoListings = view.findViewById(R.id.txtLandlordListingsNoListings); rcyLandlordListings.setLayoutManager(new LinearLayoutManager(getActivity())); btnPostListing = view.findViewById(R.id.btnLandlordListingsPostListing); btnPostListing.setOnClickListener(onAddListing); listedHouses = new ArrayList<>(); for (House house : houses){ if (house.getPosted()){ listedHouses.add(house); } } if (listedHouses.size() != 0){ txtNoListings.setVisibility(View.INVISIBLE); adapter = new LandlordListingsRecyclerviewAdapter(getActivity(), listedHouses); adapter.setItemClickListener(this); adapter.setLongClickItemListener(this); rcyLandlordListings.setAdapter(adapter); return view; } txtNoListings.setVisibility(View.VISIBLE); return view; } public void setRouterAction(LandlordRouterAction routerActionListener) { this.routerActionListener = routerActionListener; } @Override public void onItemClick(View view, int position) { if (routerActionListener != null){ House house = listedHouses.get(position); routerActionListener.onNavigateToTenantProfile(house); } } View.OnClickListener onAddListing = new View.OnClickListener() { @Override public void onClick(View v) { AddListingDialogFragment addListingDialogFragment = new AddListingDialogFragment(); addListingDialogFragment.setHouses(houses); addListingDialogFragment.setAddListingDialogActionListener(LandlordListingsFragment.this); addListingDialogFragment.show(getActivity().getFragmentManager(), null); } }; public void setLandlord(Landlord landlord) { this.landlord = landlord; } public void setHouses(List<House> houses) { this.houses = houses; } @Override public void onAddListing(House house) { txtNoListings.setVisibility(View.INVISIBLE); if (listedHouses.size() == 0){ adapter = new LandlordListingsRecyclerviewAdapter(getActivity(), listedHouses); adapter.setItemClickListener(this); adapter.setLongClickItemListener(this); rcyLandlordListings.setAdapter(adapter); } adapter.addHouse(house, adapter.getItemCount()); } @Override public boolean onLongClick(View view, final int position) { final AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create(); alertDialog.setTitle("Remove Listing"); alertDialog.setMessage("Are you sure you want to remove this property?"); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Remove", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { House house = listedHouses.get(position); house.setPosted(false); Network network = Network.getInstance(); network.postListing(house); adapter.removeHouse(house); if (listedHouses.isEmpty()){ txtNoListings.setVisibility(View.VISIBLE); } alertDialog.dismiss(); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Don't Remove", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { alertDialog.dismiss(); } }); alertDialog.show(); return true; } }
[ "rts1234567@hotmail.com" ]
rts1234567@hotmail.com
923f9164a8b6abe00cc77cff6057f9ffa9058867
f322bc5148e0ae25ce7e460181f9c8e849c496c6
/src/main/java/br/com/zentic/workshopmongo/WorkshopmongoApplication.java
2aa4db5706c9adf784820adf78c331030c54d372
[]
no_license
4cruzeta/-workshop-springboot2-mongodb
a79c320cf69d893ee0eecc4531c9cc862a32eeff
d4284dec91f26af48d95e2301267316fb1d87c98
refs/heads/master
2020-12-23T18:53:38.364555
2020-02-01T17:59:33
2020-02-01T17:59:33
237,239,701
0
0
null
null
null
null
UTF-8
Java
false
false
334
java
package br.com.zentic.workshopmongo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class WorkshopmongoApplication { public static void main(String[] args) { SpringApplication.run(WorkshopmongoApplication.class, args); } }
[ "4cruzetam@gmail.com" ]
4cruzetam@gmail.com
218979a502dfc7590f411914f3e9e07c100c3438
8428d966b8c4988a0d59600ea240da5e043053bb
/news-serch/lenta-parser/src/main/java/ru/ifmo/rain/chulkov/news/lenta/LentaParser.java
d0f690b5e1913cbbb85ba952f186e54e0f1d3416
[]
no_license
FonGadke/softwerke-practice
033b99353dda3a16a49d3afce489e61667b3cf4d
2e87a29debd5963f981c3d6bffc2b8f9078bcfae
refs/heads/master
2022-09-16T09:20:23.068421
2020-05-14T12:33:36
2020-05-14T12:33:36
247,793,777
0
0
null
2022-09-01T23:21:43
2020-03-16T18:55:02
Java
UTF-8
Java
false
false
1,530
java
package ru.ifmo.rain.chulkov.news.lenta; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; import ru.ifmo.rain.chulkov.news.abstrparser.NewsParser; import ru.ifmo.rain.chulkov.news.abstrparser.NewsParserAbstr; import ru.ifmo.rain.chulkov.news.lenta.util.ArticleInfo; import com.google.gson.*; import java.util.HashMap; import java.util.Map; @SuppressWarnings("deprecation") @Component() @Service(value = NewsParser.class) public class LentaParser extends NewsParserAbstr { private final String url = "https://api.lenta.ru/lists/latest"; @Override public Map<String, Integer> parseNews() { Map<String, Integer> result = new HashMap<>(); String content = getContent(url); content = content.substring(content.indexOf('['), content.length() - 1); ArticleInfo[] info = new Gson().fromJson(content, ArticleInfo[].class); for (ArticleInfo i: info) { String[] words = i.toString().split("[\\p{Blank}\\p{Punct}]"); for (String w: words) { String word = w.toLowerCase(); if (!prepositions.contains(word)) { if (result.containsKey(word)) { result.replace(word, result.get(word) + 1); } else { result.put(word, 1); } } } } return result; } @Override public String getName() { return "Lenta.ru"; } }
[ "k146.chulkov@yandex.ru" ]
k146.chulkov@yandex.ru
8941f0c3ccd348f03fd372a5f467a2a82de84482
4b53571a1d699f5c2c66ff8f5620f32f83ff55d5
/src/com/mipsasm/assembling/input/exceptions/UnknownTagException.java
6befb5e97bc065085b647f0c332345099daf046c
[]
no_license
Daniel-BG/Assembler-Linker-for-MIPS
993d20f4d7bf586083979b3b1945bf460801123f
9fcca152f04f95b2ce745c613845f44b69a00e3c
refs/heads/master
2021-01-23T13:43:21.877678
2015-03-03T17:35:10
2015-03-03T17:35:10
31,611,511
2
0
null
null
null
null
UTF-8
Java
false
false
200
java
package com.mipsasm.assembling.input.exceptions; public class UnknownTagException extends Exception { /** * */ private static final long serialVersionUID = 7272042585175882638L; }
[ "danielbasgar@gmail.com" ]
danielbasgar@gmail.com
4561fd97c963d6ff66650a7ed926dbb16b43ec95
bd565244dd66376f0c01ba5dafe6eaf800ab6c6a
/src/que7/RandomArray.java
feafb09a620cacd73aef9e58d24ca9fc89fc4070
[]
no_license
NikithaMN-05/finalJavaCode
9f9d44e1eaa4cdb5546f3a10f5ca0cbeb9fd432b
c1bfa03c88faaecb823533ddb300e50163cf09cf
refs/heads/main
2023-04-18T05:05:22.859730
2021-05-05T16:29:27
2021-05-05T16:29:27
364,639,854
0
0
null
null
null
null
UTF-8
Java
false
false
1,418
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 que7; /** * * @author S541994 */ import java.util.InputMismatchException; import java.util.Random; import java.util.Scanner; public class RandomArray { public static void main(String[] args) { System.out.println("***Narsing rao nikitha madhari***"); Random randomValues = new Random(); int[] centuryArray = new int[100]; for (int i = 0; i < centuryArray.length; i++) { centuryArray[i] = randomValues.nextInt(); System.out.println(i + " " + centuryArray[i]); } @SuppressWarnings("resource") Scanner scanner = new Scanner(System.in); System.out.println("Please enter the index number"); try { int givenIndex = scanner.nextInt(); if (givenIndex >= centuryArray.length) { System.out .println("at Index : " + givenIndex + " " + " Element value is : " + centuryArray[givenIndex]); } } catch (InputMismatchException | NumberFormatException nmfe) { System.out.println("Please enter the valid format"); } catch (IndexOutOfBoundsException e) { System.out.println("Index out of bound"); } } }
[ "77766697+NikithaMN-05@users.noreply.github.com" ]
77766697+NikithaMN-05@users.noreply.github.com
6fcf32543a647605d35d03a6ed346cc8458608ee
c2f571990c86c88f7d76659a70f68044b08b3226
/src/br/com/guia/tests/httpAuthentication/BasicHttpAuthentitationTest.java
1f25decaac2e85ad152b5497fe0ce1251d3ff430
[]
no_license
heronmedeiros/JavaHttpAuthentication
6d7b928816c1d4831e97147d821804894a3536dd
c5dca60f1c0b5d3be8247c96e45ceb3baaa2aa59
refs/heads/master
2021-01-22T05:06:32.644702
2011-09-08T20:55:21
2011-09-08T20:55:21
2,349,592
0
0
null
null
null
null
UTF-8
Java
false
false
508
java
package br.com.guia.tests.httpAuthentication; import static org.junit.Assert.assertEquals; import java.net.PasswordAuthentication; import org.junit.Test; import br.com.guia.authentication.BasicHttpAuthentication; public class BasicHttpAuthentitationTest { @Test public void PasswordAuthentication_should_return_PasswordAuthentication() { BasicHttpAuthentication bha = new BasicHttpAuthentication(); assertEquals(PasswordAuthentication.class, bha.getPasswordAuthentication().getClass()); } }
[ "=" ]
=
a2611ef061b311baf9472b6da6f1a65479bfb5ba
bf3a2be2c285dc8083d3398f67eff55f59a590fb
/symja/src/main/java/org/hipparchus/stat/ranking/RankingAlgorithm.java
ca5e77229ac85eefb6daa3fc70d47675cd3487e1
[]
no_license
tranleduy2000/symja_java7
9efaa4ab3e968de27bb0896ff64e6d71d6e315a1
cc257761258e443fe3613ce681be3946166584d6
refs/heads/master
2021-09-07T01:45:50.664082
2018-02-15T09:33:51
2018-02-15T09:33:51
105,413,861
2
1
null
2017-10-03T08:14:56
2017-10-01T02:17:38
Java
UTF-8
Java
false
false
1,554
java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.hipparchus.stat.ranking; /** * Interface representing a rank transformation. */ public interface RankingAlgorithm { /** * Performs a rank transformation on the input data, returning an array * of ranks. * <p> * Ranks should be 1-based - that is, the smallest value * returned in an array of ranks should be greater than or equal to one, * rather than 0. Ranks should in general take integer values, though * implementations may return averages or other floating point values * to resolve ties in the input data. * * @param data array of data to be ranked * @return an array of ranks corresponding to the elements of the input array */ double[] rank(double[] data); }
[ "tranleduy1233@gmail.com" ]
tranleduy1233@gmail.com
703f791d705f5563d736ec3e0ebe25bb190714e8
52bb36e2d97ba57bc4f64b3d69b1b59366b1b323
/src/test/java/com/pathak/bimal/msscbeerservice/web/controller/BeerControllerTest.java
202f09632eb06d5d0ece887ada6dd0b9338c36ec
[]
no_license
dwass047/mssc-beer-service
8cf33ee0f8663ec587b53d8757be65a507141068
def7e3e47966d048c866747de6f59209ab805d54
refs/heads/master
2023-03-19T22:13:43.657149
2021-03-17T03:37:11
2021-03-17T03:37:11
277,981,501
0
0
null
null
null
null
UTF-8
Java
false
false
2,775
java
package com.pathak.bimal.msscbeerservice.web.controller; import com.fasterxml.jackson.databind.ObjectMapper; import com.pathak.bimal.msscbeerservice.services.BeerService; import com.pathak.bimal.msscbeerservice.web.model.BeerDto; import com.pathak.bimal.msscbeerservice.web.model.BeerStyleEnum; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import java.math.BigDecimal; import java.util.UUID; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.BDDMockito.given; @WebMvcTest(BeerController.class) class BeerControllerTest { @Autowired MockMvc mockMvc; @Autowired ObjectMapper objectMapper; @MockBean BeerService beerService; @Test void getBeerById() throws Exception { given(beerService.getById(any(), anyBoolean())).willReturn(getValidBeerDto()); mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/beer/"+ UUID.randomUUID().toString()) .accept(MediaType.APPLICATION_JSON)) .andExpect(MockMvcResultMatchers.status().isOk()); } @Test void saveNewBeer() throws Exception { BeerDto beerDto = getValidBeerDto(); String beerDtoJson = objectMapper.writeValueAsString(beerDto); given(beerService.saveNewBeer(any())).willReturn(getValidBeerDto()); mockMvc.perform(MockMvcRequestBuilders.post("/api/v1/beer/") .contentType(MediaType.APPLICATION_JSON) .content(beerDtoJson)) .andExpect(MockMvcResultMatchers.status().isCreated()); } @Test void updateBeerById() throws Exception { given(beerService.updateBeer(any(),any())).willReturn(getValidBeerDto()); BeerDto beerDto = getValidBeerDto(); String beerDtoJson = objectMapper.writeValueAsString(beerDto); mockMvc.perform(MockMvcRequestBuilders.put("/api/v1/beer/"+ UUID.randomUUID().toString()) .contentType(MediaType.APPLICATION_JSON) .content(beerDtoJson)) .andExpect(MockMvcResultMatchers.status().isNoContent()); } BeerDto getValidBeerDto(){ return BeerDto.builder() .beerName("My Beer") .beerStyle(BeerStyleEnum.ALE) .price(new BigDecimal("2.99")) // .upc(BeerLoader.BEER_1_UPC) .build(); } }
[ "dwass.pathak@gmail.com" ]
dwass.pathak@gmail.com
9bbc8c2773e3e8bcdc3f211a9dafad36615f0f02
b296e946923b22b0842f55759ee0e8725903f745
/src/edu/sorting/DualPivotQuicksort20220112.java
d1f04c189d8faae5b458a8d1f9d6a4864ec94d35
[ "MIT", "GPL-2.0-only", "LicenseRef-scancode-free-unknown" ]
permissive
bourgesl/nearly-optimal-mergesort-code
b74e130cdcbef9ae0da198d7514abc2c09c57045
407f157a28dbb6720fd240df805ec9078e4f3058
refs/heads/master
2022-11-21T23:30:38.167196
2022-11-18T11:03:27
2022-11-18T11:03:27
156,525,815
5
1
MIT
2018-11-14T16:36:15
2018-11-07T09:57:32
Java
UTF-8
Java
false
false
36,403
java
/* * Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package edu.sorting; // package java.util; // TODO import java.util.Arrays; // import java.util.concurrent.CountedCompleter; // import java.util.concurrent.RecursiveTask; /** * This class implements powerful and fully optimized versions, both * sequential and parallel, of the Dual-Pivot Quicksort algorithm by * Vladimir Yaroslavskiy, Jon Bentley and Josh Bloch. This algorithm * offers O(n log(n)) performance on all data sets, and is typically * faster than traditional (one-pivot) Quicksort implementations. * * There are also additional algorithms, invoked from the Dual-Pivot * Quicksort such as merging sort, sorting network, Radix sort, heap * sort, mixed (simple, pin, pair) insertion sort, counting sort and * parallel merge sort. * * @author Vladimir Yaroslavskiy * @author Jon Bentley * @author Josh Bloch * @author Doug Lea * * @version 2020.06.14 * * @since 1.7 * 14 ^ 18 */ /* Vladimir's version: final DualPivotQuicksort.java (2022.01.12) */ public final class DualPivotQuicksort20220112 implements wildinter.net.mergesort.Sorter { private final static boolean TRACE = false; private final static boolean TRACE_ALLOC = false; public final static DualPivotQuicksort20220112 INSTANCE = new DualPivotQuicksort20220112(); /** * Prevents instantiation. */ private DualPivotQuicksort20220112() { } // avoid alloc final Sorter sorter = new Sorter(); @Override public void sort(final int[] A, final int low, final int high) { // preallocation of temporary arrays into custom Sorter class sorter.initBuffers(high - low + 1, low); sort(sorter, A, 0, low, high + 1); // exclusive } @Override public String toString() { return getClass().getSimpleName(); } /* From Vladimir's source code: */ /** * Max array size to use mixed insertion sort. */ private static final int MAX_MIXED_INSERTION_SORT_SIZE = 113; /** * Max array size to use insertion sort. */ private static final int MAX_INSERTION_SORT_SIZE = 26; /** * Min array size to use merging sort. */ private static final int MIN_MERGING_SORT_SIZE = 4 << 10; /** * Min size of the first run to continue with scanning. */ private static final int MIN_FIRST_RUN_SIZE = 16; /** * Min factor for the first runs to continue scanning. */ private static final int MIN_FIRST_RUNS_FACTOR = 7; /** * Max capacity of the index array for tracking runs. */ private static final int MAX_RUN_CAPACITY = 5 << 10; /** * Min array size to use Radix sort. */ private static final int MIN_RADIX_SORT_SIZE = 6 << 10; /** * Threshold of mixed insertion sort is increased by this value. */ private static final int DEPTH = 3 << 1; /** * Min depth to invoke Radix sort. */ private static final int MIN_RADIX_SORT_DEPTH = DEPTH << 2; /** * Max recursive partitioning depth before using heap sort. */ private static final int MAX_RECURSION_DEPTH = 64 * DEPTH; /** * Max length of additional buffer, * limited by max_heap / 64 or 256m elements (2gb max). */ private static final int MAX_BUFFER_LENGTH = (int) Math.min(Runtime.getRuntime().maxMemory() >> 6, 256L << 20); /** * Sorts the specified range of the array using Dual-Pivot Quicksort. * * @param sorter parallel context * @param a the array to be sorted * @param bits the combination of recursion depth and bit flag, where * the right bit "0" indicates that range is the leftmost part * @param low the index of the first element, inclusive, to be sorted * @param high the index of the last element, exclusive, to be sorted */ static void sort(Sorter sorter, int[] a, int bits, int low, int high) { while (true) { if (TRACE) { System.out.println("DPQSsort[" + a.length + "] bits = " + bits + " in [" + low + " - " + high + "]"); } int end = high - 1, size = high - low; /* * Run mixed insertion sort on small non-leftmost parts. */ if (size < MAX_MIXED_INSERTION_SORT_SIZE + bits && (bits & 1) > 0) { mixedInsertionSort(a, low, high - ((size >> 2) << 1), high); return; } /* * Invoke insertion sort on small leftmost part. */ if (size < MAX_INSERTION_SORT_SIZE) { insertionSort(a, low, high, (bits & 1) == 0); return; } /* * Check if the whole array or large non-leftmost * parts are nearly sorted and then merge runs. */ if ((bits == 0 || size > MIN_MERGING_SORT_SIZE && (bits & 1) > 0) && tryMergingSort(sorter, a, low, size)) { return; } /* * Switch to heap sort, if execution time is quadratic. */ if ((bits += DEPTH) > MAX_RECURSION_DEPTH) { heapSort(a, low, high); return; } /* * Use an inexpensive approximation of the golden ratio * to select five sample elements and determine pivots. */ int step = (size >> 2) + (size >> 3) + (size >> 8) + 1; /* * Five elements around (and including) the central element * will be used for pivot selection as described below. The * unequal choice of spacing these elements was empirically * determined to work well on a wide variety of inputs. */ int e1 = low + step; int e5 = end - step; int e3 = (e1 + e5) >>> 1; int e2 = (e1 + e3) >>> 1; int e4 = (e3 + e5) >>> 1; int a3 = a[e3]; boolean isRandom = a[e1] > a[e2] || a[e2] > a[e3] || a[e3] > a[e4] || a[e4] > a[e5]; /* * Sort these elements in place by the combination * of 4-element sorting network and insertion sort. * * 1 ------------o-----o------------ * | | * 2 ------o-----|-----o-----o------ * | | | * 4 ------|-----o-----o-----o------ * | | * 5 ------o-----------o------------ */ if (a[e2] > a[e5]) { int t = a[e2]; a[e2] = a[e5]; a[e5] = t; } if (a[e1] > a[e4]) { int t = a[e1]; a[e1] = a[e4]; a[e4] = t; } if (a[e1] > a[e2]) { int t = a[e1]; a[e1] = a[e2]; a[e2] = t; } if (a[e4] > a[e5]) { int t = a[e4]; a[e4] = a[e5]; a[e5] = t; } if (a[e2] > a[e4]) { int t = a[e2]; a[e2] = a[e4]; a[e4] = t; } /* * Insert the third element. */ if (a3 < a[e2]) { if (a3 < a[e1]) { a[e3] = a[e2]; a[e2] = a[e1]; a[e1] = a3; } else { a[e3] = a[e2]; a[e2] = a3; } } else if (a3 > a[e4]) { if (a3 > a[e5]) { a[e3] = a[e4]; a[e4] = a[e5]; a[e5] = a3; } else { a[e3] = a[e4]; a[e4] = a3; } } /* * Try Radix sort on large fully random data, * taking into account parallel context. */ if (size > MIN_RADIX_SORT_SIZE && a[e1] < a[e2] && a[e2] < a[e4] && a[e4] < a[e5] && isRandom && (true /* || sorter == null */ || bits > MIN_RADIX_SORT_DEPTH) && tryRadixSort(sorter, a, low, high)) { return; } // Pointers int lower = low; // The index of the last element of the left part int upper = end; // The index of the first element of the right part /* * Partitioning with two pivots on array of random elements. */ if (a[e1] < a[e2] && a[e2] < a[e3] && a[e3] < a[e4] && a[e4] < a[e5]) { /* * Use the first and fifth of the five sorted elements as * the pivots. These values are inexpensive approximation * of tertiles. Note, that pivot1 < pivot2. */ int pivot1 = a[e1]; int pivot2 = a[e5]; /* * The first and the last elements to be sorted are moved * to the locations formerly occupied by the pivots. When * partitioning is completed, the pivots are swapped back * into their final positions, and excluded from the next * subsequent sorting. */ a[e1] = a[lower]; a[e5] = a[upper]; /* * Skip elements, which are less or greater than the pivots. */ while (a[++lower] < pivot1); while (a[--upper] > pivot2); /* * Backward 3-interval partitioning * * left part central part right part * +------------------------------------------------------------------+ * | < pivot1 | ? | pivot1 <= && <= pivot2 | > pivot2 | * +------------------------------------------------------------------+ * ^ ^ ^ * | | | * lower k upper * * Pointer k is the last index of ?-part * Pointer lower is the last index of left part * Pointer upper is the first index of right part * * Invariants: * * all in (low, lower] < pivot1 * all in (k, upper) in [pivot1, pivot2] * all in [upper, end) > pivot2 */ for (int unused = --lower, k = ++upper; --k > lower; ) { int ak = a[k]; if (ak < pivot1) { // Move a[k] to the left side while (a[++lower] < pivot1) { if (lower == k) { break; } } if (a[lower] > pivot2) { a[k] = a[--upper]; a[upper] = a[lower]; } else { a[k] = a[lower]; } a[lower] = ak; } else if (ak > pivot2) { // Move a[k] to the right side a[k] = a[--upper]; a[upper] = ak; } } /* * Swap the pivots into their final positions. */ a[low] = a[lower]; a[lower] = pivot1; a[end] = a[upper]; a[upper] = pivot2; /* * Sort non-left parts recursively (possibly in parallel), * excluding known pivots. */ /* if (size > MIN_PARALLEL_SORT_SIZE && sorter != null) { sorter.forkSorter(bits | 1, lower + 1, upper); sorter.forkSorter(bits | 1, upper + 1, high); } else { */ sort(sorter, a, bits | 1, lower + 1, upper); sort(sorter, a, bits | 1, upper + 1, high); // } } else { // Partitioning with one pivot /* * Use the third of the five sorted elements as the pivot. * This value is inexpensive approximation of the median. */ int pivot = a[e3]; /* * The first element to be sorted is moved to the * location formerly occupied by the pivot. After * completion of partitioning the pivot is swapped * back into its final position, and excluded from * the next subsequent sorting. */ a[e3] = a[lower]; /* * Dutch National Flag partitioning * * left part central part right part * +------------------------------------------------------+ * | < pivot | ? | == pivot | > pivot | * +------------------------------------------------------+ * ^ ^ ^ * | | | * lower k upper * * Pointer k is the last index of ?-part * Pointer lower is the last index of left part * Pointer upper is the first index of right part * * Invariants: * * all in (low, lower] < pivot * all in (k, upper) == pivot * all in [upper, end] > pivot */ for (int k = ++upper; --k > lower; ) { int ak = a[k]; if (ak != pivot) { a[k] = pivot; if (ak < pivot) { // Move a[k] to the left side while (a[++lower] < pivot); if (a[lower] > pivot) { a[--upper] = a[lower]; } a[lower] = ak; } else { // ak > pivot - Move a[k] to the right side a[--upper] = ak; } } } /* * Swap the pivot into its final position. */ a[low] = a[lower]; a[lower] = pivot; /* * Sort the right part (possibly in parallel), excluding * known pivot. All elements from the central part are * equal and therefore already sorted. */ /* if (size > MIN_PARALLEL_SORT_SIZE && sorter != null) { sorter.forkSorter(bits | 1, upper, high); } else { */ sort(sorter, a, bits | 1, upper, high); // } } high = lower; // Iterate along the left part } } /** * Sorts the specified range of the array using mixed insertion sort. * * Mixed insertion sort is combination of pin insertion sort, * simple insertion sort and pair insertion sort. * * In the context of Dual-Pivot Quicksort, the pivot element * from the left part plays the role of sentinel, because it * is less than any elements from the given part. Therefore, * expensive check of the left range can be skipped on each * iteration unless it is the leftmost call. * * @param a the array to be sorted * @param low the index of the first element, inclusive, to be sorted * @param end the index of the last element for simple insertion sort * @param high the index of the last element, exclusive, to be sorted */ private static void mixedInsertionSort(int[] a, int low, int end, int high) { if (TRACE) { System.out.println("mixedInsertionSort[" + a.length + "] in [" + low + " - " + high + "]"); } /* * Start with pin insertion sort. */ for (int i, p = high; ++low < end && low < p; ) { int ai = a[i = low]; /* * Find pin element, smaller than the given element. */ while (ai < a[--p]); /* * Swap these elements. */ ai = a[p]; a[p] = a[i]; /* * Insert element into sorted part. */ while (ai < a[--i]) { a[i + 1] = a[i]; } a[i + 1] = ai; } /* * Continue with simple insertion sort. */ for (int i; low < end; ++low) { int ai = a[i = low]; /* * Insert element into sorted part. */ while (ai < a[--i]) { a[i + 1] = a[i]; } a[i + 1] = ai; } /* * Finish with pair insertion sort. */ for (int i; low < high; ++low) { int a1 = a[i = low], a2 = a[++low]; /* * Insert two elements per iteration: at first, insert the * larger element and then insert the smaller element, but * from the position where the larger element was inserted. */ if (a1 > a2) { while (a1 < a[--i]) { a[i + 2] = a[i]; } a[++i + 1] = a1; while (a2 < a[--i]) { a[i + 1] = a[i]; } a[i + 1] = a2; } else if (a1 < a[i - 1]) { while (a2 < a[--i]) { a[i + 2] = a[i]; } a[++i + 1] = a2; while (a1 < a[--i]) { a[i + 1] = a[i]; } a[i + 1] = a1; } } } /** * Sorts the specified range of the array using insertion sort. * * @param a the array to be sorted * @param low the index of the first element, inclusive, to be sorted * @param high the index of the last element, exclusive, to be sorted * @param leftmost indicates that the range is the leftmost part */ private static void insertionSort(int[] a, int low, int high, boolean leftmost) { if (TRACE) { System.out.println("insertionSort[" + a.length + "] in [" + low + " - " + high + "]"); } if (leftmost) { for (int i, k = low; ++k < high; ) { int ai = a[i = k]; if (ai < a[i - 1]) { while (--i >= low && ai < a[i]) { a[i + 1] = a[i]; } a[i + 1] = ai; } } } else { for (int i; ++low < high; ) { int ai = a[i = low]; while (ai < a[--i]) { a[i + 1] = a[i]; } a[i + 1] = ai; } } } /** * Tries to sort the specified range of the array * using LSD (Least Significant Digit) Radix sort. * * @param a the array to be sorted * @param low the index of the first element, inclusive, to be sorted * @param high the index of the last element, exclusive, to be sorted * @return {@code true} if the array is finally sorted, otherwise {@code false} */ static boolean tryRadixSort(Sorter sorter, int[] a, int low, int high) { if (TRACE) { System.out.println("tryRadixSort[" + a.length + "] in [" + low + " - " + high + "]"); } int[] b; int offset = low, size = high - low; /* * Allocate additional buffer. */ if (sorter != null && (b = (int[]) sorter.b) != null) { offset = sorter.offset; } else { if (TRACE_ALLOC) { System.out.println("tryRadixSort: alloc b: " + (high - low)); } if ((b = (int[]) tryAllocate(a, size)) == null) { return false; } } int start = low - offset; int last = high - offset; /* * Count the number of all digits. */ int[] count1 = new int[1024]; int[] count2 = new int[2048]; int[] count3 = new int[2048]; for (int i = low; i < high; ++i) { count1[ a[i] & 0x3FF]--; count2[(a[i] >>> 10) & 0x7FF]--; count3[(a[i] >>> 21) ^ 0x400]--; // Reverse the sign bit } /* * Detect digits to be processed. */ boolean processDigit1 = processDigit(count1, 1023, -size, high); boolean processDigit2 = processDigit(count2, 2047, -size, high); boolean processDigit3 = processDigit(count3, 2047, -size, high); /* * Process the 1-st digit. */ if (processDigit1) { for (int i = low; i < high; ++i) { b[count1[a[i] & 0x3FF]++ - offset] = a[i]; } } /* * Process the 2-nd digit. */ if (processDigit2) { if (processDigit1) { for (int i = start; i < last; ++i) { a[count2[(b[i] >>> 10) & 0x7FF]++] = b[i]; } } else { for (int i = low; i < high; ++i) { b[count2[(a[i] >>> 10) & 0x7FF]++ - offset] = a[i]; } } } /* * Process the 3-rd digit. */ if (processDigit3) { if (processDigit1 ^ processDigit2) { for (int i = start; i < last; ++i) { a[count3[(b[i] >>> 21) ^ 0x400]++] = b[i]; } } else { for (int i = low; i < high; ++i) { b[count3[(a[i] >>> 21) ^ 0x400]++ - offset] = a[i]; } } } /* * Copy the buffer to original array, if we process ood number of digits. */ if (processDigit1 ^ processDigit2 ^ processDigit3) { System.arraycopy(b, low - offset, a, low, size); } return true; } /** * Checks the count array and then creates histogram. * * @param count the count array * @param last the last index of count array * @param total the total number of elements * @param high the index of the last element, exclusive * @return {@code true} if the digit must be processed, otherwise {@code false} */ private static boolean processDigit(int[] count, int last, int total, int high) { /* * Check if we can skip given digit. */ for (int c : count) { if (c == total) { return false; } if (c < 0) { break; } } /* * Compute the histogram. */ count[last] += high; for (int i = last; i > 0; --i) { count[i - 1] += count[i]; } return true; } /** * Sorts the specified range of the array using heap sort. * * @param a the array to be sorted * @param low the index of the first element, inclusive, to be sorted * @param high the index of the last element, exclusive, to be sorted */ private static void heapSort(int[] a, int low, int high) { if (TRACE) { System.out.println("heapSort[" + a.length + "] in [" + low + " - " + high + "]"); } for (int k = (low + high) >>> 1; k > low; ) { pushDown(a, --k, a[k], low, high); } while (--high > low) { int max = a[low]; pushDown(a, low, a[high], low, high); a[high] = max; } } /** * Pushes specified element down during heap sort. * * @param a the given array * @param p the start index * @param value the given element * @param low the index of the first element, inclusive, to be sorted * @param high the index of the last element, exclusive, to be sorted */ private static void pushDown(int[] a, int p, int value, int low, int high) { for (int k ;; a[p] = a[p = k]) { k = (p << 1) - low + 2; // Index of the right child if (k > high) { break; } if (k == high || a[k] < a[k - 1]) { --k; } if (a[k] <= value) { break; } } a[p] = value; } /** * Tries to sort the specified range of the array using merging sort. * * @param sorter parallel context * @param a the array to be sorted * @param low the index of the first element to be sorted * @param size the array size * @return {@code true} if the array is finally sorted, otherwise {@code false} */ private static boolean tryMergingSort(Sorter sorter, int[] a, int low, int size) { if (TRACE) { System.out.println("tryMergeRuns[" + a.length + "] in [" + low + " - " + (low + size) + "]"); } /* * The run array is constructed only if initial runs are * long enough to continue, run[i] then holds start index * of the i-th sequence of elements in non-descending order. */ int[] run = null; int high = low + size; int count = 1, last = low; /* * Identify all possible runs. */ for (int k = low + 1; k < high; ) { /* * Find the end index of the current run. */ if (a[k - 1] < a[k]) { // Identify ascending sequence while (++k < high && a[k - 1] <= a[k]); } else if (a[k - 1] > a[k]) { // Identify descending sequence while (++k < high && a[k - 1] >= a[k]); // Reverse into ascending order for (int i = last - 1, j = k; ++i < --j && a[i] > a[j]; ) { int ai = a[i]; a[i] = a[j]; a[j] = ai; } } else { // Identify constant sequence for (int ak = a[k]; ++k < high && ak == a[k]; ); if (k < high) { continue; } } /* * Check special cases. */ if (sorter.runInit || (run == null)) { sorter.runInit = false; // LBO if (k == high) { /* * The array is monotonous sequence, * and therefore already sorted. */ return true; } if (k - low < MIN_FIRST_RUN_SIZE) { /* * The first run is too small * to proceed with scanning. */ return false; } if (false && TRACE_ALLOC) { System.out.println("tryMergeRuns: alloc runs: " + (((size >> 10) | 0x7F) & 0x3FF)); // Initial min 127, max 1023, extended to 5120 run = new int[((size >> 10) | 0x7F) & 0x3FF]; } else { run = sorter.run; // LBO: prealloc } run[0] = low; } else if (a[last - 1] > a[last]) { // Start new run if (count > (k - low) >> MIN_FIRST_RUNS_FACTOR) { /* * The first runs are not long * enough to continue scanning. */ return false; } if (++count == MAX_RUN_CAPACITY) { /* * Array is not highly structured. */ return false; } if (false && count == run.length) { // LBO: prealloc /* * Increase capacity of index array. */ // System.out.println("alloc run (resize)"); run = Arrays.copyOf(run, count << 1); } } run[count] = (last = k); if (++k == high) { /* * This is single-element run at the end. */ --k; } } /* * Merge runs of highly structured array. */ if (count > 1) { if (TRACE) { System.out.println("Merge runs:"); int prev = run[0]; for (int i = 1, end; i <= count; i++) { end = run[i] - 1; System.out.println("run " + i + " in [" + prev + " - " + end + "] <=> [" + a[prev] + " - " + a[end] + "]"); prev = run[i]; } } int[] b; int offset = low; if (sorter != null && (b = (int[]) sorter.b) != null) { offset = sorter.offset; } else { if (TRACE_ALLOC) { System.out.println("tryMergeRuns: alloc b: " + size); } if ((b = (int[]) tryAllocate(a, size)) == null) { return false; } } mergeRuns(a, b, offset, 1, /*sorter != null,*/ run, 0, count); } return true; } /** * Merges the specified runs. * * @param a the source array * @param b the temporary buffer used in merging * @param offset the start index in the source, inclusive * @param aim specifies merging: to source ( > 0), buffer ( < 0) or any ( == 0) * @param run the start indexes of the runs, inclusive * @param lo the start index of the first run, inclusive * @param hi the start index of the last run, inclusive * @return the destination where runs are merged */ private static int[] mergeRuns(int[] a, int[] b, int offset, int aim, /*boolean parallel,*/ int[] run, int lo, int hi) { if (TRACE) { System.out.println("mergeRuns[" + a.length + "] in [" + run[lo] + " - " + run[hi] + "]"); } if (hi - lo == 1) { if (aim >= 0) { return a; } System.arraycopy(a, run[lo], b, run[lo] - offset, run[hi] - run[lo]); return b; } /* * Split into approximately equal parts. */ int mi = lo, rmi = (run[lo] + run[hi]) >>> 1; while (run[++mi + 1] <= rmi); /* * Merge the left and right parts. */ int[] a1, a2; /* if (parallel && hi - lo > MIN_RUN_COUNT) { RunMerger merger = new RunMerger(a, b, offset, 0, run, mi, hi).forkMe(); a1 = mergeRuns(a, b, offset, -aim, true, run, lo, mi); a2 = (int[]) merger.getDestination(); } else { */ a1 = mergeRuns(a, b, offset, -aim, /*false,*/ run, lo, mi); a2 = mergeRuns(a, b, offset, 0, /*false,*/ run, mi, hi); // } int[] dst = a1 == a ? b : a; int k = a1 == a ? run[lo] - offset : run[lo]; int lo1 = a1 == b ? run[lo] - offset : run[lo]; int hi1 = a1 == b ? run[mi] - offset : run[mi]; int lo2 = a2 == b ? run[mi] - offset : run[mi]; int hi2 = a2 == b ? run[hi] - offset : run[hi]; /* if (parallel) { new Merger(null, dst, k, a1, lo1, hi1, a2, lo2, hi2).invoke(); } else { */ mergeParts(/*null,*/ dst, k, a1, lo1, hi1, a2, lo2, hi2); // } return dst; } /** * Merges the sorted parts. * * @param dst the destination where parts are merged * @param k the start index of the destination, inclusive * @param a1 the first part * @param lo1 the start index of the first part, inclusive * @param hi1 the end index of the first part, exclusive * @param a2 the second part * @param lo2 the start index of the second part, inclusive * @param hi2 the end index of the second part, exclusive */ private static void mergeParts(/*Merger merger,*/ int[] dst, int k, int[] a1, int lo1, int hi1, int[] a2, int lo2, int hi2) { if (TRACE) { System.out.println("mergeParts[" + dst.length + "] in [" + lo1 + " - " + hi1 + "] and [" + lo2 + " - " + hi2 + "]"); } // if (merger != null && a1 == a2) { // LBO: remove block (parallel disabled) // } /* * Merge small parts sequentially. */ while (lo1 < hi1 && lo2 < hi2) { dst[k++] = a1[lo1] < a2[lo2] ? a1[lo1++] : a2[lo2++]; } if (dst != a1 || k < lo1) { while (lo1 < hi1) { dst[k++] = a1[lo1++]; } } if (dst != a2 || k < lo2) { while (lo2 < hi2) { dst[k++] = a2[lo2++]; } } } static final class Sorter { final int[] run; int[] b; int offset; boolean runInit; Sorter() { // preallocate max runs: if (TRACE_ALLOC) { System.out.println("Sorter: pre-alloc runs: " + MAX_RUN_CAPACITY); } run = new int[MAX_RUN_CAPACITY]; } void initBuffers(final int length, final int offset) { if ((b == null) || (b.length < length)) { if (TRACE_ALLOC) { System.out.println("Sorter: alloc b: " + length); } b = new int[length]; } this.runInit = true; this.offset = offset; } } /** * Tries to allocate memory for additional buffer. * * @param a the array of given type * @param length the additional buffer length * @return {@code null} if requested length is too large, otherwise created buffer */ private static Object tryAllocate(Object a, int length) { if (length > MAX_BUFFER_LENGTH) { return null; } try { if (a instanceof int[]) { return new int[length]; } if (a instanceof long[]) { return new long[length]; } if (a instanceof float[]) { return new float[length]; } if (a instanceof double[]) { return new double[length]; } throw new IllegalArgumentException("Unknown array: " + a.getClass().getName()); } catch (OutOfMemoryError e) { return null; } } }
[ "bourges.laurent@gmail.com" ]
bourges.laurent@gmail.com
16c8eaf16cf0c692b8c56579ef9ae6213eba4648
944b649d0d0fd45898f1d5701060c4f158c1d106
/BDD/AlchemyCRM3.java
56ac4cdeb9deb8261a43c9b11ffa3eaf57737649
[]
no_license
sucharitha-garapati/sdet
cd2ade3c0bbcf84b79d4c5e2394132857efd117e
59c85e81ab3fa3249563d3bf0c6f68570503f5c2
refs/heads/main
2023-03-29T02:54:45.745927
2021-04-09T05:17:22
2021-04-09T05:17:22
333,637,841
0
0
null
null
null
null
UTF-8
Java
false
false
339
java
package TestRunner; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions( features = "src/test/java/features", glue = {"TestDefination"}, tags="@CRMScenario3", monochrome = true ) public class AlchemyCRM3 { }
[ "noreply@github.com" ]
noreply@github.com
9119c06c4bfaf9bd83756bb2af8f65b100935797
e9d967710a45fb9d8c68859818faa2e5213e7cd2
/src/main/java/io/velog/posting/VelogApplication.java
2f01de18cb35845ddc3a47d994d2525695513455
[]
no_license
dragontiger-dev/velog
51dd9c09435cab6e4416b7da433e511b687813c4
d8bc8246a1e21d154f221faeec0dcb92a0625fa5
refs/heads/main
2023-05-02T19:27:26.964302
2021-05-28T14:38:15
2021-05-28T14:38:15
368,109,563
0
0
null
null
null
null
UTF-8
Java
false
false
319
java
package io.velog.posting; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class VelogApplication { public static void main(String[] args) { SpringApplication.run(VelogApplication.class, args); } }
[ "dragontiger.dev@gmail.com" ]
dragontiger.dev@gmail.com
626db3ca39154c04129853f5753d55fb33b77a5f
64d632cb325a9e40d69ad94ed9a6f087cfcab3d2
/Interview/src/signiwis/Solution.java
f04f6f4cf39d6f33a018fb0d7ff2615779afd907
[]
no_license
vikas-kumars/JavaProject
044c67c462fe16135dc9026e098ac557bdc94fb0
17a5ce93b4f2ea0b5b9b434549703b179756919f
refs/heads/master
2020-04-05T18:40:51.134036
2018-12-24T12:45:57
2018-12-24T12:45:57
157,108,713
0
0
null
null
null
null
UTF-8
Java
false
false
1,437
java
package signiwis; /*import java.util.Scanner; public class Solution { // Complete the aVeryBigSum function below. static long aVeryBigSum(long[] ar) { long sum=0; for(int i=0;i<ar.length;i++) sum=sum+ar[i]; return sum; } public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); long[] ar=new long[n]; String[] str=s.nextLine().split(" "); for(int i=0;i<n;i++) { //ar[i]=Long.parseLong(str[i]); //ar[i]=l; //System.out.println("hello"); //ar[i]=s.nextLong(); //ar[i]=Integer.parseInt(s.nextLine()); ar[i]=s.nextLong(); } long value=aVeryBigSum(ar); System.out.println(value); } } */ import java.io.*; import java.util.*; import java.math.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); // double d=sc.nextDouble() List<BigInteger> input = new ArrayList<>(); sc.nextLine(); BigInteger sum = BigInteger.ZERO; for(int i=0; i<n; i++){ sum = sum.add(new BigInteger(sc.next())); } System.out.println(sum); } }
[ "vikas@ADMINRG-EAU15BT" ]
vikas@ADMINRG-EAU15BT
79ed7a8042364025bc565980a42b2e34fe7f1cd8
656643ba5fd250d7d4d7f470b99c86b453f82617
/app/src/main/java/com/piercelbrooks/mobibot/SerialFragment.java
e7bb48c77016b2831a955c23a16da0113e61c95f
[]
no_license
PierceLBrooks/MobiBot-Android
1a990fdb46932ae50c33c85f4d35b76fb428e390
5b37b376e6a2e91acaf666c61b4556b0e4c94a32
refs/heads/master
2021-05-17T17:58:15.227591
2020-04-20T07:05:44
2020-04-20T07:05:44
250,907,251
0
0
null
null
null
null
UTF-8
Java
false
false
4,367
java
// Author: Pierce Brooks package com.piercelbrooks.mobibot; import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; import com.piercelbrooks.common.BasicListFragment; import com.piercelbrooks.common.Utilities; import java.util.List; public abstract class SerialFragment <T extends Serial> extends BasicListFragment<MayoralFamily> { private static final String TAG = "MB-SerialFrag"; private static final String TAB = " * "; private Button serialExit; private TextView serialTitle; protected abstract T getSerial(); protected abstract String getTitle(); protected abstract void onExit(); public SerialFragment() { super(); } @Override protected boolean itemLabelAffix() { return false; } @Override protected void itemClick(View view, int position) { } @Override protected int getItemID() { return R.id.serial_item_label; } @Override protected int getItemLayout() { return R.layout.serial_item; } @Override public @LayoutRes int getLayout() { return R.layout.serial_fragment; } @Override public void createView(@NonNull View view) { serialExit = view.findViewById(R.id.serial_exit); serialExit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onExit(); } }); serialTitle = view.findViewById(R.id.serial_title); serialTitle.setText(getTitle()); load(); } @Override public void onBirth() { } @Override public void onDeath() { } public void unload() { removeItems(); } public void load() { load(getSerial()); } public void load(T serial) { unload(); if (serial != null) { List<String> serialization = serial.getSerialization(); if (serialization != null) { int levelPrevious = -1; int level = -1; boolean value = false; String member = ""; String temp = ""; for (int i = 0; i != serialization.size(); ++i) { temp += serialization.get(i)+"\n"; } Log.d(TAG, temp); for (int i = 0; i != serialization.size(); ++i) { temp = serialization.get(i); if (temp == null) { continue; } levelPrevious = level; level = Utilities.count(temp, '\t'); if (!value) { member += temp; if (levelPrevious == level) { value = !value; } else { member = TAB+member.replaceAll("\t", TAB); addItem(member); member = ""; } } else { value = !value; if (member.isEmpty()) { continue; } temp = temp.trim(); if ((!member.trim().isEmpty()) && (!temp.isEmpty())) { member += " = "; } if (!temp.isEmpty()) { member += temp; member = member.replaceAll("\t", TAB); } member = TAB+member; if (!member.isEmpty()) { addItem(member); member = ""; } } } } } } }
[ "piercebrooks@rocketmail.com" ]
piercebrooks@rocketmail.com
9d70c785e32459af873a6a577d602ee100d7c16d
a3654688d465b8d5b84a89ce57f8bb724b56fdf7
/abstractClassesDemo/src/abstractClassesDemo/CustomerManager.java
a2f0ae67a5c06a4d8bed40954a43f02f427d5edd
[]
no_license
sergennkeles/javaa
7400c209eadd1985ab83f92c76c33dd9aae33684
c2c090b5285cf49d6a38a70b7e641cb9af8b4d77
refs/heads/master
2023-04-23T18:21:35.479810
2021-05-13T15:16:02
2021-05-13T15:16:02
362,247,340
4
0
null
null
null
null
UTF-8
Java
false
false
174
java
package abstractClassesDemo; public class CustomerManager { BaseDatabaseManager baseDatabaseManager; public void getCustomer() { baseDatabaseManager.getData(); } }
[ "65495192+sergennkeles@users.noreply.github.com" ]
65495192+sergennkeles@users.noreply.github.com
3d5d8ef4faa00a48bff2167dfd23b96618159341
e1731e421fc6d89154f0b65c019a8bc0bcb47752
/gateway-service/src/main/java/academy/digitalab/store/gateway/GatewayServiceApplication.java
bdd3745b824057cf1b72c2081d7f5f78f6439eee
[]
no_license
alfmedib/ms-curso-youtube
7509e8ce35ea3674c4745abd84ae064ddc99146e
c79800f03f255f7ee23bdf67c680b0b5bdfe3a09
refs/heads/master
2022-11-03T18:46:55.937356
2020-06-18T17:41:08
2020-06-18T17:41:08
271,840,909
0
0
null
null
null
null
UTF-8
Java
false
false
428
java
package academy.digitalab.store.gateway; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; @EnableEurekaClient @SpringBootApplication public class GatewayServiceApplication { public static void main(String[] args) { SpringApplication.run(GatewayServiceApplication.class, args); } }
[ "alfmedis@gmail.com" ]
alfmedis@gmail.com
7d5e299c427ec3b69a47739eacc022bb7d7b13c7
2e83ac8dba8cadef071fa71e6450e36d7a96f29e
/src/main/java/tag/array/_219_ContainsDuplicateII.java
2974b9cc9dbad11bd1c73800974ec2e89208bf49
[]
no_license
hjkmba/leetcode
977ec2fae9d6e7058317454a247d79161e720e36
0c61bf808f06ddbaadbfdc92b9a89cabbbbf6e7b
refs/heads/master
2021-09-01T12:52:22.725964
2017-12-27T03:28:22
2017-12-27T03:28:22
105,979,663
0
0
null
null
null
null
UTF-8
Java
false
false
1,702
java
package tag.array; import java.util.*; /** * Created by DHunter on 2017/10/7. */ public class _219_ContainsDuplicateII { // time limit exceed public boolean containsNearbyDuplicate(int[] nums, int k) { for (int i = 0; i < nums.length-1; i++) { for (int j = 1; j <= k && i+j < nums.length; j++) { if (nums[i] == nums[i+j]) return true; } } return false; } public boolean containsNearbyDuplicate2(int[] nums, int k) { HashMap<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>>(); for (int i = 0; i < nums.length; i++) { if (map.get(nums[i]) == null) { map.put(nums[i], new ArrayList<Integer>()); } map.get(nums[i]).add(i); } for (Map.Entry<Integer, List<Integer>> entry : map.entrySet()) { List<Integer> index = entry.getValue(); if (index.size() > 1) { for (int i = 0; i < index.size() - 1; i++) { for (int j = i + 1; j < index.size(); j++) { if (Math.abs(index.get(i) - index.get(j)) <= k) { return true; } } } } } return false; } public boolean betterAnswer(int[] nums, int k) { HashSet<Integer> set = new HashSet<Integer>(); for (int i = 0; i < nums.length; i++) { if (i > k) { set.remove(nums[i - k - 1]); } if (!set.add(nums[i])) { return true; } } return false; } }
[ "hjkmba@163.com" ]
hjkmba@163.com
65a8813c78ab1bcf48b440c222f0226643002704
9633324216599db0cf1146770c62da8123dc1702
/src/fractalzoomer/gui/TwirlPlaneDialog.java
1bcad56428e82fd841d638ffa2af4ffebbd2fe86
[]
no_license
avachon100501/Fractal-Zoomer
fe3287371fd8716aa3239dd6955239f2c5d161cd
d21c173b8b12f11108bf844b53e09bc0d55ebeb5
refs/heads/master
2022-10-05T21:42:07.433545
2020-06-05T11:19:17
2020-06-05T11:19:17
null
0
0
null
null
null
null
UTF-8
Java
false
false
7,654
java
/* * Copyright (C) 2020 hrkalona2 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package fractalzoomer.gui; import fractalzoomer.main.MainWindow; import fractalzoomer.main.app_settings.Settings; import fractalzoomer.utils.MathUtils; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.geom.Point2D; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JOptionPane; import javax.swing.JRadioButtonMenuItem; import javax.swing.JTextField; import static javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE; /** * * @author hrkalona2 */ public class TwirlPlaneDialog extends JDialog { private MainWindow ptra; private JOptionPane optionPane; public TwirlPlaneDialog(MainWindow ptr, Settings s, int oldSelected, JRadioButtonMenuItem[] planes) { super(ptr); ptra = ptr; setTitle("Twirl"); setModal(true); setIconImage(getIcon("/fractalzoomer/icons/mandel2.png").getImage()); JTextField field_rotation = new JTextField(); field_rotation.setText("" + s.fns.plane_transform_angle); final JTextField field_real = new JTextField(); if (s.fns.plane_transform_center[0] == 0) { field_real.setText("" + 0.0); } else { field_real.setText("" + s.fns.plane_transform_center[0]); } final JTextField field_imaginary = new JTextField(); if (s.fns.plane_transform_center[1] == 0) { field_imaginary.setText("" + 0.0); } else { field_imaginary.setText("" + s.fns.plane_transform_center[1]); } JTextField field_radius = new JTextField(); field_radius.setText("" + s.fns.plane_transform_radius); final JCheckBox current_center = new JCheckBox("Current Center"); current_center.setSelected(false); current_center.setFocusable(false); current_center.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!current_center.isSelected()) { if (s.fns.plane_transform_center[0] == 0) { field_real.setText("" + 0.0); } else { field_real.setText("" + s.fns.plane_transform_center[0]); } field_real.setEditable(true); if (s.fns.plane_transform_center[1] == 0) { field_imaginary.setText("" + 0.0); } else { field_imaginary.setText("" + s.fns.plane_transform_center[1]); } field_imaginary.setEditable(true); } else { Point2D.Double p = MathUtils.rotatePointRelativeToPoint(s.xCenter, s.yCenter, s.fns.rotation_vals, s.fns.rotation_center); field_real.setText("" + p.x); field_real.setEditable(false); field_imaginary.setText("" + p.y); field_imaginary.setEditable(false); } } }); Object[] message = { " ", "Set the twirl angle in degrees.", "Angle:", field_rotation, " ", "Set the twirl radius.", "Radius:", field_radius, " ", "Set the twirl center (User Point).", "Real:", field_real, "Imaginary:", field_imaginary, current_center, " "}; optionPane = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION)); } }); optionPane.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { Object value = optionPane.getValue(); if (value == JOptionPane.UNINITIALIZED_VALUE) { //ignore reset return; } //Reset the JOptionPane's value. //If you don't do this, then if the user //presses the same button next time, no //property change event will be fired. optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); if ((Integer) value == JOptionPane.CANCEL_OPTION || (Integer) value == JOptionPane.NO_OPTION || (Integer) value == JOptionPane.CLOSED_OPTION) { planes[oldSelected].setSelected(true); s.fns.plane_type = oldSelected; dispose(); return; } try { double temp3 = Double.parseDouble(field_rotation.getText()); double temp4 = Double.parseDouble(field_radius.getText()); double tempReal = Double.parseDouble(field_real.getText()); double tempImaginary = Double.parseDouble(field_imaginary.getText()); if (temp4 <= 0) { JOptionPane.showMessageDialog(ptra, "Twirl radius must be greater than 0.", "Error!", JOptionPane.ERROR_MESSAGE); return; } s.fns.plane_transform_center[0] = tempReal; s.fns.plane_transform_center[1] = tempImaginary; s.fns.plane_transform_angle = temp3; s.fns.plane_transform_radius = temp4; } catch (Exception ex) { JOptionPane.showMessageDialog(ptra, "Illegal Argument!", "Error!", JOptionPane.ERROR_MESSAGE); return; } dispose(); ptra.defaultFractalSettings(); } } }); //Make this dialog display it. setContentPane(optionPane); pack(); setResizable(false); setLocation((int) (ptra.getLocation().getX() + ptra.getSize().getWidth() / 2) - (getWidth() / 2), (int) (ptra.getLocation().getY() + ptra.getSize().getHeight() / 2) - (getHeight() / 2)); setVisible(true); } private ImageIcon getIcon(String path) { return new ImageIcon(getClass().getResource(path)); } }
[ "hrkalona@gmail.com" ]
hrkalona@gmail.com
a15ad72ee84445d753f864afd8a72e2dc293bc46
65eca402cda4a38a9a25b706cb8985813637da01
/baodan/src/com/tw/web/dao/impl/ShouYiForUserDaoImpl.java
f445345cb9cfaa1b5c02640049ccc2c05f3487d7
[]
no_license
tianti2018/newy
9acb071b05a001dcb0bf0bbda0627723c3db9fa4
7d7f02aeceeba2e5171505d3ce904ccd2e06ec03
refs/heads/master
2020-03-17T00:51:15.919587
2018-06-15T12:55:02
2018-06-15T12:55:02
133,132,349
0
0
null
null
null
null
UTF-8
Java
false
false
6,521
java
package com.tw.web.dao.impl; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.util.Date; import java.util.List; import java.util.SortedMap; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import com.tw.web.dao.HongbaoyDao; import com.tw.web.dao.ShouYiForUserDao; import com.tw.web.dao.UseryDao; import com.tw.web.hibernate.persistent.Hongbaoy; import com.tw.web.hibernate.persistent.ShouYiForUser; import com.tw.web.hibernate.persistent.Usery; import com.tw.web.util.CommUtils; import com.tw.web.util.HongBaoUtil; import com.tw.web.util.WeiXinFuKuanUtil; @Repository public class ShouYiForUserDaoImpl extends CRUDBaseHibernateDAOImpl implements ShouYiForUserDao { @Override protected Class getPojoClass() { return ShouYiForUser.class; } @Autowired private UseryDao useryDao; @Autowired private HongbaoyDao hongbaoyDao; @Override public Hongbaoy tongguo(ShouYiForUser shouYiForUser) { if(shouYiForUser!=null){ Usery usery = null; List<Usery> userys = useryDao.findEntityByPropertiName("dianPuId", shouYiForUser.getDianpuId()); if(userys!=null&&userys.size()>0){ usery = userys.get(0); } if(usery!=null){ Integer amount = CommUtils.getInt(shouYiForUser.getShouyi()); if(amount<0) amount = 0-amount; String billNo = HongBaoUtil.createBillNo(); shouYiForUser.setBeizhu("提现审核通过"); shouYiForUser.setDakuanDan(billNo); shouYiForUser.setTixian(2); shouYiForUser.setPassDate(new Date()); update(shouYiForUser); Hongbaoy hongbaoy = new Hongbaoy(); hongbaoy.setAddTime(new Date()); hongbaoy.setAmount(amount); hongbaoy.setBillNo(billNo); hongbaoy.setBufaNum(0); hongbaoy.setDianpuId(shouYiForUser.getDianpuId()); hongbaoy.setOpenid(usery.getWxOpenid()); hongbaoy.setShouyiId(shouYiForUser.getId()); hongbaoy.setResult(1); hongbaoyDao.saveOrUpdate(hongbaoy); return hongbaoy; } } return null; } @Override public String fahongbao(Hongbaoy hongbaoy) { String message=""; if(hongbaoy!=null){ SortedMap<String, String> map = HongBaoUtil.createMap(hongbaoy.getBillNo(), hongbaoy.getOpenid(), null,hongbaoy.getAmount()*100); HongBaoUtil.sign(map); String requestXML = HongBaoUtil.getRequestXml(map); try { String path="/shanrenwuyu.p12"; if(System.getProperty("os.name").toLowerCase().contains("windows")) { path="c:/shanrenwuyu.p12"; } FileInputStream instream = new FileInputStream(new File(path)); String responseXML = HongBaoUtil.post(requestXML,instream); Document document = DocumentHelper.parseText(responseXML); Element root = document.getRootElement(); List<Element> elements = root.elements(); String return_msg = ""; String return_code = ""; String result_code = ""; String send_listid = ""; for(Element el:elements){ if(el.getName().trim().equals("return_code")){ return_code = el.getTextTrim(); } if(el.getName().trim().equals("return_msg")){ return_msg = el.getTextTrim(); message=return_msg; } if(el.getName().trim().equals("result_code")){ result_code = el.getTextTrim(); } if(el.getName().trim().equals("send_listid")){ send_listid = el.getTextTrim(); } } if (send_listid!="") { message="发放成功"; }else if(responseXML.contains("请求已受理")){ message="发放成功"; } } catch (KeyManagementException e) { e.printStackTrace(); } catch (UnrecoverableKeyException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (CertificateException e) { e.printStackTrace(); } catch (KeyStoreException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } } return message; } @Override public String weiXinFuKuan(Hongbaoy hongbaoy) { String message=""; if(hongbaoy!=null){ SortedMap<String, String> map = WeiXinFuKuanUtil.createMap(hongbaoy.getBillNo(), hongbaoy.getOpenid(), null,hongbaoy.getAmount()*100); WeiXinFuKuanUtil.sign(map); String requestXML = WeiXinFuKuanUtil.getRequestXml(map); try { String path="/shanrenwuyu.p12"; if(System.getProperty("os.name").toLowerCase().contains("windows")) { path="c:/shanrenwuyu.p12"; } FileInputStream instream = new FileInputStream(new File(path)); String responseXML = WeiXinFuKuanUtil.postFuQian(requestXML,instream); Document document = DocumentHelper.parseText(responseXML); Element root = document.getRootElement(); List<Element> elements = root.elements(); String return_msg = ""; String return_code = ""; String result_code = ""; String send_listid = ""; for(Element el:elements){ if(el.getName().trim().equals("return_code")){ return_code = el.getTextTrim(); } if(el.getName().trim().equals("return_msg")){ return_msg = el.getTextTrim(); message=return_msg; } if(el.getName().trim().equals("result_code")){ result_code = el.getTextTrim(); } if(el.getName().trim().equals("send_listid")){ send_listid = el.getTextTrim(); } } if (send_listid!="") { message="发放成功"; }else if(responseXML.contains("请求已受理")){ message="发放成功"; } } catch (KeyManagementException e) { e.printStackTrace(); } catch (UnrecoverableKeyException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (CertificateException e) { e.printStackTrace(); } catch (KeyStoreException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } } return message; } }
[ "Administrator@USER-20180508RT.lan" ]
Administrator@USER-20180508RT.lan
90a950d63ebbc3039b1cf428ff3595a0efca3151
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/2/2_6bae7b1a40dec492953b638b80e7c1a23df5967e/CheckOutAction/2_6bae7b1a40dec492953b638b80e7c1a23df5967e_CheckOutAction_t.java
6e7d1560c974c453818a8d7aad27537150181855
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
4,383
java
package net.sourceforge.eclipseccase.ui.actions; import org.eclipse.team.core.TeamException; import net.sourceforge.eclipseccase.ui.dialogs.ActivityDialog; import net.sourceforge.eclipseccase.ClearCasePreferences; import net.sourceforge.eclipseccase.ClearDlgHelper; import java.util.*; import net.sourceforge.eclipseccase.ClearCaseProvider; import net.sourceforge.eclipseccase.ui.CommentDialog; import net.sourceforge.eclipseccase.ui.DirectoryLastComparator; import net.sourceforge.eclipseccase.ui.console.ConsoleOperationListener; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.window.Window; public class CheckOutAction extends ClearCaseWorkspaceAction { @Override public void execute(IAction action) { String maybeComment = ""; int maybeDepth = IResource.DEPTH_ZERO; if (!ClearCasePreferences.isUseClearDlg() && !ClearCasePreferences.isUCM() && ClearCasePreferences.isCommentCheckout()) { CommentDialog dlg = new CommentDialog(getShell(), "Checkout comment"); if (dlg.open() == Window.CANCEL) return; maybeComment = dlg.getComment(); maybeDepth = dlg.isRecursive() ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO; } final String comment = maybeComment; final int depth = maybeDepth; //UCM checkout. if(ClearCasePreferences.isUCM()){ checkoutWithActivity(depth); return; } IWorkspaceRunnable runnable = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { try { IResource[] resources = getSelectedResources(); beginTask(monitor, "Checking out...", resources.length); if (ClearCasePreferences.isUseClearDlg()) { monitor.subTask("Executing ClearCase user interface..."); ClearDlgHelper.checkout(resources); } else { // Sort resources with directories last so that the // modification of a // directory doesn't abort the modification of files // within // it. List resList = Arrays.asList(resources); Collections.sort(resList, new DirectoryLastComparator()); ConsoleOperationListener opListener = new ConsoleOperationListener(monitor); for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; ClearCaseProvider provider = ClearCaseProvider.getClearCaseProvider(resource); if (provider != null) { provider.setComment(comment); provider.setOperationListener(opListener); provider.checkout(new IResource[] { resource }, depth, subMonitor(monitor)); } } } } finally { monitor.done(); updateActionEnablement(); } } }; executeInBackground(runnable, "Checking out resources from ClearCase"); } @Override public boolean isEnabled() { IResource[] resources = getSelectedResources(); if (resources.length == 0) return false; for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; ClearCaseProvider provider = ClearCaseProvider.getClearCaseProvider(resource); if (provider == null || provider.isUnknownState(resource) || provider.isIgnored(resource) || !provider.isClearCaseElement(resource)) return false; if (provider.isCheckedOut(resource)) return false; } return true; } private void checkoutWithActivity(int depth){ IResource[] resources = getSelectedResources(); for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; ClearCaseProvider provider = ClearCaseProvider.getClearCaseProvider(resource); if (provider != null) { ActivityDialog dlg = new ActivityDialog(getShell(),provider); if (dlg.open() == Window.CANCEL) return; // String activitySelector = dlg.getActivity().getActivitySelector(); provider.setActivity(activitySelector); provider.setComment(dlg.getComment());// try { provider.checkout(new IResource[] { resource }, depth, null); } catch (TeamException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
7c020aa83308e8d0ff28ef9e274f60a7b42be907
3c1ff9c064b51a390162d6f85b56894f4c5104fb
/src/main/java/com/example/demo/config/BeanConfig.java
2e7ceee386b4b8c6ec8f84f95a27b8c14b26c719
[]
no_license
pradipshir60/ShoppingCartProject
f793b9e95f5f67844a58532ac6c1454843c8be8b
f173838050a69f413a1a7b619a9539bab483f687
refs/heads/master
2023-05-24T06:34:57.869934
2021-06-10T03:26:56
2021-06-10T03:26:56
375,554,150
0
0
null
null
null
null
UTF-8
Java
false
false
709
java
package com.example.demo.config; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.persistence.EntityManagerFactory; @Configuration public class BeanConfig { @Autowired private EntityManagerFactory entityManagerFactory; @Bean public SessionFactory getSessionFactory() { if (entityManagerFactory.unwrap(SessionFactory.class) == null) { throw new NullPointerException("factory is not a hibernate factory"); } return entityManagerFactory.unwrap(SessionFactory.class); } }
[ "pradipshirsath123@gmail.com" ]
pradipshirsath123@gmail.com
aead1c35f8cbcf407a6340ea952d9e3d8220828b
00c56f9bdf01c25970b01c6e3e35fe4a0778803a
/src/core/Part/Part.java
6df51e3308af3f40b248573005a9886a3d342658
[]
no_license
NAG47/BOM_Comparator
5e0fd0f980fd46a98d3267cd509d8409750768f7
c57b13cfebbc8c364996249e0d4a3baf6ffca695
refs/heads/master
2021-01-13T01:17:37.080617
2017-02-09T15:27:53
2017-02-09T15:27:53
81,442,060
0
0
null
2017-02-09T15:18:03
2017-02-09T11:11:12
Java
UTF-8
Java
false
false
3,669
java
package core.Part; import java.text.DecimalFormat; public class Part implements Comparable<Object>{ private String id; private String name; private int pos; private String MKNum; private String matNum; private Double matQty; private String paymentNum; private Double qty; public Double correctQty = 0.0; //FOr testing private String view; private String weldNum; private boolean matched = false; private DecimalFormat format = new DecimalFormat("##.000"); private String machineType; private Double scrapFactorPercentage; public Part(int pos, String id, String name, String MKNum, String matNum, Double matQty, String view, String weldNum, String paymentNum, Double qty){ this.pos = pos; this.id = id; this.name = name; this.MKNum = MKNum; this.matNum = matNum; this.matQty = matQty; this.view = view; this.weldNum = weldNum; this.paymentNum = paymentNum; this.qty = qty; } //IM Part public Part(String id, String name, String MKNum){ this.id = id; this.name = name; this.MKNum = MKNum; } //SF part public Part(String id, String machineType, Double scrapFactorPercentage){ this.id = id; this.machineType = machineType; this.scrapFactorPercentage = scrapFactorPercentage; } public boolean getMatched(){ return matched; } public String getMachineType(){ return machineType; } public Double getScrapFactor(){ return scrapFactorPercentage; } public void setMatched(boolean m){ matched = m; } public void setQty(Double qty){ this.qty = qty; } public String getWeldNum(){ return weldNum; } public void setMKNum(String num){ MKNum = num; } public String getMKNum(){ return MKNum; } public String getMatNum(){ return matNum; } public String getPaymentNum(){ return paymentNum; } public String getName(){ return name; } public void setName(String n){ this.name = n; } public Double getQty(){ return qty; } public void addQty(double q){ qty = qty + q; } public Double getMatQty(){ return matQty; } public void setID(String ID){ id = ID; } public String getID(){ return id; } public void setPos(int num){ this.pos = num; } public int getPos(){ return pos; } public String getView(){ return view; } public void clear(){ this.MKNum = ""; this.matNum = ""; this.matQty = 0.0; this.paymentNum = ""; this.view = ""; this.weldNum = ""; } public Double formatDouble(Double d){ d = Math.ceil(d * 1000) / 1000; Double db = Double.parseDouble(format.format(d)); return db; } public boolean compareQty(Part part){ try { double change = formatDouble(part.getQty()) - formatDouble(this.getQty()); if (Math.abs(change) != 0) { part.correctQty = this.getQty(); this.correctQty = part.getQty(); return false; } return true; } catch (Exception e) { System.out.println(this + " - " + part.getQty() + ", " + this.getQty()); } return false; } public boolean equals(Object obj){ //System.out.println(this + " =? " + p); Part p = (Part) obj; if (this.pos == p.getPos()) { if(this.id.equals(p.getID())){ return true; } return false; } return false; } public String toString(){ return id; //DO NOT CHANGE THIS } @Override public int compareTo(Object arg0) { if (arg0 instanceof Part) { Part part = (Part) arg0; if (this.getID().compareTo(part.getID()) < 0) { return -1; } else return 1; } return 0; } }
[ "noreply@github.com" ]
noreply@github.com
cadc18f954106bca9cd30de122e9ed1b52ae5d46
14285d504bdd06341778b5583bea8b386b2f9c82
/Proceed High Language/src/org/kaivos/phl/test/program/ProgramTest.java
d499fdd3d9badf5191e33959967d20292de67570
[]
no_license
fergusq/second-phl
f46b065383e6acb1765f58e72bf1df0202ba465c
9588c119b441afd104e36f2b7728823c4c6a053e
refs/heads/master
2016-09-10T00:26:51.177534
2015-10-04T14:24:20
2015-10-04T14:24:20
40,195,645
1
0
null
null
null
null
UTF-8
Java
false
false
1,030
java
package org.kaivos.phl.test.program; import static org.junit.Assert.*; import org.junit.Test; import org.kaivos.phl.program.Module; import org.kaivos.phl.program.Program; import org.kaivos.phl.util.Version; public class ProgramTest { @Test public void testAddingModule() { Program p = new Program(); Module m = new Module("m"); p.registerModule(m); assertEquals(m, p.resolveModule("m").orElse(null)); } @Test public void testAddingModuleWithVersion() { Program p = new Program(); Module m1 = new Module("m", Version.of(2, 3, 4)), m2 = new Module("m", Version.of(2, 3, 5)); p.registerModule(m1); p.registerModule(m2); assertEquals(m2, p.resolveModule("m").orElse(null)); } @Test public void testAddingAndResolvingModuleWithVersion() { Program p = new Program(); Module m1 = new Module("m", Version.of(2, 3, 4)), m2 = new Module("m", Version.of(2, 3, 5)); p.registerModule(m1); p.registerModule(m2); assertEquals(m1, p.resolveModule("m", Version.of(2, 3, 4)).orElse(null)); } }
[ "iikka@kaivos.org" ]
iikka@kaivos.org
47afa0a8141093d8eb675e48a34aefabfa7a5e21
008046eefa1dade7e8d8e05087d2de29ab9cd48b
/src/leetcode/OJ074_Searcha2DMatrix.java
869920c965920cc525594b56d8681cc41d0b4490
[]
no_license
felowchu/leetcode
9abd7089660d78e48ae086a0b0f3b76d7c6ee20d
6dca48c170726eefc1061a69b456ec996b37f83c
refs/heads/master
2020-12-02T19:47:47.302283
2017-11-12T14:51:46
2017-11-12T14:51:46
96,390,886
0
0
null
null
null
null
UTF-8
Java
false
false
552
java
package leetcode; public class OJ074_Searcha2DMatrix { public boolean searchMatrix(int[][] matrix, int target){ int row = matrix.length; if(row == 0) return false; int col = matrix[0].length; int index1 = 0, index2 = col - 1; while (index1 <= row - 1 && index2 >= 0){ if(matrix[index1][index2] > target) index2--; else if(matrix[index1][index2] < target) index1++; else return true; } return false; } }
[ "867670310@qq.com" ]
867670310@qq.com
75aae05fe646a1debe0f68a801d513b87faaa738
b862fbb999f27d9979726a107b8167a18f57d7b0
/src/2014/ccc14j1.java
91613d3ae1b90cf69845f29cff118576dc9cc601
[]
no_license
zhangandrew37/Competitive-Programming-Java
9e194ccb34fb4e22ee3a8017d5f6d4c0e219398c
e1277b97869bd804f81045a09d93139af544a6ce
refs/heads/master
2021-12-23T11:25:44.232561
2021-12-21T18:54:41
2021-12-21T18:54:41
227,512,061
0
0
null
null
null
null
UTF-8
Java
false
false
515
java
import java.util.*; public class ccc14j1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); if(a==60 && b==60 && c==60) { System.out.println("Equilateral"); } else if(a+b+c==180 && ((a==b)||(a==c)||(b==c))) { System.out.println("Isosceles"); } else if(a+b+c==180 && ((a!=b)||(a!=c)||(b!=c))) { System.out.println("Scalene"); } else if(a+b+c!=180) { System.out.println("Error"); } } }
[ "noreply@github.com" ]
noreply@github.com
bd4d3289b608d6fbc57dbcba083bef6b9424c906
5a254336d5d79c9383129c46a1d007ace6f7e30a
/src/java/play/learn/java/design/extension_object/Soldier.java
e478e46068c6cd4979fdd8202dc5538e952f1334
[ "Apache-2.0" ]
permissive
jasonwee/videoOnCloud
837b1ece7909a9a9d9a12f20f3508d05c37553ed
b896955dc0d24665d736a60715deb171abf105ce
refs/heads/master
2023-09-03T00:04:51.115717
2023-09-02T18:12:55
2023-09-02T18:12:55
19,120,021
1
5
null
2015-06-03T11:11:00
2014-04-24T18:47:52
Python
UTF-8
Java
false
false
318
java
package play.learn.java.design.extension_object; public class Soldier implements SoldierExtension { private SoldierUnit unit; public Soldier(SoldierUnit soldierUnit) { this.unit = soldierUnit; } @Override public void soldierReady() { System.out.println("[Solider] " + unit.getName() + " is ready!"); } }
[ "peichieh@gmail.com" ]
peichieh@gmail.com
ddac774aa626ab15062522f84daeb861ad0b1a42
f3bdc1ccf0b999155f4a18d19969f6921962c7b7
/src/test/arda/entity/creature/HobbitTest.java
c96ee3ae08ec7340c2491302e46f7cdcf635e5a6
[ "MIT" ]
permissive
synthghost/cellular-automaton-lab
750334d5ff9887b0b167885295eff07168b777ab
4c6249dfcac8acec8476af14f05e27e6c8a0f2da
refs/heads/master
2023-05-30T07:57:26.007794
2021-06-12T00:35:30
2021-06-12T00:35:30
376,101,659
0
0
null
null
null
null
UTF-8
Java
false
false
4,663
java
package test.arda.entity.creature; import static org.junit.jupiter.api.Assertions.*; import java.awt.Color; import main.arda.world.World; import test.arda.ResetsWorld; import main.arda.world.Coordinate; import org.junit.jupiter.api.Test; import main.arda.entity.creature.Hobbit; import main.arda.entity.creature.Nazgul; import main.arda.entity.creature.Rabbit; import main.arda.entity.shrubbery.Stone; import org.junit.jupiter.api.BeforeEach; public class HobbitTest extends ResetsWorld { Hobbit hobbit; @Override @BeforeEach public void init() { super.init(); hobbit = new Hobbit("Bilbo", new Coordinate(10, 10)); World.addEntity(hobbit); } @Test void testColor() { assertEquals(new Color(0, 200, 255, 255), hobbit.color(), hobbit.toString()); hobbit.starve(5); assertEquals(new Color(0, 200, 255, 155), hobbit.color()); } @Test void testDecide() { Stone stone1 = new Stone(new Coordinate(9, 10)); Stone stone2 = new Stone(new Coordinate(10, 9)); Stone stone3 = new Stone(new Coordinate(11, 10)); Stone stone4 = new Stone(new Coordinate(10, 11)); World.addEntity(stone1); World.addEntity(stone2); World.addEntity(stone3); World.addEntity(stone4); // Ticking calls decide() hobbit.tick(); // Hobbit is surrounded and can't move assertEquals(new Coordinate(10, 10), hobbit.getPosition()); World.getEntities().remove(stone4); hobbit.tick(); // Hobbit has an opening assertEquals(new Coordinate(10, 11), hobbit.getPosition()); hobbit.tick(); // Hobbit moves somewhere else assertNotEquals(new Coordinate(10, 11), hobbit.getPosition()); } @Test void testDecideWhenNazgulNearby() { Nazgul nazgul1 = new Nazgul("A", new Coordinate(9, 10)); Nazgul nazgul2 = new Nazgul("B", new Coordinate(10, 9)); Nazgul nazgul3 = new Nazgul("C", new Coordinate(11, 10)); Nazgul nazgul4 = new Nazgul("D", new Coordinate(10, 11)); World.addEntity(nazgul1); World.addEntity(nazgul2); World.addEntity(nazgul3); World.addEntity(nazgul4); // Ticking calls decide() hobbit.tick(); // Hobbit is surrounded and can't move assertEquals(new Coordinate(10, 10), hobbit.getPosition()); World.getEntities().remove(nazgul4); hobbit.tick(); // Hobbit has an opening assertEquals(new Coordinate(10, 11), hobbit.getPosition()); hobbit.tick(); // Hobbit does not move back from where it came, as that would // move it closer to the Nazgul assertNotEquals(new Coordinate(10, 10), hobbit.getPosition()); // Hobbit moves somewhere else assertNotEquals(new Coordinate(10, 11), hobbit.getPosition()); } @Test void testDecideWhenRabbitNearby() { Rabbit rabbit1 = new Rabbit("A", new Coordinate(10, 7)); World.addEntity(rabbit1); // Ticking calls decide() hobbit.tick(); // Hobbit moves toward Rabbit assertEquals(new Coordinate(10, 9), hobbit.getPosition()); hobbit.tick(); // Hobbit moves somewhere else assertNotEquals(new Coordinate(10, 9), hobbit.getPosition()); } @Test void testDecideWhenHobbitNearby() { Hobbit hobbit1 = new Hobbit("A", new Coordinate(10, 7)); World.addEntity(hobbit1); // Ticking calls decide() hobbit.tick(); // Hobbit moves toward other Hobbit assertEquals(new Coordinate(10, 9), hobbit.getPosition()); hobbit.tick(); // Hobbit moves somewhere else assertNotEquals(new Coordinate(10, 9), hobbit.getPosition()); } @Test void testMove() { hobbit.move(new Coordinate(11, 11)); assertEquals(new Coordinate(11, 11), hobbit.getPosition()); hobbit.move(null); assertEquals(new Coordinate(11, 11), hobbit.getPosition()); } @Test void testEat() { hobbit.getInventory().scan(); // Reduce the Hobbit's health hobbit.starve(5); assertEquals(5, hobbit.getHealth()); assertTrue(hobbit.getInventory().hasFood()); for (int i = 0; i < 20; i++) { // Ticking calls eat() hobbit.tick(); } assertEquals(7, hobbit.getHealth()); assertFalse(hobbit.getInventory().hasFood()); // When out of food, eating again has no effect hobbit.eat(); assertEquals(7, hobbit.getHealth()); } }
[ "60333233+synthghost@users.noreply.github.com" ]
60333233+synthghost@users.noreply.github.com
4ee641dfbaec7ab7aa12dac48d71548f414a0afc
f5521a8c658865aa645cfd11391018bdd81fc373
/app/src/main/java/com/example/pratamajambipelayangan/MapsActivity.java
12b27039ed89f04dcccb57c243563ef7a1a9a2e9
[]
no_license
ekastan/PratamaJambiPelayangan3
0df9439729561521ca71d64fbf2c975ee1515d0c
36bd5320bd870e5dd473ea580025d1c232c371a3
refs/heads/master
2022-11-14T04:48:07.284419
2020-07-12T08:11:50
2020-07-12T08:11:50
279,020,720
0
0
null
null
null
null
UTF-8
Java
false
false
4,216
java
package com.example.pratamajambipelayangan; import android.app.Dialog; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import androidx.fragment.app.FragmentActivity; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { private GoogleMap mMap; private TextView txtNPWP; private String id; Dialog myDialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); myDialog = new Dialog(MapsActivity.this); txtNPWP = findViewById(R.id.txtNPWP); Button btnPanggil = findViewById(R.id.btnPanggil); Button btnWA = findViewById(R.id.btnWA); Button btnEmail = findViewById(R.id.btnEmail); Intent intent = getIntent(); id = intent.getStringExtra(konfigurasi.EMP_ID); txtNPWP.setText(id); btnPanggil.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:074162620")); startActivity(intent); } }); btnEmail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent selectorIntent = new Intent(Intent.ACTION_SENDTO); selectorIntent.setData(Uri.parse("mailto:")); final Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"kpp.325@pajak.go.id"}); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Konsultasi Perpajakan"); emailIntent.putExtra(Intent.EXTRA_TEXT, "Konsultasi Perpajakan untuk :\n NPWP:\nNama WP:\nTentang:\n"); emailIntent.setSelector( selectorIntent ); startActivity(Intent.createChooser(emailIntent, "Send email...")); } }); btnWA.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = "https://api.whatsapp.com/send?phone=+6281273996830L&text=Saya ingin berkonsultasi mengenai permasalahan perpajakan"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); } /** * Manipulates the map once available. * This callback is triggered when the map is ready to be used. * This is where we can add markers or lines, add listeners or move the camera. In this case, * we just add a marker near Sydney, Australia. * If Google Play services is not installed on the device, the user will be prompted to install * it inside the SupportMapFragment. This method will only be triggered once the user has * installed Google Play services and returned to the app. */ @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // Add a marker in Sydney and move the camera LatLng sydney = new LatLng(-1.6111515, 103.57533); Marker marker = mMap.addMarker(new MarkerOptions().position(sydney)); marker.showInfoWindow(); mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); mMap.animateCamera(CameraUpdateFactory.zoomTo(16.0f)); } }
[ "kawa130484@gmail.com" ]
kawa130484@gmail.com
abb351f1d368c06d05e5f0167abbdfc1b25077a3
4dc0f0e0d0cc6ac5f2da9f5534d6bcd109d89bef
/springboot-vue-quickstart/springboot-vue-element/springboot-restful-backend-element/src/main/java/org/jeedevframework/springboot/app/entity/App.java
efff53554787e36a837ae28d85c56555e55c93e3
[]
no_license
huligong1234/springboot-learning
70a0f37de7aaef246671d9578323161fba23a7d7
2e832330a816afdb8b37d9def4997f6341f81955
refs/heads/master
2022-06-28T20:43:12.467279
2019-10-03T03:52:01
2019-10-03T03:52:01
137,196,057
4
1
null
2022-06-17T03:29:04
2018-06-13T09:49:39
Java
UTF-8
Java
false
false
1,419
java
package org.jeedevframework.springboot.app.entity; import java.util.Date; import javax.persistence.*; import com.fasterxml.jackson.annotation.JsonFormat; @Entity @Table(name = "app") public class App { @Id @GeneratedValue(strategy= GenerationType.AUTO) private Integer id; private Date gmtCreate; private Date gmtModified; private int reOrder; private int isDeleted; private String appCode; private String appName; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") public Date getGmtCreate() { return gmtCreate; } public void setGmtCreate(Date gmtCreate) { this.gmtCreate = gmtCreate; } @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") public Date getGmtModified() { return gmtModified; } public void setGmtModified(Date gmtModified) { this.gmtModified = gmtModified; } public int getReOrder() { return reOrder; } public void setReOrder(int reOrder) { this.reOrder = reOrder; } public int getIsDeleted() { return isDeleted; } public void setIsDeleted(int isDeleted) { this.isDeleted = isDeleted; } public String getAppCode() { return appCode; } public void setAppCode(String appCode) { this.appCode = appCode; } public String getAppName() { return appName; } public void setAppName(String appName) { this.appName = appName; } }
[ "huligong1234@126.com" ]
huligong1234@126.com
8e7b6b2b5c9d5c3e680d7f561a1de54ca340f74f
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/31/31_cf088c494f2c5b846bb30d9b899ca698997d8a72/TermSession/31_cf088c494f2c5b846bb30d9b899ca698997d8a72_TermSession_t.java
4785264b5f66453dd55737b9447be5e1e8cb8341
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
11,740
java
/* * Copyright (C) 2007 The Android Open Source 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 jackpal.androidterm.session; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; import java.nio.charset.CodingErrorAction; import java.util.ArrayList; import android.os.Handler; import android.os.Message; import android.util.Log; import jackpal.androidterm.Exec; import jackpal.androidterm.TermDebug; import jackpal.androidterm.model.SessionFinishCallback; import jackpal.androidterm.model.UpdateCallback; import jackpal.androidterm.util.ByteQueue; import jackpal.androidterm.util.TermSettings; /** * A terminal session, consisting of a TerminalEmulator, a TranscriptScreen, * the PID of the process attached to the session, and the I/O streams used to * talk to the process. */ public class TermSession { private TermSettings mSettings; private UpdateCallback mNotify; private SessionFinishCallback mFinishCallback; private int mProcId; private FileDescriptor mTermFd; private FileOutputStream mTermOut; private FileInputStream mTermIn; private TranscriptScreen mTranscriptScreen; private TerminalEmulator mEmulator; private Thread mPollingThread; private ByteQueue mByteQueue; private byte[] mReceiveBuffer; private CharBuffer mWriteCharBuffer; private ByteBuffer mWriteByteBuffer; private CharsetEncoder mUTF8Encoder; private String mProcessExitMessage; private static final int DEFAULT_COLUMNS = 80; private static final int DEFAULT_ROWS = 24; private static final String DEFAULT_SHELL = "/system/bin/sh -"; private static final String DEFAULT_INITIAL_COMMAND = "export PATH=/data/local/bin:$PATH"; // Number of rows in the transcript private static final int TRANSCRIPT_ROWS = 10000; private static final int NEW_INPUT = 1; private static final int PROCESS_EXITED = 2; private boolean mIsRunning = false; private Handler mMsgHandler = new Handler() { @Override public void handleMessage(Message msg) { if (!mIsRunning) { return; } if (msg.what == NEW_INPUT) { readFromProcess(); } else if (msg.what == PROCESS_EXITED) { onProcessExit((Integer) msg.obj); } } }; public TermSession(TermSettings settings, SessionFinishCallback finishCallback, String initialCommand) { mSettings = settings; mFinishCallback = finishCallback; int[] processId = new int[1]; createSubprocess(processId); mProcId = processId[0]; mTermOut = new FileOutputStream(mTermFd); mTermIn = new FileInputStream(mTermFd); int[] colorScheme = settings.getColorScheme(); mTranscriptScreen = new TranscriptScreen(DEFAULT_COLUMNS, TRANSCRIPT_ROWS, DEFAULT_ROWS, colorScheme[0], colorScheme[2]); mEmulator = new TerminalEmulator(settings, mTranscriptScreen, DEFAULT_COLUMNS, DEFAULT_ROWS, mTermOut); mIsRunning = true; Thread watcher = new Thread() { @Override public void run() { Log.i(TermDebug.LOG_TAG, "waiting for: " + mProcId); int result = Exec.waitFor(mProcId); Log.i(TermDebug.LOG_TAG, "Subprocess exited: " + result); mMsgHandler.sendMessage(mMsgHandler.obtainMessage(PROCESS_EXITED, result)); } }; watcher.setName("Process watcher"); watcher.start(); mWriteCharBuffer = CharBuffer.allocate(2); mWriteByteBuffer = ByteBuffer.allocate(4); mUTF8Encoder = Charset.forName("UTF-8").newEncoder(); mUTF8Encoder.onMalformedInput(CodingErrorAction.REPLACE); mUTF8Encoder.onUnmappableCharacter(CodingErrorAction.REPLACE); mReceiveBuffer = new byte[4 * 1024]; mByteQueue = new ByteQueue(4 * 1024); mPollingThread = new Thread() { private byte[] mBuffer = new byte[4096]; @Override public void run() { try { while(true) { int read = mTermIn.read(mBuffer); if (read == -1) { // EOF -- process exited return; } mByteQueue.write(mBuffer, 0, read); mMsgHandler.sendMessage( mMsgHandler.obtainMessage(NEW_INPUT)); } } catch (IOException e) { } catch (InterruptedException e) { } } }; mPollingThread.setName("Input reader"); mPollingThread.start(); sendInitialCommand(initialCommand); } private void sendInitialCommand(String initialCommand) { if (initialCommand == null || initialCommand.equals("")) { initialCommand = DEFAULT_INITIAL_COMMAND; } if (initialCommand.length() > 0) { write(initialCommand + '\r'); } } public void write(String data) { try { mTermOut.write(data.getBytes("UTF-8")); mTermOut.flush(); } catch (IOException e) { // Ignore exception // We don't really care if the receiver isn't listening. // We just make a best effort to answer the query. } } public void write(int codePoint) { CharBuffer charBuf = mWriteCharBuffer; ByteBuffer byteBuf = mWriteByteBuffer; CharsetEncoder encoder = mUTF8Encoder; try { charBuf.clear(); byteBuf.clear(); Character.toChars(codePoint, charBuf.array(), 0); encoder.reset(); encoder.encode(charBuf, byteBuf, true); encoder.flush(byteBuf); mTermOut.write(byteBuf.array(), 0, byteBuf.position()-1); mTermOut.flush(); } catch (IOException e) { // Ignore exception } } private void createSubprocess(int[] processId) { String shell = mSettings.getShell(); if (shell == null || shell.equals("")) { shell = DEFAULT_SHELL; } ArrayList<String> argList = parse(shell); String arg0 = argList.get(0); String[] args = argList.toArray(new String[1]); mTermFd = Exec.createSubprocess(arg0, args, null, processId); } private ArrayList<String> parse(String cmd) { final int PLAIN = 0; final int WHITESPACE = 1; final int INQUOTE = 2; int state = WHITESPACE; ArrayList<String> result = new ArrayList<String>(); int cmdLen = cmd.length(); StringBuilder builder = new StringBuilder(); for (int i = 0; i < cmdLen; i++) { char c = cmd.charAt(i); if (state == PLAIN) { if (Character.isWhitespace(c)) { result.add(builder.toString()); builder.delete(0,builder.length()); state = WHITESPACE; } else if (c == '"') { state = INQUOTE; } else { builder.append(c); } } else if (state == WHITESPACE) { if (Character.isWhitespace(c)) { // do nothing } else if (c == '"') { state = INQUOTE; } else { state = PLAIN; builder.append(c); } } else if (state == INQUOTE) { if (c == '\\') { if (i + 1 < cmdLen) { i += 1; builder.append(cmd.charAt(i)); } } else if (c == '"') { state = PLAIN; } else { builder.append(c); } } } if (builder.length() > 0) { result.add(builder.toString()); } return result; } public FileOutputStream getTermOut() { return mTermOut; } public TranscriptScreen getTranscriptScreen() { return mTranscriptScreen; } public TerminalEmulator getEmulator() { return mEmulator; } public void setUpdateCallback(UpdateCallback notify) { mNotify = notify; } public void updateSize(int columns, int rows) { // Inform the attached pty of our new size: Exec.setPtyWindowSize(mTermFd, rows, columns, 0, 0); mEmulator.updateSize(columns, rows); } public String getTranscriptText() { return mTranscriptScreen.getTranscriptText(); } /** * Look for new input from the ptty, send it to the terminal emulator. */ private void readFromProcess() { int bytesAvailable = mByteQueue.getBytesAvailable(); int bytesToRead = Math.min(bytesAvailable, mReceiveBuffer.length); try { int bytesRead = mByteQueue.read(mReceiveBuffer, 0, bytesToRead); mEmulator.append(mReceiveBuffer, 0, bytesRead); } catch (InterruptedException e) { } if (mNotify != null) { mNotify.onUpdate(); } } public void updatePrefs(TermSettings settings) { mSettings = settings; mEmulator.updatePrefs(settings); int[] colorScheme = settings.getColorScheme(); mTranscriptScreen.setDefaultColors(colorScheme[0], colorScheme[2]); } public void reset() { mEmulator.reset(); } /* XXX We should really get this ourselves from the resource bundle, but we cannot hold a context */ public void setProcessExitMessage(String message) { mProcessExitMessage = message; } private void onProcessExit(int result) { if (mSettings.closeWindowOnProcessExit()) { if (mFinishCallback != null) { mFinishCallback.onSessionFinish(this); } finish(); } else if (mProcessExitMessage != null) { try { byte[] msg = ("\r\n[" + mProcessExitMessage + "]").getBytes("UTF-8"); mEmulator.append(msg, 0, msg.length); mNotify.onUpdate(); } catch (UnsupportedEncodingException e) { // Never happens } } } public void finish() { Exec.hangupProcessGroup(mProcId); Exec.close(mTermFd); mIsRunning = false; mTranscriptScreen.finish(); } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
145843b228f13d4e0bcc3a0cfa16367b4ef23996
980ef8bafb796683ff95bd3a03f607c037d450cd
/src/main/java/com/epam/tolstolutskyi/task9/localization/provider/CookiesLocalizationProvider.java
80b848e02f2506577c066e81439db102b5f7cc08
[]
no_license
Evgeniy-Tolstolutskiy/internet_shop
238634570755db5f753b3a5b45b4fbe2f945a4f6
a245246de673a663a2f48e7320444cfcca027d21
refs/heads/master
2021-01-13T06:10:53.842557
2017-06-20T09:05:05
2017-06-20T09:05:05
94,870,359
0
0
null
null
null
null
UTF-8
Java
false
false
960
java
package com.epam.tolstolutskyi.task9.localization.provider; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class CookiesLocalizationProvider implements LocalizationProvider { private int cookieTimeout; public CookiesLocalizationProvider(int cookieTimeout) { this.cookieTimeout = cookieTimeout; } public void saveLocale(String locale, HttpServletRequest request, HttpServletResponse response) { Cookie cookie = new Cookie("locale", locale); cookie.setMaxAge(cookieTimeout); response.addCookie(cookie); } public String getLocale(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); if (cookies == null) { throw new NullPointerException("cookies are disabled"); } String locale = ""; for (Cookie cookie : cookies) { if (cookie.getName().equals("locale")) { locale = cookie.getValue(); } } return locale; } }
[ "izhenya7@gmail.com" ]
izhenya7@gmail.com
3f161393ef8d5392ef6f9da4053ce15d44bdeeae
c2746cece274f6d2b14083d4781e6e51ef3c9fcb
/src/main/java/com/alicloud/openservices/tablestore/timestream/model/expression/GeoPolygonExpression.java
3d8298e1481980b375b164b687d610f87e204010
[ "Apache-2.0" ]
permissive
aliyun/aliyun-tablestore-java-sdk
4c7e7a91be13e8b2584148b1db64aa65bf6a9188
0718c5d7563cf1b43c635e883b66a4331d876fe9
refs/heads/master
2023-08-04T21:50:39.930193
2023-07-27T12:36:00
2023-07-27T12:36:00
58,621,439
55
23
Apache-2.0
2023-09-07T05:41:27
2016-05-12T08:10:04
Java
UTF-8
Java
false
false
927
java
package com.alicloud.openservices.tablestore.timestream.model.expression; import com.alicloud.openservices.tablestore.model.search.query.GeoBoundingBoxQuery; import com.alicloud.openservices.tablestore.model.search.query.GeoPolygonQuery; import com.alicloud.openservices.tablestore.model.search.query.Query; import java.util.Arrays; import java.util.List; /** * Created by yanglian on 2019/4/9. */ public class GeoPolygonExpression implements Expression { private GeoPolygonQuery query; public GeoPolygonExpression(List<String> polygonList) { query = new GeoPolygonQuery(); query.setPoints(polygonList); } public GeoPolygonExpression(String[] polygonList) { query = new GeoPolygonQuery(); query.setPoints(Arrays.asList(polygonList)); } @Override public Query getQuery(String columnName) { query.setFieldName(columnName); return query; } }
[ "yanglian@yangliandeMacBook-Pro.local" ]
yanglian@yangliandeMacBook-Pro.local
f52b2bfdac37c19f87d8fb46edc85fa0d3a0eee0
f4bdafe62aed690dda916eab33bc52ba21fedf10
/Switch/src/com/company/SumOddRange.java
6cc0843491a4b3bd8beccfa92d87a14cb0efee1d
[]
no_license
osman-s/Java2020
6cf1c8700c76c59696546bbbf06f39e40f5e5401
5d4db5514ae844db37e99df402211583ea5147d6
refs/heads/main
2023-01-14T01:03:26.147687
2020-11-20T23:18:42
2020-11-20T23:18:42
308,532,639
0
0
null
null
null
null
UTF-8
Java
false
false
626
java
package com.company; public class SumOddRange { public static boolean isOdd(int number) { if (number < 0) { return false; } if (number % 2 == 0) { return false; } else { return true; } } public static int sumOdd(int start, int end) { if ((end >= start) && start > 0 && end > 0) { int sum = 0; for (int i=start; i <= end; i++) { if(isOdd(i)) { sum += i; } } return sum; } else { return -1; } } }
[ "osmanshasan@gmail.com" ]
osmanshasan@gmail.com
9283c3646f60484d580ff411d3b4c632e1255c81
06cab87750932062518d74c725358fd4724d44da
/net/minecraft/server/Packet29DestroyEntity.java
3177f6f3d3573b8bb47b7811cce8cd36626e18a0
[]
no_license
ammaraskar/mc-dev
4c4ca4842bfebe97fa4157000296a80d9aa6d9be
db794558e5961372b3558385f8ae0ddf03e6747d
refs/heads/master
2021-01-09T06:28:51.458689
2012-03-30T15:08:24
2012-03-30T20:11:24
null
0
0
null
null
null
null
UTF-8
Java
false
false
616
java
package net.minecraft.server; import java.io.DataInputStream; import java.io.DataOutputStream; public class Packet29DestroyEntity extends Packet { public int a; public Packet29DestroyEntity() {} public Packet29DestroyEntity(int i) { this.a = i; } public void a(DataInputStream datainputstream) { this.a = datainputstream.readInt(); } public void a(DataOutputStream dataoutputstream) { dataoutputstream.writeInt(this.a); } public void handle(NetHandler nethandler) { nethandler.a(this); } public int a() { return 4; } }
[ "erikbroes@grum.nl" ]
erikbroes@grum.nl
869388f7077ea311a2d343fdd5b6ef62a299fe89
accb81bec5df52611e40c6edbbd9f31664337d0d
/productInfo/src/productinfo/Product.java
86f0b9b1408e4a46f68b856285abb11c40668f37
[]
no_license
saifulcs40/Java2015Saif
e64ef6ff6ad845e1097fb52967d7e1279385a47f
a5ff16f69d77df09e2cb4f1b56494f7d545d681e
refs/heads/master
2021-09-02T05:13:59.868963
2017-12-30T17:56:34
2017-12-30T17:56:34
108,231,689
0
0
null
null
null
null
UTF-8
Java
false
false
1,192
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 productinfo; /** * * @author Saiful Islam */ class Product { private int productId; private String productName; private String brandName; private double unitPrice; public Product() { } public Product(int productId, String productName, String brandName, double unitPrice) { this.productId = productId; this.productName = productName; this.brandName = brandName; this.unitPrice = unitPrice; } public int getProductId() { return productId; } public String getProductName() { return productName; } public String getBrandName() { return brandName; } public double getUnitPrice() { return unitPrice; } @Override public String toString() { return "Product{" + "productId=" + productId + ", productName=" + productName + ", brandName=" + brandName + ", unitPrice=" + unitPrice + '}'; } }
[ "noreply@github.com" ]
noreply@github.com
f67b0b44f0d841983448240b67b9b6db54f5515e
24677eca954fde71416d2f83e2247f05a63c03c3
/android/app/src/main/java/org/iita/ckanmobile/MainActivity.java
edc4fa8024c9c2db10d47383cebe9c6e5a343d44
[]
no_license
iitadmcoders/ckanmobile
0727d011bfd5f1228a9aeb629a58a1a6646a8475
5fd9b8c4e6b004a8797d0d48363229b3e94aa884
refs/heads/master
2020-12-28T10:01:03.652180
2020-02-11T05:31:32
2020-02-11T05:31:32
238,281,000
0
0
null
null
null
null
UTF-8
Java
false
false
1,198
java
package org.iita.ckanmobile; import android.os.Build; import android.os.Bundle; import android.view.ViewTreeObserver; import android.view.WindowManager; import io.flutter.app.FlutterActivity; import io.flutter.plugins.GeneratedPluginRegistrant; public class MainActivity extends FlutterActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(0x00000000); //transparent status bar GeneratedPluginRegistrant.registerWith(this); ViewTreeObserver viewTreeObserver = getFlutterView().getViewTreeObserver(); viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { getFlutterView().getViewTreeObserver().removeOnGlobalLayoutListener(this); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }); } else { GeneratedPluginRegistrant.registerWith(this); } } }
[ "ayukaphanuel@gmail.com" ]
ayukaphanuel@gmail.com
78c63c2da989ee019cda25d72ba7a3a188ca3d4b
df9de4bef9fb2457462ba2133792fb5618b2104e
/app/src/main/java/com/hjy/dagger2demo/constant/Config.java
708b7226a783fa3008beae5488bf0e744bb385fe
[]
no_license
JiayiHuang/Dagger2Demo
498b7311154d7dfc447643732288be3e42e29bc9
f3948aae80349562bd514be784f994fc600fdf6c
refs/heads/master
2021-05-11T12:23:26.431348
2018-01-17T07:06:54
2018-01-17T07:06:54
117,657,540
0
0
null
null
null
null
UTF-8
Java
false
false
248
java
package com.hjy.dagger2demo.constant; /** * <pre> * author : HJY * time : 2018/01/16/16:52 * desc : 文件描述 * version: 当前版本号 * </pre> */ public class Config { public static final String TAG = "TAG"; }
[ "huangjiyun@v1.cn" ]
huangjiyun@v1.cn
64fe8da7967e151c0e3124ad20593b11a3448961
baa3ca16ece08d8af0b085b58167c0876fb55c96
/Tercero/PADSOF 2.0/P4/src/control/ControlCrearRespuesta.java
5e478d5522fea6e2bc279a1a9253e21a504bd1b5
[]
no_license
ZhijieQ/inf-uam
851d66b1484a63cdf6e2f35209075abf07bdb830
38079fdd5da5bb0ea35fa3265e813e0fe1a3bdd1
refs/heads/master
2021-06-01T10:20:44.917316
2016-08-23T18:24:12
2016-08-23T18:24:12
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,588
java
package control; import grupo.GrupoEstudio; import gui.*; import java.awt.event.*; import javax.swing.JOptionPane; import usuario.Estudiante; import mailUam.MailUam; /** * @author Antonio Gomez lucas, Mario Valdemaro Garcia Roque * * Clase ControlCrearRespuesta */ public class ControlCrearRespuesta implements ActionListener { private MailUam modelo; private Ventana v; /** * Constructor de ControlCrearRespuesta * * @param v * Modelo de las ventanas * @param modelo * Aplicacion donde estan los datos */ public ControlCrearRespuesta(Ventana v, MailUam modelo) { this.modelo = modelo; this.v = v; } /** * @return the modelo */ public MailUam getModelo() { return modelo; } /** * @param modelo * the modelo to set */ public void setModelo(MailUam modelo) { this.modelo = modelo; } /** * @return the v */ public Ventana getV() { return v; } /** * @param v * the v to set */ public void setV(Ventana v) { this.v = v; } @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub Object source = arg0.getSource(); System.out.println("Activando controlador: " + getClass()); GUICrearRespuesta crearRespuesta = v.getCrearRespuesta(); if (source.equals(crearRespuesta.getBotonMensajes())) { GUIMensaje menuMensaje = getV().getMensajes(); menuMensaje.setValores(); System.out.println("Cambiando a Mensajes"); v.cambiarPanelMenuMensajes(); } else if (source.equals(crearRespuesta.getBotonGrupos())) { System.out.println("Cambiando a Grupos"); GUIMenuGrupo menuGrupo = v.getMenuGrupos(); menuGrupo.setValores(); v.cambiarPanelMenuGrupos(); } else if (source.equals(crearRespuesta.getBotonVerPerfil())) { System.out.println("Cambiando a Perfil"); GUIVerPerfil verPerfil = v.getPerfil(); verPerfil.setValores(modelo.getLogged()); v.cambiarPanelPerfil(); } else if (source.equals(crearRespuesta.getBotonSalir())) { System.out.println("Cambiando a Salir"); modelo.logout(); v.cambiarPanelLogin(); } else if (source.equals(crearRespuesta.getButtonResponder())) { if (crearRespuesta.getTextRespuesta() == null || crearRespuesta.getTextRespuesta().equals("")) { JOptionPane.showMessageDialog(crearRespuesta, "No se puede crear una respuesta sin contenido", "Error", JOptionPane.ERROR_MESSAGE); return; } else { if (!(getModelo().getLogged() instanceof Estudiante)) { JOptionPane.showMessageDialog(crearRespuesta, "Para responder debe de ser un estudiante", "Error", JOptionPane.ERROR_MESSAGE); getV().cambiarPanelVerGrupo(); return; } getModelo().cargarGrupos(); getModelo().cargarUsuarios(); GrupoEstudio g = (GrupoEstudio) getModelo().buscarGrupo( getV().getListarPreguntas().getGrupo().getNombre()); crearRespuesta.setPregunta(g.buscarPregunta(crearRespuesta .getPregunta().getCuerpo())); crearRespuesta.getPregunta().addRespuesta( crearRespuesta.getTextRespuestaText(), (Estudiante) getModelo().getLogged()); // System.out.println(((GrupoEstudio)getModelo().buscarGrupo("asd")).getListaPreguntas().get(0).getListaRespuestas()); getModelo().guardarGrupos(); getModelo().guardarUsuarios(); System.out.println(crearRespuesta.getPregunta() .getListaRespuestas()); v.cambiarPanelVerGrupo(); } } } }
[ "mariogr_93@hotmail.com" ]
mariogr_93@hotmail.com
6e81e55c0223839780e07d3696f01fe497d48c62
b93cc73aca11b52da609a8c95dbd7a5d97543e75
/app/src/main/java/com/jsoft/jcomic/GridViewActivity.java
ca6d90a5f2f3819d1807b48f6b7cc6ea85ad30ac
[]
no_license
komangulo/JComics-Lector-De-Comics-En-Japones
2c4faedc2d6d00e4826df92cd320c403e4262ba0
1f1d7c80d1f4adcb778cd5d8371ad6a39b0004c4
refs/heads/master
2020-04-23T23:57:05.532376
2019-02-19T10:29:34
2019-02-19T10:29:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
9,194
java
package com.jsoft.jcomic; import android.content.Intent; import android.content.res.Resources; import android.net.Uri; import android.net.http.HttpResponseCache; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.util.TypedValue; import android.view.View; import android.webkit.WebSettings; import android.webkit.WebViewClient; import android.webkit.WebView; import android.widget.GridView; import com.jsoft.jcomic.adapter.GridViewImageAdapter; import com.jsoft.jcomic.helper.AppConstant; import com.jsoft.jcomic.helper.BookDTO; import com.jsoft.jcomic.helper.BookmarkDb; import com.jsoft.jcomic.helper.Utils; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; public class GridViewActivity extends AppCompatActivity { private Utils utils; private ArrayList<String> imagePaths = new ArrayList<>(); private GridViewImageAdapter adapter; private GridView gridView; private WebView webView; private int columnWidth; private List<BookDTO> books; private BookmarkDb bookmarkDb; private GridViewActivity gridViewActivity; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); bookmarkDb = new BookmarkDb(this); books = bookmarkDb.getBookmarkedList(); //books = new ArrayList<BookDTO>(); enableHttpCaching(); gridViewActivity = this; setContentView(R.layout.activity_grid_view); utils = new Utils(this); initWebView(); gridView = initGridLayout(); adapter = new GridViewImageAdapter(GridViewActivity.this, columnWidth, books); gridView.setAdapter(adapter); bookmarkDb.clearDb(); } @Override public void onResume() { super.onResume(); books = bookmarkDb.getBookmarkedList(); adapter = new GridViewImageAdapter(GridViewActivity.this, columnWidth, books); gridView.setAdapter(adapter); } @Override public void onBackPressed() { if (webView.getVisibility() == View.VISIBLE && webView.canGoBack()) { webView.goBack(); return; } else if (webView.getVisibility() == View.VISIBLE) { webView.setVisibility(View.GONE); gridView.setVisibility(View.VISIBLE); return; } // Otherwise defer to system default behavior. super.onBackPressed(); } private GridView initGridLayout() { Resources r = getResources(); gridView = (GridView) findViewById(R.id.grid_view); float padding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, AppConstant.GRID_PADDING, r.getDisplayMetrics()); int numColumns = 3; columnWidth = (int) ((utils.getScreenWidth() - ((numColumns + 1) * padding)) / numColumns); gridView.setNumColumns(numColumns); gridView.setColumnWidth(columnWidth); gridView.setStretchMode(GridView.NO_STRETCH); gridView.setPadding((int) padding, (int) padding, (int) padding, (int) padding); gridView.setHorizontalSpacing((int) padding); gridView.setVerticalSpacing((int) padding); return gridView; } private void initWebView() { webView = (WebView) findViewById(R.id.web_view); webView.setVisibility(View.INVISIBLE); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { try { Uri uri = Uri.parse(url); if (/*(uri.getHost().contains("dm5.com") && uri.getPath().startsWith("/manhua-") && (uri.getQueryParameter("from") != null || webView.getUrl().contains("search?title="))) || */(uri.getHost().contains("cartoonmad.com") && uri.getPath().startsWith("/m/comic/")) || (uri.getHost().contains("comicbus.com") && uri.getPath().startsWith("/comic/"))) { Intent i = new Intent(gridViewActivity, EpisodeListActivity.class); i.putExtra("bookUrl", url); startActivity(i); return true; } else if (uri.getHost().contains("dm5.com")) { new InterceptDM5Task("UTF-8", view).execute(new URL(uri.toString())); return true; } } catch (Exception e) { Log.e("jComics", "Caught by shouldOverrideUrlLoading", e); } return false; } }); } public class InterceptDM5Task extends AsyncTask<URL, Integer, List<String>> { private String encoding; private WebView wv; private String url; public InterceptDM5Task(String encoding, WebView wv) { this.encoding = encoding; this.wv = wv; } protected List<String> doInBackground(URL... urls) { List<String> result = new ArrayList<String>(); URL urlConn = urls[0]; this.url = urls[0].toString(); try { HttpURLConnection conn = (HttpURLConnection) urlConn.openConnection(); conn.setReadTimeout(5000); conn.setUseCaches(true); conn.setRequestProperty("Referer", "http://m.dm5.com/manhua-list/"); InputStream is = new BufferedInputStream(conn.getInputStream()); BufferedReader in = new BufferedReader(new InputStreamReader(is, encoding)); String readLine; while ((readLine = in.readLine()) != null) { result.add(readLine); } in.close(); is.close(); } catch (Exception e) { Log.e("jComics", "Caught by InterceptDM5Task", e); } return result; } protected void onProgressUpdate(Integer... progress) { } protected void onPostExecute(List<String> result) { String data = ""; if (result.size() > 0) { for (int i=0;i<result.size();i++) { data = data + "\n" + result.get(i).replaceAll("\\s{4,}", "\n"); } } if (data.contains("chapteritem")) { Intent i = new Intent(gridViewActivity, EpisodeListActivity.class); i.putExtra("bookUrl", url); gridViewActivity.startActivity(i); } else { data = data.replaceAll("var tagid = \"(.*)\";", "var tagid = \"$1\"; var categoryid = \"0\""); wv.loadDataWithBaseURL(url, data, "text/html; charset=utf-8", "utf-8", null); } } } public void getEpisodeList(int position) { Intent i = new Intent(this, EpisodeListActivity.class); i.putExtra("bookUrl", books.get(position).getBookUrl()); startActivityForResult(i, position); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { } public void goToCartoonMad(View view) { openWebView("https://www.cartoonmad.com/m/?act=2"); } public void goTo8Comic(View view) { openWebView("http://m.comicbus.com/"); } public void goToDM5(View view) { webView.setVisibility(View.VISIBLE); gridView.setVisibility(View.GONE); try { new InterceptDM5Task("UTF-8", webView).execute(new URL("http://m.dm5.com/manhua-list/")); } catch (Exception e) { Log.e("jComics", "Caught by goToDM5", e); } } public void goToHome(View view) { webView.setVisibility(View.GONE); gridView.setVisibility(View.VISIBLE); } private void openWebView(String url) { webView.setVisibility(View.VISIBLE); gridView.setVisibility(View.GONE); webView.loadUrl(url); } private void enableHttpCaching() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { try { File httpCacheDir = new File(getApplicationContext().getCacheDir() , "http"); long httpCacheSize = 100 * 1024 * 1024; // 10 MiB HttpResponseCache.install(httpCacheDir, httpCacheSize); } catch (IOException e) { } } else { File httpCacheDir = new File(getApplicationContext().getCacheDir() , "http"); try { HttpResponseCache.install(httpCacheDir, 100 * 1024 * 1024); } catch (IOException e) { } } } }
[ "jordenyt@gmail.com" ]
jordenyt@gmail.com
bc2bfc4003e514b94553fc2cbe23e97139bd3d43
2c08b138b073a113b5f9ed9591cd15476276f390
/src/main/java/com/zlp/AutoCreateTableApplication.java
47e3d5bcfe786e93c4bdff2821ce3852dcf32835
[]
no_license
zlp676825368/auto-create-table
a80fbcb95fc6fb06d0a8175b3580837489eb9817
d9016b5e967b18eeca24b0620703a7f52020bf2b
refs/heads/main
2023-01-05T15:42:44.569862
2020-11-05T01:40:53
2020-11-05T01:40:53
310,161,020
1
0
null
null
null
null
UTF-8
Java
false
false
440
java
package com.zlp; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; @SpringBootApplication public class AutoCreateTableApplication { public static void main(String[] args) { SpringApplication.run(AutoCreateTableApplication.class, args); } }
[ "13882870519@163.com" ]
13882870519@163.com
4a9ef897b7c3d363ac6f0f6c590b7f52d04831dd
a2c0d4468bf975eb22b1c1cb037a9d9849d6bc14
/ProyectosJava/almacenWebService/AlmacenWS/src/java/pe/com/almacen/bean/ProductoBean.java
cd663572fecc7b4db4337e75d5c9e28a45ca26f9
[]
no_license
Iccher/DUKENET
ae4225fc9264ca44ff8a24075c8005764ce1f971
97ce6413309f30a247698c538a1389d9b4127fa5
refs/heads/master
2021-01-10T17:56:39.052859
2013-04-12T00:38:46
2013-04-12T00:38:46
null
0
0
null
null
null
null
UTF-8
Java
false
false
645
java
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package pe.com.almacen.bean; /** * * @author Ronalc */ public class ProductoBean { private String idProducto; private String cantidadProducto; public String getIdProducto() { return idProducto; } public void setIdProducto(String idProducto) { this.idProducto = idProducto; } public String getCantidadProducto() { return cantidadProducto; } public void setCantidadProducto(String cantidadProducto) { this.cantidadProducto = cantidadProducto; } }
[ "rnld1503@gmail.com" ]
rnld1503@gmail.com
d76145a315c36435738c3b74743ed1caf7788f14
6c24d430f0b138800302de8931119d303f008f2a
/161-One-Edit-Distance/solution.java
c7c73b51e13369487c13d50f558347c4613b6d74
[]
no_license
Charliebob/LeetCode
740981c80769924bb5d9b150346971b2c8d05347
a230b1ba0fe4ae289ef67c91f4c8c9e649c8cb8a
refs/heads/master
2020-12-07T15:32:05.206723
2016-10-12T22:04:53
2016-10-12T22:04:53
58,330,106
0
0
null
null
null
null
UTF-8
Java
false
false
949
java
public class Solution { public boolean isOneEditDistance(String s, String t) { //if(Math.abs(s.length()-t.length())>1) return false; for (int i = 0; i < Math.min(s.length(), t.length()); i++) { if (s.charAt(i) != t.charAt(i)) { if (s.length() == t.length()) // s has the same length as t, so the only possibility is replacing one char in s and t return s.substring(i + 1).equals(t.substring(i + 1)); else if (s.length() < t.length()) // t is longer than s, so the only possibility is deleting one char from t return s.substring(i).equals(t.substring(i + 1)); else // s is longer than t, so the only possibility is deleting one char from s return t.substring(i).equals(s.substring(i + 1)); } } //All previous chars are the same, the only possibility is deleting the end char in the longer one of s and t return Math.abs(s.length() - t.length()) == 1; } }
[ "cxz131330@utdallas.edu" ]
cxz131330@utdallas.edu
437c1db6614d6fedc40692d21181b25f51ff1b64
2564154d166bc5623a8108102aa948a64a5391cd
/cathayWeb/src/com/fxdms/rmi/service/MyRMISocket.java
947ab6a0cdf4218816082135537f8618224ff713
[]
no_license
thorhsu/cathay
64dc1ad10db366624bc5a770c1e958b6ea766b09
ac74e18a601104bf5f4a508b2e9799cd1ec1d641
refs/heads/master
2021-01-21T14:24:29.161731
2017-06-24T11:35:23
2017-06-24T11:35:23
95,278,328
1
0
null
null
null
null
UTF-8
Java
false
false
983
java
package com.fxdms.rmi.service; import java.io.IOException; import java.io.Serializable; import java.net.ServerSocket; import java.net.Socket; import java.rmi.server.RMISocketFactory; import org.apache.log4j.Logger; public class MyRMISocket extends RMISocketFactory implements Serializable { /** * */ private static final long serialVersionUID = 1L; private Logger logger = Logger.getLogger(MyRMISocket.class); public Socket createSocket(String host, int port) throws IOException { System.out.println("my host:" + host + "| port:" + port); logger.info("my host:" + host + "| port:" + port); return new Socket(host, port); } public ServerSocket createServerSocket(int port) throws IOException { System.out.println("RMI transfert port =" + port); if (port == 0) port = 1099; System.out.println("RMI transfert port =" + port); logger.info("RMI transfer port =" + port); return new ServerSocket(port); } }
[ "thorshu@gmail.com" ]
thorshu@gmail.com
ebea377f62ce8f06acce814ff8bf1dfcc5465dfa
a171912df3804e92a7bd4ce87546529fbdff38f3
/src/com/ss/lms/service/AdminService.java
659cd464daaa5ab95f090647ee2b69aaa299e2d9
[]
no_license
brunoara21/lms_jdbc
a28aa285c42d5badf9018ee051b6db9d6c74c268
4a4938434724e7023129ca88c465c918a2224bbd
refs/heads/main
2023-06-26T05:55:12.229932
2021-07-26T17:03:52
2021-07-26T17:03:52
386,892,634
0
0
null
null
null
null
UTF-8
Java
false
false
27,932
java
/** * */ package com.ss.lms.service; import java.sql.Connection; import java.sql.SQLException; import java.util.Arrays; import java.util.List; import com.ss.lms.dao.AuthorDAO; import com.ss.lms.dao.BookAuthorsDAO; import com.ss.lms.dao.BookCopiesDAO; import com.ss.lms.dao.BookDAO; import com.ss.lms.dao.BookGenresDAO; import com.ss.lms.dao.BookLoansDAO; import com.ss.lms.dao.BorrowerDAO; import com.ss.lms.dao.GenreDAO; import com.ss.lms.dao.LibraryBranchDAO; import com.ss.lms.dao.PublisherDAO; import com.ss.lms.model.Author; import com.ss.lms.model.BaseModel; import com.ss.lms.model.Book; import com.ss.lms.model.BookAuthors; import com.ss.lms.model.BookCopies; import com.ss.lms.model.BookGenres; import com.ss.lms.model.BookLoans; import com.ss.lms.model.Borrower; import com.ss.lms.model.Genre; import com.ss.lms.model.LibraryBranch; import com.ss.lms.model.Publisher; /** * @author Bruno * */ public class AdminService extends BaseService{ Util util = new Util(); public String add(BaseModel toAdd) { if (toAdd instanceof Publisher) { return addPublisher((Publisher) toAdd); } else if (toAdd instanceof Author) { return addAuthor((Author) toAdd); } else if (toAdd instanceof Genre) { return addGenre((Genre) toAdd); } else if (toAdd instanceof LibraryBranch) { return addLibraryBranch((LibraryBranch) toAdd); } else if (toAdd instanceof Book) { return addBook((Book) toAdd); } else if (toAdd instanceof Borrower) { return addBorrower((Borrower) toAdd); } return "Something went wrong when adding."; } public String update(BaseModel toUpdate) { if (toUpdate instanceof Publisher) { return updatePublisher((Publisher) toUpdate); } else if (toUpdate instanceof Author) { return updateAuthor((Author) toUpdate); } else if (toUpdate instanceof Genre) { return updateGenre((Genre) toUpdate); } else if (toUpdate instanceof LibraryBranch) { return updateLibraryBranch((LibraryBranch) toUpdate); } else if (toUpdate instanceof Book) { return updateBook((Book) toUpdate); } else if (toUpdate instanceof Borrower) { return updateBorrower((Borrower) toUpdate); } return "Something went wrong when updating."; } public String delete(BaseModel toDelete) { if (toDelete instanceof Publisher) { return deletePublisher((Publisher) toDelete); } else if (toDelete instanceof Author) { return deleteAuthor((Author) toDelete); } else if (toDelete instanceof Genre) { return deleteGenre((Genre) toDelete); } else if (toDelete instanceof LibraryBranch) { return deleteLibraryBranch((LibraryBranch) toDelete); } else if (toDelete instanceof Book) { return deleteBook((Book) toDelete); } else if (toDelete instanceof Borrower) { return deleteBorrower((Borrower) toDelete); } return "Something went wrong when deleting."; } public String addBook(Book toAdd) { Connection conn = null; try { try { conn = util.getConnection(); BookDAO bdao = new BookDAO(conn); BookAuthorsDAO badao = new BookAuthorsDAO(conn); BookGenresDAO bgdao = new BookGenresDAO(conn); Integer pK = bdao.createBook(toAdd); toAdd.setBookId(pK); for (Author a : toAdd.getBookAuthors()) { if (a != null) { BookAuthors bookAuthor = new BookAuthors(); bookAuthor.setValues(Arrays.asList(a, toAdd)); badao.createBookAuthors(bookAuthor); } } for (Genre g : toAdd.getBookGenres()) { if (g != null) { BookGenres bookGenre = new BookGenres(); bookGenre.setValues(Arrays.asList(g, toAdd)); bgdao.createBookGenres(bookGenre); } } conn.commit(); return "Book added successfully"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Book could not be added"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Book could not be added, problem with connection."; } } public String addAuthorToBook(Book toUpdate, Author toAdd) { Connection conn = null; try { try { conn = util.getConnection(); BookAuthorsDAO badao = new BookAuthorsDAO(conn); BookAuthors ba = new BookAuthors(); ba.setValues(Arrays.asList(toAdd, toUpdate)); badao.createBookAuthors(ba); conn.commit(); return "Author '" + toAdd.getName() + "' successfully added into Book"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Author could not be added"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Author could not be added, problem with connection."; } } public String deleteAuthorFromBook(Book toUpdate, Author toDelete) { Connection conn = null; try { try { conn = util.getConnection(); BookAuthorsDAO badao = new BookAuthorsDAO(conn); BookAuthors ba = new BookAuthors(); ba.setValues(Arrays.asList(toDelete, toUpdate)); badao.deleteBookAuthors(ba); conn.commit(); return "Author '" + toDelete.getName() + "' successfully deleted from Book"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Author could not be deleted"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Author could not be deleted, problem with connection."; } } public String updateAuthorFromBook(Book book, Author toUpdate, Author fromUpdate) { Connection conn = null; try { try { conn = util.getConnection(); BookAuthorsDAO badao = new BookAuthorsDAO(conn); BookAuthors ba = new BookAuthors(); ba.setValues(Arrays.asList(toUpdate, book)); badao.updateBookAuthors_Author(ba, fromUpdate.getAuthorId()); conn.commit(); return "Author '" + toUpdate.getName() + "' to '"+ fromUpdate.getName()+"' successfully updated from Book"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Author could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Author could not be updated, problem with connection."; } } public String addGenreToBook(Book toUpdate, Genre toAdd) { Connection conn = null; try { try { conn = util.getConnection(); BookGenresDAO bgdao = new BookGenresDAO(conn); BookGenres bg = new BookGenres(); bg.setValues(Arrays.asList(toAdd, toUpdate)); bgdao.createBookGenres(bg); conn.commit(); return "Genre '" + toAdd.getName() + "' successfully added into Book"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Genre could not be added"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Genre could not be added, problem with connection."; } } public String deleteGenreFromBook(Book toUpdate, Genre toDelete) { Connection conn = null; try { try { conn = util.getConnection(); BookGenresDAO bgdao = new BookGenresDAO(conn); BookGenres bg = new BookGenres(); bg.setValues(Arrays.asList(toDelete, toUpdate)); bgdao.deleteBookGenres(bg); conn.commit(); return "Genre '" + toDelete.getName() + "' successfully deleted from Book"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Genre could not be deleted"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Genre could not be deleted, problem with connection."; } } public String updateGenreFromBook(Book book, Genre toUpdate, Genre fromUpdate) { Connection conn = null; try { try { conn = util.getConnection(); BookGenresDAO bgdao = new BookGenresDAO(conn); BookGenres bg = new BookGenres(); bg.setValues(Arrays.asList(toUpdate, book)); bgdao.updateBookGenres_Genre(bg, fromUpdate.getGenreId()); conn.commit(); return "Genre '" + toUpdate.getName() + "' to '"+ fromUpdate.getName()+"' successfully updated from Book"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Genre could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Genre could not be updated, problem with connection."; } } public String updatePublisherFromBook(Book book, Publisher toUpdate) { Connection conn = null; try { try { conn = util.getConnection(); BookDAO bdao = new BookDAO(conn); String oldPublisher = book.getPublisher().getName(); book.setPublisher(toUpdate); bdao.updateBook(book); conn.commit(); return "Publisher from '" + oldPublisher + "' to '" + toUpdate.getName() + "' successfully updated for Book"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Publisher could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Publisher could not be updated, problem with connection."; } } public String updateTitleFromBook(Book book, String toUpdate) { Connection conn = null; try { try { conn = util.getConnection(); BookDAO bdao = new BookDAO(conn); book.setTitle(toUpdate); bdao.updateBook(book); conn.commit(); return "Title successfully updated to '" + toUpdate + "' from Book"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Title could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Title could not be updated, problem with connection."; } } public String updateBook(Book toUpdate) { Connection conn = null; try { try { conn = util.getConnection(); BookDAO pdao = new BookDAO(conn); pdao.updateBook(toUpdate); conn.commit(); return "Book '" + toUpdate.getTitle() + "' successfully updated"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Book could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Book could not be updated, problem with connection."; } } public String deleteBook(Book toDelete) { Connection conn = null; try { try { conn = util.getConnection(); BookDAO bdao = new BookDAO(conn); bdao.deleteBook(toDelete); conn.commit(); return "Book '" + toDelete.getTitle() + "' successfully deleted"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Book could not be deleted"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Book could not be deleted, problem with connection."; } } public List<Book> readBooks() { Connection conn = null; try { try { conn = util.getConnection(); BookDAO bdao = new BookDAO(conn); BookAuthorsDAO badao = new BookAuthorsDAO(conn); BookGenresDAO bgdao = new BookGenresDAO(conn); BookCopiesDAO bcdao = new BookCopiesDAO(conn); List<Book> books = bdao.readAllBooks(); for(Book b: books) { b.setBookAuthors(badao.readAllBookAuthors_Authors(b.getBookId())); b.setBookGenres(bgdao.readAllBookGenres_Genres(b.getBookId())); b.setBookBranches(bcdao.readAllBookCopies_Branches(b.getBookId())); } return books; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public String addAuthor(Author toAdd) { Connection conn = null; try { try { conn = util.getConnection(); AuthorDAO adao = new AuthorDAO(conn); Integer pK = adao.createAuthor(toAdd); toAdd.setAuthorId(pK); conn.commit(); return "Author '" + toAdd.getAuthorName() + "' added successfully"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Author could not be added"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Author could not be added, problem with connection."; } } public String updateAuthor(Author toUpdate) { Connection conn = null; try { try { conn = util.getConnection(); AuthorDAO adao = new AuthorDAO(conn); adao.updateAuthor(toUpdate); conn.commit(); return "Author '" + toUpdate.getAuthorName() + "' successfully updated"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Author could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Author could not be updated, problem with connection."; } } public String deleteAuthor(Author toDelete) { Connection conn = null; try { try { conn = util.getConnection(); AuthorDAO adao = new AuthorDAO(conn); adao.deleteAuthor(toDelete); conn.commit(); return "Author '" + toDelete.getAuthorName() + "' successfully deleted"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Author could not be deleted"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Author could not be deleted, problem with connection."; } } public List<Author> readAuthors() { Connection conn = null; try { try { conn = util.getConnection(); AuthorDAO adao = new AuthorDAO(conn); List<Author> authors = adao.readAllAuthors(); // TODO POPULATE CHILD ELEMENTS return authors; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public Author readAuthor(Integer pK) { Connection conn = null; try { try { conn = util.getConnection(); AuthorDAO adao = new AuthorDAO(conn); Author author = adao.readAuthor(pK); // TODO POPULATE CHILD ELEMENTS return author; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public String addPublisher(Publisher toAdd) { Connection conn = null; try { try { conn = util.getConnection(); PublisherDAO pdao = new PublisherDAO(conn); Integer pK = pdao.createPublisher(toAdd); toAdd.setPublisherId(pK); conn.commit(); return "Publisher '" + toAdd.getPublisherName() + "' added successfully"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Publisher could not be added"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Publisher could not be added, problem with connection."; } } public String updatePublisher(Publisher toUpdate) { Connection conn = null; try { try { conn = util.getConnection(); PublisherDAO pdao = new PublisherDAO(conn); pdao.updatePublisher(toUpdate); conn.commit(); return "Publisher '" + toUpdate.getPublisherName() + "' successfully updated"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Publisher could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Publisher could not be updated, problem with connection."; } } public String deletePublisher(Publisher toDelete) { Connection conn = null; try { try { conn = util.getConnection(); PublisherDAO pdao = new PublisherDAO(conn); pdao.deletePublisher(toDelete); conn.commit(); return "Publisher '" + toDelete.getPublisherName() + "' successfully deleted"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Publisher could not be deleted"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Publisher could not be deleted, problem with connection."; } } public List<Publisher> readPublishers() { Connection conn = null; try { try { conn = util.getConnection(); PublisherDAO pdao = new PublisherDAO(conn); List<Publisher> publishers = pdao.readAllPublishers(); // TODO POPULATE CHILD ELEMENTS return publishers; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public Publisher readPublisher(Integer pK) { Connection conn = null; try { try { conn = util.getConnection(); PublisherDAO pdao = new PublisherDAO(conn); Publisher publisher = pdao.readPublisher(pK); // TODO POPULATE CHILD ELEMENTS return publisher; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public String addGenre(Genre toAdd) { Connection conn = null; try { try { conn = util.getConnection(); GenreDAO pdao = new GenreDAO(conn); Integer pK = pdao.createGenre(toAdd); toAdd.setGenreId(pK); conn.commit(); return "Genre '" + toAdd.getGenreName() + "' added successfully"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Genre could not be added"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Genre could not be added, problem with connection."; } } public String updateGenre(Genre toUpdate) { Connection conn = null; try { try { conn = util.getConnection(); GenreDAO pdao = new GenreDAO(conn); pdao.updateGenre(toUpdate); conn.commit(); return "Genre '" + toUpdate.getGenreName() + "' successfully updated"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Genre could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Genre could not be updated, problem with connection."; } } public String deleteGenre(Genre toDelete) { Connection conn = null; try { try { conn = util.getConnection(); GenreDAO pdao = new GenreDAO(conn); pdao.deleteGenre(toDelete); conn.commit(); return "Genre '" + toDelete.getGenreName() + "' successfully deleted"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Genre could not be deleted"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Genre could not be deleted, problem with connection."; } } public List<Genre> readGenres() { Connection conn = null; try { try { conn = util.getConnection(); GenreDAO pdao = new GenreDAO(conn); List<Genre> genres = pdao.readAllGenres(); // TODO POPULATE CHILD ELEMENTS return genres; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public Genre readGenre(Integer pK) { Connection conn = null; try { try { conn = util.getConnection(); GenreDAO gdao = new GenreDAO(conn); Genre genre = gdao.readGenre(pK); // TODO POPULATE CHILD ELEMENTS return genre; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public String addBorrower(Borrower toAdd) { Connection conn = null; try { try { conn = util.getConnection(); BorrowerDAO pdao = new BorrowerDAO(conn); Integer pK = pdao.createBorrower(toAdd); toAdd.setCardNo(pK); conn.commit(); return "Borrower '" + toAdd.getBorrowerName() + "' added successfully"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Borrower could not be added"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Borrower could not be added, problem with connection."; } } public String updateBorrower(Borrower toUpdate) { Connection conn = null; try { try { conn = util.getConnection(); BorrowerDAO pdao = new BorrowerDAO(conn); pdao.updateBorrower(toUpdate); conn.commit(); return "Borrower '" + toUpdate.getBorrowerName() + "' successfully updated"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Borrower could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Borrower could not be updated, problem with connection."; } } public String deleteBorrower(Borrower toDelete) { Connection conn = null; try { try { conn = util.getConnection(); BorrowerDAO pdao = new BorrowerDAO(conn); pdao.deleteBorrower(toDelete); conn.commit(); return "Borrower '" + toDelete.getBorrowerName() + "' successfully deleted"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Borrower could not be deleted"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Borrower could not be deleted, problem with connection."; } } public List<Borrower> readBorrowers() { Connection conn = null; try { try { conn = util.getConnection(); BorrowerDAO pdao = new BorrowerDAO(conn); List<Borrower> borrowers = pdao.readAllBorrowers(); // TODO POPULATE CHILD ELEMENTS return borrowers; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public Borrower readBorrower(Integer cardNo) { Connection conn = null; try { try { conn = util.getConnection(); BorrowerDAO bdao = new BorrowerDAO(conn); Borrower borrower = bdao.readBorrower(cardNo); // TODO POPULATE CHILD ELEMENTS return borrower; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public List<BookLoans> readBookLoansFromBorrower(Borrower borrower) { Connection conn = null; try { try { conn = util.getConnection(); BookLoansDAO bldao = new BookLoansDAO(conn); List<BookLoans> bookLoans = bldao.readAllBookLoans_FromBorrower(borrower); // TODO POPULATE CHILD ELEMENTS return bookLoans; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public String updateDueDate(BookLoans bookLoan) { Connection conn = null; try { try { conn = util.getConnection(); BookLoansDAO bldao = new BookLoansDAO(conn); bldao.updateBookLoans(bookLoan); conn.commit(); return "Book Loan succesfully updated. New due date is '" + bookLoan.getDueDate().toLocalDateTime().toLocalDate() + "'"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Book Loan could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Book Loan could not be updated, problem with connection."; } } public String addLibraryBranch(LibraryBranch toAdd) { Connection conn = null; try { try { conn = util.getConnection(); LibraryBranchDAO pdao = new LibraryBranchDAO(conn); Integer pK = pdao.createLibraryBranch(toAdd); toAdd.setBranchId(pK); conn.commit(); return "Library Branch '" + toAdd.getBranchName() + "' added successfully"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Library Branch could not be added"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Library Branch could not be added, problem with connection."; } } public String updateLibraryBranch(LibraryBranch toUpdate) { Connection conn = null; try { try { conn = util.getConnection(); LibraryBranchDAO pdao = new LibraryBranchDAO(conn); pdao.updateLibraryBranch(toUpdate); conn.commit(); return "Library Branch '" + toUpdate.getBranchName() + "' successfully updated"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Library Branch could not be updated"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Library Branch could not be updated, problem with connection."; } } public String deleteLibraryBranch(LibraryBranch toDelete) { Connection conn = null; try { try { conn = util.getConnection(); LibraryBranchDAO pdao = new LibraryBranchDAO(conn); pdao.deleteLibraryBranch(toDelete); conn.commit(); return "Library Branch '" + toDelete.getBranchName() + "' successfully deleted"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Library Branch could not be deleted"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Library Branch could not be deleted, problem with connection."; } } public List<LibraryBranch> readLibraryBranches() { Connection conn = null; try { try { conn = util.getConnection(); LibraryBranchDAO pdao = new LibraryBranchDAO(conn); List<LibraryBranch> publishers = pdao.readAllLibraryBranches(); // TODO POPULATE CHILD ELEMENTS return publishers; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public LibraryBranch readLibraryBranch(Integer pK) { Connection conn = null; try { try { conn = util.getConnection(); LibraryBranchDAO lbdao = new LibraryBranchDAO(conn); LibraryBranch libBranch = lbdao.readLibraryBranch(pK); // TODO POPULATE CHILD ELEMENTS return libBranch; } catch (Exception e) { e.printStackTrace(); } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); } return null; } public String addBookCopies(BookCopies toAdd) { Connection conn = null; try { try { conn = util.getConnection(); BookCopiesDAO bcdao = new BookCopiesDAO(conn); bcdao.createBookCopies(toAdd); conn.commit(); return "Book Copies added successfully"; } catch (Exception e) { e.printStackTrace(); conn.rollback(); return "Book Copies could not be added"; } finally { if (conn != null) { conn.close(); } } } catch (SQLException e) { e.printStackTrace(); return "Book Copies could not be added, problem with connection."; } } }
[ "bruno.rebaza@smoothstack.com" ]
bruno.rebaza@smoothstack.com
7edbc0adaf7b56676344e3a03d7721ebb1655990
64322bd5f1416d50a1e9e14a87acde2ce746dd08
/src/com/android/launcher3/Hotseat.java
37fec7e10e125c706f01ca1305d074ef0720d867
[ "Apache-2.0" ]
permissive
woshiwzy/mylauncher3
aef83ddc278fedd8edf6ee9a1165efee866dc0b3
8b9a0b230e12534b820a86643c36bef6246193a8
refs/heads/master
2021-06-21T01:52:06.165156
2017-08-02T07:02:48
2017-08-02T07:02:48
99,083,290
0
0
null
null
null
null
UTF-8
Java
false
false
8,989
java
/* * Copyright (C) 2011 The Android Open Source 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 com.android.launcher3; import android.content.ComponentName; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; import android.widget.TextView; import java.util.ArrayList; public class Hotseat extends FrameLayout { private static final String TAG = "Hotseat"; private CellLayout mContent; private Launcher mLauncher; private int mAllAppsButtonRank; private boolean mTransposeLayoutWithOrientation; private boolean mIsLandscape; public Hotseat(Context context) { this(context, null); } public Hotseat(Context context, AttributeSet attrs) { this(context, attrs, 0); } public Hotseat(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); Resources r = context.getResources(); mTransposeLayoutWithOrientation = r.getBoolean(R.bool.hotseat_transpose_layout_with_orientation); mIsLandscape = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; } public void setup(Launcher launcher) { mLauncher = launcher; } CellLayout getLayout() { return mContent; } /** * Registers the specified listener on the cell layout of the hotseat. */ @Override public void setOnLongClickListener(OnLongClickListener l) { mContent.setOnLongClickListener(l); } private boolean hasVerticalHotseat() { return (mIsLandscape && mTransposeLayoutWithOrientation); } /* Get the orientation invariant order of the item in the hotseat for persistence. */ int getOrderInHotseat(int x, int y) { return hasVerticalHotseat() ? (mContent.getCountY() - y - 1) : x; } /* Get the orientation specific coordinates given an invariant order in the hotseat. */ int getCellXFromOrder(int rank) { return hasVerticalHotseat() ? 0 : rank; } int getCellYFromOrder(int rank) { return hasVerticalHotseat() ? (mContent.getCountY() - (rank + 1)) : 0; } public boolean isAllAppsButtonRank(int rank) { if (LauncherAppState.isDisableAllApps()) { return false; } else { return rank == mAllAppsButtonRank; } } /** This returns the coordinates of an app in a given cell, relative to the DragLayer */ Rect getCellCoordinates(int cellX, int cellY) { Rect coords = new Rect(); mContent.cellToRect(cellX, cellY, 1, 1, coords); int[] hotseatInParent = new int[2]; Utilities.getDescendantCoordRelativeToParent(this, mLauncher.getDragLayer(), hotseatInParent, false); coords.offset(hotseatInParent[0], hotseatInParent[1]); // Center the icon int cWidth = mContent.getShortcutsAndWidgets().getCellContentWidth(); int cHeight = mContent.getShortcutsAndWidgets().getCellContentHeight(); int cellPaddingX = (int) Math.max(0, ((coords.width() - cWidth) / 2f)); int cellPaddingY = (int) Math.max(0, ((coords.height() - cHeight) / 2f)); coords.offset(cellPaddingX, cellPaddingY); return coords; } @Override protected void onFinishInflate() { super.onFinishInflate(); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); mAllAppsButtonRank = grid.hotseatAllAppsRank; mContent = (CellLayout) findViewById(R.id.layout); if (grid.isLandscape && !grid.isLargeTablet()) { mContent.setGridSize(1, (int) grid.numHotseatIcons); } else { mContent.setGridSize((int) grid.numHotseatIcons, 1); } mContent.setIsHotseat(true); resetLayout(); } void resetLayout() { mContent.removeAllViewsInLayout(); if (!LauncherAppState.isDisableAllApps()) { // Add the Apps button Context context = getContext(); LayoutInflater inflater = LayoutInflater.from(context); TextView allAppsButton = (TextView) inflater.inflate(R.layout.all_apps_button, mContent, false); Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon); Utilities.resizeIconDrawable(d); allAppsButton.setCompoundDrawables(null, d, null, null); allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label)); allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener()); if (mLauncher != null) { allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener()); mLauncher.setAllAppsButton(allAppsButton); allAppsButton.setOnClickListener(mLauncher); allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler); } // Note: We do this to ensure that the hotseat is always laid out in the orientation of // the hotseat in order regardless of which orientation they were added int x = getCellXFromOrder(mAllAppsButtonRank); int y = getCellYFromOrder(mAllAppsButtonRank); CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x,y,1,1); lp.canReorder = false; mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true); } } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { // We don't want any clicks to go through to the hotseat unless the workspace is in // the normal state. if (mLauncher.getWorkspace().workspaceInModalState()) { return true; } return false; } void addAllAppsFolder(IconCache iconCache, ArrayList<AppInfo> allApps, ArrayList<ComponentName> onWorkspace, Launcher launcher, Workspace workspace) { if (LauncherAppState.isDisableAllApps()) { FolderInfo fi = new FolderInfo(); fi.cellX = getCellXFromOrder(mAllAppsButtonRank); fi.cellY = getCellYFromOrder(mAllAppsButtonRank); fi.spanX = 1; fi.spanY = 1; fi.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT; fi.screenId = mAllAppsButtonRank; fi.itemType = LauncherSettings.Favorites.ITEM_TYPE_FOLDER; fi.title = "More Apps"; LauncherModel.addItemToDatabase(launcher, fi, fi.container, fi.screenId, fi.cellX, fi.cellY, false); FolderIcon folder = FolderIcon.fromXml(R.layout.folder_icon, launcher, getLayout(), fi, iconCache); workspace.addInScreen(folder, fi.container, fi.screenId, fi.cellX, fi.cellY, fi.spanX, fi.spanY); for (AppInfo info: allApps) { ComponentName cn = info.intent.getComponent(); if (!onWorkspace.contains(cn)) { Log.d(TAG, "Adding to 'more apps': " + info.intent); ShortcutInfo si = info.makeShortcut(); fi.add(si); } } } } void addAppsToAllAppsFolder(ArrayList<AppInfo> apps) { if (LauncherAppState.isDisableAllApps()) { View v = mContent.getChildAt(getCellXFromOrder(mAllAppsButtonRank), getCellYFromOrder(mAllAppsButtonRank)); FolderIcon fi = null; if (v instanceof FolderIcon) { fi = (FolderIcon) v; } else { return; } FolderInfo info = fi.getFolderInfo(); for (AppInfo a: apps) { ShortcutInfo si = a.makeShortcut(); info.add(si); } } } }
[ "wzyfly@sina.com" ]
wzyfly@sina.com
90d72de2e994ea8e6d16f7d8108dee796ea05c00
e9368c9381eb2215b8968f271c5952eae18a2428
/poker/src/main/java/com/dy/kata/poker/v1/PokerGame.java
f3124f47682f6f6ffb7565d9e613524493732a9b
[]
no_license
oracs/codekata
bcaba4df775ab2f0d02409030d6b574c72576461
6b9f316427f1b25059b05112fc0a07dd85ad60a0
refs/heads/master
2021-09-10T14:46:28.888641
2018-03-28T01:35:05
2018-03-28T01:35:05
109,691,254
0
0
null
null
null
null
UTF-8
Java
false
false
564
java
package com.dy.kata.poker.v1; import static com.dy.kata.poker.v1.Rule.highcardRule; import static com.dy.kata.poker.v1.Rule.rules; public class PokerGame { public String play(String hand1, String hand2) { Player player1 = parseHand(hand1); Player player2 = parseHand(hand2); Result result = player1.compare(player2, rules(highcardRule())); return String.format("%s wins. - with %s", result.getWinner(), result.getReason()); } private Player parseHand(String hand) { return new Parser().parse(hand); } }
[ "oracs@163.com" ]
oracs@163.com
9dbc7bf09f5df2469b8496d18c1d74e1b1cdeb0f
129e41ad71545d7323d6749f5c949b296fc09d5c
/Data Structures/src/com/mirdar/dataStructures/lcs/package-info.java
3afe2c2ec3306822df2ccfc90ecb2c9f8e86bdcf
[]
no_license
mirdar/Data-Structures
a4cb1b1f46ad754005b310e90bf578a24fd3b4c3
490c5b9468b08e2c2a1dce6c7030e7595c3c38d0
refs/heads/master
2020-05-22T00:04:42.916596
2016-11-02T02:55:54
2016-11-02T02:55:54
62,187,345
1
0
null
null
null
null
GB18030
Java
false
false
388
java
/** * */ /** * @author mirdar * 1. dp实现了 最长公共子序列 并以树的形式打印出所有子序列 * 2. 循环形式与dp形式实现了 最长公共子串 * 3. 实现了最短递增子序列,循环形式(利用到二叉查找),dp形式 * 4. 实现了最短子序列和 归并形式与一个简单的方式求解 * * */ package com.mirdar.dataStructures.lcs;
[ "mirdar@foxmail.com" ]
mirdar@foxmail.com
bd846e50eff75d8a720675439e46b89b437e856d
63990ae44ac4932f17801d051b2e6cec4abb8ad8
/bus-gitlab/src/main/java/org/aoju/bus/gitlab/LicenseTemplatesApi.java
67371bdd2644cee46d20a7e1d65ccb207f74c3ae
[ "MIT" ]
permissive
xeon-ye/bus
2cca99406a540cf23153afee8c924433170b8ba5
6e927146074fe2d23f9c9f23433faad5f9e40347
refs/heads/master
2023-03-16T17:47:35.172996
2021-02-22T10:31:48
2021-02-22T10:31:48
null
0
0
null
null
null
null
UTF-8
Java
false
false
6,792
java
/********************************************************************************* * * * The MIT License (MIT) * * * * Copyright (c) 2015-2021 aoju.org Greg Messner and other contributors. * * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * of this software and associated documentation files (the "Software"), to deal * * in the Software without restriction, including without limitation the rights * * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included in * * all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * * THE SOFTWARE. * * * ********************************************************************************/ package org.aoju.bus.gitlab; import org.aoju.bus.gitlab.models.LicenseTemplate; import javax.ws.rs.core.Response; import java.util.List; import java.util.Optional; import java.util.stream.Stream; /** * This class provides an entry point to all the GitLab API licenses calls. * * @author Kimi Liu * @version 6.2.0 * @see <a href="https://docs.gitlab.com/ce/api/templates/licenses.html">Licenses API</a> * @since JDK 1.8+ */ public class LicenseTemplatesApi extends AbstractApi { public LicenseTemplatesApi(GitLabApi gitLabApi) { super(gitLabApi); } /** * Get a List of all license templates. * * <pre><code>GitLab Endpoint: GET /templates/licenses</code></pre> * * @return a List of LicenseTemplate instances * @throws GitLabApiException if any exception occurs */ public List<LicenseTemplate> getLicenseTemplates() throws GitLabApiException { return (getLicenseTemplates(false, getDefaultPerPage()).all()); } /** * Get a Stream of all license templates. * * <pre><code>GitLab Endpoint: GET /templates/licenses</code></pre> * * @return a Stream of LicenseTemplate instances * @throws GitLabApiException if any exception occurs */ public Stream<LicenseTemplate> getLicenseTemplatesStream() throws GitLabApiException { return (getLicenseTemplates(false, getDefaultPerPage()).stream()); } /** * Get a Pager of all license templates. * * <pre><code>GitLab Endpoint: GET /templates/licenses</code></pre> * * @param itemsPerPage the number of LicenseTemplate instances that will be fetched per page * @return a Pager of LicenseTemplate instances * @throws GitLabApiException if any exception occurs */ public Pager<LicenseTemplate> getLicenseTemplates(int itemsPerPage) throws GitLabApiException { return (getLicenseTemplates(false, itemsPerPage)); } /** * Get a List of popular license templates. * * <pre><code>GitLab Endpoint: GET /templates/licenses?popular=true</code></pre> * * @return a List of popular LicenseTemplate instances * @throws GitLabApiException if any exception occurs */ public List<LicenseTemplate> getPopularLicenseTemplates() throws GitLabApiException { return (getLicenseTemplates(true, getDefaultPerPage()).all()); } /** * Get a Stream of popular license templates. * * <pre><code>GitLab Endpoint: GET /templates/licenses?popular=true</code></pre> * * @return a Stream of popular LicenseTemplate instances * @throws GitLabApiException if any exception occurs */ public Stream<LicenseTemplate> getPopularLicenseTemplatesStream() throws GitLabApiException { return (getLicenseTemplates(true, getDefaultPerPage()).stream()); } /** * Get a Pager of license templates. * * <pre><code>GitLab Endpoint: GET /templates/licenses</code></pre> * * @param popular if true, returns only popular licenses. * @param itemsPerPage the number of LicenseTemplate instances that will be fetched per page * @return a Pager of LicenseTemplate instances * @throws GitLabApiException if any exception occurs */ public Pager<LicenseTemplate> getLicenseTemplates(Boolean popular, int itemsPerPage) throws GitLabApiException { GitLabApiForm formData = new GitLabApiForm().withParam("popular", popular); return (new Pager<LicenseTemplate>(this, LicenseTemplate.class, itemsPerPage, formData.asMap(), "templates", "licenses")); } /** * Get a single license template. * * <pre><code>GitLab Endpoint: GET /templates/licenses/:key</code></pre> * * @param key The key of the license template * @return a LicenseTemplate instance * @throws GitLabApiException if any exception occurs */ public LicenseTemplate getLicenseTemplate(String key) throws GitLabApiException { Response response = get(Response.Status.OK, null, "licenses", key); return (response.readEntity(LicenseTemplate.class)); } /** * Get a single license template as the value of an Optional. * * <pre><code>GitLab Endpoint: GET /templates/licenses/:key</code></pre> * * @param key The key of the license template * @return a single license template as the value of an Optional. */ public Optional<LicenseTemplate> getOptionalLicenseTemplate(String key) { try { return (Optional.ofNullable(getLicenseTemplate(key))); } catch (GitLabApiException glae) { return (GitLabApi.createOptionalFromException(glae)); } } }
[ "839536@qq.com" ]
839536@qq.com
464b75feacf614c4b16a8c9fe97832602d17d53a
0ef83246357d8cc16882c3ee5489c981085d8617
/app/src/main/java/cn/xiaocool/hongyunschool/utils/MultiPartStringRequest.java
a4f51b24a0e01cc18e8f3d3c7022ae5d79db7bd0
[]
no_license
dk123sw/HongYunSchool_android
6eb77b8edcd95af922cb0809e60e8dc185efac70
ef485c6f3bf904ab60b8632d787571ecfcf2b2bf
refs/heads/master
2021-01-12T17:09:02.920827
2016-10-25T09:35:54
2016-10-25T09:35:54
71,517,815
1
0
null
2016-10-21T01:18:03
2016-10-21T01:18:02
null
UTF-8
Java
false
false
3,414
java
/** * Copyright 2013 Mani Selvaraj * <p> * 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 * <p> * http://www.apache.org/licenses/LICENSE-2.0 * <p> * 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 cn.xiaocool.hongyunschool.utils; import com.android.volley.NetworkResponse; import com.android.volley.Request; import com.android.volley.Response; import com.android.volley.Response.ErrorListener; import com.android.volley.Response.Listener; import com.android.volley.toolbox.HttpHeaderParser; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; /** * MultipartRequest - To handle the large file uploads. * Extended from JSONRequest. You might want to change to StringRequest based on your response type. * @author Mani Selvaraj * */ public class MultiPartStringRequest extends Request<String> implements MultiPartRequest { private final Listener<String> mListener; /* To hold the parameter name and the File to upload */ private Map<String, File> fileUploads = new HashMap<String, File>(); /* To hold the parameter name and the string content to upload */ private Map<String, String> stringUploads = new HashMap<String, String>(); /** * Creates a new request with the given method. * * @param method the request {@link Method} to use * @param url URL to fetch the string at * @param listener Listener to receive the String response * @param errorListener Error listener, or null to ignore errors */ public MultiPartStringRequest(int method, String url, Listener<String> listener, ErrorListener errorListener) { super(method, url, errorListener); mListener = listener; } @Override public void addFileUpload(String param, File file) { fileUploads.put(param, file); } @Override public void addStringUpload(String param, String content) { stringUploads.put(param, content); } @Override public Map<String, File> getFileUploads() { return fileUploads; } /** * 要上传的文件 */ /** * 要上传的参数 */ @Override public Map<String, String> getStringUploads() { return stringUploads; } @Override protected Response<String> parseNetworkResponse(NetworkResponse response) { String parsed; try { parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); } catch (UnsupportedEncodingException e) { parsed = new String(response.data); } return Response.success(parsed, HttpHeaderParser.parseCacheHeaders(response)); } @Override protected void deliverResponse(String response) { if (mListener != null) { mListener.onResponse(response); } } /** * 空表示不上传 */ public String getBodyContentType() { return null; } }
[ "1328254616@qq.com" ]
1328254616@qq.com
ee15ec0cdd806994f811f14c39f7ae5dc6bf9a41
ea142fc74ed864cdae0be99a1371e3dfd00aefe2
/db/src/main/java/cn/pumpkin/db/sp/SPImpl.java
c242f355dac0fb5763cf651d100317bacd854239
[]
no_license
MMLoveMeMM/Zhehu
0c38e7ab93e5e6f435b9bf8bf3aea80317d4dc89
11a3d13767a93a9a64b8902d3d175bae904e4257
refs/heads/master
2020-04-08T12:14:38.568996
2019-02-14T08:54:21
2019-02-14T08:54:21
159,338,729
0
0
null
null
null
null
UTF-8
Java
false
false
3,711
java
package cn.pumpkin.db.sp; import android.content.Context; import android.content.SharedPreferences; import java.util.Map; /** * @author: zhibao.Liu * @version: * @date: 2018/12/17 20:36 * @des: * @see {@link } */ public class SPImpl implements ISP { private SharedPreferences sharedPreferences; public SPImpl(Context context, String name) { sharedPreferences = context.getApplicationContext().getSharedPreferences(name, Context.MODE_PRIVATE); } @Override public void putApply(String key, Object object) { if (null == object) { return; } SharedPreferences.Editor editor = sharedPreferences.edit(); if (object instanceof String) { editor.putString(key, (String) object); } else if (object instanceof Integer) { editor.putInt(key, (Integer) object); } else if (object instanceof Boolean) { editor.putBoolean(key, (Boolean) object); } else if (object instanceof Float) { editor.putFloat(key, (Float) object); } else if (object instanceof Long) { editor.putLong(key, (Long) object); } else { editor.putString(key, object.toString()); } editor.apply(); } @Override public void putCommit(String key, Object object) { if (null == object) { return; } SharedPreferences.Editor editor = sharedPreferences.edit(); if (object instanceof String) { editor.putString(key, (String) object); } else if (object instanceof Integer) { editor.putInt(key, (Integer) object); } else if (object instanceof Boolean) { editor.putBoolean(key, (Boolean) object); } else if (object instanceof Float) { editor.putFloat(key, (Float) object); } else if (object instanceof Long) { editor.putLong(key, (Long) object); } else { editor.putString(key, object.toString()); } editor.commit(); } @Override public Object get(String key, Object defaultObject) { if (defaultObject instanceof String) { return sharedPreferences.getString(key, (String) defaultObject); } else if (defaultObject instanceof Integer) { return sharedPreferences.getInt(key, (Integer) defaultObject); } else if (defaultObject instanceof Boolean) { return sharedPreferences.getBoolean(key, (Boolean) defaultObject); } else if (defaultObject instanceof Float) { return sharedPreferences.getFloat(key, (Float) defaultObject); } else if (defaultObject instanceof Long) { return sharedPreferences.getLong(key, (Long) defaultObject); } else { return sharedPreferences.getString(key, null); } } /** * 移除某个key值已经对应的值 * * @param key */ @Override public void remove(String key) { SharedPreferences.Editor editor = sharedPreferences.edit(); editor.remove(key); editor.commit(); } /** * 清除所有的数据 */ @Override public void clear() { SharedPreferences.Editor editor = sharedPreferences.edit(); editor.clear(); editor.commit(); } /** * 查询某个key是否存在 * * @param key * @return */ @Override public boolean contains(String key) { return sharedPreferences.contains(key); } /** * 返回所有的键值对 * * @return */ @Override public Map<String, ?> getAll() { return sharedPreferences.getAll(); } }
[ "liuzhibao@xl.cn" ]
liuzhibao@xl.cn
ae82269640cbc0ad540d340ec7d66da9cca498da
c0e6fc6a0c715c91a24cb598b79da276c4e39d22
/src/main/java/yandex/cloud/api/mdb/opensearch/v1/Opensearch.java
e1d73fd51f588d7ce7bb27e5886fe55bac725b90
[ "MIT" ]
permissive
yandex-cloud/java-genproto
9bbffd1a6ae346562ddc7a69a6a2e0afb194a63c
2b28369a6af1e497200058446aef473bd95af846
refs/heads/master
2023-09-04T05:34:01.719629
2023-08-28T09:31:29
2023-08-28T09:31:29
206,794,093
2
3
null
null
null
null
UTF-8
Java
false
true
84,863
java
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: yandex/cloud/mdb/opensearch/v1/config/opensearch.proto package yandex.cloud.api.mdb.opensearch.v1; public final class Opensearch { private Opensearch() {} public static void registerAllExtensions( com.google.protobuf.ExtensionRegistryLite registry) { } public static void registerAllExtensions( com.google.protobuf.ExtensionRegistry registry) { registerAllExtensions( (com.google.protobuf.ExtensionRegistryLite) registry); } public interface OpenSearchConfig2OrBuilder extends // @@protoc_insertion_point(interface_extends:yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2) com.google.protobuf.MessageOrBuilder { /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> * @return Whether the maxClauseCount field is set. */ boolean hasMaxClauseCount(); /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> * @return The maxClauseCount. */ com.google.protobuf.Int64Value getMaxClauseCount(); /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> */ com.google.protobuf.Int64ValueOrBuilder getMaxClauseCountOrBuilder(); /** * <pre> * the percentage or absolute value (10%, 512mb) of heap space that is allocated to fielddata * </pre> * * <code>string fielddata_cache_size = 4;</code> * @return The fielddataCacheSize. */ java.lang.String getFielddataCacheSize(); /** * <pre> * the percentage or absolute value (10%, 512mb) of heap space that is allocated to fielddata * </pre> * * <code>string fielddata_cache_size = 4;</code> * @return The bytes for fielddataCacheSize. */ com.google.protobuf.ByteString getFielddataCacheSizeBytes(); /** * <code>string reindex_remote_whitelist = 6;</code> * @return The reindexRemoteWhitelist. */ java.lang.String getReindexRemoteWhitelist(); /** * <code>string reindex_remote_whitelist = 6;</code> * @return The bytes for reindexRemoteWhitelist. */ com.google.protobuf.ByteString getReindexRemoteWhitelistBytes(); } /** * Protobuf type {@code yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2} */ public static final class OpenSearchConfig2 extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2) OpenSearchConfig2OrBuilder { private static final long serialVersionUID = 0L; // Use OpenSearchConfig2.newBuilder() to construct. private OpenSearchConfig2(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { super(builder); } private OpenSearchConfig2() { fielddataCacheSize_ = ""; reindexRemoteWhitelist_ = ""; } @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance( UnusedPrivateParameter unused) { return new OpenSearchConfig2(); } @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; } private OpenSearchConfig2( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { this(); if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { boolean done = false; while (!done) { int tag = input.readTag(); switch (tag) { case 0: done = true; break; case 26: { com.google.protobuf.Int64Value.Builder subBuilder = null; if (maxClauseCount_ != null) { subBuilder = maxClauseCount_.toBuilder(); } maxClauseCount_ = input.readMessage(com.google.protobuf.Int64Value.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom(maxClauseCount_); maxClauseCount_ = subBuilder.buildPartial(); } break; } case 34: { java.lang.String s = input.readStringRequireUtf8(); fielddataCacheSize_ = s; break; } case 50: { java.lang.String s = input.readStringRequireUtf8(); reindexRemoteWhitelist_ = s; break; } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { done = true; } break; } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(this); } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException( e).setUnfinishedMessage(this); } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfig2_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfig2_fieldAccessorTable .ensureFieldAccessorsInitialized( yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.class, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder.class); } public static final int MAX_CLAUSE_COUNT_FIELD_NUMBER = 3; private com.google.protobuf.Int64Value maxClauseCount_; /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> * @return Whether the maxClauseCount field is set. */ @java.lang.Override public boolean hasMaxClauseCount() { return maxClauseCount_ != null; } /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> * @return The maxClauseCount. */ @java.lang.Override public com.google.protobuf.Int64Value getMaxClauseCount() { return maxClauseCount_ == null ? com.google.protobuf.Int64Value.getDefaultInstance() : maxClauseCount_; } /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> */ @java.lang.Override public com.google.protobuf.Int64ValueOrBuilder getMaxClauseCountOrBuilder() { return getMaxClauseCount(); } public static final int FIELDDATA_CACHE_SIZE_FIELD_NUMBER = 4; private volatile java.lang.Object fielddataCacheSize_; /** * <pre> * the percentage or absolute value (10%, 512mb) of heap space that is allocated to fielddata * </pre> * * <code>string fielddata_cache_size = 4;</code> * @return The fielddataCacheSize. */ @java.lang.Override public java.lang.String getFielddataCacheSize() { java.lang.Object ref = fielddataCacheSize_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); fielddataCacheSize_ = s; return s; } } /** * <pre> * the percentage or absolute value (10%, 512mb) of heap space that is allocated to fielddata * </pre> * * <code>string fielddata_cache_size = 4;</code> * @return The bytes for fielddataCacheSize. */ @java.lang.Override public com.google.protobuf.ByteString getFielddataCacheSizeBytes() { java.lang.Object ref = fielddataCacheSize_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); fielddataCacheSize_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } public static final int REINDEX_REMOTE_WHITELIST_FIELD_NUMBER = 6; private volatile java.lang.Object reindexRemoteWhitelist_; /** * <code>string reindex_remote_whitelist = 6;</code> * @return The reindexRemoteWhitelist. */ @java.lang.Override public java.lang.String getReindexRemoteWhitelist() { java.lang.Object ref = reindexRemoteWhitelist_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); reindexRemoteWhitelist_ = s; return s; } } /** * <code>string reindex_remote_whitelist = 6;</code> * @return The bytes for reindexRemoteWhitelist. */ @java.lang.Override public com.google.protobuf.ByteString getReindexRemoteWhitelistBytes() { java.lang.Object ref = reindexRemoteWhitelist_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); reindexRemoteWhitelist_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; } @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (maxClauseCount_ != null) { output.writeMessage(3, getMaxClauseCount()); } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(fielddataCacheSize_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 4, fielddataCacheSize_); } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(reindexRemoteWhitelist_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 6, reindexRemoteWhitelist_); } unknownFields.writeTo(output); } @java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (maxClauseCount_ != null) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, getMaxClauseCount()); } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(fielddataCacheSize_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, fielddataCacheSize_); } if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(reindexRemoteWhitelist_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, reindexRemoteWhitelist_); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; } @java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2)) { return super.equals(obj); } yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 other = (yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2) obj; if (hasMaxClauseCount() != other.hasMaxClauseCount()) return false; if (hasMaxClauseCount()) { if (!getMaxClauseCount() .equals(other.getMaxClauseCount())) return false; } if (!getFielddataCacheSize() .equals(other.getFielddataCacheSize())) return false; if (!getReindexRemoteWhitelist() .equals(other.getReindexRemoteWhitelist())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasMaxClauseCount()) { hash = (37 * hash) + MAX_CLAUSE_COUNT_FIELD_NUMBER; hash = (53 * hash) + getMaxClauseCount().hashCode(); } hash = (37 * hash) + FIELDDATA_CACHE_SIZE_FIELD_NUMBER; hash = (53 * hash) + getFielddataCacheSize().hashCode(); hash = (37 * hash) + REINDEX_REMOTE_WHITELIST_FIELD_NUMBER; hash = (53 * hash) + getReindexRemoteWhitelist().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input, extensionRegistry); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input, extensionRegistry); } @java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } public static Builder newBuilder(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } @java.lang.Override public Builder toBuilder() { return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); } @java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /** * Protobuf type {@code yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements // @@protoc_insertion_point(builder_implements:yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2) yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfig2_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfig2_fieldAccessorTable .ensureFieldAccessorsInitialized( yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.class, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder.class); } // Construct using yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.newBuilder() private Builder() { maybeForceBuilderInitialization(); } private Builder( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); } private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessageV3 .alwaysUseFieldBuilders) { } } @java.lang.Override public Builder clear() { super.clear(); if (maxClauseCountBuilder_ == null) { maxClauseCount_ = null; } else { maxClauseCount_ = null; maxClauseCountBuilder_ = null; } fielddataCacheSize_ = ""; reindexRemoteWhitelist_ = ""; return this; } @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfig2_descriptor; } @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getDefaultInstanceForType() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance(); } @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 build() { yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 buildPartial() { yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 result = new yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2(this); if (maxClauseCountBuilder_ == null) { result.maxClauseCount_ = maxClauseCount_; } else { result.maxClauseCount_ = maxClauseCountBuilder_.build(); } result.fielddataCacheSize_ = fielddataCacheSize_; result.reindexRemoteWhitelist_ = reindexRemoteWhitelist_; onBuilt(); return result; } @java.lang.Override public Builder clone() { return super.clone(); } @java.lang.Override public Builder setField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.setField(field, value); } @java.lang.Override public Builder clearField( com.google.protobuf.Descriptors.FieldDescriptor field) { return super.clearField(field); } @java.lang.Override public Builder clearOneof( com.google.protobuf.Descriptors.OneofDescriptor oneof) { return super.clearOneof(oneof); } @java.lang.Override public Builder setRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { return super.setRepeatedField(field, index, value); } @java.lang.Override public Builder addRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.addRepeatedField(field, value); } @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2) { return mergeFrom((yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2)other); } else { super.mergeFrom(other); return this; } } public Builder mergeFrom(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 other) { if (other == yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance()) return this; if (other.hasMaxClauseCount()) { mergeMaxClauseCount(other.getMaxClauseCount()); } if (!other.getFielddataCacheSize().isEmpty()) { fielddataCacheSize_ = other.fielddataCacheSize_; onChanged(); } if (!other.getReindexRemoteWhitelist().isEmpty()) { reindexRemoteWhitelist_ = other.reindexRemoteWhitelist_; onChanged(); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; } @java.lang.Override public final boolean isInitialized() { return true; } @java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; } private com.google.protobuf.Int64Value maxClauseCount_; private com.google.protobuf.SingleFieldBuilderV3< com.google.protobuf.Int64Value, com.google.protobuf.Int64Value.Builder, com.google.protobuf.Int64ValueOrBuilder> maxClauseCountBuilder_; /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> * @return Whether the maxClauseCount field is set. */ public boolean hasMaxClauseCount() { return maxClauseCountBuilder_ != null || maxClauseCount_ != null; } /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> * @return The maxClauseCount. */ public com.google.protobuf.Int64Value getMaxClauseCount() { if (maxClauseCountBuilder_ == null) { return maxClauseCount_ == null ? com.google.protobuf.Int64Value.getDefaultInstance() : maxClauseCount_; } else { return maxClauseCountBuilder_.getMessage(); } } /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> */ public Builder setMaxClauseCount(com.google.protobuf.Int64Value value) { if (maxClauseCountBuilder_ == null) { if (value == null) { throw new NullPointerException(); } maxClauseCount_ = value; onChanged(); } else { maxClauseCountBuilder_.setMessage(value); } return this; } /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> */ public Builder setMaxClauseCount( com.google.protobuf.Int64Value.Builder builderForValue) { if (maxClauseCountBuilder_ == null) { maxClauseCount_ = builderForValue.build(); onChanged(); } else { maxClauseCountBuilder_.setMessage(builderForValue.build()); } return this; } /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> */ public Builder mergeMaxClauseCount(com.google.protobuf.Int64Value value) { if (maxClauseCountBuilder_ == null) { if (maxClauseCount_ != null) { maxClauseCount_ = com.google.protobuf.Int64Value.newBuilder(maxClauseCount_).mergeFrom(value).buildPartial(); } else { maxClauseCount_ = value; } onChanged(); } else { maxClauseCountBuilder_.mergeFrom(value); } return this; } /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> */ public Builder clearMaxClauseCount() { if (maxClauseCountBuilder_ == null) { maxClauseCount_ = null; onChanged(); } else { maxClauseCount_ = null; maxClauseCountBuilder_ = null; } return this; } /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> */ public com.google.protobuf.Int64Value.Builder getMaxClauseCountBuilder() { onChanged(); return getMaxClauseCountFieldBuilder().getBuilder(); } /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> */ public com.google.protobuf.Int64ValueOrBuilder getMaxClauseCountOrBuilder() { if (maxClauseCountBuilder_ != null) { return maxClauseCountBuilder_.getMessageOrBuilder(); } else { return maxClauseCount_ == null ? com.google.protobuf.Int64Value.getDefaultInstance() : maxClauseCount_; } } /** * <pre> * the maximum number of allowed boolean clauses in a query * </pre> * * <code>.google.protobuf.Int64Value max_clause_count = 3;</code> */ private com.google.protobuf.SingleFieldBuilderV3< com.google.protobuf.Int64Value, com.google.protobuf.Int64Value.Builder, com.google.protobuf.Int64ValueOrBuilder> getMaxClauseCountFieldBuilder() { if (maxClauseCountBuilder_ == null) { maxClauseCountBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< com.google.protobuf.Int64Value, com.google.protobuf.Int64Value.Builder, com.google.protobuf.Int64ValueOrBuilder>( getMaxClauseCount(), getParentForChildren(), isClean()); maxClauseCount_ = null; } return maxClauseCountBuilder_; } private java.lang.Object fielddataCacheSize_ = ""; /** * <pre> * the percentage or absolute value (10%, 512mb) of heap space that is allocated to fielddata * </pre> * * <code>string fielddata_cache_size = 4;</code> * @return The fielddataCacheSize. */ public java.lang.String getFielddataCacheSize() { java.lang.Object ref = fielddataCacheSize_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); fielddataCacheSize_ = s; return s; } else { return (java.lang.String) ref; } } /** * <pre> * the percentage or absolute value (10%, 512mb) of heap space that is allocated to fielddata * </pre> * * <code>string fielddata_cache_size = 4;</code> * @return The bytes for fielddataCacheSize. */ public com.google.protobuf.ByteString getFielddataCacheSizeBytes() { java.lang.Object ref = fielddataCacheSize_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); fielddataCacheSize_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** * <pre> * the percentage or absolute value (10%, 512mb) of heap space that is allocated to fielddata * </pre> * * <code>string fielddata_cache_size = 4;</code> * @param value The fielddataCacheSize to set. * @return This builder for chaining. */ public Builder setFielddataCacheSize( java.lang.String value) { if (value == null) { throw new NullPointerException(); } fielddataCacheSize_ = value; onChanged(); return this; } /** * <pre> * the percentage or absolute value (10%, 512mb) of heap space that is allocated to fielddata * </pre> * * <code>string fielddata_cache_size = 4;</code> * @return This builder for chaining. */ public Builder clearFielddataCacheSize() { fielddataCacheSize_ = getDefaultInstance().getFielddataCacheSize(); onChanged(); return this; } /** * <pre> * the percentage or absolute value (10%, 512mb) of heap space that is allocated to fielddata * </pre> * * <code>string fielddata_cache_size = 4;</code> * @param value The bytes for fielddataCacheSize to set. * @return This builder for chaining. */ public Builder setFielddataCacheSizeBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); fielddataCacheSize_ = value; onChanged(); return this; } private java.lang.Object reindexRemoteWhitelist_ = ""; /** * <code>string reindex_remote_whitelist = 6;</code> * @return The reindexRemoteWhitelist. */ public java.lang.String getReindexRemoteWhitelist() { java.lang.Object ref = reindexRemoteWhitelist_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); reindexRemoteWhitelist_ = s; return s; } else { return (java.lang.String) ref; } } /** * <code>string reindex_remote_whitelist = 6;</code> * @return The bytes for reindexRemoteWhitelist. */ public com.google.protobuf.ByteString getReindexRemoteWhitelistBytes() { java.lang.Object ref = reindexRemoteWhitelist_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); reindexRemoteWhitelist_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** * <code>string reindex_remote_whitelist = 6;</code> * @param value The reindexRemoteWhitelist to set. * @return This builder for chaining. */ public Builder setReindexRemoteWhitelist( java.lang.String value) { if (value == null) { throw new NullPointerException(); } reindexRemoteWhitelist_ = value; onChanged(); return this; } /** * <code>string reindex_remote_whitelist = 6;</code> * @return This builder for chaining. */ public Builder clearReindexRemoteWhitelist() { reindexRemoteWhitelist_ = getDefaultInstance().getReindexRemoteWhitelist(); onChanged(); return this; } /** * <code>string reindex_remote_whitelist = 6;</code> * @param value The bytes for reindexRemoteWhitelist to set. * @return This builder for chaining. */ public Builder setReindexRemoteWhitelistBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); reindexRemoteWhitelist_ = value; onChanged(); return this; } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); } @java.lang.Override public final Builder mergeUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.mergeUnknownFields(unknownFields); } // @@protoc_insertion_point(builder_scope:yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2) } // @@protoc_insertion_point(class_scope:yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2) private static final yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 DEFAULT_INSTANCE; static { DEFAULT_INSTANCE = new yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2(); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getDefaultInstance() { return DEFAULT_INSTANCE; } private static final com.google.protobuf.Parser<OpenSearchConfig2> PARSER = new com.google.protobuf.AbstractParser<OpenSearchConfig2>() { @java.lang.Override public OpenSearchConfig2 parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return new OpenSearchConfig2(input, extensionRegistry); } }; public static com.google.protobuf.Parser<OpenSearchConfig2> parser() { return PARSER; } @java.lang.Override public com.google.protobuf.Parser<OpenSearchConfig2> getParserForType() { return PARSER; } @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getDefaultInstanceForType() { return DEFAULT_INSTANCE; } } public interface OpenSearchConfigSet2OrBuilder extends // @@protoc_insertion_point(interface_extends:yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfigSet2) com.google.protobuf.MessageOrBuilder { /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> * @return Whether the effectiveConfig field is set. */ boolean hasEffectiveConfig(); /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> * @return The effectiveConfig. */ yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getEffectiveConfig(); /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> */ yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder getEffectiveConfigOrBuilder(); /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> * @return Whether the userConfig field is set. */ boolean hasUserConfig(); /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> * @return The userConfig. */ yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getUserConfig(); /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> */ yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder getUserConfigOrBuilder(); /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> * @return Whether the defaultConfig field is set. */ boolean hasDefaultConfig(); /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> * @return The defaultConfig. */ yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getDefaultConfig(); /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> */ yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder getDefaultConfigOrBuilder(); } /** * Protobuf type {@code yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfigSet2} */ public static final class OpenSearchConfigSet2 extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfigSet2) OpenSearchConfigSet2OrBuilder { private static final long serialVersionUID = 0L; // Use OpenSearchConfigSet2.newBuilder() to construct. private OpenSearchConfigSet2(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { super(builder); } private OpenSearchConfigSet2() { } @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance( UnusedPrivateParameter unused) { return new OpenSearchConfigSet2(); } @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; } private OpenSearchConfigSet2( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { this(); if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { boolean done = false; while (!done) { int tag = input.readTag(); switch (tag) { case 0: done = true; break; case 10: { yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder subBuilder = null; if (effectiveConfig_ != null) { subBuilder = effectiveConfig_.toBuilder(); } effectiveConfig_ = input.readMessage(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom(effectiveConfig_); effectiveConfig_ = subBuilder.buildPartial(); } break; } case 18: { yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder subBuilder = null; if (userConfig_ != null) { subBuilder = userConfig_.toBuilder(); } userConfig_ = input.readMessage(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom(userConfig_); userConfig_ = subBuilder.buildPartial(); } break; } case 26: { yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder subBuilder = null; if (defaultConfig_ != null) { subBuilder = defaultConfig_.toBuilder(); } defaultConfig_ = input.readMessage(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.parser(), extensionRegistry); if (subBuilder != null) { subBuilder.mergeFrom(defaultConfig_); defaultConfig_ = subBuilder.buildPartial(); } break; } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { done = true; } break; } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(this); } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException( e).setUnfinishedMessage(this); } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfigSet2_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfigSet2_fieldAccessorTable .ensureFieldAccessorsInitialized( yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2.class, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2.Builder.class); } public static final int EFFECTIVE_CONFIG_FIELD_NUMBER = 1; private yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 effectiveConfig_; /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> * @return Whether the effectiveConfig field is set. */ @java.lang.Override public boolean hasEffectiveConfig() { return effectiveConfig_ != null; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> * @return The effectiveConfig. */ @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getEffectiveConfig() { return effectiveConfig_ == null ? yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance() : effectiveConfig_; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> */ @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder getEffectiveConfigOrBuilder() { return getEffectiveConfig(); } public static final int USER_CONFIG_FIELD_NUMBER = 2; private yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 userConfig_; /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> * @return Whether the userConfig field is set. */ @java.lang.Override public boolean hasUserConfig() { return userConfig_ != null; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> * @return The userConfig. */ @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getUserConfig() { return userConfig_ == null ? yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance() : userConfig_; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> */ @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder getUserConfigOrBuilder() { return getUserConfig(); } public static final int DEFAULT_CONFIG_FIELD_NUMBER = 3; private yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 defaultConfig_; /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> * @return Whether the defaultConfig field is set. */ @java.lang.Override public boolean hasDefaultConfig() { return defaultConfig_ != null; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> * @return The defaultConfig. */ @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getDefaultConfig() { return defaultConfig_ == null ? yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance() : defaultConfig_; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> */ @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder getDefaultConfigOrBuilder() { return getDefaultConfig(); } private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; } @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (effectiveConfig_ != null) { output.writeMessage(1, getEffectiveConfig()); } if (userConfig_ != null) { output.writeMessage(2, getUserConfig()); } if (defaultConfig_ != null) { output.writeMessage(3, getDefaultConfig()); } unknownFields.writeTo(output); } @java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (effectiveConfig_ != null) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, getEffectiveConfig()); } if (userConfig_ != null) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, getUserConfig()); } if (defaultConfig_ != null) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, getDefaultConfig()); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; } @java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2)) { return super.equals(obj); } yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 other = (yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2) obj; if (hasEffectiveConfig() != other.hasEffectiveConfig()) return false; if (hasEffectiveConfig()) { if (!getEffectiveConfig() .equals(other.getEffectiveConfig())) return false; } if (hasUserConfig() != other.hasUserConfig()) return false; if (hasUserConfig()) { if (!getUserConfig() .equals(other.getUserConfig())) return false; } if (hasDefaultConfig() != other.hasDefaultConfig()) return false; if (hasDefaultConfig()) { if (!getDefaultConfig() .equals(other.getDefaultConfig())) return false; } if (!unknownFields.equals(other.unknownFields)) return false; return true; } @java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasEffectiveConfig()) { hash = (37 * hash) + EFFECTIVE_CONFIG_FIELD_NUMBER; hash = (53 * hash) + getEffectiveConfig().hashCode(); } if (hasUserConfig()) { hash = (37 * hash) + USER_CONFIG_FIELD_NUMBER; hash = (53 * hash) + getUserConfig().hashCode(); } if (hasDefaultConfig()) { hash = (37 * hash) + DEFAULT_CONFIG_FIELD_NUMBER; hash = (53 * hash) + getDefaultConfig().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input, extensionRegistry); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input, extensionRegistry); } @java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } public static Builder newBuilder(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } @java.lang.Override public Builder toBuilder() { return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); } @java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /** * Protobuf type {@code yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfigSet2} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements // @@protoc_insertion_point(builder_implements:yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfigSet2) yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2OrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfigSet2_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfigSet2_fieldAccessorTable .ensureFieldAccessorsInitialized( yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2.class, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2.Builder.class); } // Construct using yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2.newBuilder() private Builder() { maybeForceBuilderInitialization(); } private Builder( com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); } private void maybeForceBuilderInitialization() { if (com.google.protobuf.GeneratedMessageV3 .alwaysUseFieldBuilders) { } } @java.lang.Override public Builder clear() { super.clear(); if (effectiveConfigBuilder_ == null) { effectiveConfig_ = null; } else { effectiveConfig_ = null; effectiveConfigBuilder_ = null; } if (userConfigBuilder_ == null) { userConfig_ = null; } else { userConfig_ = null; userConfigBuilder_ = null; } if (defaultConfigBuilder_ == null) { defaultConfig_ = null; } else { defaultConfig_ = null; defaultConfigBuilder_ = null; } return this; } @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfigSet2_descriptor; } @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 getDefaultInstanceForType() { return yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2.getDefaultInstance(); } @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 build() { yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 buildPartial() { yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 result = new yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2(this); if (effectiveConfigBuilder_ == null) { result.effectiveConfig_ = effectiveConfig_; } else { result.effectiveConfig_ = effectiveConfigBuilder_.build(); } if (userConfigBuilder_ == null) { result.userConfig_ = userConfig_; } else { result.userConfig_ = userConfigBuilder_.build(); } if (defaultConfigBuilder_ == null) { result.defaultConfig_ = defaultConfig_; } else { result.defaultConfig_ = defaultConfigBuilder_.build(); } onBuilt(); return result; } @java.lang.Override public Builder clone() { return super.clone(); } @java.lang.Override public Builder setField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.setField(field, value); } @java.lang.Override public Builder clearField( com.google.protobuf.Descriptors.FieldDescriptor field) { return super.clearField(field); } @java.lang.Override public Builder clearOneof( com.google.protobuf.Descriptors.OneofDescriptor oneof) { return super.clearOneof(oneof); } @java.lang.Override public Builder setRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { return super.setRepeatedField(field, index, value); } @java.lang.Override public Builder addRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { return super.addRepeatedField(field, value); } @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2) { return mergeFrom((yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2)other); } else { super.mergeFrom(other); return this; } } public Builder mergeFrom(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 other) { if (other == yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2.getDefaultInstance()) return this; if (other.hasEffectiveConfig()) { mergeEffectiveConfig(other.getEffectiveConfig()); } if (other.hasUserConfig()) { mergeUserConfig(other.getUserConfig()); } if (other.hasDefaultConfig()) { mergeDefaultConfig(other.getDefaultConfig()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; } @java.lang.Override public final boolean isInitialized() { return true; } @java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; } private yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 effectiveConfig_; private com.google.protobuf.SingleFieldBuilderV3< yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder> effectiveConfigBuilder_; /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> * @return Whether the effectiveConfig field is set. */ public boolean hasEffectiveConfig() { return effectiveConfigBuilder_ != null || effectiveConfig_ != null; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> * @return The effectiveConfig. */ public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getEffectiveConfig() { if (effectiveConfigBuilder_ == null) { return effectiveConfig_ == null ? yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance() : effectiveConfig_; } else { return effectiveConfigBuilder_.getMessage(); } } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> */ public Builder setEffectiveConfig(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 value) { if (effectiveConfigBuilder_ == null) { if (value == null) { throw new NullPointerException(); } effectiveConfig_ = value; onChanged(); } else { effectiveConfigBuilder_.setMessage(value); } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> */ public Builder setEffectiveConfig( yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder builderForValue) { if (effectiveConfigBuilder_ == null) { effectiveConfig_ = builderForValue.build(); onChanged(); } else { effectiveConfigBuilder_.setMessage(builderForValue.build()); } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> */ public Builder mergeEffectiveConfig(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 value) { if (effectiveConfigBuilder_ == null) { if (effectiveConfig_ != null) { effectiveConfig_ = yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.newBuilder(effectiveConfig_).mergeFrom(value).buildPartial(); } else { effectiveConfig_ = value; } onChanged(); } else { effectiveConfigBuilder_.mergeFrom(value); } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> */ public Builder clearEffectiveConfig() { if (effectiveConfigBuilder_ == null) { effectiveConfig_ = null; onChanged(); } else { effectiveConfig_ = null; effectiveConfigBuilder_ = null; } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> */ public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder getEffectiveConfigBuilder() { onChanged(); return getEffectiveConfigFieldBuilder().getBuilder(); } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> */ public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder getEffectiveConfigOrBuilder() { if (effectiveConfigBuilder_ != null) { return effectiveConfigBuilder_.getMessageOrBuilder(); } else { return effectiveConfig_ == null ? yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance() : effectiveConfig_; } } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 effective_config = 1 [(.yandex.cloud.required) = true];</code> */ private com.google.protobuf.SingleFieldBuilderV3< yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder> getEffectiveConfigFieldBuilder() { if (effectiveConfigBuilder_ == null) { effectiveConfigBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder>( getEffectiveConfig(), getParentForChildren(), isClean()); effectiveConfig_ = null; } return effectiveConfigBuilder_; } private yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 userConfig_; private com.google.protobuf.SingleFieldBuilderV3< yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder> userConfigBuilder_; /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> * @return Whether the userConfig field is set. */ public boolean hasUserConfig() { return userConfigBuilder_ != null || userConfig_ != null; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> * @return The userConfig. */ public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getUserConfig() { if (userConfigBuilder_ == null) { return userConfig_ == null ? yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance() : userConfig_; } else { return userConfigBuilder_.getMessage(); } } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> */ public Builder setUserConfig(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 value) { if (userConfigBuilder_ == null) { if (value == null) { throw new NullPointerException(); } userConfig_ = value; onChanged(); } else { userConfigBuilder_.setMessage(value); } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> */ public Builder setUserConfig( yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder builderForValue) { if (userConfigBuilder_ == null) { userConfig_ = builderForValue.build(); onChanged(); } else { userConfigBuilder_.setMessage(builderForValue.build()); } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> */ public Builder mergeUserConfig(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 value) { if (userConfigBuilder_ == null) { if (userConfig_ != null) { userConfig_ = yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.newBuilder(userConfig_).mergeFrom(value).buildPartial(); } else { userConfig_ = value; } onChanged(); } else { userConfigBuilder_.mergeFrom(value); } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> */ public Builder clearUserConfig() { if (userConfigBuilder_ == null) { userConfig_ = null; onChanged(); } else { userConfig_ = null; userConfigBuilder_ = null; } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> */ public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder getUserConfigBuilder() { onChanged(); return getUserConfigFieldBuilder().getBuilder(); } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> */ public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder getUserConfigOrBuilder() { if (userConfigBuilder_ != null) { return userConfigBuilder_.getMessageOrBuilder(); } else { return userConfig_ == null ? yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance() : userConfig_; } } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 user_config = 2;</code> */ private com.google.protobuf.SingleFieldBuilderV3< yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder> getUserConfigFieldBuilder() { if (userConfigBuilder_ == null) { userConfigBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder>( getUserConfig(), getParentForChildren(), isClean()); userConfig_ = null; } return userConfigBuilder_; } private yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 defaultConfig_; private com.google.protobuf.SingleFieldBuilderV3< yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder> defaultConfigBuilder_; /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> * @return Whether the defaultConfig field is set. */ public boolean hasDefaultConfig() { return defaultConfigBuilder_ != null || defaultConfig_ != null; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> * @return The defaultConfig. */ public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 getDefaultConfig() { if (defaultConfigBuilder_ == null) { return defaultConfig_ == null ? yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance() : defaultConfig_; } else { return defaultConfigBuilder_.getMessage(); } } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> */ public Builder setDefaultConfig(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 value) { if (defaultConfigBuilder_ == null) { if (value == null) { throw new NullPointerException(); } defaultConfig_ = value; onChanged(); } else { defaultConfigBuilder_.setMessage(value); } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> */ public Builder setDefaultConfig( yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder builderForValue) { if (defaultConfigBuilder_ == null) { defaultConfig_ = builderForValue.build(); onChanged(); } else { defaultConfigBuilder_.setMessage(builderForValue.build()); } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> */ public Builder mergeDefaultConfig(yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2 value) { if (defaultConfigBuilder_ == null) { if (defaultConfig_ != null) { defaultConfig_ = yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.newBuilder(defaultConfig_).mergeFrom(value).buildPartial(); } else { defaultConfig_ = value; } onChanged(); } else { defaultConfigBuilder_.mergeFrom(value); } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> */ public Builder clearDefaultConfig() { if (defaultConfigBuilder_ == null) { defaultConfig_ = null; onChanged(); } else { defaultConfig_ = null; defaultConfigBuilder_ = null; } return this; } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> */ public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder getDefaultConfigBuilder() { onChanged(); return getDefaultConfigFieldBuilder().getBuilder(); } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> */ public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder getDefaultConfigOrBuilder() { if (defaultConfigBuilder_ != null) { return defaultConfigBuilder_.getMessageOrBuilder(); } else { return defaultConfig_ == null ? yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.getDefaultInstance() : defaultConfig_; } } /** * <code>.yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfig2 default_config = 3;</code> */ private com.google.protobuf.SingleFieldBuilderV3< yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder> getDefaultConfigFieldBuilder() { if (defaultConfigBuilder_ == null) { defaultConfigBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2.Builder, yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfig2OrBuilder>( getDefaultConfig(), getParentForChildren(), isClean()); defaultConfig_ = null; } return defaultConfigBuilder_; } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); } @java.lang.Override public final Builder mergeUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.mergeUnknownFields(unknownFields); } // @@protoc_insertion_point(builder_scope:yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfigSet2) } // @@protoc_insertion_point(class_scope:yandex.cloud.mdb.opensearch.v1.config.OpenSearchConfigSet2) private static final yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 DEFAULT_INSTANCE; static { DEFAULT_INSTANCE = new yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2(); } public static yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 getDefaultInstance() { return DEFAULT_INSTANCE; } private static final com.google.protobuf.Parser<OpenSearchConfigSet2> PARSER = new com.google.protobuf.AbstractParser<OpenSearchConfigSet2>() { @java.lang.Override public OpenSearchConfigSet2 parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return new OpenSearchConfigSet2(input, extensionRegistry); } }; public static com.google.protobuf.Parser<OpenSearchConfigSet2> parser() { return PARSER; } @java.lang.Override public com.google.protobuf.Parser<OpenSearchConfigSet2> getParserForType() { return PARSER; } @java.lang.Override public yandex.cloud.api.mdb.opensearch.v1.Opensearch.OpenSearchConfigSet2 getDefaultInstanceForType() { return DEFAULT_INSTANCE; } } private static final com.google.protobuf.Descriptors.Descriptor internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfig2_descriptor; private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfig2_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfigSet2_descriptor; private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfigSet2_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; } private static com.google.protobuf.Descriptors.FileDescriptor descriptor; static { java.lang.String[] descriptorData = { "\n6yandex/cloud/mdb/opensearch/v1/config/" + "opensearch.proto\022%yandex.cloud.mdb.opens" + "earch.v1.config\032\036google/protobuf/wrapper" + "s.proto\032\035yandex/cloud/validation.proto\"\212" + "\001\n\021OpenSearchConfig2\0225\n\020max_clause_count" + "\030\003 \001(\0132\033.google.protobuf.Int64Value\022\034\n\024f" + "ielddata_cache_size\030\004 \001(\t\022 \n\030reindex_rem" + "ote_whitelist\030\006 \001(\t\"\221\002\n\024OpenSearchConfig" + "Set2\022X\n\020effective_config\030\001 \001(\01328.yandex." + "cloud.mdb.opensearch.v1.config.OpenSearc" + "hConfig2B\004\350\3071\001\022M\n\013user_config\030\002 \001(\01328.ya" + "ndex.cloud.mdb.opensearch.v1.config.Open" + "SearchConfig2\022P\n\016default_config\030\003 \001(\01328." + "yandex.cloud.mdb.opensearch.v1.config.Op" + "enSearchConfig2Bz\n\"yandex.cloud.api.mdb." + "opensearch.v1ZTgithub.com/yandex-cloud/g" + "o-genproto/yandex/cloud/mdb/opensearch/v" + "1/config;opensearchb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { com.google.protobuf.WrappersProto.getDescriptor(), yandex.cloud.api.Validation.getDescriptor(), }); internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfig2_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfig2_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfig2_descriptor, new java.lang.String[] { "MaxClauseCount", "FielddataCacheSize", "ReindexRemoteWhitelist", }); internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfigSet2_descriptor = getDescriptor().getMessageTypes().get(1); internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfigSet2_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_yandex_cloud_mdb_opensearch_v1_config_OpenSearchConfigSet2_descriptor, new java.lang.String[] { "EffectiveConfig", "UserConfig", "DefaultConfig", }); com.google.protobuf.ExtensionRegistry registry = com.google.protobuf.ExtensionRegistry.newInstance(); registry.add(yandex.cloud.api.Validation.required); com.google.protobuf.Descriptors.FileDescriptor .internalUpdateFileDescriptor(descriptor, registry); com.google.protobuf.WrappersProto.getDescriptor(); yandex.cloud.api.Validation.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) }
[ "ycloud-bot@yandex.ru" ]
ycloud-bot@yandex.ru
532cd6375d5158aabfdee7ae3adc952041e5eb80
5eca4c927e277ec85ee1eef00694c75f4272301c
/src/main/java/com/appleyk/exception/BaseException.java
24b6211f923947ef803cf0e8dd5a8fd69af0f56c
[]
no_license
kobeyk/Spring-Boot-MultiFile-UpLoad
7bf1df65489a7a348f67568d0f3cededec329cf1
04d98db4720d9bc9b1a3c9a75fea0f766be39667
refs/heads/master
2020-03-17T20:42:05.553537
2018-05-18T08:17:53
2018-05-18T08:17:53
133,924,815
4
0
null
null
null
null
UTF-8
Java
false
false
720
java
package com.appleyk.exception; import com.appleyk.result.ResponseMessage; public class BaseException extends Exception{ private static final long serialVersionUID = 1636053543616552109L; private Integer errorCode; public BaseException(String message) { super(message); } public BaseException(ResponseMessage responseMessage) { super(responseMessage.getMessage()); this.errorCode = responseMessage.getStatus(); } public BaseException(ResponseMessage responseMessage, String message) { super(message); this.errorCode = responseMessage.getStatus(); } public Integer getErrorCode() { return errorCode; } public void setErrorCode(Integer errorCode) { this.errorCode = errorCode; } }
[ "437704792@qq.com" ]
437704792@qq.com
894b82a40e812e3a9d210b2515e11d16b74c2a4f
0a5b95ea97f9d210e489b14f3f0328a3f63b7c45
/src/main/java/dnd/dice/Dice.java
91269103bc6992b804f1c93c38bb68e972ce4fdc
[]
no_license
3296Fall2020/projects-02-d-d-d
759d218b7502f3a7bbc928ec667a0047a861f612
f5a3c089ed158cfd0ec5299e14ca69168d2a36ca
refs/heads/master
2023-01-23T02:57:11.312938
2020-12-01T19:54:47
2020-12-01T19:54:47
307,774,895
0
0
null
2020-12-01T19:54:49
2020-10-27T17:17:09
Java
UTF-8
Java
false
false
2,842
java
package dnd.dice; import dnd.dice.RandomNumberGenerator; public class Dice { private RandomNumberGenerator randomNumberGenerator; public Dice() { this. randomNumberGenerator = new RandomNumberGenerator(); } // rolls a single die with possible values between 1 and dieSize public int roll(int dieSize) { return randomNumberGenerator.randomIntInRange(1, dieSize); } // rolls multiple dice (number of dice given by numRolls) // size of the dice is given by dieSize public int[] roll(int dieSize, int numRolls) { int result[] = new int[numRolls]; for (int i = 0; i < numRolls; i++) { result[i] = randomNumberGenerator.randomIntInRange(1, dieSize); } return result; } // rolls multiple dice (number of dice given by numRolls) and returns the sum of all rolls // size of the dice is given by dieSize public int rollSum(int dieSize, int numRolls) { int result = 0; for (int i = 0; i < numRolls; i++) { result += randomNumberGenerator.randomIntInRange(1, dieSize); } return result; } // rolls multiple dice of various sizes // the sizes of the dice are given as an array, which is an input // e.g. an input of [6, 10, 20] would roll 3 dice - one 6-sided die, one 10-sized die, and one 20-sided die public int[] roll(int[] diceSizes) { int numRolls = diceSizes.length; int result[] = new int[numRolls]; for (int i = 0; i < numRolls; i++) { result[i] = randomNumberGenerator.randomIntInRange(1, diceSizes[i]); } return result; } // rolls a die with sides between minRoll and dieSize // e.g. an input of (6,2), would roll a die with sides 2, 3, 4, 5, 6 public int rollWithMin(int dieSize, int minRoll) { return randomNumberGenerator.randomIntInRange(minRoll, dieSize); } // rolls multiple dice with sides between minRoll and dieSize // e.g. an input of (6, 3, 2) would rolle 3 dice with sides 2, 3, 4, 5, 6 public int[] rollWithMin(int dieSize, int numRolls, int minRoll) { int result[] = new int[numRolls]; for (int i = 0; i < numRolls; i++) { result[i] = randomNumberGenerator.randomIntInRange(minRoll, dieSize); } return result; } // rolls multiple dice each with minimum and maximum values // max sizes are given as an array in diceSizes // min sizes are given as an array in minRolls public int[] rollWithMin(int[] diceSizes, int[] minRolls) { int numRolls = diceSizes.length; int result[] = new int[numRolls]; for (int i = 0; i < numRolls; i++) { result[i] = randomNumberGenerator.randomIntInRange(minRolls[i], diceSizes[i]); } return result; } }
[ "tug81211@temple.edu" ]
tug81211@temple.edu
a077c0b6836c44db2a77ff5c607b09ee58f4463a
fc50c7a674843f6d864aee8ae2cb29128c2817df
/src/main/java/com/ksea/spring/activemq/controller/ActivemqController.java
ccf21da5c4c6f31c82dbf263cbbbfb1df21439bb
[]
no_license
ksea55/ksea-activemq
44d59bcb793791b557d202729460787448d3a49c
32dffd84f05581237db3ec5ab2a3cb908db48d16
refs/heads/master
2021-01-23T11:33:48.125898
2017-06-19T06:07:08
2017-06-19T06:07:08
93,150,027
0
0
null
null
null
null
UTF-8
Java
false
false
1,972
java
package com.ksea.spring.activemq.controller; import javax.annotation.Resource; import com.ksea.spring.activemq.producer.queue.QueueSender; import com.ksea.spring.activemq.producer.topic.TopicSender; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; /** * @author liang * @description controller测试 */ @Controller @RequestMapping("/activemq") public class ActivemqController { @Resource QueueSender queueSender; @Resource TopicSender topicSender; /** * 发送消息到队列 * Queue队列:仅有一个订阅者会收到消息,消息一旦被处理就不会存在队列中 * * @param message * @return String */ @ResponseBody @RequestMapping("queueSender") public String queueSender(@RequestParam("message") String message) { String opt = ""; try { queueSender.send("test.queue", message); opt = "suc"; } catch (Exception e) { opt = e.getCause().toString(); } return opt; } /** * 发送消息到主题 * Topic主题 :放入一个消息,所有订阅者都会收到 * 这个是主题目的地是一对多的 * * @param message * @return String */ @ResponseBody @RequestMapping("topicSender") public String topicSender(@RequestParam("message") String message) { String opt = ""; try { topicSender.send("test.topic", message); opt = "suc"; } catch (Exception e) { opt = e.getCause().toString(); } return opt; } @RequestMapping(value = "index", method = RequestMethod.GET) public String index() { return "index"; } }
[ "wangyang198118@126.com" ]
wangyang198118@126.com
7d9e313fb51f794e227a1a3e57aed19eaf40feff
1b4e075655bb6f4c47e711e90755f7db04330e11
/Testing/android-tools-testing/04/demos/exercise-files/after/NoteKeeper/app/src/androidTest/java/com/jwhh/notekeeper/NoteCreationTest.java
0f1a7e64cd419bac347ff29f1929e2804aa1aa31
[]
no_license
IsaacGerald/Android-Fundamentals
1892bc65e70dfe0ec1a3b766600359aadaa64a47
ccf79ada26eb6a41646b06ef7a365ff7e425326e
refs/heads/master
2023-02-28T22:06:05.577740
2021-02-06T06:51:18
2021-02-06T06:51:18
334,341,747
0
0
null
null
null
null
UTF-8
Java
false
false
2,473
java
package com.jwhh.notekeeper; import androidx.test.espresso.ViewInteraction; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.rule.ActivityTestRule; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; import static androidx.test.espresso.Espresso.*; import static androidx.test.espresso.action.ViewActions.*; import static androidx.test.espresso.matcher.ViewMatchers.*; import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; import static org.hamcrest.Matchers.*; import static androidx.test.espresso.Espresso.pressBack; import static androidx.test.espresso.assertion.ViewAssertions.*; @RunWith(AndroidJUnit4.class) public class NoteCreationTest { static DataManager sDataManager; @BeforeClass public static void classSetUp() { sDataManager = DataManager.getInstance(); } @Rule public ActivityTestRule<NoteListActivity> mNoteListActivityRule = new ActivityTestRule<>(NoteListActivity.class); @Test public void createNewNote() { final CourseInfo course = sDataManager.getCourse("java_lang"); final String noteTitle = "Test note title"; final String noteText = "This is the body of our test note"; // ViewInteraction fabNewNote = onView(withId(R.id.fab)); // fabNewNote.perform(click()); onView(withId(R.id.fab)).perform(click()); onView(withId(R.id.spinner_courses)).perform(click()); onData(allOf(instanceOf(CourseInfo.class), equalTo(course))).perform(click()); onView(withId(R.id.spinner_courses)).check(matches(withSpinnerText( containsString(course.getTitle())))); onView(withId(R.id.text_note_title)).perform(typeText(noteTitle)) .check(matches(withText(containsString(noteTitle)))); onView(withId(R.id.text_note_text)).perform(typeText(noteText), closeSoftKeyboard()); onView(withId(R.id.text_note_text)).check(matches(withText(containsString(noteText)))); pressBack(); int noteIndex = sDataManager.getNotes().size() - 1; NoteInfo note = sDataManager.getNotes().get(noteIndex); assertEquals(course, note.getCourse()); assertEquals(noteTitle, note.getTitle()); assertEquals(noteText, note.getText()); } }
[ "geraldodhiambo47@gmail.com" ]
geraldodhiambo47@gmail.com
4a556c559f0de09e42fa524603b43ee7f79ad221
ed28460c5d24053259ab189978f97f34411dfc89
/Software Engineering/Java Fundamentals/Java OOP Advanced/05. Object Communication and Events/Exercise/src/demoObserverPattern/UserImpl.java
8449c852a8904dd1d7a27ea49a49a2932d399931
[]
no_license
Dimulski/SoftUni
6410fa10ba770c237bac617205c86ce25c5ec8f4
7954b842cfe0d6f915b42702997c0b4b60ddecbc
refs/heads/master
2023-01-24T20:42:12.017296
2020-01-05T08:40:14
2020-01-05T08:40:14
48,689,592
2
1
null
2023-01-12T07:09:45
2015-12-28T11:33:32
Java
UTF-8
Java
false
false
1,249
java
package demoObserverPattern; public class UserImpl implements User { private String username; private String emailAddress; private Observable observable; UserImpl(String username, String emailAddress, Observable observable) { this.username = username; this.emailAddress = emailAddress; this.observable = observable; } public String getUsername() { return this.username; } private void setUsername(String username) { this.username = username; } public String getEmailAddress() { return this.emailAddress; } private void setEmailAddress(String emailAddress) { this.emailAddress = emailAddress; } public void setObservable(Observable observable) { this.observable = observable; } public void update() { read(); unsubscribe(); } // @Override // public void subscribe(Observable observable) { // this.observable = observable; // } private void read() { System.out.println(this.getUsername() + " received:"); System.out.println(this.observable.getScheduleMessage()); } public void unsubscribe() { this.observable.removeObserver(this); } }
[ "george.dimulski@gmail.com" ]
george.dimulski@gmail.com
5eb0232ee0bffd7b297bdcbc104e3b86b36e27bd
b27e601b6dc713e2eb2e5685f53e47ea7aa44b8c
/src/main/java/info/xiaomo/eurekaserver/EurekaServerApplication.java
5d99fb590b385558c5769b6ae91fdf39ba203bd1
[]
no_license
SpringCloudZone/eurekaServer
c75445635cfc3c5f3c7af595ea45a4b4a9fc9e10
5745a5361941fe6cae2e52f5baaf5c01a384762a
refs/heads/master
2020-03-22T08:38:51.588613
2018-08-30T02:23:19
2018-08-30T02:23:19
null
0
0
null
null
null
null
UTF-8
Java
false
false
435
java
package info.xiaomo.eurekaserver; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @SpringBootApplication @EnableEurekaServer public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } }
[ "hupeng@duiba.com.cn" ]
hupeng@duiba.com.cn
173f63b7daf6667aa73f8b180324b892809e9381
023f923cd9681ae8b9bce138a7c19b05a5dac8a8
/オブジェクト指向/Polymorphism/src/iphone2/Mp3Player.java
e076b1a50ed590efc418ae9243fa1ca0499b8a10
[]
no_license
kpt5/ProgrammerCollege
e7fec90229ee22659acf2f23350e9d64d2d5f818
9e80689c96c8bc80dedaec946da265ec4341df6e
refs/heads/master
2020-12-15T07:19:47.552325
2020-02-10T15:36:56
2020-02-10T15:36:56
222,373,834
0
0
null
null
null
null
UTF-8
Java
false
false
170
java
package iphone2; public interface Mp3Player { public abstract void play(); public abstract void stop(); public abstract void next(); public abstract void back(); }
[ "kpt.555.b@gmail.com" ]
kpt.555.b@gmail.com
f38295c71f58d08a56bdc5c7d07ba9c22466d1f4
511a97edf737d5af107703c86167b3bc6e37caec
/CodingTest/src/KaKao2.java
c6f8e384b7f1860e1e79e93ae430bdafb633ea5d
[]
no_license
shyun-ab/Algorithm-Study
b98bfd905775e53c5f28f720f6d8d409d6a5fed3
8aa2b71b85f534f48a59cfcbf321cbada14dfb52
refs/heads/master
2021-08-18T12:40:47.973593
2018-10-19T16:52:29
2018-10-19T16:52:29
114,747,729
0
0
null
null
null
null
UHC
Java
false
false
1,194
java
//카카오 2019 신입 공채 - 실패율 import java.util.*; public class KaKao2 { public static void main(String args[]) throws Exception { int[] input = {4, 4, 4, 4, 4}; int[] output = solution(4, input); System.out.println(output); } public static int[] solution(int N, int[] stages) { double[][] table = new double[2][N]; double[] cal = new double[N]; int[] answer = new int[N]; for(int i = 0; i < stages.length; i++) { int tmp = stages[i]; if(tmp <= N) table[0][tmp-1]++; for(int j = 0; j < tmp; j++) { if(j < N) table[1][j]++; } } for(int i = 0; i < N; i++) { if(table[1][i] != 0) { table[1][i] = (table[0][i] / table[1][i]); } cal[i] = table[1][i]; table[0][i] = i+1; } Arrays.sort(cal); for(int i = N-1; i >= 0; i--) { for(int j = 0; j < N; j++) { if(cal[i] == table[1][j]) { answer[N-i-1] = (int) table[0][j]; table[1][j] = -1; break; } } } return answer; } }
[ "shyun.ab@gmail.com" ]
shyun.ab@gmail.com
84d8a935ab81ec01f6fc42fb7282fee82883dea6
c25e23ef29c7cfc0ad65cca639ecf9d6f012061d
/camel-core/src/main/java/org/apache/camel/util/component/AbstractApiEndpoint.java
3e4514e8c0a92bdb67684ff8f28f080c1f9586b2
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-unknown", "Apache-2.0" ]
permissive
sarvex/camel
e8bfe583d8220155492ed0caecad70e66e86ea87
1d2b4ec72403dc787d2515862a3511f9adbb3c9d
refs/heads/master
2023-05-11T18:05:22.102302
2023-05-02T02:06:27
2023-05-02T02:06:27
32,274,776
0
0
Apache-2.0
2023-05-02T02:06:28
2015-03-15T17:46:52
Java
UTF-8
Java
false
false
10,787
java
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.camel.util.component; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import org.apache.camel.CamelContext; import org.apache.camel.Component; import org.apache.camel.impl.DefaultEndpoint; import org.apache.camel.spi.ExecutorServiceManager; import org.apache.camel.spi.ThreadPoolProfile; import org.apache.camel.spi.UriParam; import org.apache.camel.util.EndpointHelper; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Abstract base class for API Component Endpoints. */ public abstract class AbstractApiEndpoint<E extends ApiName, T> extends DefaultEndpoint implements PropertyNamesInterceptor, PropertiesInterceptor { // thread pool executor with Endpoint Class name as keys private static Map<String, ExecutorService> executorServiceMap = new ConcurrentHashMap<String, ExecutorService>(); // logger protected final Logger log = LoggerFactory.getLogger(getClass()); // API name protected final E apiName; // API method name protected final String methodName; // API method helper protected final ApiMethodHelper<? extends ApiMethod> methodHelper; // endpoint configuration protected final T configuration; // property name for Exchange 'In' message body @UriParam protected String inBody; // candidate methods based on method name and endpoint configuration private List<ApiMethod> candidates; // cached Executor service private ExecutorService executorService; // cached property names and values private Set<String> endpointPropertyNames; private Map<String, Object> endpointProperties; public AbstractApiEndpoint(String endpointUri, Component component, E apiName, String methodName, ApiMethodHelper<? extends ApiMethod> methodHelper, T endpointConfiguration) { super(endpointUri, component); this.apiName = apiName; this.methodName = methodName; this.methodHelper = methodHelper; this.configuration = endpointConfiguration; } public boolean isSingleton() { return true; } /** * Returns generated helper that extends {@link ApiMethodPropertiesHelper} to work with API properties. * @return properties helper. */ protected abstract ApiMethodPropertiesHelper<T> getPropertiesHelper(); @Override public void configureProperties(Map<String, Object> options) { super.configureProperties(options); // set configuration properties first try { T configuration = getConfiguration(); EndpointHelper.setReferenceProperties(getCamelContext(), configuration, options); EndpointHelper.setProperties(getCamelContext(), configuration, options); } catch (Exception e) { throw new IllegalArgumentException(e); } // validate and initialize state initState(); afterConfigureProperties(); } /** * Initialize proxies, create server connections, etc. after endpoint properties have been configured. */ protected abstract void afterConfigureProperties(); /** * Initialize endpoint state, including endpoint arguments, find candidate methods, etc. */ private void initState() { // compute endpoint property names and values this.endpointPropertyNames = Collections.unmodifiableSet( getPropertiesHelper().getEndpointPropertyNames(configuration)); final HashMap<String, Object> properties = new HashMap<String, Object>(); getPropertiesHelper().getEndpointProperties(configuration, properties); this.endpointProperties = Collections.unmodifiableMap(properties); // get endpoint property names final Set<String> arguments = new HashSet<String>(); arguments.addAll(endpointPropertyNames); // add inBody argument for producers if (inBody != null) { arguments.add(inBody); } interceptPropertyNames(arguments); final String[] argNames = arguments.toArray(new String[arguments.size()]); // create a list of candidate methods candidates = new ArrayList<ApiMethod>(); candidates.addAll(methodHelper.getCandidateMethods(methodName, argNames)); candidates = Collections.unmodifiableList(candidates); // error if there are no candidates if (candidates.isEmpty()) { throw new IllegalArgumentException( String.format("No matching method for %s/%s, with arguments %s", apiName.getName(), methodName, arguments)); } // log missing/extra properties for debugging if (log.isDebugEnabled()) { final Set<String> missing = methodHelper.getMissingProperties(methodName, arguments); if (!missing.isEmpty()) { log.debug("Method {} could use one or more properties from {}", methodName, missing); } } } @Override public void interceptPropertyNames(Set<String> propertyNames) { // do nothing by default } @Override public void interceptProperties(Map<String, Object> properties) { // do nothing by default } /** * Returns endpoint configuration object. * One of the generated *EndpointConfiguration classes that extends component configuration class. * * @return endpoint configuration object */ public final T getConfiguration() { return configuration; } /** * Returns API name. * @return apiName property. */ public final E getApiName() { return apiName; } /** * Returns method name. * @return methodName property. */ public final String getMethodName() { return methodName; } /** * Returns method helper. * @return methodHelper property. */ public final ApiMethodHelper<? extends ApiMethod> getMethodHelper() { return methodHelper; } /** * Returns candidate methods for this endpoint. * @return list of candidate methods. */ public final List<ApiMethod> getCandidates() { return candidates; } /** * Returns name of parameter passed in the exchange In Body. * @return inBody property. */ public final String getInBody() { return inBody; } /** * Sets the name of a parameter to be passed in the exchange In Body. * @param inBody parameter name * @throws IllegalArgumentException for invalid parameter name. */ public final void setInBody(String inBody) throws IllegalArgumentException { // validate property name ObjectHelper.notNull(inBody, "inBody"); if (!getPropertiesHelper().getValidEndpointProperties(getConfiguration()).contains(inBody)) { throw new IllegalArgumentException("Unknown property " + inBody); } this.inBody = inBody; } public final Set<String> getEndpointPropertyNames() { return endpointPropertyNames; } public final Map<String, Object> getEndpointProperties() { return endpointProperties; } /** * Returns an instance of an API Proxy based on apiName, method and args. * Called by {@link AbstractApiConsumer} or {@link AbstractApiProducer}. * * @param method method about to be invoked * @param args method arguments * @return a Java object that implements the method to be invoked. * @see AbstractApiProducer * @see AbstractApiConsumer */ public abstract Object getApiProxy(ApiMethod method, Map<String, Object> args); private static ExecutorService getExecutorService( Class<? extends AbstractApiEndpoint> endpointClass, CamelContext context, String threadProfileName) { // lookup executorService for extending class name final String endpointClassName = endpointClass.getName(); ExecutorService executorService = executorServiceMap.get(endpointClassName); // CamelContext will shutdown thread pool when it shutdown so we can // lazy create it on demand // but in case of hot-deploy or the likes we need to be able to // re-create it (its a shared static instance) if (executorService == null || executorService.isTerminated() || executorService.isShutdown()) { final ExecutorServiceManager manager = context.getExecutorServiceManager(); // try to lookup a pool first based on profile ThreadPoolProfile poolProfile = manager.getThreadPoolProfile( threadProfileName); if (poolProfile == null) { poolProfile = manager.getDefaultThreadPoolProfile(); } // create a new pool using the custom or default profile executorService = manager.newScheduledThreadPool(endpointClass, threadProfileName, poolProfile); executorServiceMap.put(endpointClassName, executorService); } return executorService; } public final ExecutorService getExecutorService() { if (this.executorService == null) { // synchronize on class to avoid creating duplicate class level executors synchronized (getClass()) { this.executorService = getExecutorService(getClass(), getCamelContext(), getThreadProfileName()); } } return this.executorService; } /** * Returns Thread profile name. Generated as a constant THREAD_PROFILE_NAME in *Constants. * @return thread profile name to use. */ protected abstract String getThreadProfileName(); }
[ "dhirajsb@yahoo.com" ]
dhirajsb@yahoo.com
4a6c06352e1a5729b383750af281325324ef7084
172608aff79fd969e7e12e41c40e44d73ebdd56e
/src/main/java/pd/state/connection/EstadoPreparado.java
8bedf5a97b0b4011fe1bfed280a285d012b48809
[]
no_license
McAdri/PD.ecp1
971a1fb76c823c3667b6df12f11f886eba4f08a1
ccf3aebff3a7be6a162766758eb44342ba15ef48
refs/heads/master
2016-08-12T17:14:27.762133
2015-10-22T10:06:21
2015-10-22T10:06:21
43,972,799
0
0
null
null
null
null
UTF-8
Java
false
false
691
java
package pd.state.connection; public class EstadoPreparado extends EstadoConexion{ public EstadoPreparado(Conexion conexion){ super(conexion); } @Override public void parar(){ this.conexion.setEstado(new EstadoParado(this.conexion)); } @Override public void cerrar(){ this.conexion.setEstado(new EstadoCerrado(this.conexion)); } @Override public void iniciar(){ } @Override public void abrir(){ } @Override public void enviar(String string){ this.conexion.getLink().enviar(string); this.conexion.setEstado(new EstadoEsperando(this.conexion)); } @Override public Estado getEstado(){ return Estado.PREPARADO; } }
[ "adrian.santos@sdggroup.com" ]
adrian.santos@sdggroup.com
5f1b8740986072331bad2e08fbca53f6a3d69709
a16896d86af608ba4413c358c8428f9420d9d2ae
/Lab3/src/problem3B/Cylinder.java
8ac54ecc5dba28461d9da2a110e22378fdf56ce4
[]
no_license
lusamdebonfils/MPP
4a07b8577be65cbf0acdfad677e5bc882e005ec3
3b63df20fc77e32735931221117ed0703137d016
refs/heads/master
2020-06-17T23:24:30.293925
2019-07-09T23:22:48
2019-07-09T23:22:48
196,096,521
0
0
null
null
null
null
UTF-8
Java
false
false
463
java
package problem3B; public class Cylinder { private double height = 1.0; private Circle circle; public Cylinder() { circle = new Circle(); } public Cylinder(double radius) { circle = new Circle(radius); } public Cylinder(double radius, double height) { this(radius); this.height = height; } public double getHeight() { return height; } public double getVolume() { return Math.PI * circle.getRadius() * circle.getRadius() * height; } }
[ "lusamdebonfils@users.noreply.github.com" ]
lusamdebonfils@users.noreply.github.com
4e152af15c5403d5c57a294cb4f7587ee64b449e
54e14f439f06d53fbcc6390e517fba0ea404143b
/AliceKaretskyPd9+10/src/search/Fibonacci.java
069bb699e706c8ecec2a579c3549814afa911a9d
[]
no_license
akaretsky5542/alicekclasswork
112a10ba1ffadbcdb02a2d081cbb38d4e983174f
d49f5774f52044711185631b08fc854a5de02024
refs/heads/master
2021-09-04T11:12:15.946247
2017-12-05T20:30:07
2017-12-05T20:30:07
103,176,674
0
0
null
null
null
null
UTF-8
Java
false
false
372
java
package search; public class Fibonacci { public int[] sequenceNums; public Fibonacci() { int[] sequenceNums = {1,1,2,3, 4}; } public int createSequence(int x, int y ) { if(x == 0) { return sequenceNums[0]; } else { int newNum = createSequence(x, 0) + createSequence(0,y); return newNum; } } }
[ "BT_1N3_08@BT_1N3_08.bktech.local" ]
BT_1N3_08@BT_1N3_08.bktech.local
276cb481efed987ffdaffaaacd445451974e5e99
ac7ec742b5d52c5a68488122f74b5682c15ba0b1
/rabbitmq-study/src/main/java/com/itxwl/rabbitmqstudy/seckill/service/ISeckKillService.java
6db9c023cd73f0961da76101e967151019fac625
[]
no_license
SunYi21/xuewenliang
a902d01872edbf451450222efa38f80d3792799e
d809511b80c5b870ee466a15deb1bcf3d36a9249
refs/heads/master
2023-02-19T06:05:23.645930
2021-01-20T11:47:59
2021-01-20T11:47:59
null
0
0
null
null
null
null
UTF-8
Java
false
false
147
java
package com.itxwl.rabbitmqstudy.seckill.service; public interface ISeckKillService { void getShopByType(String userName, Integer shopType); }
[ "17530235750@163.com" ]
17530235750@163.com
c96697cb8dc2c15019aef9607d5b395c7de8a26a
6c81a8c5bf3d818e61caa3ba458065794746f525
/src/UnmapPrecision.java
77eba31a884a30cabce5adf39286b3fac8645afa
[]
no_license
coco-bigdata/BiologyAnalyze
3873fb5a284d9643bdcb7c48114912fe40c3dca9
c55ff38e9f80455679a863c008f8bd5e80eea1bb
refs/heads/master
2021-12-29T18:41:43.775723
2018-01-27T16:39:51
2018-01-27T16:39:51
null
0
0
null
null
null
null
GB18030
Java
false
false
1,159
java
import java.io.BufferedReader; import util.FileStreamUtil; import java.util.*; /** * 分析 为匹配reads分段匹配后 匹配的reads数目 * @author wuxuehong * 2012-3-13 */ public class UnmapPrecision { Set<String> reads = new HashSet<String>(); public void readUnmapp(String filename){ try{ BufferedReader br = FileStreamUtil.getBufferedReader(filename); String str = br.readLine(); Scanner s = null; String readid; while(str != null){ s = new Scanner(str); readid = s.next(); readid = readid.substring(0,readid.indexOf('_')); reads.add(readid); str = br.readLine(); } }catch (Exception e) { } } public UnmapPrecision() { // TODO Auto-generated constructor stub String base = "E:/morehouse/o6/FormatConvert/Fusion/unmappble/bwa/FormatConvert/Fusion/maxprecision/filter/"; readUnmapp(base+"crick_CT.txt"); readUnmapp(base+"watson_CT.txt"); readUnmapp(base+"watson_GA.txt"); readUnmapp(base+"crick_GA.txt"); System.out.println(reads.size()); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub new UnmapPrecision(); } }
[ "wuxuehong214@163.com" ]
wuxuehong214@163.com
8cafc56d8ae90d1e034be22ff9345046ae7dd466
aad82f53c79bb1b0fa0523ca0b9dd18d8f39ec6d
/Shilpa Sreedhar K/jan22/pgm17_squarenum.java
0f6b7b5810136b27bd397eb643d3f54bc0c0af4c
[]
no_license
Cognizant-Training-Coimbatore/Lab-Excercise-Batch-2
54b4d87238949f3ffa0b3f0209089a1beb93befe
58d65b309377b1b86a54d541c3d1ef5acb868381
refs/heads/master
2020-12-22T06:12:23.330335
2020-03-17T12:32:29
2020-03-17T12:32:29
236,676,704
1
0
null
2020-10-13T19:56:02
2020-01-28T07:00:34
Java
UTF-8
Java
false
false
327
java
import java.util.Scanner; public class pgm17_squarenum { public static void main(String[] args) { // TODO Auto-generated method stub int a,sq; Scanner s = new Scanner(System.in); System.out.print("enter a number:"); a = s.nextInt(); sq = a*a; System.out.print("square is : " +sq); } }
[ "noreply@github.com" ]
noreply@github.com
c319355753551f6e80dfce2cbb39cff0035a649e
71cae4563143cbfcd3b9756c2a3d8552e2513cb1
/src/problems/Problem.java
f756ec618b4982dc9c5c7b02d015d629643328b2
[]
no_license
ajanaliz/Search-Problem-Solving-API
7c7c07a98fce8d11d832141f130e6643b94b56b5
6c63927a846ef07151b0807d3223a07b9b92d30a
refs/heads/master
2020-03-15T22:45:09.309878
2018-05-06T22:06:11
2018-05-06T22:06:17
132,379,353
0
0
null
null
null
null
UTF-8
Java
false
false
806
java
package problems; import java.util.Vector; public class Problem { public Node getFirstNode() { // TODO Auto-generated method stub return null; } public int getHcost(Node np){ return 0; } public Vector<Integer> getWalls() { // TODO Auto-generated method stub return null; } public Node getFinalNode() { // TODO Auto-generated method stub return null; } public Node getRandomNode() { // TODO Auto-generated method stub return null; } public Vector<Node> setPopulation() { return null ; } public Vector<Node> setChildsOFGeneration(){ return null ; } public double getGenerationFitness (){ return 0; } public boolean found(){ return false; } public void mutateChilds (){ } public void selectParent() { // TODO Auto-generated method stub } }
[ "ali.janalizadeh@outlook.com" ]
ali.janalizadeh@outlook.com
bc30b7a2f22f9a354ca599e3c0f34caefef6494b
7de8e456cba64db720a94881334dba469c598457
/src/main/java/ru/tsvlad/companion_telegram_bot/state/state_classes/FreeState.java
f7a0e3253171a924015a7c93ad4696bee7d8e53d
[]
no_license
TSVlad/CompanionTelegramBotPublic
130b4cb4b5e4a9293d8f9781a38732b2df21a8df
fefc95a25c40726cb7271eb0047c1bdbc120b7f6
refs/heads/main
2023-04-04T19:04:45.470895
2021-03-25T11:40:12
2021-03-25T11:40:12
351,404,512
0
0
null
null
null
null
UTF-8
Java
false
false
1,725
java
package ru.tsvlad.companion_telegram_bot.state.state_classes; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.api.objects.Update; import ru.tsvlad.companion_telegram_bot.service.*; import ru.tsvlad.companion_telegram_bot.state.State; import ru.tsvlad.companion_telegram_bot.state.StateAndMethodEntry; import ru.tsvlad.companion_telegram_bot.update_handler.CommandHandler; @Component public class FreeState implements BotState{ private State state = State.FREE_BOT_STATE; private ChatStateService chatStateService; private CommandHandler commandHandler; @Autowired public FreeState(CommandHandler commandHandler) { this.commandHandler = commandHandler; } @Override public StateAndMethodEntry handleUpdate(Update update) { StateAndMethodEntry reply = new StateAndMethodEntry(null, null); Message message = update.getMessage(); if (message != null && message.hasText() && message.isCommand()) { // reply = handleInputMessage(message); reply = commandHandler.handleCommand(message); } return reply; } @Override public State getState() { return state; } // private StateAndMethodEntry handleInputMessage(Message message) { // // } public ChatStateService getChatStateService() { return chatStateService; } //Чтобы не было цикла инъекций @Autowired public void setChatStateService(ChatStateService chatStateService) { this.chatStateService = chatStateService; } }
[ "vladislav.kolmykov@yandex.ru" ]
vladislav.kolmykov@yandex.ru
e2f09c4d946dbce67d1c431d004da049871c808b
e4229474bf644f73bad2a80d8378dbb11e63ee4c
/RestaurantAdvisor/app/src/main/java/fr/dbope/restaurantadvisor/RecupereRestaurantsActivity.java
9c3966f2ace0e36a044b3a2fb95aedd690f32104
[]
no_license
dan-bope/Restaurant-Advisor-Front
19750fdb8dc09be5022afd772810ac7d1b18ba3a
627255c1ad8baaf323fb760d06c2b2ee64e635ca
refs/heads/main
2023-03-27T07:07:53.051333
2021-03-29T09:48:09
2021-03-29T09:48:09
349,457,346
0
0
null
null
null
null
UTF-8
Java
false
false
4,672
java
package fr.dbope.restaurantadvisor; import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; import java.util.List; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; public class RecupereRestaurantsActivity extends AppCompatActivity { private List<RecupereRestaurantsResponse> recupereRestaurantsResponseList = new ArrayList<>(); GridView gridView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recupere_restaurants); gridView = findViewById(R.id.gridView); getAllRestaurants(); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { startActivity(new Intent(RecupereRestaurantsActivity.this, RestaurantClickedActivity.class).putExtra("data",recupereRestaurantsResponseList.get(position))); //String message = "Name : "+recupereRestaurantsResponseList.get(position).getName(); //Toast.makeText(RecupereRestaurantsActivity.this,message,Toast.LENGTH_LONG).show(); } }); } public void getAllRestaurants() { Call<List<RecupereRestaurantsResponse>> recupereRestaurantsResponse = ApiRecupereRestaurant.getRecupereRestaurants().getAllRestaurants(); recupereRestaurantsResponse.enqueue(new Callback<List<RecupereRestaurantsResponse>>() { @Override public void onResponse(Call<List<RecupereRestaurantsResponse>> call, Response<List<RecupereRestaurantsResponse>> response) { if (response.isSuccessful()) { String message = "Request successful ..."; Toast.makeText(RecupereRestaurantsActivity.this,message,Toast.LENGTH_LONG).show(); recupereRestaurantsResponseList = response.body(); customAdapter customAdapter = new customAdapter(recupereRestaurantsResponseList,RecupereRestaurantsActivity.this); gridView.setAdapter(customAdapter); }else { String message = "An error occurred try again later ..."; Toast.makeText(RecupereRestaurantsActivity.this,message,Toast.LENGTH_LONG).show(); } } @Override public void onFailure(Call<List<RecupereRestaurantsResponse>> call, Throwable t) { String message = t.getLocalizedMessage(); Toast.makeText(RecupereRestaurantsActivity.this,message,Toast.LENGTH_LONG).show(); } }); } public class customAdapter extends BaseAdapter { private List<RecupereRestaurantsResponse> recupereRestaurantsResponseList; private Context context; private LayoutInflater layoutInflater; public customAdapter(List<RecupereRestaurantsResponse> recupereRestaurantsResponseList, Context context) { this.recupereRestaurantsResponseList = recupereRestaurantsResponseList; this.context = context; this.layoutInflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE); } @Override public int getCount() { return recupereRestaurantsResponseList.size(); } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null){ convertView = layoutInflater.inflate(R.layout.row_grid_items,parent,false); } ImageView imageView = convertView.findViewById(R.id.imageView); TextView textView = convertView.findViewById(R.id.textView); textView.setText(recupereRestaurantsResponseList.get(position).getName()); GlideApp.with(context).load(recupereRestaurantsResponseList.get(position).getPhoto()) .into(imageView); return convertView; } } }
[ "danbope2@gmail.com" ]
danbope2@gmail.com
c515017ce722933eff30b9958b9caa682f7be641
7532574908fb50cf4d98fb8292673efbcd5c91cd
/Exam1/src/main/java/com/hand/App.java
13bd118908e7cbf5a7611d77e80e1163d22e0662
[]
no_license
LewisRM/10960_Exam
e9ab986222af3c6c2f92205c9af952c5bd3b5e0d
e76ee2e75c4d65cd362f26150276c78c1076d4a4
refs/heads/master
2021-01-20T19:34:32.186747
2016-07-29T12:37:20
2016-07-29T12:37:20
64,479,271
0
0
null
null
null
null
GB18030
Java
false
false
645
java
package com.hand; /** * Hello world! * */ public class App { public static void main( String[] args ) { printP(101,200); } public static void printP(int m,int n){ int a[] = new int[n-m]; int temp=0; int j=0; for (int i = m; i <= n; i++) { j=0; for (j = 2; j < i/2; j++) { if(i%j==0) break; } if(j==i/2) { a[temp]=i; temp++; } } System.out.print("一共有"+temp+"个素数,分别是:"); for (int i = 0; i <= temp; i++) { if(i<(temp-1)) System.out.print(a[i]+","); if(i==(temp-1)) System.out.print(a[i]); } } }
[ "changjiang.li@hand-china.com" ]
changjiang.li@hand-china.com
3a5bd4a1f7147b692822f4f3c258b9074aba13dd
dd95d3b8bb3363a9c7002e2f361625fa79e6c2ac
/src/ID.java
535d82dace3c067f62d54f4e06fd5e483ae5bcfd
[]
no_license
pvmiseeffoC/Wave
7dd093e00d5a97c92955a0e660562ac319d5735e
eeb896d8d9d5ee1618beabe19954269e785087e4
refs/heads/master
2021-07-08T07:26:45.641280
2017-10-02T07:39:44
2017-10-02T07:39:44
null
0
0
null
null
null
null
UTF-8
Java
false
false
156
java
public enum ID { Player(), BasicEnemy(), Trail(), FastEnemy(), BigEnemy(), HomingEnemy(), EnemyBoss(), TrailOval(), MenuParticle(); }
[ "borisgluzov@gmail.com" ]
borisgluzov@gmail.com
5a653777d717d48c39d031930e44554d75219ed6
04f2945762012b30007fa6e09d4893384f6d60f9
/client/src/main/java/com/yanhuada/client/dao/ClientArtSpeakMapper.java
4cd9a8d5c7e4481511784f686b6f34c250ccb064
[]
no_license
yanhuada/zero-backend
0a054e27df051954275d087198c16bed4f54cc4d
7745b528c8d61ed178eb0eba60409f6f8f91ad66
refs/heads/master
2023-01-19T14:34:31.303416
2020-12-03T15:34:31
2020-12-03T15:34:31
318,236,887
0
0
null
null
null
null
UTF-8
Java
false
false
447
java
package com.yanhuada.client.dao; import com.yanhuada.common.model.PagerDto; import com.yanhuada.model.ArtSpeak; import org.apache.ibatis.annotations.Param; import java.util.List; /** * @author yanhuada * CREATE ON 2020/8/18 13:54 */ public interface ClientArtSpeakMapper { List<ArtSpeak> list( @Param("artSpeakTypeId") Long artSpeakTypeId, @Param("page") PagerDto page); Long total(@Param("artSpeakTypeId") Long artSpeakTypeId); }
[ "2584135898@qq.com" ]
2584135898@qq.com
534513105fab095dbd4212de9b5a6ce01966b5d9
9f74ac0d6d7cab743312e4e543df9282f3404b83
/index_project/src/main/java/eoms/com/cn/controller/BocoController.java
9764cf38ca6ed7211c96a632443ae87839e6bf7c
[ "Apache-2.0" ]
permissive
Docrong/springboot
8e208fd2f44ce8ec8924c3b7b18f36cc9dfa8938
bc60927247b2c2c94f5e2c25bf528d17a367ab6d
refs/heads/master
2023-05-14T07:27:14.102615
2020-11-24T16:15:25
2020-11-24T16:15:25
208,694,813
1
0
Apache-2.0
2023-05-09T18:46:29
2019-09-16T02:41:22
Java
UTF-8
Java
false
false
1,289
java
package eoms.com.cn.controller; import eoms.com.cn.model.Company; import eoms.com.cn.service.CompanyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Map; /** * @author : gr * @date : 2019/12/11 16:34 */ @Controller public class BocoController { @Autowired private CompanyService service; @RequestMapping("/test") public String test(HttpServletRequest request, HttpServletResponse response) { return "test"; } @RequestMapping("/list") public String list(HttpServletRequest request, HttpServletResponse response) { Map result = service.findAll(); System.out.println(result); return "list"; } @RequestMapping("/add") public String add(HttpServletRequest request, HttpServletResponse response)throws Exception { String id = String.valueOf(request.getParameter("id")); if (!"null".equals(id)&&!"".equals(id)) { Company company = service.findById(id); request.setAttribute("object",company); }else{ Company company = new Company(); request.setAttribute("object",company); } return "add"; } }
[ "1107719463@qq.com" ]
1107719463@qq.com
8a3021efb54358d5b634fd0dfa3b00ae13c986e6
537016adb9f3a476e15c558b2591d4539b63c47f
/src/com/java/online/Test11.java
2dc3e73792a522a0b1cdcee4fc456cced3c28e63
[]
no_license
aakash140/Online_Code
c23a3aba5cbdeefae382577f12f11a3e4435fcd2
537373268cc6160f29f756d81cfb88004ed62db7
refs/heads/master
2021-01-10T14:45:23.023320
2016-02-06T14:09:06
2016-02-06T14:09:06
51,204,943
0
0
null
null
null
null
UTF-8
Java
false
false
1,054
java
/** * http://www.spoj.com/problems/TOANDFRO/ */ package com.java.online; import java.io.File; import java.util.Scanner; public class Test11 { public static void main(String[] args) throws Exception{ //Scanner scan=new Scanner(System.in); Scanner scan=new Scanner(new File("src/Input.txt")); int columns=0; while((columns=scan.nextInt())>1){ String encodedMessage=scan.next(); printDecodedMessage(columns,encodedMessage); System.out.println(); } scan.close(); } public static void printDecodedMessage(int columns,String encodedMessage){ int rows=encodedMessage.length()/columns; char[] encodedArray=encodedMessage.toCharArray(); char[][] decodedArray=new char[rows][columns]; int k=0; for(int i=0;i<rows;i++){ if(i%2==0) for(int j=0;j<columns;j++,k++) decodedArray[i][j]=encodedArray[k]; else for(int j=columns-1;j>=0;j--,k++) decodedArray[i][j]=encodedArray[k]; } for(int col=0;col<columns;col++){ for(int row=0;row<rows;row++) System.out.print(decodedArray[row][col]); } } }
[ "aakash.gupta140@gmail.com" ]
aakash.gupta140@gmail.com
bcc1924346ec640e7ad1b61eb9363f78498850c0
e489735ec8909a024db5510a5bfda35fd74dabec
/GameModel.java
7fa3e07ce2676489a18a9acdc2a155fd64e0d40a
[]
no_license
neiden/deadwood
cfaf31a4c8685a35cabf55c0d106bae47789a564
b1dfd543ce1923d2f94e7919dd59a6d7db0d11e6
refs/heads/master
2023-07-17T01:00:42.754319
2020-03-14T00:22:57
2020-03-14T00:22:57
403,836,396
0
0
null
null
null
null
UTF-8
Java
false
false
6,601
java
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Scanner; public class GameModel { private Player currPlayer; private ArrayList<Player> playerList; private Board board; private Bank bank; private Scanner scanner; private int dayNumber; private int initialDay; private boolean running; private int numPlayers; private ArrayList<Scene> scenes; private ArrayList<String> devOptions; public GameModel(ArrayList<Set> sets, ArrayList<Scene> scenes){ board = new Board(sets); scanner = new Scanner(System.in); playerList = new ArrayList<>(); running = true; this.scenes = scenes; initialDay = 0; dayNumber = 0; devOptions = new ArrayList<>(); bank = new Bank(); } //Initializes the game with the appropriate player names public void init(ArrayList<String> playerNames){ devOptions.add("locations"); devOptions.add("playerInfo"); devOptions.add("setLocation"); devOptions.add("setRank"); devOptions.add("setCurrency"); devOptions.add("setRemainingScenes"); devOptions.add("setDay"); devOptions.add("infoSet"); int numPlayers = playerNames.size(); board.setNumPlayers(numPlayers); for(int i = 0; i < numPlayers; i ++){ playerList.add(new Player(playerNames.get(i), board.getSet("trailer"), board, (i+1))); } setDayRules(numPlayers); board.setScenes(scenes); currPlayer = playerList.get(0); currPlayer.setTurn(true); } //Helper class to sort players based on who has more points class SortbyRoll implements Comparator<Player> { public int compare(Player a, Player b){ return b.points - a.points; } } //Auxiliary method to determine if a scene should be closed or not public void sceneClosureCheck(){ if(currPlayer.currSet.getCurrScene() != null){ if(currPlayer.currSet.getShotsRemaining() < 1){//If scene completed, clean up variables bank.bonusMoneyDistribution(playerList, currPlayer.currSet); killScene(currPlayer.currSet.getCurrScene()); currPlayer.currSet.setCurrScene(null); } } } //Method that ends the current turn, setting all of the values to their proper positions. //Return true if the last day has just been completed, false otherwise public boolean endCurrTurn(){ boolean end = false; currPlayer.setTurn(false); if (playerList.indexOf(currPlayer) == playerList.size() - 1) { currPlayer = playerList.get(0); } else { currPlayer = playerList.get(playerList.indexOf(currPlayer) + 1); } sceneClosureCheck(); currPlayer.setTurn(true); currPlayer.setMoved(false); currPlayer.setUpgraded(false); currPlayer.createOptionList(); if (board.scenesRemaining() < 2) { if(endDay()){ end = true; } if(dayNumber > 0){ startDay(); } } return end; } //Creates a list of Player objects sorted in order of highest points public ArrayList<Player> calcScore(){ for (int i = 0; i < playerList.size(); i++) { playerList.get(i).points = playerList.get(i).credits + playerList.get(i).dollars + (5 * playerList.get(i).rank); } Collections.sort(playerList, new SortbyRoll()); return playerList; } //Cleans up a scene, deleting itself from the set it was related to and cleaning all affected Player objects private void killScene(Scene scene){ for (int i = 0; i < playerList.size(); i++) { if(playerList.get(i).currSet.getCurrScene() != null) { if (playerList.get(i).currSet.getCurrScene().name.equals(scene.name) && (playerList.get(i).role != null)) { playerList.get(i).currSet.setRoleActor(playerList.get(i).role.getName(), null); playerList.get(i).practiceChips = 0; if(i == playerList.size() - 1) { board.getSet(playerList.get(i).currSet.name).setCurrScene(null); } playerList.get(i).role = null; } } } } private void startDay(){ board.setScenes(scenes); } //Ends the day, placing all players back at the trailer and resetting the board private boolean endDay(){ dayNumber--; if(dayNumber != 0) { for (int i = 0; i < playerList.size(); i++) { playerList.get(i).currSet = board.getSet("trailer"); playerList.get(i).role = null; playerList.get(i).practiceChips = 0; } board.resetShots(); return false; } else{ return true; } } //Sets the rules based on how many people are playing private void setDayRules(int numPlayers) { switch (numPlayers) { case 2: case 3: dayNumber = 3; initialDay = 3; break; case 4: dayNumber = 4; initialDay = 4; break; case 5: dayNumber = 4; initialDay = 4; for (int i = 0; i < playerList.size(); i++) { playerList.get(i).setCredits(2); } break; case 6: dayNumber = 4; initialDay = 4; for (int i = 0; i < playerList.size(); i++) { playerList.get(i).setCredits(4); } break; case 7: case 8: dayNumber = 4; initialDay = 4; for (int i = 0; i < playerList.size(); i++) { playerList.get(i).setRank(2); playerList.get(i).updatePlayerIcon(); } break; } } public Player getCurrPlayer(){ return currPlayer; } public ArrayList<Player> getPlayerList(){ return playerList; } public ArrayList<Set> getSets(){ return board.sets; } }
[ "swanbej3@wwu.edu" ]
swanbej3@wwu.edu
0077d887727de72c11fadd76571061a2bad24f75
5a8489b0873dcf915bf7693e2ffbfc05b23dcb35
/FRSystem/src/main/java/com/example/facesample/CrashHandler.java
383fcbfa1b1fdb0349188ca55b7410a0b11cdc1e
[]
no_license
ygx4zh/Face
971fa7d413ea74ac03403bddb6289a9e59b27825
3fae8eebbbc92bb4d6f84a5f45f35e79b6b19478
refs/heads/master
2020-03-13T05:31:38.299355
2018-05-20T03:11:43
2018-05-20T03:11:43
130,986,124
1
0
null
null
null
null
UTF-8
Java
false
false
2,484
java
package com.example.facesample; import android.os.Build; import android.os.Environment; import android.util.Log; import com.example.facesample.utils.AppHelper; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; import java.lang.Thread.UncaughtExceptionHandler; import java.lang.reflect.Field; import java.util.Arrays; public class CrashHandler implements UncaughtExceptionHandler{ private static final String TAG = "CrashHandler"; private final UncaughtExceptionHandler handler; public CrashHandler(){ handler = Thread.getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(this); } @Override public void uncaughtException(Thread thread, Throwable throwable) { StringBuilder sBuf = new StringBuilder(); String curTime = AppHelper.curTime(); sBuf.append("time").append("=").append(curTime).append("\n"); injectBuildConfig(sBuf); File file = new File(Environment.getExternalStorageDirectory(), "face_log"); if(!file.exists() || file.isFile()) file.mkdir(); File log = new File(file, curTime.replace(" ","_") + ".log"); try { sBuf.append("----------------------------------------------------------\n"); PrintStream ps = new PrintStream(new FileOutputStream(log)); ps.print(sBuf.toString()); throwable.printStackTrace(ps); Log.e(TAG, "uncaughtException: write log success"); } catch (Exception e) { Log.e(TAG, "uncaughtException: write log fail"); } if (handler != null) { handler.uncaughtException(thread, throwable); }else{ android.os.Process.killProcess(android.os.Process.myPid()); } } private void injectBuildConfig(StringBuilder buffer){ Field[] fields = Build.class.getDeclaredFields(); String name = ""; Object value = ""; for (Field f: fields){ name = f.getName(); buffer.append(name).append("="); try { value = f.get(null); if(value instanceof String[]){ buffer.append(Arrays.toString((String[]) value)); }else { buffer.append(value.toString()); } } catch (Exception e) { } buffer.append("\n"); } } }
[ "sinsyet@163.com" ]
sinsyet@163.com
cc576ec50f368328a5eb927a06f07c80eeea98f1
bc755257a5ee5427102e962564c8717af89bef2b
/src/ArtPort/Catalog/Vehicle/Vehicle.java
e545d56df519327d1bc2420760724919d59cf514
[]
no_license
yuraNikolaenko/ArtPort
9978e5046298655776c19e2216dccd13dfe2bd9d
14a36fde7eed3128be0d1b959ca6fb63775dceb3
refs/heads/master
2021-01-24T06:46:59.907981
2017-06-18T21:37:55
2017-06-18T21:37:55
93,315,608
0
0
null
null
null
null
UTF-8
Java
false
false
917
java
package ArtPort.Catalog.Vehicle; import ArtPort.Catalog.AbstractCatalog; public class Vehicle extends AbstractCatalog implements ArtPort.Interface.IVehicle { private String stateNumber; public Vehicle() { } public Vehicle(String stateNumber) { this.setStateNumber(stateNumber); } public String getStateNumber() { return stateNumber; } public void setStateNumber(String stateNumber) { this.stateNumber = stateNumber; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Vehicle vehicle = (Vehicle) o; return stateNumber != null ? stateNumber.equals(vehicle.stateNumber) : vehicle.stateNumber == null; } @Override public int hashCode() { return stateNumber != null ? stateNumber.hashCode() : 0; } }
[ "y.nikolaenko@gmail.com" ]
y.nikolaenko@gmail.com
ee68d703ccebc40aa38ba89874909e8ee28593e9
45ffa28ac0e53b8afb40e68e8234dfb926df3572
/BibliosModel/src/model/Commande.java
a99fba53cb808b08e42856a47d8d04f02d6a11f0
[]
no_license
tMercken/Biblios
3fdf0d1be5812a083f50b76d62e1e621f783229b
24fddabec0f2adb977b8390d758a9ebd0224b0ed
refs/heads/master
2020-05-28T02:04:27.429939
2015-12-18T10:59:23
2015-12-18T10:59:23
47,396,545
0
0
null
2015-12-04T10:10:12
2015-12-04T10:10:12
null
UTF-8
Java
false
false
1,466
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 model; //import java.util.Collection; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; /** * * @author client */ public class Commande { private Integer id; private Date date; private HashMap<Integer, LigneCommande> ligneCommandeHashMap; private Client client; public Commande (Date dateCommande, HashMap<Integer, LigneCommande> ligneCommandeHashMap, Client clientCommande) { this.date = dateCommande; this.ligneCommandeHashMap = ligneCommandeHashMap; this.client = clientCommande; } public HashMap<Integer, LigneCommande> getLigneCommandeHashMap() { return ligneCommandeHashMap; } public void setLigneCommandeHashMap(HashMap<Integer, LigneCommande> ligneCommandeHashMap) { this.ligneCommandeHashMap = ligneCommandeHashMap; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } public Client getClient() { return client; } public void setClient(Client client) { this.client = client; } }
[ "thierry.mercken@skynet.be" ]
thierry.mercken@skynet.be
b5b0c80ac349deb30f799997b3992168f8aa4952
1522f8894885e1e11ea4d318782dd79274b2369e
/src/main/java/com/streamviewer/rest/util/CustomServletContextListener.java
d3fdab63c62933ffc8641274bcf39ca41604233e
[]
no_license
pawankumar01/StreamViewer
dd4ef31545bc7343235902931187797ac6847092
ab2bdd8edf6c0ff9c4b2a43de987c56016a54465
refs/heads/master
2020-04-21T13:57:33.900532
2019-02-10T07:36:56
2019-02-10T07:36:56
169,618,280
0
0
null
null
null
null
UTF-8
Java
false
false
792
java
package com.streamviewer.rest.util; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; /** * Listens to servlet callbacks */ public class CustomServletContextListener implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent sce) { // Connect to database and create table for the first time Injection.provideUserDatabase().connect(); Injection.provideUserDatabase().createTableIfNotExists(); Injection.provideChatDatabase().connect(); Injection.provideChatDatabase().createTableIfNotExists(); } @Override public void contextDestroyed(ServletContextEvent sce) { // Disconnect database Injection.provideUserDatabase().close(); Injection.provideChatDatabase().close(); } }
[ "pawan.kumar.cse06@gmail.com" ]
pawan.kumar.cse06@gmail.com
448232e05a32d087ce020b5b189542158265081e
5972fe575a7e3fa3234812d1985c85817b303f34
/app/src/main/java/com/example/susananaranjovillamil/orale/ShowSuggestion.java
ffb04103ac03146995b67199485319902854536d
[]
no_license
susanaranjo/OraleApp
23dcd16dc69ae8ccd8ab5a715ad70add05a8667c
b70511ba1e7415bd8005918cf009cd9bfa0f4fa2
refs/heads/master
2020-04-05T14:05:39.257799
2017-07-06T14:35:11
2017-07-06T14:35:11
94,765,865
0
0
null
null
null
null
UTF-8
Java
false
false
7,281
java
package com.example.susananaranjovillamil.orale; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.GridView; import android.widget.ImageView; import java.util.ArrayList; /** * Created by susana.naranjo.villamil on 6/18/17. */ public class ShowSuggestion extends AppCompatActivity implements View.OnClickListener{ GridView list; GridView listSelected; AdapterSelected adapter2=null; ArrayList<Pictogram> pictograms = null; ArrayList<Pictogram> symptoms =null; ArrayList<Pictogram> symptomsSuggested =null; ArrayList<Illness> illnesses=null; Button saveButton; CustomListAdapter adapter=null; final Context context = this; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.show_suggestions); saveButton= (Button) findViewById(R.id.saveButton); saveButton.setOnClickListener(this); pictograms= PictogramsRepository.getInstance().getPictograms(); illnesses=IllnessesRepository.getInstance().getIllnesses(); Intent in =getIntent(); symptoms=in.getParcelableArrayListExtra("symptoms"); symptomsSuggested=new ArrayList<Pictogram>(); addSugestions(); if (symptomsSuggested.size()==0){ Intent intent = new Intent(this, ShowCauses.class); intent.putParcelableArrayListExtra("symptoms", symptoms); startActivityForResult(intent,1); } list=(GridView)findViewById(R.id.list); adapter=new CustomListAdapter(this, symptomsSuggested); list.setAdapter((ArrayAdapter) adapter); listSelected=(GridView)findViewById(R.id.list_selected); adapter2=new AdapterSelected(this, symptoms); listSelected.setAdapter((ArrayAdapter) adapter2); list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int in_index = 0; int in_index2 = 0; int s=0; while(in_index2<symptoms.size()){ if(symptoms.get(+in_index2).getName().equals(symptomsSuggested.get(+position).getName())){ s++; } in_index2++; } if (s==0) { while ((!pictograms.get(+in_index).getName().equals(symptomsSuggested.get(+position).getName()))) { in_index++; } symptoms.add(pictograms.get(in_index)); adapter2.notifyDataSetChanged(); } } }); listSelected.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int position, long id) { final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); final View mView = getLayoutInflater().inflate(R.layout.delete_dialog,null); ImageView picto = (ImageView) mView.findViewById(R.id.picto); picto.setImageResource(symptoms.get(+position).getImgid()); Button cancel = (Button) mView.findViewById(R.id.button); Button delete = (Button) mView.findViewById(R.id.button2); alertDialogBuilder.setView(mView); final AlertDialog dialog = alertDialogBuilder.create(); dialog.show(); delete.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view){ symptoms.remove(symptoms.get(+position)); adapter2.notifyDataSetChanged(); dialog.dismiss(); } }); cancel.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view){ dialog.dismiss(); } }); } }); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.saveButton: Intent intent = new Intent(this, ShowCauses.class); intent.putParcelableArrayListExtra("symptoms", symptoms); startActivityForResult(intent,1); break; default: break; } } public void addSugestions() { int in_index=0; int in_index2=0; int in_index3=0; int in_index4=0; int s=0; int s2=0; while(in_index < illnesses.size()) { while (in_index2<illnesses.get(+in_index).getSymptoms().size()){ while (in_index3<symptoms.size()){ if(symptoms.get(+in_index3).getName().equals(illnesses.get(+in_index).getSymptoms().get(+in_index2))){ s++; } in_index3++; } in_index2++; in_index3=0; } if(s>1){ in_index2=0; in_index3=0; while (in_index2<illnesses.get(+in_index).getSymptoms().size()){ while((!pictograms.get(+in_index3).getName().equals(illnesses.get(+in_index).getSymptoms().get(+in_index2)))){ in_index3++; } while(in_index4<symptoms.size()){ if(illnesses.get(+in_index).getSymptoms().get(+in_index2).equals(symptoms.get(+in_index4).getName())){ s2++; } in_index4++; } if (s2==0){ symptomsSuggested.add(pictograms.get(in_index3)); } s2=0; in_index2++; in_index3=0; in_index4=0; } } s=0; in_index++; in_index2=0; } } public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode==1){ if(resultCode == RESULT_OK){ ArrayList<Pictogram> finalSymptoms=data.getParcelableArrayListExtra("finalSymptoms"); Intent intent = new Intent(); intent.putParcelableArrayListExtra("finalSymptoms", finalSymptoms); setResult(RESULT_OK, intent); finish(); }else{ finish(); } } } }
[ "snaranjov@gmail.com" ]
snaranjov@gmail.com
39adf1b50fc2cb31d34fab3db2bd525305163c11
2dfe364b758c5ea33ca62838a809caba5857bba7
/java/crm/crm_mapper/src/main/java/com/kaishengit/crm/mapper/DeptMapper.java
9c1fea3e669fe23ba4a17bef879806ec2258471f
[]
no_license
guoshiliang/java23
a13da16b6eff2e6f88381298b8db967aeb684c34
6365b732e79627214ae3bcb699f468745d1532ab
refs/heads/master
2020-12-02T22:12:52.406917
2017-07-30T15:53:29
2017-07-30T15:53:29
96,097,549
0
0
null
null
null
null
UTF-8
Java
false
false
868
java
package com.kaishengit.crm.mapper; import com.kaishengit.crm.entity.Dept; import com.kaishengit.crm.entity.DeptExample; import org.apache.ibatis.annotations.Param; import java.util.List; /** * Created by Administrator on 2017/7/17 0017. */ public interface DeptMapper { long countByExample(DeptExample example); int deleteByExample(DeptExample example); int deleteByPrimaryKey(Integer id); int insert(Dept record); int insertSelective(Dept record); List<Dept> selectByExample(DeptExample example); Dept selectByPrimaryKey(Integer id); int updateByExampleSelective(@Param("record") Dept record, @Param("example") DeptExample example); int updateByExample(@Param("record") Dept record, @Param("example") DeptExample example); int updateByPrimaryKeySelective(Dept record); int updateByPrimaryKey(Dept record); }
[ "1171039533@qq.com" ]
1171039533@qq.com
0fa61fc740fe165c0ef092af292467627e416920
c97f37adf205e2845f9c292d1e898e52fe895c59
/src/_02_Encapsulation/EXERCISES/_05_Pizza_Calories/Pizza.java
fdf010ced910a66d095194266a3a45f5636126b0
[]
no_license
Tuscann/JAVA-OOP-Basics---2017
6ca2fee9820b37849aca40c389830f8c863969a6
25bf3fa94de5f2bf4c4d87151df786134b117cba
refs/heads/master
2021-08-17T06:51:35.376179
2017-11-20T21:52:26
2017-11-20T21:52:26
108,080,775
2
2
null
null
null
null
UTF-8
Java
false
false
1,996
java
package _02_Encapsulation.EXERCISES._05_Pizza_Calories; public class Pizza { private String name; private Dough dough; private int numberOfToppings; private Topping[] toppings; private int indexCount; public Pizza(String name, int numberOfToppings) throws Exception { this.setName(name); this.setNumberOfToppings(numberOfToppings); this.setToppings(new Topping[numberOfToppings]); } public String getName() { return name; } private void setName(String name) throws Exception { if (name.trim().length() == 0 || name.length() > 15) { throw new Exception("Pizza name should be between 1 and 15 symbols."); } this.name = name; } // public Dough getDough() { // return dough; // } public void setDough(Dough dough) { this.dough = dough; } // public int getNumberOfToppings() { // return numberOfToppings; // } private void setNumberOfToppings(int numberOfToppings) throws Exception { if (numberOfToppings < 0 || numberOfToppings > 10) { throw new Exception("Number of toppings should be in range [0..10]."); } this.numberOfToppings = numberOfToppings; } public Topping[] getToppings() { return toppings; } private void setToppings(Topping[] toppings) { this.toppings = toppings; } public void addTopping(Topping topping) { this.toppings[this.indexCount++] = topping; } private double getCalories() { double total = getTotal(); return total; } private double getTotal() { double total = 0.0; total += this.dough.getCalories(); for (Topping topping : this.getToppings()) { total += topping.getCalories(); } return total; } @Override public String toString() { return String.format("%s - %.2f", this.getName(), this.getCalories()); } }
[ "fbinnzhivko@gmail.com" ]
fbinnzhivko@gmail.com
5fe3621867baf2a16a5d904055651b345f067e71
ed22850ce88b9c382dc9e63dc9f35bf2246eeca1
/FirstLineAndroid/RuntimePermissionTest/app/src/androidTest/java/org/sunjw/runtimepermissiontest/ExampleInstrumentedTest.java
7b3328e3d17cd379b48e6a7624d596934a3772c2
[]
no_license
sunjw/some-learning
75419745d49898b0e1e4daf855faf8ddbc00ef0f
477db71b1ae81221a002ed2ca3288cf5f2a30d5d
refs/heads/master
2023-08-08T05:12:55.772436
2023-08-02T09:19:08
2023-08-02T09:19:08
236,288,527
2
0
null
2023-09-07T01:37:48
2020-01-26T09:00:15
C
UTF-8
Java
false
false
766
java
package org.sunjw.runtimepermissiontest; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumentation test, which will execute on an Android device. * * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("org.sunjw.runtimepermissiontest", appContext.getPackageName()); } }
[ "sunjw8888@gmail.com" ]
sunjw8888@gmail.com
5804d059cf7064520bf686365c9045b679051879
a3fc4030dfb7540312bb52dd67e3389ef7aba97d
/module-service-producer/src/main/java/com/logan/springcloud/repository/UserRepository.java
777467bde23504cb8511761e075f8b895ccc2c7a
[]
no_license
JasonBabylon/spring-cloud-eureka
9488c3f7c3a84dc7ed8b8d495d39c842d6363405
aeecbd46ecd492936b4b66c4089c66213c2cf1d3
refs/heads/master
2021-06-25T13:19:50.213655
2020-12-04T05:44:32
2020-12-04T05:44:32
146,234,251
0
0
null
null
null
null
UTF-8
Java
false
false
282
java
package com.logan.springcloud.repository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import com.logan.springcloud.entity.User; @Repository public interface UserRepository extends JpaRepository<User, Long> { }
[ "chengang.hong@dbappsecurity.com.cn" ]
chengang.hong@dbappsecurity.com.cn
43662311580b8701914c755519db9869e5d114f5
b9a71bb2805d5f0d5ac98c59d984246463285d34
/testing/drools-master/knowledge-api-legacy5-adapter/src/main/java/org/drools/builder/conf/MultiValueKnowledgeBuilderOption.java
1e2f4426760cb063f57010948dbc4c92c61cecfa
[ "MIT" ]
permissive
rokn/Count_Words_2015
486f3b292954adc76c9bcdbf9a37eb07421ddd2a
e07f6fc9dfceaf773afc0c3a614093e16a0cde16
refs/heads/master
2021-01-10T04:23:49.999237
2016-01-11T19:53:31
2016-01-11T19:53:31
48,538,207
1
1
null
null
null
null
UTF-8
Java
false
false
833
java
/* * Copyright 2010 Red Hat, Inc. and/or its affiliates. * * 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.drools.builder.conf; /** * A markup interface for MultiValueKnowledgeBuilderConfiguration options */ public interface MultiValueKnowledgeBuilderOption extends KnowledgeBuilderOption { }
[ "marto_dimitrov@mail.bg" ]
marto_dimitrov@mail.bg
4c1d51b1c7dea7fe3edd85fcb7acf8adeb8cc151
40e4ce9d3ab15fa3a1eb2698a82b86552adb7eb1
/src/vo/PdtPageInfo.java
f53875247e7babe2060611ff992f36cd99050269
[]
no_license
Taeila92/fourplay
2c90417ca8d3619cbd8a7f06588a2844521d5ff7
164c0e93dc230f44c26d6dfdbd7fd9b19d4699d6
refs/heads/master
2023-03-23T20:15:12.879175
2021-03-17T04:05:57
2021-03-17T04:05:57
326,875,116
0
1
null
2021-01-07T13:51:45
2021-01-05T03:28:14
Java
UHC
Java
false
false
2,650
java
package vo; public class PdtPageInfo { // 상품 목록 페이지에 필요한 데이터들을 저장하는 클래스(어드민과 프론트 공용) private int cpage, pcnt, spage, epage, rcnt, bsize, psize; // 현재 page번호, page수, 시작page, 종료page, 게시글수, 블록크기, page크기 private String isview, schtype, keyword, sdate, edate, bcata, scata, sprice, eprice, stock; // 검색조건 : 게시여부-admin, 키워드(상품명, 상품아이디), 등록기간-admin, 대분류, 소분류, 가격대, 재고-admin private String ord; // 정렬조건 : 가격price(오a내d), 상품명name(오a), 등록일date(오a내d), 인기salecnt(내d), 리뷰review(내d) public int getCpage() { return cpage; } public void setCpage(int cpage) { this.cpage = cpage; } public int getPcnt() { return pcnt; } public void setPcnt(int pcnt) { this.pcnt = pcnt; } public int getSpage() { return spage; } public void setSpage(int spage) { this.spage = spage; } public int getEpage() { return epage; } public void setEpage(int epage) { this.epage = epage; } public int getRcnt() { return rcnt; } public void setRcnt(int rcnt) { this.rcnt = rcnt; } public int getBsize() { return bsize; } public void setBsize(int bsize) { this.bsize = bsize; } public int getPsize() { return psize; } public void setPsize(int psize) { this.psize = psize; } public String getIsview() { return isview; } public void setIsview(String isview) { this.isview = isview; } public String getSchtype() { return schtype; } public void setSchtype(String schtype) { this.schtype = schtype; } public String getKeyword() { return keyword; } public void setKeyword(String keyword) { this.keyword = keyword; } public String getSdate() { return sdate; } public void setSdate(String sdate) { this.sdate = sdate; } public String getEdate() { return edate; } public void setEdate(String edate) { this.edate = edate; } public String getBcata() { return bcata; } public void setBcata(String bcata) { this.bcata = bcata; } public String getScata() { return scata; } public void setScata(String scata) { this.scata = scata; } public String getSprice() { return sprice; } public void setSprice(String sprice) { this.sprice = sprice; } public String getEprice() { return eprice; } public void setEprice(String eprice) { this.eprice = eprice; } public String getStock() { return stock; } public void setStock(String stock) { this.stock = stock; } public String getOrd() { return ord; } public void setOrd(String ord) { this.ord = ord; } }
[ "kim920125@naver.com" ]
kim920125@naver.com
8e512e42a91450d4411ccee81a13b8ade1d76c97
cba76809e4fe50cd49fcbd10c198f5135cca5b0d
/core-app/src/main/java/com/streaming/core/config/R2DBCConfig.java
437d0c117a28ba9b9175a6c53408dbd7de342e9f
[ "Apache-2.0" ]
permissive
rayh176/streaming-webflux
89ca5a20743c9379cdec853d44c79657a1e7fc15
0c616a141d1f11c922d1f377d936130510c8606e
refs/heads/master
2023-04-12T07:10:15.524024
2021-05-07T09:47:39
2021-05-07T09:47:39
364,918,734
0
0
null
null
null
null
UTF-8
Java
false
false
3,381
java
package com.streaming.core.config; import com.streaming.core.RepositoryPackage; import com.streaming.core.repos.PlayerRepository; import io.r2dbc.h2.H2ConnectionConfiguration; import io.r2dbc.h2.H2ConnectionFactory; import io.r2dbc.spi.ConnectionFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.core.convert.converter.Converter; import org.springframework.core.io.ClassPathResource; import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration; import org.springframework.data.r2dbc.convert.R2dbcCustomConversions; import org.springframework.data.r2dbc.repository.R2dbcRepository; import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories; import org.springframework.r2dbc.connection.R2dbcTransactionManager; import org.springframework.r2dbc.connection.init.CompositeDatabasePopulator; import org.springframework.r2dbc.connection.init.ConnectionFactoryInitializer; import org.springframework.r2dbc.connection.init.ResourceDatabasePopulator; import org.springframework.transaction.ReactiveTransactionManager; import java.time.LocalDateTime; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; import java.util.TimeZone; @Configuration @EnableR2dbcRepositories(basePackages = {"com.streaming.core.repos"}, basePackageClasses = {PlayerRepository.class, RepositoryPackage.class}, includeFilters= @ComponentScan.Filter (type = FilterType.ASSIGNABLE_TYPE, classes = R2dbcRepository.class) ) public class R2DBCConfig extends AbstractR2dbcConfiguration { @Bean public H2ConnectionFactory connectionFactory() { return new H2ConnectionFactory( H2ConnectionConfiguration.builder() .url("r2dbc:h2:mem:./data/db") .username("sa") .build() ); } @Bean public R2dbcCustomConversions r2dbcCustomConversions() { List<Converter> converters = new ArrayList<>(); converters.add(new LocalDateTimeConverter()); return new R2dbcCustomConversions(converters); } @Bean ReactiveTransactionManager transactionManager(ConnectionFactory connectionFactory) { return new R2dbcTransactionManager(connectionFactory); } public static class LocalDateTimeConverter implements Converter <LocalDateTime, ZonedDateTime> { @Override public ZonedDateTime convert(LocalDateTime localDateTime) { return LocalDateTime.MAX.atZone(TimeZone.getDefault().toZoneId()); } } @Bean public ConnectionFactoryInitializer initializer(ConnectionFactory connectionFactory) { ConnectionFactoryInitializer initializer = new ConnectionFactoryInitializer(); initializer.setConnectionFactory(connectionFactory); CompositeDatabasePopulator populator = new CompositeDatabasePopulator(); populator.addPopulators(new ResourceDatabasePopulator(new ClassPathResource("schema.sql"))); populator.addPopulators(new ResourceDatabasePopulator(new ClassPathResource("data.sql"))); initializer.setDatabasePopulator(populator); return initializer; } }
[ "rayh176@gmail.com" ]
rayh176@gmail.com
8095dc7eaf3277c9c81cc10280d4d1bb04941273
8f57c35c3086098ce8e3cec5f64b9a77e8de6d4c
/instrument-plugin-load/src/main/java/com/penck/manager/PluginManager.java
fa24c62ddd012a6c332da2c4e4ff8cca982fcd65
[]
no_license
QDPeng/PluginTest
4c4c96bbdf7dcf2ccb94379db2246f861b451df3
05a3d5ed6fdce0960f34bf72a1a120e7ecb77cd6
refs/heads/master
2021-01-19T03:46:58.626688
2017-03-09T08:39:33
2017-03-09T08:39:33
84,414,449
2
2
null
null
null
null
UTF-8
Java
false
false
19,525
java
/* * Copyright (C) 2015 HouKx <hkx.aidream@gmail.com> * * 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.penck.manager; import android.app.Application; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.res.AssetManager; import android.content.res.Resources; import android.os.Looper; import android.app.Instrumentation; import com.penck.manager.delegate.DelegateActivityThread; import com.penck.manager.environment.CreateActivityData; import com.penck.manager.environment.PlugInfo; import com.penck.manager.environment.PluginClassLoader; import com.penck.manager.environment.PluginContext; import com.penck.manager.environment.PluginInstrumentation; import com.penck.manager.selector.DefaultActivitySelector; import com.penck.manager.selector.DynamicActivitySelector; import com.penck.manager.utils.FileUtil; import com.penck.manager.utils.PluginManifestUtil; import com.penck.manager.utils.Trace; import com.penck.manager.verify.PluginNotFoundException; import com.penck.manager.verify.PluginOverdueVerifier; import com.penck.manager.verify.SimpleLengthVerifier; import java.io.File; import java.io.FileFilter; import java.io.FileNotFoundException; import java.lang.reflect.Field; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** * 插件管理器 * * @author HouKangxi * @author Lody */ public class PluginManager implements FileFilter { /** * 插件管理器单例 */ private static PluginManager SINGLETON; /** * 插件包名 -- 插件信息 的映射 */ private final Map<String, PlugInfo> pluginPkgToInfoMap = new ConcurrentHashMap<String, PlugInfo>(); /** * 全局上下文 */ private Context context; /** * 插件dex opt输出路径 */ private String dexOutputPath; /** * 私有目录中存储插件的路径 */ private File dexInternalStoragePath; private ClassLoader pluginParentClassLoader = ClassLoader.getSystemClassLoader().getParent(); /** * Activity生命周期监听器 */ private PluginActivityLifeCycleCallback pluginActivityLifeCycleCallback; /** * 插件过期验证器 (默认只对比文件长度) */ private PluginOverdueVerifier pluginOverdueVerifier = new SimpleLengthVerifier(); private DynamicActivitySelector activitySelector = DefaultActivitySelector.getDefault(); /** * 插件管理器私有构造器 * * @param context Application上下文 */ private PluginManager(Context context) { if (!isMainThread()) { throw new IllegalThreadStateException("PluginManager must init in UI Thread!"); } this.context = context; File optimizedDexPath = context.getDir(Globals.PRIVATE_PLUGIN_OUTPUT_DIR_NAME, Context.MODE_PRIVATE); dexOutputPath = optimizedDexPath.getAbsolutePath(); dexInternalStoragePath = context.getDir( Globals.PRIVATE_PLUGIN_ODEX_OUTPUT_DIR_NAME, Context.MODE_PRIVATE ); DelegateActivityThread delegateActivityThread = DelegateActivityThread.getSingleton(); Instrumentation originInstrumentation = delegateActivityThread.getInstrumentation(); if (!(originInstrumentation instanceof PluginInstrumentation)) { PluginInstrumentation pluginInstrumentation = new PluginInstrumentation(originInstrumentation); delegateActivityThread.setInstrumentation(pluginInstrumentation); } } /** * 取得插件管理器单例,<br> * NOTICE: 你必须在启动插件管理器前初始化插件管理器! * * @return 插件管理器单例 */ public static PluginManager getSingleton() { checkInit(); return SINGLETON; } private static void checkInit() { if (SINGLETON == null) { throw new IllegalStateException("Please init the PluginManager first!"); } } /** * 初始化插件管理器,请不要传入易变的Context,那将造成内存泄露! * * @param context Application上下文 */ public static void init(Context context) { if (SINGLETON != null) { Trace.store("PluginManager have been initialized, YOU needn't initialize it again!"); return; } Trace.store("init PluginManager..."); SINGLETON = new PluginManager(context); } /** * 尝试通过插件ID或插件包名取得插件信息,如果插件没有找到,抛出异常. * * @param plugPkg 插件ID或插件包名 * @return 插件信息 */ public PlugInfo tryGetPluginInfo(String plugPkg) throws PluginNotFoundException { PlugInfo plug = findPluginByPackageName(plugPkg); if (plug == null) { throw new PluginNotFoundException("plug not found by:" + plugPkg); } return plug; } public File getPluginBasePath(PlugInfo plugInfo) { return new File(getDexInternalStoragePath(), plugInfo.getId() + "-dir"); } public File getPluginLibPath(PlugInfo plugInfo) { return new File(getDexInternalStoragePath(), plugInfo.getId() + "-dir/lib/"); } /** * 指定插件包名取得插件信息 * * @param packageName 插件包名 * @return 插件信息 */ public PlugInfo findPluginByPackageName(String packageName) { return pluginPkgToInfoMap.get(packageName); } /** * 取得当前维护的全部插件 * * @return 当前维护的全部插件 */ public Collection<PlugInfo> getPlugins() { return pluginPkgToInfoMap.values(); } /** * 指定包名卸载一个插件 * * @param pkg 插件包名 */ public void uninstallPluginByPkg(String pkg) { removePlugByPkg(pkg); } private PlugInfo removePlugByPkg(String pkg) { PlugInfo pl; synchronized (this) { pl = pluginPkgToInfoMap.remove(pkg); if (pl == null) { return null; } } return pl; } /** * 加载指定插件或指定目录下的所有插件 * <p> * 都使用文件名作为Id * * @param pluginSrcDirFile - apk或apk目录 * @return 插件集合 * @throws Exception */ public Collection<PlugInfo> loadPlugin(final File pluginSrcDirFile) throws Exception { if (pluginSrcDirFile == null || !pluginSrcDirFile.exists()) { Trace.store("invalidate plugin file or Directory :" + pluginSrcDirFile); return null; } if (pluginSrcDirFile.isFile()) { PlugInfo one = buildPlugInfo(pluginSrcDirFile, null, null); if (one != null) { savePluginToMap(one); } return Collections.singletonList(one); } // synchronized (this) { // pluginPkgToInfoMap.clear(); // } File[] pluginApkFiles = pluginSrcDirFile.listFiles(this); if (pluginApkFiles == null || pluginApkFiles.length == 0) { throw new FileNotFoundException("could not find plugins in:" + pluginSrcDirFile); } for (File pluginApk : pluginApkFiles) { try { PlugInfo plugInfo = buildPlugInfo(pluginApk, null, null); if (plugInfo != null) { savePluginToMap(plugInfo); } } catch (Throwable e) { e.printStackTrace(); } } return pluginPkgToInfoMap.values(); } private synchronized void savePluginToMap(PlugInfo plugInfo) { pluginPkgToInfoMap.put(plugInfo.getPackageName(), plugInfo); } private PlugInfo buildPlugInfo(File pluginApk, String pluginId, String targetFileName) throws Exception { PlugInfo info = new PlugInfo(); info.setId(pluginId == null ? pluginApk.getName() : pluginId); File privateFile = new File(dexInternalStoragePath, targetFileName == null ? pluginApk.getName() : targetFileName); info.setFilePath(privateFile.getAbsolutePath()); //Copy Plugin to Private Dir if (!pluginApk.getAbsolutePath().equals(privateFile.getAbsolutePath())) { copyApkToPrivatePath(pluginApk, privateFile); } String dexPath = privateFile.getAbsolutePath(); //Load Plugin Manifest PluginManifestUtil.setManifestInfo(context, dexPath, info); //Load Plugin Res try { AssetManager am = AssetManager.class.newInstance(); am.getClass().getMethod("addAssetPath", String.class) .invoke(am, dexPath); info.setAssetManager(am); Resources hotRes = context.getResources(); Resources res = new Resources(am, hotRes.getDisplayMetrics(), hotRes.getConfiguration()); info.setResources(res); } catch (Exception e) { throw new RuntimeException("Unable to create Resources&Assets for " + info.getPackageName() + " : " + e.getMessage()); } //Load classLoader for Plugin PluginClassLoader pluginClassLoader = new PluginClassLoader(info, dexPath, dexOutputPath , getPluginLibPath(info).getAbsolutePath(), pluginParentClassLoader); info.setClassLoader(pluginClassLoader); ApplicationInfo appInfo = info.getPackageInfo().applicationInfo; Application app = makeApplication(info, appInfo); attachBaseContext(info, app); info.setApplication(app); Trace.store("Build pluginInfo => " + info); return info; } private void attachBaseContext(PlugInfo info, Application app) { try { Field mBase = ContextWrapper.class.getDeclaredField("mBase"); mBase.setAccessible(true); mBase.set(app, new PluginContext(context.getApplicationContext(), info)); } catch (Throwable e) { e.printStackTrace(); } } /** * 插件中可能需要公用某些依赖库以减小体积,当你有这个需求的时候,请使用本API. * @param parentClassLoader classLoader */ public void setPluginParentClassLoader(ClassLoader parentClassLoader) { if (parentClassLoader != null) { this.pluginParentClassLoader = parentClassLoader; }else { this.pluginParentClassLoader = ClassLoader.getSystemClassLoader().getParent(); } } public ClassLoader getPluginParentClassLoader() { return pluginParentClassLoader; } /** * 构造插件的Application * * @param plugInfo 插件信息 * @param appInfo 插件ApplicationInfo * @return 插件App */ private Application makeApplication(PlugInfo plugInfo, ApplicationInfo appInfo) { String appClassName = appInfo.className; if (appClassName == null) { //Default Application appClassName = Application.class.getName(); } try { return (Application) plugInfo.getClassLoader().loadClass(appClassName).newInstance(); } catch (Throwable e) { throw new RuntimeException("Unable to create Application for " + plugInfo.getPackageName() + ": " + e.getMessage()); } } /** * 将Apk复制到私有目录 * @see PluginOverdueVerifier * 可设置插件覆盖校检器来验证插件是否需要覆盖 * * @param pluginApk 插件apk原始路径 * @param targetPutApk 要拷贝到的目标位置 */ private void copyApkToPrivatePath(File pluginApk, File targetPutApk) { if (pluginOverdueVerifier != null) { //仅当私有目录中插件已存在时需要检验 if (targetPutApk.exists() && pluginOverdueVerifier.isOverdue(pluginApk, targetPutApk)) { return; } } FileUtil.copyFile(pluginApk, targetPutApk); } /** * @return 存储插件的私有目录 */ File getDexInternalStoragePath() { return dexInternalStoragePath; } Context getContext() { return context; } /** * @return 插件Activity生命周期监听器 */ public PluginActivityLifeCycleCallback getPluginActivityLifeCycleCallback() { return pluginActivityLifeCycleCallback; } /** * 设置插件Activity生命周期监听器 * * @param pluginActivityLifeCycleCallback 插件Activity生命周期监听器 */ public void setPluginActivityLifeCycleCallback( PluginActivityLifeCycleCallback pluginActivityLifeCycleCallback) { this.pluginActivityLifeCycleCallback = pluginActivityLifeCycleCallback; } /** * @return 插件验证校检器 */ public PluginOverdueVerifier getPluginOverdueVerifier() { return pluginOverdueVerifier; } /** * 设置插件验证校检器 * * @param pluginOverdueVerifier 插件验证校检器 */ public void setPluginOverdueVerifier(PluginOverdueVerifier pluginOverdueVerifier) { this.pluginOverdueVerifier = pluginOverdueVerifier; } @Override public boolean accept(File pathname) { return !pathname.isDirectory() && pathname.getName().endsWith(".apk"); } //====================================================== //=================启动插件相关方法======================= //====================================================== /** * 启动插件的主Activity * * @param from fromContext * @param plugInfo 插件Info * @param intent 通过此Intent可以向插件传参, 可以为null */ public void startMainActivity(Context from, PlugInfo plugInfo, Intent intent) { if (!pluginPkgToInfoMap.containsKey(plugInfo.getPackageName())) { return; } ActivityInfo activityInfo = plugInfo.getMainActivity().activityInfo; if (activityInfo == null) { throw new ActivityNotFoundException("Cannot find Main Activity from plugin."); } startActivity(from, plugInfo, activityInfo, intent); } /** * 启动插件的主Activity * * @param from fromContext * @param plugInfo 插件Info */ public void startMainActivity(Context from, PlugInfo plugInfo) { startMainActivity(from, plugInfo, null); } /** * 启动插件的主Activity * @param from fromContext * @param pluginPkgName 插件包名 * @throws PluginNotFoundException 该插件未加载时抛出 * @throws ActivityNotFoundException 插件Activity信息找不到时抛出 */ public void startMainActivity(Context from, String pluginPkgName) throws PluginNotFoundException, ActivityNotFoundException { PlugInfo plugInfo = tryGetPluginInfo(pluginPkgName); startMainActivity(from, plugInfo); } /** * 启动插件的指定Activity * * @param from fromContext * @param plugInfo 插件信息 * @param activityInfo 要启动的插件activity信息 * @param intent 通过此Intent可以向插件传参, 可以为null */ public void startActivity(Context from, PlugInfo plugInfo, ActivityInfo activityInfo, Intent intent) { if (activityInfo == null) { throw new ActivityNotFoundException("Cannot find ActivityInfo from plugin, could you declare this Activity in plugin?"); } if (intent == null) { intent = new Intent(); } CreateActivityData createActivityData = new CreateActivityData(activityInfo.name, plugInfo.getPackageName()); intent.setClass(from, activitySelector.selectDynamicActivity(activityInfo)); intent.putExtra(Globals.FLAG_ACTIVITY_FROM_PLUGIN, createActivityData); from.startActivity(intent); } public DynamicActivitySelector getActivitySelector() { return activitySelector; } public void setActivitySelector(DynamicActivitySelector activitySelector) { if (activitySelector == null) { activitySelector = DefaultActivitySelector.getDefault(); } this.activitySelector = activitySelector; } /** * 启动插件的指定Activity * * @param from fromContext * @param plugInfo 插件信息 * @param targetActivity 要启动的插件activity类名 * @param intent 通过此Intent可以向插件传参, 可以为null */ public void startActivity(Context from, PlugInfo plugInfo, String targetActivity, Intent intent) { ActivityInfo activityInfo = plugInfo.findActivityByClassName(targetActivity); startActivity(from, plugInfo, activityInfo, intent); } /** * 启动插件的指定Activity * * @param from fromContext * @param plugInfo 插件信息 * @param targetActivity 要启动的插件activity类名 */ public void startActivity(Context from, PlugInfo plugInfo, String targetActivity) { startActivity(from, plugInfo, targetActivity, null); } /** * 启动插件的指定Activity * * @param from fromContext * @param pluginPkgName 插件包名 * @param targetActivity 要启动的插件activity类名 */ public void startActivity(Context from, String pluginPkgName, String targetActivity) throws PluginNotFoundException, ActivityNotFoundException { startActivity(from, pluginPkgName, targetActivity, null); } /** * 启动插件的指定Activity * * @param from fromContext * @param pluginPkgName 插件包名 * @param targetActivity 要启动的插件activity类名 * @param intent 通过此Intent可以向插件传参, 可以为null */ public void startActivity(Context from, String pluginPkgName, String targetActivity, Intent intent) throws PluginNotFoundException, ActivityNotFoundException { PlugInfo plugInfo = tryGetPluginInfo(pluginPkgName); startActivity(from, plugInfo, targetActivity, intent); } public void dump() { Trace.store(pluginPkgToInfoMap.size() + " Plugins is loaded, " + Arrays.toString(pluginPkgToInfoMap.values().toArray())); } /** * @return 当前是否为主线程 */ public boolean isMainThread() { return Looper.getMainLooper() == Looper.myLooper(); } }
[ "liusp_008@sina.com" ]
liusp_008@sina.com
07d9aef71f8485193117936a9dd493c67fd0608c
8bfbd322cfb5fa5664bc944776bf785afcae5229
/src/com/vless/wificam/CamSettActivity.java
4e1c11ac733f567330f9f56a3a794a234663da61
[]
no_license
wwkkww1983/WifiCamAndroid
855a1b41338145e66d2772b8ff1d25bdefff61a0
c810d73ae705975325cbd718048417f6727438d8
refs/heads/master
2021-05-29T08:25:25.041001
2015-07-07T07:04:04
2015-07-07T07:04:04
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,560
java
package com.vless.wificam; import com.vless.wificam.Control.CameraSettingsFragment; import com.vless.wificam.frags.WifiCamFragment; import com.vless.wificam.impls.OnEcarInfoListener; import android.content.Context; import android.net.wifi.WifiManager; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTransaction; import android.util.Log; import android.view.Window; public class CamSettActivity extends FragmentActivity { private WifiManager wifiManager; private WifiCamFragment camSettFrg; private OnEcarInfoListener onDataListener = new OnEcarInfoListener() { @Override public void setOnEcarInfoListener(int what) { Log.i("onDataListener", "what : " + what); onBackPressed(); finish(); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); wifiManager = (WifiManager) getApplicationContext().getSystemService( Context.WIFI_SERVICE); Bundle bundle = new Bundle(); bundle.putBoolean("isWifiEnabled", wifiManager.isWifiEnabled()); bundle.putInt("netWorkId", wifiManager.getConnectionInfo() .getNetworkId()); setContentView(R.layout.net_settings); FragmentTransaction fragTransaction = getSupportFragmentManager() .beginTransaction(); fragTransaction.add(R.id.llNetSettings, camSettFrg = new CameraSettingsFragment()); camSettFrg.setArguments(bundle); camSettFrg.setOnEcarFragListener(onDataListener); fragTransaction.commit(); } }
[ "744682157@qq.com" ]
744682157@qq.com
3e245385e837d67d68012ce5d122e9c63bec0f59
848e9276feb912ebc7b53a83e249a5de02bc6783
/src/main/java/com/example/pollsapplication/config/SecurityConfig.java
6c106087f5783a005b4c3a2ba3982bddef282e47
[]
no_license
tvuchova/polls-application
b211dca936d006c11caf6faa89590a4219b0d2c3
276e485a1411f2a04be70cc16615ac5b3496f97e
refs/heads/master
2020-05-14T01:59:46.039834
2019-04-22T07:47:44
2019-04-22T07:47:44
181,687,671
0
0
null
null
null
null
UTF-8
Java
false
false
3,697
java
package com.example.pollsapplication.config; import com.example.pollsapplication.security.CustomUserDetailsService; import com.example.pollsapplication.security.JwtAuthenticationEntryPoint; import com.example.pollsapplication.security.JwtAuthenticationFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.BeanIds; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity( securedEnabled = true, jsr250Enabled = true, prePostEnabled = true ) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired CustomUserDetailsService customUserDetailsService; @Autowired private JwtAuthenticationEntryPoint unauthorizedHandler; @Bean public JwtAuthenticationFilter jwtAuthenticationFilter() { return new JwtAuthenticationFilter(); } @Override public void configure( AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { authenticationManagerBuilder .userDetailsService(customUserDetailsService) .passwordEncoder(passwordEncoder()); } @Bean(BeanIds.AUTHENTICATION_MANAGER) @Override public AuthenticationManager authenticationManagerBean() throws Exception { return super.authenticationManagerBean(); } @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } @Override protected void configure(HttpSecurity http) throws Exception { http .cors() .and() .csrf() .disable() .exceptionHandling() .authenticationEntryPoint(unauthorizedHandler) .and() .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .authorizeRequests() .antMatchers("/", "/favicon.ico", "/**/*.png", "/**/*.gif", "/**/*.svg", "/**/*.jpg", "/**/*.html", "/**/*.css", "/**/*.js") .permitAll() .antMatchers("/api/auth/**") .permitAll() .antMatchers("/api/user/checkUsernameAvailability", "/api/user/checkEmailAvailability") .permitAll() .antMatchers(HttpMethod.GET, "/api/polls/**", "/api/users/**") .permitAll() .anyRequest() .authenticated(); // Add our custom JWT security filter http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class); } }
[ "temenuzhka.vuchova@tick42.com" ]
temenuzhka.vuchova@tick42.com
9f103ae178e8ad0be0e40d7722ef8a493388a9b1
fa0cf934703768baac2390a0849af9c8141a94e3
/ltybd-bdapplication/src/main/java/com/ltybd/util/DateStyle.java
af6cb449e995f851b7a5c8706b9b89652e551fc5
[]
no_license
NONO9527/ltybd-root
44c4a8bbef3d708c82772874fb14ae654ca05229
c8a650f3f204ff1abeecdc9178869e3a47bdde93
refs/heads/master
2021-12-30T09:23:46.933731
2018-02-08T01:24:14
2018-02-08T01:24:14
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,408
java
package com.ltybd.util; /** * * * @author lty-been * @version 创建时间2015年7月9日 下午2:12:44 * */ public enum DateStyle { YYYY_MM("yyyy-MM", false), YYYY_MM_DD("yyyy-MM-dd", false), YYYY_MM_DD_HH_MM( "yyyy-MM-dd HH:mm", false), YYYY_MM_DD_HH_MM_SS( "yyyy-MM-dd HH:mm:ss", false),YYYY_MM_DD_HH_MM_SS_SSS( "yyyy-MM-dd HH:mm:ss.SSS", false), YYYY_MM_EN("yyyy/MM", false), YYYY_MM_DD_EN("yyyy/MM/dd", false), YYYY_MM_DD_HH_MM_EN( "yyyy/MM/dd HH:mm", false), YYYY_MM_DD_HH_MM_SS_EN( "yyyy/MM/dd HH:mm:ss", false), YYYY_MM_CN("yyyy年MM月", false), YYYY_MM_DD_CN("yyyy年MM月dd日", false), YYYY_MM_DD_HH_MM_CN( "yyyy年MM月dd日 HH:mm", false), YYYY_MM_DD_HH_MM_SS_CN( "yyyy年MM月dd日 HH:mm:ss", false), HH_MM("HH:mm", true), HH_MM_SS("HH:mm:ss", true), MM_DD("MM-dd", true), MM_DD_HH_MM("MM-dd HH:mm", true), MM_DD_HH_MM_SS( "MM-dd HH:mm:ss", true), MM_DD_EN("MM/dd", true), MM_DD_HH_MM_EN("MM/dd HH:mm", true), MM_DD_HH_MM_SS_EN( "MM/dd HH:mm:ss", true), MM_DD_CN("MM月dd日", true), MM_DD_HH_MM_CN("MM月dd日 HH:mm", true), MM_DD_HH_MM_SS_CN( "MM月dd日 HH:mm:ss", true); private String value; private boolean isShowOnly; DateStyle(String value, boolean isShowOnly) { this.value = value; this.isShowOnly = isShowOnly; } public String getValue() { return value; } public boolean isShowOnly() { return isShowOnly; } }
[ "shuai.hong@lantaiyuan.com" ]
shuai.hong@lantaiyuan.com
a7feabaccff64c5e4432eebb50acc3b55baeeba3
eb366b98f99131eacc42c8759e7d9353a5402d8e
/TLA/src/com/tla/domain/Users.java
9965441a7ea2103f0b29c1fc4af562ef09f85dcd
[]
no_license
wangzhenyu1260/TLA
2a833f2c92aefd3e73b17d4857ea022adadf582e
b09ba42e8ff179dd22769d0a2637d690b3a29dcf
refs/heads/master
2021-03-12T22:33:11.606487
2015-05-25T00:49:01
2015-05-25T00:49:01
35,804,075
0
0
null
null
null
null
UTF-8
Java
false
false
515
java
package com.tla.domain; public class Users { private String username; private String password; private String type; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getType() { return type; } public void setType(String type) { this.type = type; } }
[ "wangzhenyu1260@126.com" ]
wangzhenyu1260@126.com
97bb13db03f8449910d29ff93d43ec1bf6953b23
6bd0f3c4eba9517a96f106958ffc45c987889a6e
/build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r/android/arch/lifecycle/extensions/R.java
f5fbd36e56bab260dffb9228d4a2c3969a296fb4
[]
no_license
Francis365/TeraTourAR
965c6c0a4d357be18cad852cf5aac6553405f90c
b4dfaf0a740d6f47abb24ff5c4fd78ef2021eb32
refs/heads/master
2020-04-11T01:46:48.967797
2018-12-12T11:06:15
2018-12-12T11:07:45
161,426,103
0
1
null
null
null
null
UTF-8
Java
false
false
8,526
java
/* AUTO-GENERATED FILE. DO NOT MODIFY. * * This class was automatically generated by the * gradle plugin from the resource data it found. It * should not be modified by hand. */ package android.arch.lifecycle.extensions; public final class R { private R() {} public static final class attr { private attr() {} public static final int font = 0x7f0300dd; public static final int fontProviderAuthority = 0x7f0300df; public static final int fontProviderCerts = 0x7f0300e0; public static final int fontProviderFetchStrategy = 0x7f0300e1; public static final int fontProviderFetchTimeout = 0x7f0300e2; public static final int fontProviderPackage = 0x7f0300e3; public static final int fontProviderQuery = 0x7f0300e4; public static final int fontStyle = 0x7f0300e5; public static final int fontWeight = 0x7f0300e7; } public static final class bool { private bool() {} public static final int abc_action_bar_embed_tabs = 0x7f040000; } public static final class color { private color() {} public static final int notification_action_color_filter = 0x7f050086; public static final int notification_icon_bg_color = 0x7f050087; public static final int ripple_material_light = 0x7f050092; public static final int secondary_text_default_material_light = 0x7f050094; } public static final class dimen { private dimen() {} public static final int compat_button_inset_horizontal_material = 0x7f060051; public static final int compat_button_inset_vertical_material = 0x7f060052; public static final int compat_button_padding_horizontal_material = 0x7f060053; public static final int compat_button_padding_vertical_material = 0x7f060054; public static final int compat_control_corner_material = 0x7f060055; public static final int notification_action_icon_size = 0x7f0600c6; public static final int notification_action_text_size = 0x7f0600c7; public static final int notification_big_circle_margin = 0x7f0600c8; public static final int notification_content_margin_start = 0x7f0600c9; public static final int notification_large_icon_height = 0x7f0600ca; public static final int notification_large_icon_width = 0x7f0600cb; public static final int notification_main_column_padding_top = 0x7f0600cc; public static final int notification_media_narrow_margin = 0x7f0600cd; public static final int notification_right_icon_size = 0x7f0600ce; public static final int notification_right_side_padding_top = 0x7f0600cf; public static final int notification_small_icon_background_padding = 0x7f0600d0; public static final int notification_small_icon_size_as_large = 0x7f0600d1; public static final int notification_subtext_size = 0x7f0600d2; public static final int notification_top_pad = 0x7f0600d3; public static final int notification_top_pad_large_text = 0x7f0600d4; } public static final class drawable { private drawable() {} public static final int notification_action_background = 0x7f0700c3; public static final int notification_bg = 0x7f0700c4; public static final int notification_bg_low = 0x7f0700c5; public static final int notification_bg_low_normal = 0x7f0700c6; public static final int notification_bg_low_pressed = 0x7f0700c7; public static final int notification_bg_normal = 0x7f0700c8; public static final int notification_bg_normal_pressed = 0x7f0700c9; public static final int notification_icon_background = 0x7f0700ca; public static final int notification_template_icon_bg = 0x7f0700cb; public static final int notification_template_icon_low_bg = 0x7f0700cc; public static final int notification_tile_bg = 0x7f0700cd; public static final int notify_panel_notification_icon_bg = 0x7f0700ce; } public static final class id { private id() {} public static final int action_container = 0x7f080015; public static final int action_divider = 0x7f080017; public static final int action_image = 0x7f080018; public static final int action_text = 0x7f08001e; public static final int actions = 0x7f080020; public static final int async = 0x7f080027; public static final int blocking = 0x7f08002c; public static final int chronometer = 0x7f08003c; public static final int forever = 0x7f08009a; public static final int icon = 0x7f0800a1; public static final int icon_group = 0x7f0800a3; public static final int info = 0x7f0800a7; public static final int italic = 0x7f0800aa; public static final int line1 = 0x7f0800b1; public static final int line3 = 0x7f0800b2; public static final int normal = 0x7f0800c3; public static final int notification_background = 0x7f0800c4; public static final int notification_main_column = 0x7f0800c5; public static final int notification_main_column_container = 0x7f0800c6; public static final int right_icon = 0x7f0800d6; public static final int right_side = 0x7f0800d7; public static final int text = 0x7f080122; public static final int text2 = 0x7f080123; public static final int time = 0x7f08012d; public static final int title = 0x7f08012e; } public static final class integer { private integer() {} public static final int status_bar_notification_info_maxnum = 0x7f09000e; } public static final class layout { private layout() {} public static final int notification_action = 0x7f0b0053; public static final int notification_action_tombstone = 0x7f0b0054; public static final int notification_template_custom_big = 0x7f0b005b; public static final int notification_template_icon_group = 0x7f0b005c; public static final int notification_template_part_chronometer = 0x7f0b0060; public static final int notification_template_part_time = 0x7f0b0061; } public static final class string { private string() {} public static final int status_bar_notification_info_overflow = 0x7f0d0059; } public static final class style { private style() {} public static final int TextAppearance_Compat_Notification = 0x7f0e0119; public static final int TextAppearance_Compat_Notification_Info = 0x7f0e011a; public static final int TextAppearance_Compat_Notification_Line2 = 0x7f0e011c; public static final int TextAppearance_Compat_Notification_Time = 0x7f0e011f; public static final int TextAppearance_Compat_Notification_Title = 0x7f0e0121; public static final int Widget_Compat_NotificationActionContainer = 0x7f0e01ca; public static final int Widget_Compat_NotificationActionText = 0x7f0e01cb; } public static final class styleable { private styleable() {} public static final int[] FontFamily = { 0x7f0300df, 0x7f0300e0, 0x7f0300e1, 0x7f0300e2, 0x7f0300e3, 0x7f0300e4 }; public static final int FontFamily_fontProviderAuthority = 0; public static final int FontFamily_fontProviderCerts = 1; public static final int FontFamily_fontProviderFetchStrategy = 2; public static final int FontFamily_fontProviderFetchTimeout = 3; public static final int FontFamily_fontProviderPackage = 4; public static final int FontFamily_fontProviderQuery = 5; public static final int[] FontFamilyFont = { 0x1010532, 0x1010533, 0x101053f, 0x101056f, 0x1010570, 0x7f0300dd, 0x7f0300e5, 0x7f0300e6, 0x7f0300e7, 0x7f030215 }; public static final int FontFamilyFont_android_font = 0; public static final int FontFamilyFont_android_fontWeight = 1; public static final int FontFamilyFont_android_fontStyle = 2; public static final int FontFamilyFont_android_ttcIndex = 3; public static final int FontFamilyFont_android_fontVariationSettings = 4; public static final int FontFamilyFont_font = 5; public static final int FontFamilyFont_fontStyle = 6; public static final int FontFamilyFont_fontVariationSettings = 7; public static final int FontFamilyFont_fontWeight = 8; public static final int FontFamilyFont_ttcIndex = 9; } }
[ "anyeji.francis@gmail.com" ]
anyeji.francis@gmail.com
ac3babd18197392bef5cce073b472c99a1c7bf5e
e12af772256dccc4f44224f68b7a3124673d9ced
/jitsi/src/net/java/sip/communicator/impl/protocol/sip/net/SslNetworkLayer.java
850b3bc3059def8309c482a2dc1a180471373bba
[]
no_license
leshikus/dataved
bc2f17d9d5304b3d7c82ccb0f0f58c7abcd25b2a
6c43ab61acd08a25b21ed70432cd0294a5db2360
refs/heads/master
2021-01-22T02:33:58.915867
2016-11-03T08:35:22
2016-11-03T08:35:22
32,135,163
2
1
null
null
null
null
UTF-8
Java
false
false
12,787
java
/* * Jitsi, the OpenSource Java VoIP and Instant Messaging client. * * Distributable under LGPL license. * See terms of license at gnu.org. */ package net.java.sip.communicator.impl.protocol.sip.net; import java.io.*; import java.net.*; import java.security.*; import java.util.*; import javax.net.ssl.*; import gov.nist.core.net.*; import net.java.sip.communicator.impl.protocol.sip.*; import net.java.sip.communicator.service.certificate.*; import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.Logger; import org.osgi.framework.*; /** * Manages jain-sip socket creation. When dealing with ssl sockets we interact * with the user when the certificate for some reason is not trusted. * * @author Damian Minkov * @author Ingo Bauersachs * @author Sebastien Vincent */ public class SslNetworkLayer implements NetworkLayer { /** * Our class logger. */ private static final Logger logger = Logger.getLogger(SslNetworkLayer.class); /** * SIP DSCP configuration property name. */ private static final String SIP_DSCP_PROPERTY = "net.java.sip.communicator.impl.protocol.SIP_DSCP"; /** * The service we use to interact with user. */ private CertificateService certificateVerification = null; /** * Creates the network layer. */ public SslNetworkLayer() { ServiceReference guiVerifyReference = SipActivator.getBundleContext().getServiceReference( CertificateService.class.getName()); if (guiVerifyReference != null) certificateVerification = (CertificateService) SipActivator.getBundleContext().getService( guiVerifyReference); } /** * Creates a server with the specified port, listen backlog, and local IP * address to bind to. Comparable to * "new java.net.ServerSocket(port,backlog,bindAddress);" * * @param port the port * @param backlog backlog * @param bindAddress local address to use * @return the newly created server socket. * @throws IOException problem creating socket. */ public ServerSocket createServerSocket(int port, int backlog, InetAddress bindAddress) throws IOException { ServerSocket sock = new ServerSocket(port, backlog, bindAddress); // XXX apparently traffic class cannot be set on ServerSocket //setTrafficClass(sock); return sock; } /** * Creates a stream socket and connects it to the specified port number at * the specified IP address. * * @param address the address to connect. * @param port the port to connect. * @return the socket * @throws IOException problem creating socket. */ public Socket createSocket(InetAddress address, int port) throws IOException { Socket sock = new Socket(address, port); setTrafficClass(sock); return sock; } /** * Constructs a datagram socket and binds it to any available port on the * local host machine. Comparable to "new java.net.DatagramSocket();" * * @return the datagram socket * @throws SocketException problem creating socket. */ public DatagramSocket createDatagramSocket() throws SocketException { DatagramSocket sock = new DatagramSocket(); setTrafficClass(sock); return sock; } /** * Creates a datagram socket, bound to the specified local address. * Comparable to "new java.net.DatagramSocket(port,laddr);" * * @param port local port to use * @param laddr local address to bind * @return the datagram socket * @throws SocketException problem creating socket. */ public DatagramSocket createDatagramSocket(int port, InetAddress laddr) throws SocketException { DatagramSocket sock = new DatagramSocket(port, laddr); setTrafficClass(sock); return sock; } /** * Creates an SSL server with the specified port, listen backlog, and local * IP address to bind to. * * @param port the port to listen to * @param backlog backlog * @param bindAddress the address to listen to * @return the server socket. * @throws IOException problem creating socket. */ public SSLServerSocket createSSLServerSocket(int port, int backlog, InetAddress bindAddress) throws IOException { SSLServerSocket sock = (SSLServerSocket) getSSLServerSocketFactory() .createServerSocket(port, backlog, bindAddress); // XXX apparently traffic class cannot be set on ServerSocket // setTrafficClass(sock); return sock; } /** * Creates a ssl server socket factory. * * @return the server socket factory. * @throws IOException problem creating factory. */ protected SSLServerSocketFactory getSSLServerSocketFactory() throws IOException { try { return certificateVerification.getSSLContext() .getServerSocketFactory(); } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } } /** * Creates ssl socket factory. * * @return the socket factory. * @throws IOException problem creating ssl socket factory. */ private SSLSocketFactory getSSLSocketFactory(InetAddress address) throws IOException { ProtocolProviderServiceSipImpl provider = null; for (ProtocolProviderServiceSipImpl pps : ProtocolProviderServiceSipImpl .getAllInstances()) { if (pps.getConnection() != null && pps.getConnection().isSameInetAddress(address)) { provider = pps; break; } } if (provider == null) throw new IOException( "The provider that requested " + "the SSL Socket could not be found"); try { ArrayList<String> identities = new ArrayList<String>(2); SipAccountID id = (SipAccountID) provider.getAccountID(); // if the proxy is configured manually, the entered name is valid // for the X.509 certificate if(!id.getAccountPropertyBoolean( ProtocolProviderFactory.PROXY_AUTO_CONFIG, false)) { String proxy = id.getAccountPropertyString( ProtocolProviderFactory.PROXY_ADDRESS); if(proxy != null) identities.add(proxy); if (logger.isDebugEnabled()) logger.debug("Added <" + proxy + "> to list of valid SIP TLS server identities."); } // the domain part of the user id is always valid String userID = id.getAccountPropertyString(ProtocolProviderFactory.USER_ID); int index = userID.indexOf('@'); if (index > -1) { identities.add(userID.substring(index + 1)); if (logger.isDebugEnabled()) logger.debug("Added <" + userID.substring(index + 1) + "> to list of valid SIP TLS server identities."); } return certificateVerification.getSSLContext( (String)id.getAccountProperty( ProtocolProviderFactory.CLIENT_TLS_CERTIFICATE), certificateVerification.getTrustManager( identities, null, new RFC5922Matcher(provider) )).getSocketFactory(); } catch (GeneralSecurityException e) { throw new IOException(e.getMessage()); } } /** * Creates a stream SSL socket and connects it to the specified port number * at the specified IP address. * * @param address the address we are connecting to. * @param port the port we use. * @return the socket. * @throws IOException problem creating socket. */ public SSLSocket createSSLSocket(InetAddress address, int port) throws IOException { SSLSocket sock = (SSLSocket) getSSLSocketFactory(address).createSocket( address, port); setTrafficClass(sock); return sock; } /** * Creates a stream SSL socket and connects it to the specified port number * at the specified IP address. * * @param address the address we are connecting to. * @param port the port we use. * @param myAddress the local address to use * @return the socket. * @throws IOException problem creating socket. */ public SSLSocket createSSLSocket(InetAddress address, int port, InetAddress myAddress) throws IOException { SSLSocket sock = (SSLSocket) getSSLSocketFactory(address).createSocket( address, port, myAddress, 0); setTrafficClass(sock); return sock; } /** * Creates a stream socket and connects it to the specified port number at * the specified IP address. Comparable to * "new java.net.Socket(address, port,localaddress);" * * @param address the address to connect to. * @param port the port we use. * @param myAddress the local address to use. * @return the created socket. * @throws IOException problem creating socket. */ public Socket createSocket(InetAddress address, int port, InetAddress myAddress) throws IOException { Socket sock = null; if (myAddress != null) sock = new Socket(address, port, myAddress, 0); else sock = new Socket(address, port); setTrafficClass(sock); return sock; } /** * Creates a new Socket, binds it to myAddress:myPort and connects it to * address:port. * * @param address the InetAddress that we'd like to connect to. * @param port the port that we'd like to connect to * @param myAddress the address that we are supposed to bind on or null for * the "any" address. * @param myPort the port that we are supposed to bind on or 0 for a random * one. * * @return a new Socket, bound on myAddress:myPort and connected to * address:port. * @throws IOException if binding or connecting the socket fail for a reason * (exception relayed from the corresponding Socket methods) */ public Socket createSocket(InetAddress address, int port, InetAddress myAddress, int myPort) throws IOException { Socket sock = null; if (myAddress != null) { sock = new Socket(address, port, myAddress, myPort); } else if (port != 0) { // myAddress is null (i.e. any) but we have a port number sock = new Socket(); sock.bind(new InetSocketAddress(port)); sock.connect(new InetSocketAddress(address, port)); } else { sock = new Socket(address, port); } setTrafficClass(sock); return sock; } /** * Sets the traffic class for the <tt>Socket</tt>. * * @param s <tt>Socket</tt> */ protected void setTrafficClass(Socket s) { int tc = getDSCP(); try { s.setTrafficClass(tc); } catch (SocketException e) { logger.warn("Failed to set traffic class on Socket", e); } } /** * Sets the traffic class for the <tt>DatagramSocket</tt>. * * @param s <tt>DatagramSocket</tt> */ protected void setTrafficClass(DatagramSocket s) { int tc = getDSCP(); try { s.setTrafficClass(tc); } catch (SocketException e) { logger.warn("Failed to set traffic class on DatagramSocket", e); } } /** * Get the SIP traffic class from configuration. * * @return SIP traffic class or 0 if not configured */ private int getDSCP() { ConfigurationService configService = SipActivator.getConfigurationService(); String dscp = (String)configService.getProperty(SIP_DSCP_PROPERTY); if(dscp != null) { return Integer.parseInt(dscp) << 2; } return 0; } }
[ "alexei.fedotov@917aa43a-1baf-11df-844d-27937797d2d2" ]
alexei.fedotov@917aa43a-1baf-11df-844d-27937797d2d2
4f2a2f6a11f6a3a278ca8e45cb9b11689f67b311
912f6133d64dff0d4bf40f9bdf20693cbd579a5f
/src/main/java/com/example/tugaspppl/service/KamarService.java
351b1ba744033ab97d456f92618e3e5384becb48
[]
no_license
nandiarani/springbootSigah
48fa2be0621629e7baaed9075097ef9b96e98997
884ee05fbc721b8e2f6cdc05907376a3ab3d8cb7
refs/heads/master
2020-03-14T15:47:04.114192
2018-05-01T07:39:19
2018-05-01T07:39:19
131,684,049
0
0
null
null
null
null
UTF-8
Java
false
false
588
java
package com.example.tugaspppl.service; import com.example.tugaspppl.dao.kamar.KamarDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.ui.Model; import javax.transaction.Transactional; @Service @Transactional public class KamarService { @Autowired private KamarDao kamarDao; public Model getAllKamar(Model model){ model.addAttribute("kamar",kamarDao.findAll()); return model; } public void softDeleteKamar(int id){ kamarDao.softDelete(id); } }
[ "nandiiaranii@gmail.com" ]
nandiiaranii@gmail.com
60eab0d5c728824dd5ddadaefce8c76e8df01d1b
12fc0f1b83cb72116d7f7ecc1a0228368c611522
/Code/Kwetter/src/main/java/Models/Tweet.java
d194c20b252bf0ec1acde5ee1a4ad70e7220e0a3
[]
no_license
Yale96/KwetterJEA
5a788af03f6cd6417b0d1891a1235e8e6660ff81
e0b11d46e48f6ece631c5e6cee8674e732fd25c7
refs/heads/master
2021-03-30T22:00:25.803027
2018-06-05T09:33:25
2018-06-05T09:33:25
124,783,456
0
0
null
null
null
null
UTF-8
Java
false
false
6,485
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 Models; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.persistence.Column; import javax.persistence.ElementCollection; 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.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Temporal; import javax.persistence.TemporalType; /** * * @author Yannick van Leeuwen */ @Entity @NamedQueries({ @NamedQuery(name = "Tweet.findById", query = "SELECT t FROM Tweet t WHERE t.id = :id"), @NamedQuery(name = "Tweet.count", query = "SELECT COUNT(t) FROM Tweet t")}) public class Tweet implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column(nullable = false) private String content; @Column(nullable = false) @Temporal(TemporalType.TIMESTAMP) private Date timeStamp; @ManyToMany @JoinTable(name = "tweet_hashtag" , joinColumns = @JoinColumn(name = "tweet_hashtag_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "hashtag_hashtag_id", referencedColumnName = "id")) private List<HashTag> hashtags; @ManyToOne(optional = false, fetch = FetchType.LAZY) @JoinColumn(name = "owner_id", referencedColumnName = "id") private User owner; @ManyToMany @JoinTable(name = "tweet_tweeter_mentions" , joinColumns = @JoinColumn(name = "tweet_mention_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "user_mention_id", referencedColumnName = "id")) private List<User> mentionedUsers; @ManyToMany @JoinTable(name = "tweet_user_likes" , joinColumns = @JoinColumn(name = "tweet_like_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "user_like_id", referencedColumnName = "id")) private List<User> likes; @ManyToMany @JoinTable(name = "tweet_user_flags" , joinColumns = @JoinColumn(name = "tweet_flag_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "user_flag_id", referencedColumnName = "id")) private List<User> flags; private String uri; public Tweet() { hashtags = new ArrayList<HashTag>(); mentionedUsers = new ArrayList<User>(); likes = new ArrayList<User>(); flags = new ArrayList<User>(); } public Tweet(String content, Date timeStamp) { this.content = content; this.timeStamp = timeStamp; } public User getOwner() { return owner; } public void setOwnerForStartup(User owner) { this.owner = owner; } public void setOwner(User owner) { this.owner = owner; if(!owner.getTweets().contains(this)) { owner.addTweet(this); } } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public Date getTimeStamp() { return timeStamp; } public void setTimeStamp(Date timeStamp) { this.timeStamp = timeStamp; } public List<HashTag> getHashtags() { return hashtags; } public void setHashtags(ArrayList<HashTag> hashtags) { this.hashtags = hashtags; } public List<User> getMentionedUsers() { return mentionedUsers; } public void setMentionedUsers(ArrayList<User> mentionedUsers) { this.mentionedUsers = mentionedUsers; } public List<User> getLikes() { return likes; } public List<User> getFlags() { return flags; } public void setFlags(List<User> flags) { this.flags = flags; } public void setLikes(ArrayList<User> likes) { this.likes = likes; } public String getUri() { return uri; } public void setUri(String uri) { this.uri = uri; } public void addHashTag(HashTag hashTag){ if(hashTag != null && hashtags != null && !hashtags.contains(hashTag)) { hashtags.add(hashTag); if(!hashTag.getTweets().contains(this)) hashTag.addTweet(this); } } public void addMention(User mention){ if(mention != null && mentionedUsers != null && !mentionedUsers.contains(mention)) { mentionedUsers.add(mention); if(!mention.getMentions().contains(this)) mention.addMention(this); } } public void addLike(User like){ if(like != null && likes != null && !likes.contains(like)) { likes.add(like); if(!like.getTweets().contains(this)) like.addLike(this); } } public void removeLike(User like){ User user = likes.stream().filter(k -> k.getId() == like.getId()).findAny().orElse(null); if (like != null && likes != null && likes.contains(user)) { likes.remove(user); if (user.getTweets().contains(this)) user.removeLike(this); } } public void addFlag(User flag){ if(flag != null && flags != null && !flags.contains(flag)) { flags.add(flag); if(!flag.getTweets().contains(this)) flag.addFlag(this); } } public void removeFlag(User flag){ User user = flags.stream().filter(k -> k.getId() == flag.getId()).findAny().orElse(null); if (flag != null && flags != null && flags.contains(user)) { flags.remove(user); if (user.getTweets().contains(this)) user.removeFlag(this); } } }
[ "yannickvanleeuwen@i-lion.nl" ]
yannickvanleeuwen@i-lion.nl
3e7a4db6f73f5f7f74037c0a73c34e37eaedfe9d
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/14/14_9d1e45ba5e0d9aa9e85f82d056390efd8a532c12/Dialog/14_9d1e45ba5e0d9aa9e85f82d056390efd8a532c12_Dialog_t.java
891f4ff4c09efb72ac7ee32f5978fde072c0db9e
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
26,482
java
package org.eclipse.jface.dialogs; /* * (c) Copyright IBM Corp. 2000, 2001. * All Rights Reserved. */ import java.util.HashMap; import org.eclipse.jface.resource.*; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; /** * A dialog is a specialized window used for narrow-focused communication * with the user. * <p> * Dialogs are usually modal. Consequently, it is generally bad practice * to open a dialog without a parent. A model dialog without a parent * is not prevented from disappearing behind the application's other windows, * making it very confusing for the user. * </p> */ public abstract class Dialog extends Window { /** * Image registry key for error image (value <code>"dialog_error_image"</code>). */ public static final String DLG_IMG_ERROR = "dialog_error_image"; //$NON-NLS-1$ /** * Image registry key for info image (value <code>"dialog_info_image"</code>). */ public static final String DLG_IMG_INFO = "dialog_info_image"; //$NON-NLS-1$ /** * Image registry key for question image (value <code>"dialog_question_image"</code>). */ public static final String DLG_IMG_QUESTION = "dialog_question_image"; //$NON-NLS-1$ /** * Image registry key for warning image (value <code>"dialog_warning_image"</code>). */ public static final String DLG_IMG_WARNING = "dialog_warning_image"; //$NON-NLS-1$ /** * Image registry key for info message image (value <code>"dialog_messsage_info_image"</code>). * @since 2.0 */ public static final String DLG_IMG_MESSAGE_INFO = "dialog_messasge_info_image"; //$NON-NLS-1$ /** * Image registry key for info message image (value <code>"dialog_messasge_warning_image"</code>). * @since 2.0 */ public static final String DLG_IMG_MESSAGE_WARNING = "dialog_messasge_warning_image"; //$NON-NLS-1$ /** * Image registry key for info message image (value <code>"dialog_message_error_image"</code>). * @since 2.0 */ public static final String DLG_IMG_MESSAGE_ERROR = "dialog_message_error_image"; //$NON-NLS-1$ static { ImageRegistry reg = JFaceResources.getImageRegistry(); reg.put(DLG_IMG_INFO, ImageDescriptor.createFromFile(Dialog.class, "images/inform.gif")); //$NON-NLS-1$ reg.put(DLG_IMG_QUESTION, ImageDescriptor.createFromFile(Dialog.class, "images/question.gif")); //$NON-NLS-1$ reg.put(DLG_IMG_WARNING, ImageDescriptor.createFromFile(Dialog.class, "images/warning.gif")); //$NON-NLS-1$ reg.put(DLG_IMG_ERROR, ImageDescriptor.createFromFile(Dialog.class, "images/error.gif")); //$NON-NLS-1$ reg.put(DLG_IMG_MESSAGE_INFO, ImageDescriptor.createFromFile(Dialog.class, "images/message_info.gif")); //$NON-NLS-1$ reg.put(DLG_IMG_MESSAGE_WARNING, ImageDescriptor.createFromFile(Dialog.class, "images/message_warning.gif")); //$NON-NLS-1$ reg.put(DLG_IMG_MESSAGE_ERROR, ImageDescriptor.createFromFile(Dialog.class, "images/message_error.gif")); //$NON-NLS-1$ } /** * The dialog area; <code>null</code> until dialog is layed out. */ protected Control dialogArea; /** * The button bar; <code>null</code> until dialog is layed out. */ protected Control buttonBar; /** * Collection of buttons created by the <code>createButton</code> method. */ private HashMap buttons = new HashMap(); /** * Font metrics to use for determining pixel sizes. */ private FontMetrics fontMetrics; /** * Number of horizontal dialog units per character, value <code>4</code>. */ private static final int HORIZONTAL_DIALOG_UNIT_PER_CHAR = 4; /** * Number of vertical dialog units per character, value <code>8</code>. */ private static final int VERTICAL_DIALOG_UNITS_PER_CHAR = 8; /** * Returns the number of pixels corresponding to the * height of the given number of characters. * <p> * The required <code>FontMetrics</code> parameter may be created in the * following way: * <code> * GC gc = new GC(control); * gc.setFont(control.getFont()); * fontMetrics = gc.getFontMetrics(); * gc.dispose(); * </code> * </p> * * @param fontMetrics used in performing the conversion * @param chars the number of characters * @return the number of pixels * @since 2.0 */ public static int convertHeightInCharsToPixels( FontMetrics fontMetrics, int chars) { return fontMetrics.getHeight() * chars; } /** * Returns the number of pixels corresponding to the * given number of horizontal dialog units. * <p> * The required <code>FontMetrics</code> parameter may be created in the * following way: * <code> * GC gc = new GC(control); * gc.setFont(control.getFont()); * fontMetrics = gc.getFontMetrics(); * gc.dispose(); * </code> * </p> * * @param fontMetrics used in performing the conversion * @param dlus the number of horizontal dialog units * @return the number of pixels * @since 2.0 */ public static int convertHorizontalDLUsToPixels( FontMetrics fontMetrics, int dlus) { // round to the nearest pixel return ( fontMetrics.getAverageCharWidth() * dlus + HORIZONTAL_DIALOG_UNIT_PER_CHAR / 2) / HORIZONTAL_DIALOG_UNIT_PER_CHAR; } /** * Returns the number of pixels corresponding to the * given number of vertical dialog units. * <p> * The required <code>FontMetrics</code> parameter may be created in the * following way: * <code> * GC gc = new GC(control); * gc.setFont(control.getFont()); * fontMetrics = gc.getFontMetrics(); * gc.dispose(); * </code> * </p> * * @param fontMetrics used in performing the conversion * @param dlus the number of vertical dialog units * @return the number of pixels * @since 2.0 */ public static int convertVerticalDLUsToPixels( FontMetrics fontMetrics, int dlus) { // round to the nearest pixel return ( fontMetrics.getHeight() * dlus + VERTICAL_DIALOG_UNITS_PER_CHAR / 2) / VERTICAL_DIALOG_UNITS_PER_CHAR; } /** * Returns the number of pixels corresponding to the * width of the given number of characters. * <p> * The required <code>FontMetrics</code> parameter may be created in the * following way: * <code> * GC gc = new GC(control); * gc.setFont(control.getFont()); * fontMetrics = gc.getFontMetrics(); * gc.dispose(); * </code> * </p> * * @param fontMetrics used in performing the conversion * @param chars the number of characters * @return the number of pixels * @since 2.0 */ public static int convertWidthInCharsToPixels( FontMetrics fontMetrics, int chars) { return fontMetrics.getAverageCharWidth() * chars; } /** * Creates a dialog instance. * Note that the window will have no visual representation (no widgets) * until it is told to open. * By default, <code>open</code> blocks for dialogs. * * @param parentShell the parent shell, or <code>null</code> to create a top-level shell */ protected Dialog(Shell parentShell) { super(parentShell); setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); setBlockOnOpen(true); } /** * Notifies that this dialog's button with the given id has been pressed. * <p> * The <code>Dialog</code> implementation of this framework method calls * <code>okPressed</code> if the ok button is the pressed, * and <code>cancelPressed</code> if the cancel button is the pressed. * All other button presses are ignored. Subclasses may override * to handle other buttons, but should call <code>super.buttonPressed</code> * if the default handling of the ok and cancel buttons is desired. * </p> * * @param buttonId the id of the button that was pressed (see * <code>IDialogConstants.*_ID</code> constants) */ protected void buttonPressed(int buttonId) { if (IDialogConstants.OK_ID == buttonId) okPressed(); else if (IDialogConstants.CANCEL_ID == buttonId) cancelPressed(); } /** * Notifies that the cancel button of this dialog has been pressed. * <p> * The <code>Dialog</code> implementation of this framework method sets * this dialog's return code to <code>Window.CANCEL</code> * and closes the dialog. Subclasses may override if desired. * </p> */ protected void cancelPressed() { setReturnCode(CANCEL); close(); } /** * Constrain the shell size to be no larger than the display bounds. * Reduce the shell size and move its origin as required. * * @since 2.0 */ protected void constrainShellSize() { // limit the shell size to the display size super.constrainShellSize(); Shell shell = getShell(); Point size = shell.getSize(); Rectangle bounds = shell.getDisplay().getClientArea(); // move the shell origin as required Point loc = shell.getLocation(); //Choose the position between the origin of the client area and //the bottom right hand corner int x = Math.max( bounds.x, Math.min(loc.x, bounds.x + bounds.width - size.x)); int y = Math.max( bounds.y, Math.min(loc.y, bounds.y + bounds.height - size.y)); shell.setLocation(x, y); } /** * Returns the number of pixels corresponding to the * height of the given number of characters. * <p> * This method may only be called after <code>initializeDialogUnits</code> * has been called. * </p> * <p> * Clients may call this framework method, but should not override it. * </p> * * @param chars the number of characters * @return the number of pixels */ protected int convertHeightInCharsToPixels(int chars) { // test for failure to initialize for backward compatibility if (fontMetrics == null) return 0; return convertHeightInCharsToPixels(fontMetrics, chars); } /** * Returns the number of pixels corresponding to the * given number of horizontal dialog units. * <p> * This method may only be called after <code>initializeDialogUnits</code> * has been called. * </p> * <p> * Clients may call this framework method, but should not override it. * </p> * * @param dlus the number of horizontal dialog units * @return the number of pixels */ protected int convertHorizontalDLUsToPixels(int dlus) { // test for failure to initialize for backward compatibility if (fontMetrics == null) return 0; return convertHorizontalDLUsToPixels(fontMetrics, dlus); } /** * Returns the number of pixels corresponding to the * given number of vertical dialog units. * <p> * This method may only be called after <code>initializeDialogUnits</code> * has been called. * </p> * <p> * Clients may call this framework method, but should not override it. * </p> * * @param dlus the number of vertical dialog units * @return the number of pixels */ protected int convertVerticalDLUsToPixels(int dlus) { // test for failure to initialize for backward compatibility if (fontMetrics == null) return 0; return convertVerticalDLUsToPixels(fontMetrics, dlus); } /** * Returns the number of pixels corresponding to the * width of the given number of characters. * <p> * This method may only be called after <code>initializeDialogUnits</code> * has been called. * </p> * <p> * Clients may call this framework method, but should not override it. * </p> * * @param chars the number of characters * @return the number of pixels */ protected int convertWidthInCharsToPixels(int chars) { // test for failure to initialize for backward compatibility if (fontMetrics == null) return 0; return convertWidthInCharsToPixels(fontMetrics, chars); } /** * Creates a new button with the given id. * <p> * The <code>Dialog</code> implementation of this framework method * creates a standard push button, registers it for selection events * including button presses, and registers default buttons with its shell. * The button id is stored as the button's client data. If the button id * is <code>IDialogConstants.CANCEL_ID</code>, the new button will be * accessible from <code>getCancelButton()</code>. If the button id is * <code>IDialogConstants.OK_ID</code>, the new button will be accesible * from <code>getOKButton()</code>. Note that the parent's layout * is assumed to be a <code>GridLayout</code> and the number of columns in this * layout is incremented. Subclasses may override. * </p> * * @param parent the parent composite * @param id the id of the button (see * <code>IDialogConstants.*_ID</code> constants * for standard dialog button ids) * @param label the label from the button * @param defaultButton <code>true</code> if the button is to be the * default button, and <code>false</code> otherwise * * @return the new button * * @see getCancelButton * @see getOKButton */ protected Button createButton( Composite parent, int id, String label, boolean defaultButton) { // increment the number of columns in the button bar ((GridLayout) parent.getLayout()).numColumns++; Button button = new Button(parent, SWT.PUSH); button.setText(label); button.setData(new Integer(id)); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { buttonPressed(((Integer) event.widget.getData()).intValue()); } }); if (defaultButton) { Shell shell = parent.getShell(); if (shell != null) { shell.setDefaultButton(button); } } button.setFont(parent.getFont()); buttons.put(new Integer(id), button); setButtonLayoutData(button); return button; } /** * Creates and returns the contents of this dialog's * button bar. * <p> * The <code>Dialog</code> implementation of this framework method * lays out a button bar and calls the <code>createButtonsForButtonBar</code> * framework method to populate it. Subclasses may override. * </p> * <p> * The returned control's layout data must be an instance of * <code>GridData</code>. * </p> * * @param parent the parent composite to contain the button bar * @return the button bar control */ protected Control createButtonBar(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); // create a layout with spacing and margins appropriate for the font size. GridLayout layout = new GridLayout(); layout.numColumns = 0; // this is incremented by createButton layout.makeColumnsEqualWidth = true; layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); composite.setLayout(layout); GridData data = new GridData( GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER); composite.setLayoutData(data); composite.setFont(parent.getFont()); // Add the buttons to the button bar. createButtonsForButtonBar(composite); return composite; } /** * Adds buttons to this dialog's button bar. * <p> * The <code>Dialog</code> implementation of this framework method adds * standard ok and cancel buttons using the <code>createButton</code> * framework method. These standard buttons will be accessible from * <code>getCancelButton</code>, and <code>getOKButton</code>. * Subclasses may override. * </p> * * @param parent the button bar composite */ protected void createButtonsForButtonBar(Composite parent) { // create OK and Cancel buttons by default createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } /* * @see Window.configureShell() */ protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setFont(JFaceResources.getDialogFont()); } /* * @see Window.initializeBounds() */ protected void initializeBounds() { String platform = SWT.getPlatform(); if ("carbon".equals(platform)) { //$NON-NLS-1$ // On Mac OS X the default button must be the right-most button Shell shell = getShell(); if (shell != null) { Button defaultButton = shell.getDefaultButton(); if (defaultButton != null && isContained(buttonBar, defaultButton)) defaultButton.moveBelow(null); } } super.initializeBounds(); } /** * Returns true if the given Control c is a direct or indirect child of * container. */ private boolean isContained(Control container, Control c) { Composite parent; while ((parent = c.getParent()) != null) { if (parent == container) return true; c = parent; } return false; } /** * The <code>Dialog</code> implementation of this <code>Window</code> method * creates and lays out the top level composite for the dialog, and * determines the appropriate horizontal and vertical dialog units * based on the font size. It then calls the <code>createDialogArea</code> * and <code>createButtonBar</code> methods to create the dialog area * and button bar, respectively. Overriding <code>createDialogArea</code> and * <code>createButtonBar</code> are recommended rather than overriding * this method. */ protected Control createContents(Composite parent) { // create the top level composite for the dialog Composite composite = new Composite(parent, 0); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); // initialize the dialog units initializeDialogUnits(composite); // create the dialog area and button bar dialogArea = createDialogArea(composite); buttonBar = createButtonBar(composite); return composite; } /** * Creates and returns the contents of the upper part * of this dialog (above the button bar). * <p> * The <code>Dialog</code> implementation of this framework method * creates and returns a new <code>Composite</code> with * standard margins and spacing. * </p> * <p> * The returned control's layout data must be an instance of * <code>GridData</code>. * </p> * <p> * Subclasses must override this method but may call <code>super</code> * as in the following example: * </p> * <pre> * Composite composite = (Composite)super.createDialogArea(parent); * //add controls to composite as necessary * return composite; * </pre> * * @param parent the parent composite to contain the dialog area * @return the dialog area control */ protected Control createDialogArea(Composite parent) { // create a composite with standard margins and spacing Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); return composite; } /** * Returns the button created by the method <code>createButton</code> * for the specified ID as defined on <code>IDialogConstants</code>. If * <code>createButton</code> was never called with this ID, or * if <code>createButton</code> is overridden, this method will return * <code>null</code>. * * @return the button for the ID or <code>null</code> * * @see createButton * @since 2.0 */ protected Button getButton(int id) { return (Button) buttons.get(new Integer(id)); } /** * Returns the button bar control. * <p> * Clients may call this framework method, but should not override it. * </p> * * @return the button bar, or <code>null</code> if * the button bar has not been created yet */ protected Control getButtonBar() { return buttonBar; } /** * Returns the button created when <code>createButton</code> is called * with an ID of <code>IDialogConstants.CANCEL_ID</code>. If * <code>createButton</code> was never called with this parameter, or * if <code>createButton</code> is overridden, <code>getCancelButton</code> * will return <code>null</code>. * * @return the cancel button or <code>null</code> * * @see createButton * @since 2.0 * @deprecated Use <code>getButton(IDialogConstants.CANCEL_ID)</code> instead. * This method will be removed soon. */ protected Button getCancelButton() { return getButton(IDialogConstants.CANCEL_ID); } /** * Returns the dialog area control. * <p> * Clients may call this framework method, but should not override it. * </p> * * @return the dialog area, or <code>null</code> if * the dialog area has not been created yet */ protected Control getDialogArea() { return dialogArea; } /** * Returns the standard dialog image with the given key. * Note that these images are managed by the dialog framework, * and must not be disposed by another party. * * @param key one of the <code>Dialog.DLG_IMG_* </code> constants * @return the standard dialog image */ public static Image getImage(String key) { return JFaceResources.getImageRegistry().get(key); } /** * Returns the button created when <code>createButton</code> is called * with an ID of <code>IDialogConstants.OK_ID</code>. If <code>createButton</code> * was never called with this parameter, or if <code>createButton</code> is * overridden, <code>getOKButton</code> will return <code>null</code>. * * @return the OK button or <code>null</code> * * @see createButton * @since 2.0 * @deprecated Use <code>getButton(IDialogConstants.OK_ID)</code> instead. * This method will be removed soon. */ protected Button getOKButton() { return getButton(IDialogConstants.OK_ID); } /** * Initializes the computation of horizontal and vertical dialog units * based on the size of current font. * <p> * This method must be called before any of the dialog unit based * conversion methods are called. * </p> * * @param control a control from which to obtain the current font */ protected void initializeDialogUnits(Control control) { // Compute and store a font metric GC gc = new GC(control); gc.setFont(JFaceResources.getDialogFont()); fontMetrics = gc.getFontMetrics(); gc.dispose(); } /** * Notifies that the ok button of this dialog has been pressed. * <p> * The <code>Dialog</code> implementation of this framework method sets * this dialog's return code to <code>Window.OK</code> * and closes the dialog. Subclasses may override. * </p> */ protected void okPressed() { setReturnCode(OK); close(); } /** * Set the layout data of the button to a GridData with * appropriate heights and widths. * @param button */ protected void setButtonLayoutData(Button button) { GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.widthHint = Math.max( widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(data); } /** * Set the layout data of the button to a FormData with appropriate heights and * widths. * @param button */ protected void setButtonLayoutFormData(Button button) { FormData data = new FormData(); data.height = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); data.width = Math.max( widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); button.setLayoutData(data); } /** * @see org.eclipse.jface.window.Window#close() */ public boolean close() { boolean returnValue = super.close(); if (returnValue) { buttons = new HashMap(); buttonBar = null; dialogArea = null; } return returnValue; } /** * Applies the dialog font to all controls that currently have the default * font. * * @param control the control to apply the font to. Font will also be applied to * its children. */ public static void applyDialogFont(Control control) { Font dialogFont = JFaceResources.getDialogFont(); Font defaultFont = JFaceResources.getDefaultFont(); applyDialogFont(control, dialogFont, defaultFont); } /** * Sets the dialog font on the control and any of its children if thier * font is not otherwise set. * * @param control the control to apply the font to. Font will also be applied to * its children. * @param dialogFont the dialog font to set * @param defaultFont the default font to compare against */ private static void applyDialogFont( Control control, Font dialogFont, Font defaultFont) { if (control.getFont().equals(defaultFont)) control.setFont(dialogFont); if (control instanceof Composite) { Control[] children = ((Composite) control).getChildren(); for (int i = 0; i < children.length; i++) applyDialogFont(children[i], dialogFont, defaultFont); } } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com