blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
listlengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c84c5aaba44042844f52ceabe700260c248d78b0 | a905127e4fe3fe1f5ae09ad5063c12d952a3045c | /src/src/y86/Register.java | 7331f4be2c650b32495f85e421e4d2679d5e5230 | []
| no_license | novinsomnia/Y86_Pipeline_Simulator | 464c328a601eda80775a17a70569a020506521b3 | bb1d4a76415741ee05bbad1ff8095dcc902938d8 | refs/heads/master | 2021-01-01T05:07:38.726575 | 2016-05-21T15:12:36 | 2016-05-21T15:12:36 | 59,366,329 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 229 | java | package y86;
public class Register {
static int eax = 0;
static int ecx = 1;
static int edx = 2;
static int ebx = 3;
static int esp = 4;
static int ebp = 5;
static int esi = 6;
static int edi = 7;
static int non = 8;
}
| [
"[email protected]"
]
| |
af978c568923a86c32d641d52e7a236afe0cd0db | 2069fb152fc44bc773e6ca551975a3f2fca1b491 | /src/main/java/elte/algo/two/backend/graphs/domain/huffmann/HuffmannLeaf.java | db589f05459c08ffac8d1024305fb9fda9317922 | []
| no_license | gerzson98/graph-algorithm-helper-backend | 5024607282fb2d23225efde7949e8c837fc550ca | c86441b28e71808c5d87dfa2c0aa39fe4908608c | refs/heads/main | 2023-08-01T01:53:07.164989 | 2021-09-15T09:18:46 | 2021-09-15T09:18:46 | 406,692,454 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 346 | java | package elte.algo.two.backend.graphs.domain.huffmann;
import elte.algo.two.backend.graphs.domain.general.Leaf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@Data
@AllArgsConstructor
@RequiredArgsConstructor
public class HuffmannLeaf extends Leaf<Integer> {
private final Character codedValue;
}
| [
"[email protected]"
]
| |
50537c4bcba8fab1217ad746b09af1c0e1e095c7 | ae780b0a8a37394cca1d0aea0b2b844d2a09f03d | /SMEpayroll/src/main/java/com/payroll/smepayroll/exception/ErrorResponse.java | 4bf02db05af2f6b1702414859918fa308f4fe486 | []
| no_license | AmitPerennial/SMEPayroll | a3eeecd1caede965bcf8f9f40fc0574786dd5af3 | 0bfea64fa797b718ef86f25ee5a3b739dfcb2a82 | refs/heads/master | 2023-07-18T13:25:50.960015 | 2021-08-31T12:48:32 | 2021-08-31T12:48:32 | 401,611,847 | 0 | 0 | null | 2021-08-31T12:48:33 | 2021-08-31T07:26:30 | Java | UTF-8 | Java | false | false | 642 | java | package com.payroll.smepayroll.exception;
public class ErrorResponse {
private int statusCode;
private String message;
public ErrorResponse() {
}
public ErrorResponse(int statusCode, String message) {
this.statusCode = statusCode;
this.message = message;
}
public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
| [
"[email protected]"
]
| |
48726490d3329765a3a4289909c59ac970900e22 | 52d70ecd16e9043be3623c66b3b2ac486422fbd4 | /src/main/java/de/fearnixx/jeak/teamspeak/voice/sound/opus/OpusParameters.java | e603b42f0d2f4db091bc39db8907bccdd6bce56a | [
"MIT",
"LicenseRef-scancode-free-unknown"
]
| permissive | jeakfrw/jeak-framework | 01cbbda4b713b1ae48e37fb8fe6fcf3d00335079 | bede7f4f575d828e67fa54c4f65b338c70c73443 | refs/heads/bleeding-1.X.X | 2023-02-20T11:35:57.312649 | 2022-01-03T19:57:07 | 2022-01-03T19:57:07 | 188,801,672 | 8 | 5 | MIT | 2021-07-30T03:18:02 | 2019-05-27T08:19:58 | Java | UTF-8 | Java | false | false | 1,574 | java | package de.fearnixx.jeak.teamspeak.voice.sound.opus;
/**
* This class was extracted from an example by manevolent.
* <p>
* URL: https://github.com/Manevolent/ts3j/blob/9d602a8f98480c2c434fa1b7c6b9b0ae893f967f/examples/audio/src/main/java/com/github/manevolent/ts3j/examples/audio/OpusParameters.java
*/
public class OpusParameters {
private final int opusFrameRate;
private final int opusBitrate;
private final int opusComplexity;
private final int opusPacketLoss;
private final boolean opusVbr;
private final boolean opusFec;
private final boolean opusMusic;
public OpusParameters(int opusFrameRate, int opusBitrate,
int opusComplexity, int opusPacketLoss,
boolean opusVbr, boolean opusFec, boolean opusMusic) {
this.opusFrameRate = opusFrameRate;
this.opusBitrate = opusBitrate;
this.opusComplexity = opusComplexity;
this.opusPacketLoss = opusPacketLoss;
this.opusVbr = opusVbr;
this.opusFec = opusFec;
this.opusMusic = opusMusic;
}
public int getOpusFrameTime() {
return opusFrameRate;
}
public int getOpusBitrate() {
return opusBitrate;
}
public int getOpusComplexity() {
return opusComplexity;
}
public int getOpusPacketLoss() {
return opusPacketLoss;
}
public boolean isOpusVbr() {
return opusVbr;
}
public boolean isOpusFec() {
return opusFec;
}
public boolean isOpusMusic() {
return opusMusic;
}
} | [
"[email protected]"
]
| |
1d098c10d319abc1baf3a1be742aff8d99820955 | dd9d6b1f4fde8ed70deb8aaa0e02a479fd438c8c | /src/com/github/nikit/cpp/player/PlaybackActivity.java | f4a475b5bc639df9d06dc9f6f8b1f2533e2b2c06 | []
| no_license | nkonev/player | 6c2d6d1474e7bebc46d6b834d41fc4fb3cdf84c6 | a376b1f3198c23a162b3770f95ba54fca1986524 | refs/heads/master | 2021-06-01T00:19:17.035862 | 2015-07-19T01:30:32 | 2015-07-19T01:30:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,388 | java | package com.github.nikit.cpp.player;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.util.SparseArray;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* Created by nik on 11.02.15.
*/
public class PlaybackActivity extends FragmentActivity implements SeekReceiver.Receiver{
private ViewPager mViewPager;
private List<Song> mSongs = new ArrayList<>();
private Fragment buttonsFragment = null;
private int currentPosition;
private int duration;
private SeekReceiver resultReceiver = null;
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(Constants.LOG_TAG, "CrimePagerActivity.onCreate()");
super.onCreate(savedInstanceState);
FragmentManager fragmentManager = getSupportFragmentManager();
buttonsFragment = fragmentManager.findFragmentById(R.id.buttonsFragmentContainer);
if (null == buttonsFragment) {
buttonsFragment = new PlaybackButtonsFragment();
fragmentManager.beginTransaction().add(R.id.buttonsFragmentContainer, buttonsFragment).commit();
}
Intent start = getIntent();
buttonsFragment.getArguments().putSerializable(Constants.SONG_ID, start.getSerializableExtra(Constants.SONG_ID));
setContentView(R.layout.activity_playback);
mViewPager = (ViewPager) findViewById(R.id.pager00);
int playlistId = start.getIntExtra(Constants.PLAYLIST_ID, Constants.PLAY_LIST_NOT_EXIST);
if(playlistId != Constants.PLAY_LIST_NOT_EXIST) {
mSongs = PlayListManager.getPlaylists().get(playlistId).getSongs();
}
FragmentManager fm = getSupportFragmentManager();
final PlaybackPagerAdapter pagerAdapter = new PlaybackPagerAdapter(fm, mSongs);
mViewPager.setAdapter(pagerAdapter);
/**
* Метод onPageChangeListener используется для обнаружения изменений в странице,
которая в настоящий момент отображается экземпляром ViewPager. При изменении
страницы заголовку CrimePagerActivity задается краткое описание Crime.
*/
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener(){
@Override
public void onPageScrolled(int pos, float posOffset, int posOffsetPixels) {
}
@Override
public void onPageSelected(int pos) {
Song song = mSongs.get(pos);
if(song.getName() != null){
setTitle(song.getArtist() + " - " + song.getName());
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
// Переключаем ViewPager на текущую песню
UUID songId = (UUID) getIntent().getSerializableExtra(Constants.SONG_ID);
for(int i = 0; i < mSongs.size(); ++i){
if(mSongs.get(i).getId().equals(songId)){
mViewPager.setCurrentItem(i);
break;
}
}
}
@Override
protected void onPause() {
super.onPause();
resultReceiver.setReceiver(null);
}
@Override
protected void onResume() {
super.onResume();
resultReceiver = new SeekReceiver(new Handler());
resultReceiver.setReceiver(this);
}
@Override
public void onReceiveResult(int resultCode, Bundle data) {
switch (resultCode) {
case Constants.SONG_CURRENT_INFO_CODE:
setCurrentPosition(data.getInt(Constants.SONG_CURRENT_POSITION_KEY));
setDuration(data.getInt(Constants.SONG_DURATION_KEY));
break;
}
//Log.d(Tags.LOG_TAG, "received " + resultCode);
}
public void setCurrentPosition(int currentPosition) {
this.currentPosition = currentPosition;
}
public int getCurrentPosition() {
return currentPosition;
}
public void setDuration(int duration) {
this.duration = duration;
}
public int getDuration() {
return duration;
}
public SeekReceiver getReceiver() {
return resultReceiver;
}
public void updateSeek() {
if (null != resultReceiver) {
Intent intent = new Intent(this, PlayerService.class);
intent.putExtra(Constants.PLAYER_SERVICE_ACTION, PlayerService.Action.GET_CURRENT_INFO);
intent.putExtra(Constants.SEEK_RECEIVER, resultReceiver);
startService(intent);
//Log.d(Tags.LOG_TAG, "Seek update intent sent");
}
}
}
class PlaybackPagerAdapter extends FragmentStatePagerAdapter {
SparseArray<Fragment> registeredFragments = new SparseArray<Fragment>();
List<Song> songs;
public PlaybackPagerAdapter(FragmentManager fm, List<Song> songs) {
super(fm);
this.songs = songs;
}
@Override
public Fragment getItem(int i) {
Song song = songs.get(i);
/*Fragment gettedFragment = registeredFragments.get(i);
if(gettedFragment==null)
gettedFragment = PlaybackFragment.newInstance(song.getId());
return gettedFragment;*/
return PlaybackViewPagerFragment.newInstance(song.getId());
}
@Override
public int getCount() {
return songs.size();
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
Fragment fragment = (Fragment) super.instantiateItem(container, position);
registeredFragments.put(position, fragment);
return fragment;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
registeredFragments.remove(position);
super.destroyItem(container, position, object);
}
public Fragment getRegisteredFragment(int position) {
return registeredFragments.get(position);
}
}
| [
"[email protected]"
]
| |
587e381e15a5d26b300ee1f0c7be77e1f877e9a0 | a9b965af1e8cf1ce3c492bc5f37374e20dbb41cf | /src/main/java/com/example/app/repository/MessageRepository.java | b95c81c155cdb5e187f8410d2f19ded8e9631b67 | []
| no_license | MohamedElqdusy/data | 0985b79698ae02a78aca945ef259ddbdbd27416a | a5d4551e0371b02af3cc3e86ffd5190ae3e16e5b | refs/heads/master | 2020-03-21T08:27:51.225046 | 2018-06-23T13:52:39 | 2018-06-23T13:52:39 | 138,345,296 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 277 | java | package com.example.app.repository;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.example.app.model.Message;
public interface MessageRepository extends MongoRepository<Message,String> {
List<Message> findAll();
}
| [
"[email protected]"
]
| |
393f6e4355289bb1835d9a14fd02f492a7b7022a | 46281901519ec063c63736c188c9a0c718c2ec16 | /TextViewPager/src/co/paulburke/android/textviewpager/PagingLayoutListener.java | c3b8d5c78f91fa0d405db39063d2475e0f4d592d | [
"Apache-2.0"
]
| permissive | jiangzhonghui/Android-TextViewPager | dcaf0c48a315fa576b0a05e9e1d9bbdd1e488aa0 | 3b8af8090b441610f327a367ec0d7a1f32f68e54 | refs/heads/master | 2021-01-18T12:07:45.372404 | 2013-12-30T20:57:56 | 2013-12-30T20:57:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,905 | java | /*
* Copyright (C) 2013 Paul Burke
*
* 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 co.paulburke.android.textviewpager;
import android.text.Layout;
import android.util.Log;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.TextView;
/**
* An {@link OnGlobalLayoutListener} that determines how many "pages" the
* current text should be split into by calculating the maximum number of lines
* that the view can display without clipping.<br>
* <br>
* Set an {@link OnPageMeasureListener} to be notified of the character offsets
* calculated for each page.
*
* @author paulburke (ipaulpro)
*/
public class PagingLayoutListener implements OnGlobalLayoutListener {
private static final String TAG = "PagingLayoutListener";
private static final boolean DEBUG = true;
/**
* Listener used to notify of a completed layout measurement.
*/
public interface OnPageMeasureListener {
/**
* Called when the character offsets have been determined.
*
* @param offsets character offsets for the current text.
* @param totalLines total number of lines in the layout.
* @param linesPerPage number of lines that fit on this view without
* clipping.
*/
public void onPageMeasure(int[] offsets, int totalLines, int linesPerPage);
}
private TextView mView;
private OnPageMeasureListener mListener;
/**
* Creates a new PreDrawListener for the given view.
*
* @param view the view to intercept drawing.
* @param listener the {@link OnPageMeasureListener} to listen for offset
* calculations.
*/
public PagingLayoutListener(TextView view, OnPageMeasureListener listener) {
mView = view;
mListener = listener;
}
@Override
public void onGlobalLayout() {
final Layout layout = mView.getLayout();
if (layout != null) {
final int height = mView.getHeight() - mView.getPaddingTop()
- mView.getPaddingBottom();
final int lineCount = layout.getLineCount();
// Last visible line
int lastLine = layout.getLineForVertical(height);
// Bottom of the last visible line
int lastLineBottom = layout.getLineBottom(lastLine);
// Check if the layout is taller than the page
if (lineCount > 0 && lastLineBottom > height) {
// Determine the number of pages needed
int pagesCount = (int) Math.ceil(lineCount / (double) lastLine);
if (DEBUG) Log.d(TAG, "onPreDraw text is too tall! Should be "+pagesCount+" pages.");
// Determine offsets for each page
int[] offsets = new int[pagesCount];
for (int i = 0; i < pagesCount; i++) {
offsets[i] = layout.getLineStart(i * lastLine);
if (DEBUG) Log.d(TAG, "onPreDraw new page at " + i + ", starting char offset = " + offsets[i]);
}
// Clip the text in this view now
CharSequence text = layout.getText().subSequence(0, offsets[1]);
mView.setText(text);
if (mListener != null)
mListener.onPageMeasure(offsets, lineCount, lastLine);
}
}
}
}
| [
"[email protected]"
]
| |
72849925e1bbaf6174cd096a6f973ebb4169faaa | 5e004cc54085ec5470e534ec207f1147be2bca4e | /NutritionCalculator/src/main/java/ru/itis/services/BasketServiceImpl.java | e497bb90617e2771f5bee383f106be76e32d3cde | []
| no_license | edgar98/semestr_work_2018 | 13c7d875000211635746e7cc1539d196dbdeb916 | 7d2996458cb819389c986bbe50d5758676985afb | refs/heads/master | 2020-04-13T16:18:47.156356 | 2018-12-27T17:02:00 | 2018-12-27T17:02:00 | 163,317,821 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,185 | java | package ru.itis.services;
import ru.itis.models.Nutrition;
import ru.itis.models.Need;
import ru.itis.models.Account;
import ru.itis.repositories.BasketRepository;
import ru.itis.repositories.UsersRepositoryJdbcTemplateImpl;
import java.util.List;
public class BasketServiceImpl implements BasketService {
private BasketRepository basketRepository;
private UsersRepositoryJdbcTemplateImpl userRepository;
public BasketServiceImpl(BasketRepository basketRepository) {
this.basketRepository=basketRepository;
}
@Override
public List<Need> getProduct(Long basketId) {
return basketRepository.getProducts(basketId);
}
@Override
public Nutrition createBasket(Account user) {
return basketRepository.createCookieBasket(user);
}
@Override
public List<Need> addProductToUserBasket(Nutrition basket, Long productId) {
basketRepository.addProduct(productId, basket.getId());
return basketRepository.getProducts(basket.getId());
}
@Override
public Nutrition getBasket(Account user) {
return basketRepository.getBasket(user);
}
}
| [
"[email protected]"
]
| |
fb16bb9145a09285e225054d117c873ad9f955aa | 44e047ffbd2d1b45b4f7dc60a2b72e2f7a28ed05 | /PagingAlgorithms/vmsim.java | 80ce08655d579ba2427505be91aaec9880005649 | []
| no_license | adf37/OperatingSystems | 4af4e00678e53809571c921d6aef1e2bc7ee14af | 182518ea24c479582e444c72f3e8f382284b6183 | refs/heads/master | 2020-08-03T21:52:24.306259 | 2016-08-24T01:23:06 | 2016-08-24T01:23:06 | 66,415,935 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 23,826 | java |
import java.io.*;
import java.util.*;
public class vmsim {
public static Queue requestQueue = new LinkedList();
public static Queue diskQueue = new LinkedList();
public static HashMap<String, ArrayList<Integer>> optMap = new HashMap<String, ArrayList<Integer>>();
public static long startTime = System.currentTimeMillis();
public static int ageWrites = 0;
public static Hashtable ageDisk = new Hashtable();
public static int numframes;
public static void main(String[] args) throws IOException {
if (!(args.length >= 3)) {
System.err.print("Too few arguments entered on command line\nArguments required: <numframes>"
+ "<opt|clock|aging|work> [<refresh>] [<tau>] <tracefile>");
System.exit(-1);
}
numframes = Integer.parseInt(args[0]);
String algorithm = args[1];
String file = "";
long refresh = 0, tau = 0;
if (algorithm.equals("aging") || algorithm.equals("work")) {
refresh = Integer.parseInt(args[2]);
if (algorithm.equals("work")) {
tau = Integer.parseInt(args[3]);
file = args[4];
} else {
file = args[3];
}
} else {
file = args[2];
}
Scanner infile = new Scanner(new File(file));
while (infile.hasNext()) {
String address = infile.next(); //hexadecimal address read in
String mode = infile.next(); //R or W bit
int bit = 0;
if (mode.equals("W")) {
bit = 1;
}
pageRequest temp = new pageRequest(address, mode, bit); //create new page request
requestQueue.add(temp); //add to queue
}
if (algorithm.equals("opt")) {
findOccurance(requestQueue);
optimal(numframes);
} else if (algorithm.equals("clock")) {
clock(numframes);
} else if (algorithm.equals("aging")) {
aging(numframes, refresh);
} else {
workingSet(numframes, refresh, tau);
}
}
public static void printResults(String alg, int nf, int ma, int pf, int w2d) {
System.out.println(alg + "\nNumber of frames:\t" + nf + "\nTotal memory accesses:\t" + ma + "\nTotal page faults:\t"
+ pf + "\nTotal Writes to disk:\t" + w2d);
}
/*-------------------------------------------------------------------------------
* Uses the optimal algorithm method to determine the proper paging to do based on knowing the future
* Goes through a queue of all of the page requests and first checks to see if the current request is neither in the page frame already
* and space is available. If space is not available must kick out page that is not used for the longest amount of time.
* Takes in the total number of frames as a parameter
* Returns nothing
* Makes a call to the printResults method after completion
----------------------------------------------------------------------------------------*/
public static void optimal(int numFrames) {
int faults = 0, count = 0, writes = 0;
Set<String> pF = new HashSet<String>();
HashSet<String> disk = new HashSet<String>();
while (requestQueue.size() > 0) { //while there are still requests
boolean open = false;
while (pF.size() < numFrames) { //make sure our page frame isn't full
pageRequest temp = (pageRequest) requestQueue.poll(); //get head of the queue
if (temp != null && !pF.contains(temp.va)) { //not in page frame then add it
pF.add(temp.va);
count++; //position counter
optMap.get(temp.va).remove(0); //remove next place(current spot) it occurs in the file
open = true;
} else {
optMap.get(temp.va).remove(0); //remove next place(current spot) it occurs in the file
count++;
}
}
if (open == false) { //nothing was open
String toBeRemoved = ""; //index to be removed
int maxdist = 0;
pageRequest temp = (pageRequest) requestQueue.poll(); //get head of the queue
if (pF.contains(temp.va)) { //if already in page frame
count++; //increment position
optMap.get(temp.va).remove(0); //remove occurance
continue;
}
for (String x : pF) { //go thru each frame to see which isn't used longest
int distance = 1;
ArrayList<Integer> l = new ArrayList<Integer>();
String current = x;
l.addAll(optMap.get(current)); //arraylist of all positions of address in file
if (l.isEmpty()) { //no further requests, get rid of it
toBeRemoved = x;
break;
}
distance = l.get(0) - count; //get distance from current request to next occurance
if (distance >= maxdist) { //currently furthest away
maxdist = distance;
toBeRemoved = x; //set to be removed
}
}
if (temp != null) {
faults++; //had a page fault
if (temp.bit == 1) { //dirty page
if (!disk.contains(temp.va)) {
disk.add(temp.va);
writes++;
}
//writeDisk(temp);
}
pF.remove(toBeRemoved); //remove from page frame
pF.add(temp.va); //add new address
count++;
optMap.get(temp.va).remove(0);
}
}
}
printResults("opt", numFrames, 1000000, faults, writes);
}
/*---------------------------------------------------------------------------------
* Finds each addresses occurances in the queue and records their position in a hashmap
* Used in association with the optimal algorithm
* Takes in the request queue of all 1000000 page requests and cycles through once
* Returns nothing just adds to global hashmap
------------------------------------------------------------------------------------*/
public static void findOccurance(Queue request) {
//HashMap<String, Set<Integer>> map = new HashMap<String, Set<Integer>>();
Queue temp = new LinkedList();
temp.addAll(request); //add all elements of requestQueue to temporary queue
int index = 0;
while (temp.size() > 0) {
pageRequest p = (pageRequest) temp.poll(); //get head of queue
if (optMap.containsKey(p.va)) { //if we already have seen this request
ArrayList<Integer> s = optMap.get(p.va); //get its list of positions in file
s.add(index); //add to list
optMap.put(p.va, s); //add back to map
} else { //unique address
ArrayList<Integer> s = new ArrayList<Integer>();
s.add(index); //add first occurance
optMap.put(p.va, s); //add to map
}
index++;
}
}
/*-----------------------------------------------------------------------------------
* Implements the clock page replacement algorithm
* Pointer points to most recently visited page in the set and checks if page is referenced or not
* If referenced reset bit and give it a "second chance", if not swap page out for new request
* Cycle through page frame until end of requests
------------------------------------------------------------------------------------*/
public static void clock(int numFrames) {
Hashtable disk = new Hashtable();
int faults = 0, writes = 0, count = 0;
pageRequest current;
Hashtable table = new Hashtable(numFrames);
Queue circQueue = new LinkedList(); //size of numFrames
Queue tempQueue = new LinkedList();
while (count < numFrames) { //while there are still empty spots just add to our queue of requests
current = (pageRequest) requestQueue.poll();
if (!table.containsKey(current.va)) {
table.put(current.va, current.bit);
count++;
}
}
pageRequest request = (pageRequest) requestQueue.poll();
circQueue.addAll(table.keySet());
while (!requestQueue.isEmpty()) {
boolean victim = false;
tempQueue.addAll(circQueue);
if (table.containsKey(request.va)) { //request is already in page frame
table.put(request.va, 1); //referenced again so change bit
//victim = true;
if (requestQueue.isEmpty()) {
break;
}
request = (pageRequest) requestQueue.poll();
}
for (int i = 0; i < numFrames; i++) {
String pointer = (String) tempQueue.poll();
Iterator<Map.Entry<String, Integer>> iter = table.entrySet().iterator();
Map.Entry<String, Integer> entry = iter.next();
String curr = entry.getKey();
int bit = entry.getValue();
int ref = (int) table.get(pointer);
if (!table.containsKey(request.va) && ref == 0) {
table.put(request.va, request.bit); //add in request
table.remove(pointer); //remove current pointer
circQueue.remove(pointer);
circQueue.add(request.va);
faults++;
if (requestQueue.isEmpty()) {
break;
}
request = (pageRequest) requestQueue.poll();
//break;
//victim = true; //found our page to evict
} else if (ref == 1) { //cost of surviving
if (!disk.containsKey(pointer)) {
writes++;
disk.put(pointer, ref);
}
table.put(pointer, 0);
}
}
//}
}
printResults("clock", numFrames, 1000000, faults, writes);
long endTime = System.currentTimeMillis();
System.out.println("Reading in file took: " + (endTime - startTime) / 1000.00 + " seconds");
}
/*-----------------------------------------------------------------------------------
* Writes the given page to the disk because its reference bit is dirty
* Takes in the pageRequest as a parameter
* Returns nothing
------------------------------------------------------------------------------------*/
public static void writeDisk(pageRequest page) {
diskQueue.add(page);
}
/*-------------------------------------------------------------------------------------
* Implements the aging page replacement scheme
* 1. add in new page
* 2. shift everything right 1 bit
* 3. On every timer interrupt(refresh) the OS looks at each page
* 4. Shft everything right 1 bit, if reference bit is set: set most-sig bit, then clear bit
*/
public static void aging(int numframes, long refresh) {
int faults = 0, writes = 0;
pageRequest request;
Hashtable requestTable = new Hashtable(numframes);
Hashtable agingTable = new Hashtable(numframes);
while (requestTable.size() < numframes) {
request = (pageRequest) requestQueue.poll(); //get first request
if (!requestTable.containsKey(request.va)) { //if hashtable doesn't contain request add
requestTable.put(request.va, request.bit); //VA | reference bit
agingTable.put(request.va, request.bit * (int) Math.pow(2, numframes)); //VA | reference counter intialized based on reference bit of reqeust
//agingQueue.add(request.va);
}
}
request = (pageRequest) requestQueue.poll();
long start = System.currentTimeMillis();
while (requestQueue.size() != 0) {
//tempQueue.addAll(agingQueue);
if (agingTable.containsKey(request.va)) {
requestTable.put(request.va, 1);
int counter = (int) agingTable.get(request.va);
counter = ((int) Math.pow(2, numframes));
agingTable.put(request.va, counter);
if (requestQueue.size() == 0) {
break;
}
request = (pageRequest) requestQueue.poll();
}
for (int i = 0; i < numframes; i++) { //iterate over to put in new age values
Iterator<Map.Entry<String, Integer>> iter = agingTable.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, Integer> e = iter.next();
String pointer = e.getKey();
int c = e.getValue();
c = c / 2;
agingTable.put(pointer, c);
}
long current = (System.currentTimeMillis()) - start;
if (current >= refresh) {
ageProcess(agingTable, requestTable);
//update queue of times
start = System.currentTimeMillis();
}
//String pointer = (String) tempQueue.poll();
//int ref = (int) requestTable.get(pointer);
if (!requestTable.containsKey(request.va)) { //have to check reference counter values
String removeKey = getMinAge(agingTable, requestTable);
requestTable.put(request.va, request.bit); //add in request
requestTable.remove(removeKey); //remove current pointer
agingTable.remove(removeKey);
agingTable.put(request.va, (int) Math.pow(2, numframes));
//agingQueue.remove(removeKey);
//agingQueue.add(request.va);
faults++;
if (requestQueue.size() == 0) {
break;
}
request = (pageRequest) requestQueue.poll();
//break;
//victim = true; //found our page to evict
} else if (requestTable.containsKey(request.va)) {
requestTable.put(request.va, 1); //page was referenced update reference bit
if (requestQueue.size() == 0) {
break;
}
request = (pageRequest) requestQueue.poll();
}
}
}
printResults("aging", numframes, 1000000, faults, ageWrites);
long endTime = System.currentTimeMillis() - startTime;
System.out.println("Aging took: " + endTime / 1000.00 + " seconds");
}
/*-------------------------------------------------------------------
* Ages the page queue for aging algorithm
* 1. shifts everything right 1 bit
* 2. if reference bit is set then sets most sig bit then clears reference bit
*/
public static void ageProcess(Hashtable agingTable, Hashtable requestTable) {
Iterator<Map.Entry<String, Integer>> iter = agingTable.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, Integer> e = iter.next();
String pointer = e.getKey();
int c = e.getValue();
c = c / 2; //shift bit right
agingTable.put(pointer, c); //update table
if (requestTable.get(pointer) == 1) { //most sig bit is set
int count = (int) Math.pow(2, numframes);
agingTable.put(pointer, (count + ((int) agingTable.get(pointer) / 2)));
if (!ageDisk.containsKey(pointer)) {
ageWrites++;
ageDisk.put(pointer, 0);
}
}
requestTable.put(pointer, 0); //clear reference bit
}
}
/*-----------------------------------------------------------------------------
* Searches through table of all the current pages and finds the page with minimum age that isn't referenced
*/
public static String getMinAge(Hashtable agingTable, Hashtable requestTable) {
String minKey = "";
int minAge = 0;
Iterator<Map.Entry<String, Integer>> iter = agingTable.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, Integer> entry = iter.next();
String pointer = entry.getKey();
int age = entry.getValue();
if (minAge == 0 && requestTable.get(pointer) == 0) {
minAge = age;
minKey = pointer;
} else {
if (age < minAge && requestTable.get(pointer) == 0) {
minAge = age;
minKey = pointer;
}
}
}
return minKey;
}
/*----------------------------------------------------------------------------------------
* All pages are kept in a circular list, as pages are added then advance clock hand
* On page fault if reference bit is 0 and time of last use is not less than tau evict current pointed page
* If reference bit is set then clear the reference bit and prepare to write to disk
* else page is in the working set so move to next item in circular queue
*
*/
public static void workingSet(int numframes, long refresh, long tau) {
Queue workingSet = new LinkedList();
Queue tempSet = new LinkedList();
Hashtable requestTable = new Hashtable();
Hashtable workingTable = new Hashtable();
Hashtable disk = new Hashtable();
pageRequest request;
int count = 0, faults = 0, writes = 0;
long start = System.currentTimeMillis();
while (workingSet.size() < numframes) { //while there are still empty frames
request = (pageRequest) requestQueue.poll();
if (!workingTable.containsKey(request.va)) {
requestTable.put(request.va, request.bit);
//long currentTime = System.currentTimeMillis() - start;
workingTable.put(request.va, count);
workingSet.add(request.va);
}
count++;
}
request = (pageRequest) requestQueue.poll();
//long start = System.currentTimeMillis();
while (requestQueue.size() != 0) {
tempSet.addAll(workingSet);
if (requestTable.containsKey(request.va)) {
requestTable.put(request.va, 1);
workingTable.put(request.va, count);
count++;
if (requestQueue.size() == 0) {
break;
}
request = (pageRequest) requestQueue.poll();
}
for (int i = 0; i < numframes; i++) {
boolean evicted = false;
String pointer = (String) tempSet.poll();
long currentTime = System.currentTimeMillis() - start;
if (currentTime >= refresh) {
updateTime(requestTable, workingTable, count); //update time if refresh period passed
start = System.currentTimeMillis();
}
int ref = (int) requestTable.get(pointer);
//not in table, reference bit is 0 and it is older than tau then evict
if (!requestTable.containsKey(request.va) && ref == 0 && (int) workingTable.get(pointer) > tau) { //check to see if in WS
requestTable.put(request.va, request.bit); //add in request
requestTable.remove(pointer); //remove current pointer
workingTable.remove(pointer);
workingTable.put(request.va, count);
workingSet.remove(pointer);
workingSet.add(request.va);
faults++;
count++;
evicted = true;
if (requestQueue.isEmpty()) {
break;
}
request = (pageRequest) requestQueue.poll();
//break;
//victim = true; //found our page to evict
} else if (ref == 1 && (int) workingTable.get(pointer) > tau) { //cost of surviving
if (!disk.containsKey(pointer)) {
disk.put(pointer, ref);
writes++;
}
requestTable.put(pointer, 0);
} else if (requestTable.containsKey(request.va)) { //references a page already in set
requestTable.put(request.va, 1);
workingTable.put(request.va, count);
count++;
if (requestQueue.isEmpty()) {
break;
}
request = (pageRequest) requestQueue.poll();
} else if (i == numframes - 1 && !evicted) { //reached end and no one was evicted
Iterator<Map.Entry<String, Integer>> iter = workingTable.entrySet().iterator();
int max = 0;
String remove = "";
while (iter.hasNext()) {
Map.Entry<String, Integer> entry = iter.next();
String point = entry.getKey();
int time = entry.getValue();
if (time > max) { //find oldest
max = time;
remove = point;
}
}
requestTable.remove(remove);
requestTable.put(request.va, request.bit);
workingTable.remove(remove);
workingTable.put(request.va, count);
workingSet.remove(remove);
workingSet.add(request.va);
count++;
faults++;
if (requestQueue.isEmpty()) {
break;
}
request = (pageRequest) requestQueue.poll();
}
}
}
printResults("workingSet", numframes, 1000000, faults, writes);
long endTime = System.currentTimeMillis() - startTime;
System.out.println("WorkingSet took: " + endTime / 1000.00 + " seconds");
}
//updates the time stamp of each page in in pageframes with current line number
public static void updateTime(Hashtable requestTable, Hashtable workingTable, int counter) {
Iterator<Map.Entry<String, Integer>> iter = requestTable.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, Integer> entry = iter.next();
String key = entry.getKey();
int vt = entry.getValue();
requestTable.put(key, 0);
workingTable.put(key, counter);
}
}
public static class pageRequest {
String va = new String();
String mode = new String();
int bit = 0;
public pageRequest(String address, String mode, int bit) {
va = address;
this.mode = mode;
this.bit = bit;
}
}
}
| [
"[email protected]"
]
| |
4f7d061ce947b8b4118b3d9ecb8bd158b744d176 | 13ea5da0b7b8d4ba87d622a5f733dcf6b4c5f1e3 | /crash-reproduction-new-fitness/results/XWIKI-13196-1-19-Single_Objective_GGA-IntegrationSingleObjective-/org/xwiki/model/reference/EntityReference_ESTest_scaffolding.java | 077c8e6efc9773befedb508e48c632a2de2f5c96 | [
"MIT",
"CC-BY-4.0"
]
| permissive | STAMP-project/Botsing-basic-block-coverage-application | 6c1095c6be945adc0be2b63bbec44f0014972793 | 80ea9e7a740bf4b1f9d2d06fe3dcc72323b848da | refs/heads/master | 2022-07-28T23:05:55.253779 | 2022-04-20T13:54:11 | 2022-04-20T13:54:11 | 285,771,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,078 | java | /**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Mon May 18 01:17:39 UTC 2020
*/
package org.xwiki.model.reference;
import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
@EvoSuiteClassExclude
public class EntityReference_ESTest_scaffolding {
@org.junit.Rule
public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule();
private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000);
@BeforeClass
public static void initEvoSuiteFramework() {
org.evosuite.runtime.RuntimeSettings.className = "org.xwiki.model.reference.EntityReference";
org.evosuite.runtime.GuiSupport.initialize();
org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000;
org.evosuite.runtime.RuntimeSettings.mockSystemIn = true;
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
}
@Before
public void initTestCase(){
threadStopper.storeCurrentThreads();
threadStopper.startRecordingTime();
org.evosuite.runtime.GuiSupport.setHeadless();
org.evosuite.runtime.Runtime.getInstance().resetRuntime();
org.evosuite.runtime.agent.InstrumentingAgent.activate();
}
@After
public void doneWithTestCase(){
threadStopper.killAndJoinClientThreads();
org.evosuite.runtime.agent.InstrumentingAgent.deactivate();
org.evosuite.runtime.GuiSupport.restoreHeadlessMode();
}
private static void initializeClasses() {
org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(EntityReference_ESTest_scaffolding.class.getClassLoader() ,
"org.xwiki.model.internal.reference.LocalizedStringEntityReferenceSerializer",
"org.xwiki.model.internal.reference.StringReferenceSeparators$3",
"org.xwiki.model.internal.reference.AbstractStringEntityReferenceSerializer",
"org.xwiki.stability.Unstable",
"org.xwiki.model.internal.reference.StringReferenceSeparators$4",
"org.xwiki.component.annotation.Component",
"org.xwiki.model.reference.EntityReference",
"org.xwiki.model.internal.reference.StringReferenceSeparators",
"org.xwiki.model.internal.reference.StringReferenceSeparators$1",
"org.xwiki.text.StringUtils",
"org.xwiki.model.internal.reference.StringReferenceSeparators$2",
"org.apache.commons.lang3.StringUtils",
"org.xwiki.model.internal.reference.DefaultStringEntityReferenceSerializer",
"org.apache.commons.lang3.Validate",
"org.xwiki.model.reference.DocumentReference",
"org.xwiki.model.reference.LocalDocumentReference",
"org.apache.commons.lang3.builder.Builder",
"org.apache.commons.lang3.builder.HashCodeBuilder",
"org.xwiki.model.EntityType",
"org.xwiki.model.reference.EntityReferenceSerializer"
);
}
}
| [
"[email protected]"
]
| |
4040fc059af000700e013548de745505444e64d4 | 503c3dc0250095401ddd6f2b36c0333fd612fb81 | /Lab4/src/Shape/Cubiod.java | 0b4df107942f576196ad071fad9964f04c9d6c13 | []
| no_license | ImaginaryBIT/CE2002_OOP | 0b226e35f5746b18e692264b595da0d037d3f9d9 | caddf2904babe8490218089e6895548fe02fb6b4 | refs/heads/master | 2021-04-26T08:50:40.530432 | 2017-11-09T12:52:51 | 2017-11-09T12:52:51 | 106,941,582 | 0 | 0 | null | 2020-01-27T12:59:02 | 2017-10-14T16:01:54 | Java | UTF-8 | Java | false | false | 267 | java | package Shape;
public class Cubiod extends Rectangle{
public Cubiod(int height, int breadth) {
super(height, breadth);
// TODO Auto-generated constructor stub
}
public double area() {
return 4*super.area() + 2*Math.pow(super.getBreadth(), 2);
}
}
| [
"[email protected]"
]
| |
990d89524cd2687bac6a63f5c6c7469675d4b739 | e8866600d69c326f5704ccc2a4d8259cfa802b50 | /Java_RMI_Lab_1/src/AddInterface.java | c374d0025236335851032f8147c01f8b605c91ce | []
| no_license | Subrata11/Parallel-Processing | 84eb85d20d4a7b5e4fc5398972d73adc30e1210a | 9f772009639258c05441607070111c5f3091d852 | refs/heads/master | 2020-03-09T15:15:27.279073 | 2017-08-22T05:38:43 | 2017-08-22T05:38:43 | 128,854,576 | 0 | 1 | null | 2018-04-10T01:24:39 | 2018-04-10T01:24:39 | null | UTF-8 | Java | false | false | 137 | java | import java.rmi.Remote;
public interface AddInterface extends Remote {
public int Add(int x, int y)throws java.rmi.RemoteException;
}
| [
"[email protected]"
]
| |
0e26eda0782cad4d79c782d523695fb85ba0ae71 | 545db2340d10f011e902c430dc904361afba8ab1 | /src/kyui/event/ItemSelectListener.java | 333f5016722edce0c027fd239824249bd80f3491 | []
| no_license | EX867/PositionWriter-KyUI | 5a7df9bb5fa8a374fe21779064e9a742bc157d1c | 720bb8e070eba27927a049044b8940260b314030 | refs/heads/master | 2023-02-05T08:04:15.393163 | 2020-12-25T10:57:49 | 2020-12-25T10:57:49 | 109,265,551 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 94 | java | package kyui.event;
public interface ItemSelectListener {
public void onEvent(int index);
}
| [
"[email protected]"
]
| |
888c839847cceb105ca08f5cb6a8c58376cf8671 | 279bffecb84102ab7a91726607a5e4c1d18e961f | /publicservice/publicservice-web/src/main/java/com/qcloud/component/publicservice/web/controller/CommonQuestionController.java | 3edcba8103e474bf26dfc9499353aeb372cbb0ff | []
| no_license | ChiRains/forest | 8b71de51c477f66a134d9b515b58039a8c94c2ee | cf0b41ff83e4cee281078afe338bba792de05052 | refs/heads/master | 2021-01-19T07:13:19.597344 | 2016-08-18T01:35:54 | 2016-08-18T01:35:54 | 65,869,894 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,937 | java | package com.qcloud.component.publicservice.web.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.qcloud.component.publicservice.model.CommonQuestion;
import com.qcloud.component.publicservice.service.CommonQuestionService;
import com.qcloud.component.publicservice.web.handler.CommonQuestionHandler;
import com.qcloud.component.publicservice.web.vo.CommonQuestionVO;
import com.qcloud.pirates.data.Page;
import com.qcloud.pirates.mvc.FrontAjaxView;
import com.qcloud.pirates.web.page.PPage;
import com.qcloud.pirates.web.security.annotation.NoReferer;
@Controller
@RequestMapping(value = CommonQuestionController.DIR)
public class CommonQuestionController {
public static final String DIR = "/commonQuestion";
@Autowired
private CommonQuestionService commonQuestionService;
@Autowired
private CommonQuestionHandler commonQuestionHandler;
@RequestMapping
@NoReferer
public FrontAjaxView listCommonQuestion(PPage page) {
Page<CommonQuestion> pageInfo = commonQuestionService.page(page.getPageStart(), page.getPageSize());
List<CommonQuestion> list = pageInfo.getData();
List<CommonQuestionVO> voList = commonQuestionHandler.toVOList(list);
FrontAjaxView view = new FrontAjaxView();
view.addObject("list", voList);
return view;
}
@RequestMapping
@NoReferer
public ModelAndView getCommonQuestion(Long id) {
CommonQuestion item = commonQuestionService.get(id);
CommonQuestionVO voItem = commonQuestionHandler.toVO(item);
FrontAjaxView view = new FrontAjaxView();
view.addObject("result", voItem);
return view;
}
}
| [
"dengfei@ed19df75-bd51-b445-9863-9e54940520a8"
]
| dengfei@ed19df75-bd51-b445-9863-9e54940520a8 |
94d9cffdc36c3099b5644a5807576e8328be79fb | 020fe062b7b9ef5c535751edb5a37221028e4aa7 | /src/Module6/Session1/com/upgrad/ecommerce/domain/v1/ProductV1.java | 7bd13e52b39dee69fe0c6534cb1bd3eb75b02ac0 | []
| no_license | rohit-tambakhe/FullStack-IITB | 4899a3c7ec181140e1dc06a07628e13d3be0a878 | 2f7239b3687d0fd277a67bb16f1c177ebdec6aac | refs/heads/master | 2023-02-18T07:38:17.525645 | 2019-09-30T15:31:57 | 2019-09-30T15:31:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,310 | java | package com.upgrad.ecommerce.domain.v1;
public class ProductV1 {
private String name;
private BrandV1 brand;
private String description;
private Image[] images;
public ProductV1(String name, BrandV1 brand) {
this.name = name;
this.brand = brand;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public BrandV1 getBrand() {
return brand;
}
public void setBrand(BrandV1 brand) {
this.brand = brand;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Image[] getImages() {
return images;
}
public void setImages(Image[] images) {
this.images = images;
}
public void addImage(Image image) {
for (int i = 0; i < images.length; i++) {
if (null == images[i]) {
images[i] = image;
return;
}
}
}
public Image getDefaultImage(){
for (int i = 0; i < images.length; i++) {
if ( images[1].isDefaultImg()) {
return images[i];
}
}
return null;
}
}
| [
"[email protected]"
]
| |
ce52da366fe47cce864b27b8cdb7159347379994 | bece2302011f31a46c5402bc9d925fd404eaf1f6 | /core/src/bewareofthetruth/contract/model/gameMecanism/TeleporterLink.java | 41142dca53e310e705314644f57c50d19756ccce | []
| no_license | RoseauFragile/Beware-Of-The-Truth | 9ebacfb2f3e10a09893a39b5141596c177e00b68 | af20826e61f7edfa990efc419412e7004bb6a646 | refs/heads/master | 2022-04-06T14:29:08.897050 | 2020-03-02T16:13:50 | 2020-03-02T16:13:50 | 137,092,045 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 167 | java | package bewareofthetruth.contract.model.gameMecanism;
public enum TeleporterLink {
YELLOW, BLUE, RED, GREEN, PURPLE, WHITE, BLACK, ORANGE, PINK, BROWN, GREY;
} | [
"[email protected]"
]
| |
94943219837b5bb720830f3baf2b0cdcfbb8f1e9 | 37cf55c0ea34cc16f376960af412bf12027e607f | /src/main/java/io/github/jhipster/hoolidays/service/mapper/UserMapper.java | a7ec971d4bc11c3d5310969a7a32cceb84e1127a | []
| no_license | BulkSecurityGeneratorProject/Hoolydays | f924f8a301523565c4ab4325e9539d014e0900c1 | 6cf62dcab7d2550c6245897f4bd9ded90a5878ed | refs/heads/master | 2022-12-17T09:30:55.470689 | 2017-11-20T16:14:16 | 2017-11-20T16:14:16 | 296,573,991 | 0 | 0 | null | 2020-09-18T09:20:38 | 2020-09-18T09:20:37 | null | UTF-8 | Java | false | false | 2,361 | java | package io.github.jhipster.hoolidays.service.mapper;
import io.github.jhipster.hoolidays.domain.Authority;
import io.github.jhipster.hoolidays.domain.User;
import io.github.jhipster.hoolidays.service.dto.UserDTO;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* Mapper for the entity User and its DTO called UserDTO.
*
* Normal mappers are generated using MapStruct, this one is hand-coded as MapStruct
* support is still in beta, and requires a manual step with an IDE.
*/
@Service
public class UserMapper {
public UserDTO userToUserDTO(User user) {
return new UserDTO(user);
}
public List<UserDTO> usersToUserDTOs(List<User> users) {
return users.stream()
.filter(Objects::nonNull)
.map(this::userToUserDTO)
.collect(Collectors.toList());
}
public User userDTOToUser(UserDTO userDTO) {
if (userDTO == null) {
return null;
} else {
User user = new User();
user.setId(userDTO.getId());
user.setLogin(userDTO.getLogin());
user.setFirstName(userDTO.getFirstName());
user.setLastName(userDTO.getLastName());
user.setEmail(userDTO.getEmail());
user.setImageUrl(userDTO.getImageUrl());
user.setActivated(userDTO.isActivated());
user.setLangKey(userDTO.getLangKey());
Set<Authority> authorities = this.authoritiesFromStrings(userDTO.getAuthorities());
if(authorities != null) {
user.setAuthorities(authorities);
}
return user;
}
}
public List<User> userDTOsToUsers(List<UserDTO> userDTOs) {
return userDTOs.stream()
.filter(Objects::nonNull)
.map(this::userDTOToUser)
.collect(Collectors.toList());
}
public User userFromId(Long id) {
if (id == null) {
return null;
}
User user = new User();
user.setId(id);
return user;
}
public Set<Authority> authoritiesFromStrings(Set<String> strings) {
return strings.stream().map(string -> {
Authority auth = new Authority();
auth.setName(string);
return auth;
}).collect(Collectors.toSet());
}
}
| [
"[email protected]"
]
| |
3c328836fe4686e878443e7fe2042d9fdd47db3c | 5816483738df04b3e1242e9772693a0df1069e70 | /study/android/xmpp/Swipeback/app/src/main/java/com/dym/swipeback/MainActivity.java | 1081c855a321b388d1f7c5ae00490e31c7a48693 | []
| no_license | wongainia/myswipe-back | 2e6de715bc810d725695dafe30ecc1b124f40f67 | 7c6762e9faafb33280431ccdd46b6b6427d2b2a5 | refs/heads/master | 2021-05-07T17:03:19.399716 | 2017-10-29T01:16:33 | 2017-10-29T01:16:33 | 108,695,014 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 774 | java | package com.dym.swipeback;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import com.dym.swipeback.test.R;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn_main_test = (Button)findViewById(R.id.btn_main_test);
btn_main_test.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this,SwipeBackTestActivity.class));
}
});
}
}
| [
"[email protected]"
]
| |
c68dbe12faa1f68928f5b033161370e8da3d8bd9 | 01ca6feb1d700069282b1c14612d58a2dfce80b7 | /Leetcode/Algorithms/Remove Nth Node From End of List.java | 893387ecbe65f631b548b0b080bba7abb8b5d210 | []
| no_license | wangxingxx/Coding_Problems | 8057e258abb6f9025188db4bc5087669381691e2 | 1b0737e78b8f25aed0fd9d5cdcb9629dd0933600 | refs/heads/master | 2021-01-16T00:10:18.554789 | 2015-11-25T03:10:44 | 2015-11-25T03:10:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,637 | java | /* Problem: Remove Nth Node From End of List
* Given a linked list, remove the nth node from the end of list and return its head.
* For example,
* Given linked list: 1->2->3->4->5, and n = 2.
* After removing the second node from the end, the linked list becomes 1->2->3->5.
* Note:
* Given n will always be valid.
* Try to do this in one pass.
*/
/*1st round, in-place, on-pass*/
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
public class Solution {
public ListNode removeNthFromEnd(ListNode head, int n) {
//alg: maintain two pointers p1, p2.
//p2 is n node faster than p1.
//they moves at same pace, one at a time.
//when p2 reaches the end, p1 skips the next node, but connects the node after next node.
//return head.
//corner cases:
//null, empty, single node, remove the head.
if (head == null || n == 0) {
return head;
}
if (head.next == null && n > 0) {
return null;
}
ListNode p1 = head;
ListNode p2 = head;
while (n > 0) {
p2 = p2.next;
n--;
}
if (p2 == null) {//corner case: the node to be removed is the head.
head = head.next;
return head;
}
//general cases:
while (p2.next != null) {
p2 = p2.next;
p1 = p1.next;
}
p1.next = p1.next.next;
return head;
}
} | [
"[email protected]"
]
| |
917daca3d9d8abc1bc62c8c0536a3507dec1d6f8 | 7afc7e6cdd236d2f1218d79df1c8148016fd8756 | /src/main/net/ictcampus/chess/ChessApp.java | 1013b06fe8ecfc1c14e56bb9a6a4731907144556 | []
| no_license | luetolfre/chess | 0f91a4997ea51ebc6e749eb4c42f1dbe2e209448 | f07f930853480a4506895f537c0b436e07d1be63 | refs/heads/master | 2022-04-27T02:42:04.436241 | 2020-05-01T13:19:12 | 2020-05-01T13:19:12 | 256,972,392 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,295 | java | package net.ictcampus.chess;
import net.ictcampus.chess.gui.StartPane;
import net.ictcampus.chess.gui.Style;
import net.ictcampus.chess.model.Chess;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
/**
* <h1>Chess Application</h1>
* The ChessApp implements an Application that let's you
* play a local Chess game.
*
* @author luetolfre
* @version 1.0
* @since 2020-04-24
*/
public class ChessApp extends Application {
/**
* This is the main method which launches the Chess Game
* @param args unused.
*/
public static void main(String[] args) {
launch(args);
}
/**
* The start method starts a Stage with the StartScene.
* @param stage window the app runs in.
*/
@Override
public void start(Stage stage) {
Chess game = new Chess("p1", "p2");
stage.getIcons().add(new Image("/img/b/knight.png"));
stage.setTitle("CHESS");
Pane start = new StartPane(game, stage, "chess");
Scene scene = new Scene(start, 900, 900);
Style.setStyleSheet(scene, "/css/main.css");
stage.setScene(scene);
// primaryStage.setFullScreen(true);
stage.show();
}
}
| [
"[email protected]"
]
| |
f6a764158b3023f3bffdc82986da943289f69217 | 6153f22ccad5e550ec60e6465d77bd7088174144 | /demo/src/main/java/com/tuowazi/demo/java8_new/src/stream/execise/execise2.java | e48200bb475a679290c7965f764e22f841a66588 | [
"MIT",
"LicenseRef-scancode-other-permissive"
]
| permissive | zwxbest/Demo | a5093d4e82b269d200d23a7a390e299334301917 | 16ce40b63907d52d65ad93fba6a793847911d216 | refs/heads/master | 2023-06-08T17:15:27.688512 | 2022-03-03T03:53:31 | 2022-03-03T03:53:31 | 123,203,277 | 1 | 7 | MIT | 2023-05-26T22:15:03 | 2018-02-27T23:52:55 | Roff | UTF-8 | Java | false | false | 487 | java | package com.tuowazi.demo.java8_new.src.stream.execise;
import static java.util.stream.Collectors.toSet;
/**
* Created by zwxbest on 2018/7/30.
* 交易员都在哪些不同的城市工作过
*/
public class execise2 {
public static void main(String[] args) {
Transactions.transactions.stream().map(x->x.getTrader().getCity()).distinct().forEach(System.out::println);
Transactions.transactions.stream().map(x->x.getTrader().getCity()).collect(toSet());
}
}
| [
"[email protected]"
]
| |
ce4a4f2c0facce4f8d2530eb0b45927770106110 | 843f7294952036cfc9ce93662bbb346ed9471440 | /bboss-elasticsearch-rest-entity/src/main/java/org/frameworkset/elasticsearch/entity/ESIndice.java | 8d5c9fcd153f80738fc7c94c93ea3f848b9067cb | [
"Apache-2.0"
]
| permissive | bbossgroups/bboss-elasticsearch | 16046e471fd965dde50998154a2422a2860ae6fa | 985c7001cdfe465f658a4c754a778098c8aee181 | refs/heads/master | 2023-09-04T03:19:00.593284 | 2023-09-03T08:27:37 | 2023-09-03T08:27:37 | 104,154,908 | 478 | 128 | Apache-2.0 | 2020-06-18T03:14:17 | 2017-09-20T02:27:12 | Java | UTF-8 | Java | false | false | 3,290 | java | package org.frameworkset.elasticsearch.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
* yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb
* green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 5 0 0 0 260b 260b
* .watcher-history-3-2017.07.02
*/
public class ESIndice {
/**
* 分表策略:
* yyyy 年 3
* yyyy.MM 月 2
* yyyy.MM.dd 天 1
* 未知 -1或者null
*/
private Integer indiceSplitPolicy ;
private String health;
private String status ;
private String index;
private String uuid ;
private int pri ;
private int rep ;
@JsonProperty("docs.count")
private long docsCcount;
@JsonProperty("docs.deleted")
private long docsDeleted ;
@JsonProperty("store.size")
private String storeSize ;
@JsonProperty("pri.store.size")
private String priStoreSize;
private Date genDate;
private Map<String,String> otherDatas;
public String getHealth() {
return health;
}
public void setHealth(String health) {
this.health = health;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getIndex() {
return index;
}
public void setIndex(String index) {
this.index = index;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public int getPri() {
return pri;
}
public void setPri(int pri) {
this.pri = pri;
}
public int getRep() {
return rep;
}
public void setRep(int rep) {
this.rep = rep;
}
public long getDocsCcount() {
return docsCcount;
}
public void setDocsCcount(long docsCcount) {
this.docsCcount = docsCcount;
}
public long getDocsDeleted() {
return docsDeleted;
}
public void setDocsDeleted(long docsDeleted) {
this.docsDeleted = docsDeleted;
}
public String getStoreSize() {
return storeSize;
}
public void setStoreSize(String storeSize) {
this.storeSize = storeSize;
}
public String getPriStoreSize() {
return priStoreSize;
}
public void setPriStoreSize(String priStoreSize) {
this.priStoreSize = priStoreSize;
}
public Date getGenDate() {
return genDate;
}
public void setGenDate(Date genDate) {
this.genDate = genDate;
}
public void addOtherData(String name,String value){
if(otherDatas == null)
otherDatas = new HashMap<String, String>();
otherDatas.put(name,value);
}
public Map<String, String> getOtherDatas() {
return otherDatas;
}
public Integer getIndiceSplitPolicy() {
return indiceSplitPolicy;
}
public void setIndiceSplitPolicy(Integer indiceSplitPolicy) {
this.indiceSplitPolicy = indiceSplitPolicy;
}
}
| [
"[email protected]"
]
| |
3cd8ad3df92b491143aeb659dd3f53d3f1bf153d | c4e1e4445d57aeae5962696c23bc342a18bf5b0f | /Appinfodb/src/cn/appsys/controller/backend/BackUserController.java | f4d703a2715df3f9dedfaa66bfb50cfced629a0f | []
| no_license | Chinacheng1/caopengcheng | 47955df6a4b5c0e0d83063c251c6b7a4b3dedaa6 | bd11f2fa2475af5517899ad3599c125beb53f356 | refs/heads/master | 2020-03-17T22:56:27.830197 | 2018-05-19T03:38:01 | 2018-05-19T03:38:01 | 134,024,243 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,269 | java | package cn.appsys.controller.backend;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import cn.appsys.pojo.BackendUser;
import cn.appsys.service.backend.BackendUserService;
import cn.appsys.tools.Constants;
@Controller
@RequestMapping(value="/manager")
public class BackUserController {
@Resource
private BackendUserService backUserService;
@RequestMapping(value="/login.html")
public String backend() {
return "/backendlogin";
}
@RequestMapping(value="/dologin")
public String main(HttpServletRequest res,@RequestParam(value="userCode",required=false)String name,@RequestParam(value="userPassword",required=false)String pwd) {
BackendUser backensUser = backUserService.backLogin(name, pwd);
if(backensUser != null) {
res.getSession().setAttribute(Constants.USER_SESSION, backensUser);
return "backend/main";
}else {
return "backend/login";
}
}
@RequestMapping(value="/logout")
public String logout(HttpServletRequest res) {
res.getSession().removeAttribute(Constants.USER_SESSION);
return "redirect:/index.jsp";
}
}
| [
"[email protected]"
]
| |
e4fb2f70e6a6fa23a139b5be08c3afc5842d6963 | f43d5de70d14179639192e091c923ccd27112faa | /src/com/codeHeap/generics/genericArray/arrayImpl2/GenericArray.java | aa7d8af3d8640f86b0e3ba68fdc375988568b2b3 | []
| no_license | basumatarau/trainingJavaCore | 2c80d02d539fc6e2e599f6e9240e8f6543ef1bdf | 1efc944b77b1ac7aea44bee89b84daa843670630 | refs/heads/master | 2020-04-04T23:13:47.929352 | 2019-01-09T09:51:35 | 2019-01-09T09:51:35 | 156,351,368 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 583 | java | package com.codeHeap.generics.genericArray.arrayImpl2;
public class GenericArray<T> {
private T[] array;
public GenericArray(int size){
array = (T[]) new Object[size];
}
public void put(int index, T item){
array[index] = item;
}
public T get(int index){
return array[index];
}
public T[] represent(){
return array;
}
public static void main(String[] args) {
GenericArray<Integer> gai = new GenericArray<>(10);
Integer[] a = gai.represent();
Object[] b = gai.represent();
}
}
| [
"[email protected]"
]
| |
d175319600297a8a804c92675cc8dc261b13c309 | c6c3260fbbbb0d19fbd3202837b15cbd9aee02b0 | /src/main/java/com/ecochain/ledger/mapper/ShopOrderLogisticsDetailMapper.java | f4cf1df011ec4c95f9848ff216b58b8d29ded459 | []
| no_license | lishuo5263/supplier-service | 95ef378f588ee790f6f59d26b8b4f14874e9a515 | 0fdb54ca6c7d2f136ac03ac7aa8bc8d16d8961a3 | refs/heads/master | 2021-01-21T08:51:46.903942 | 2017-08-03T14:02:53 | 2017-08-03T14:02:53 | 91,425,666 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 721 | java | package com.ecochain.ledger.mapper;
import com.ecochain.ledger.model.ShopOrderLogisticsDetail;
import java.util.List;
import java.util.Map;
public interface ShopOrderLogisticsDetailMapper {
int deleteByPrimaryKey(Integer id);
int insert(ShopOrderLogisticsDetail record);
int insertSelective(ShopOrderLogisticsDetail record);
ShopOrderLogisticsDetail selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(ShopOrderLogisticsDetail record);
int updateByPrimaryKey(ShopOrderLogisticsDetail record);
Map findLogisticsInfoByNo(String logisticsNo);
List<Map<String,Object>> findLogisticsInfoByNo2(String logisticsNo);
Map findLogisticsInfoByOrderNo(String orderNo);
} | [
"[email protected]"
]
| |
e860f78bbb1adddef9add868169448d19d8a8c67 | 3d24486d0ded31ebbeb757f6522c09cb0250b908 | /java/edu/umass/ccbit/jsp/HttpDbJspBase.java | a78671f57f0a53bf7fa586e485889ffbf531d9b7 | []
| no_license | DigitalGizmo/tomcat-centures-src | 32add9cec7d66d4b1219710fbcd565365cd56865 | 97992cad6d8700281ea6f10fab9d85ea99a33d72 | refs/heads/master | 2020-04-17T23:27:58.664090 | 2019-01-22T16:35:31 | 2019-01-22T16:35:31 | 167,036,450 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,775 | java | /*
* Title: HttpDbJspBase<p>
* Description: base class for jsp pages which provides database connection as well as easy access to initialization and servlet parameters<p>
* Copyright: Copyright (c) 2000-2002<p>
* Company: University of Massachusetts/Center for Computer-based Instructional Technology<p>
* @author pbrown
* @version $Id: HttpDbJspBase.java,v 1.23 2003/01/16 03:05:25 pb Exp $
*
* $Log: HttpDbJspBase.java,v $
* Revision 1.23 2003/01/16 03:05:25 pb
* added mrsidinfo.root init param to allow hostname to be contacted for image info to be specified
*
* Revision 1.22 2002/04/12 14:07:55 pbrown
* fixed copyright info
*
* Revision 1.21 2001/10/25 18:50:20 pbrown
* changes sid root initialization
*
* Revision 1.20 2001/09/28 15:05:44 pbrown
* added throws UserException wherever parse is called, added activity forum code
*
* Revision 1.19 2001/09/12 19:49:59 Administrator
* added UserException to throws clause of parseRequestParameters
*
* Revision 1.18 2001/05/24 14:04:56 pbrown
* added mrsid root member to httpdbjspbase...no more init servlet
*
* Revision 1.17 2001/04/10 13:08:05 pbrown
* some bug fixs
*
* Revision 1.16 2001/02/26 16:47:36 pbrown
* changes for searching, and relocation of www root
*
* Revision 1.15 2001/01/05 21:28:30 pbrown
* finished error handler code
*
* Revision 1.14 2001/01/05 14:41:47 pbrown
* added automatic error handler
*
* Revision 1.13 2000/11/21 21:23:02 pbrown
* changes due to reimplementation of mrsid info...mrsidarchive_ parameter is
* no longer needed and has been removed from many method calls
*
* Revision 1.12 2000/08/02 20:45:04 pbrown
* fixed import for connection mangler
*
* Revision 1.11 2000/08/02 20:43:30 pbrown
* changes for new db connection mangler
*
* Revision 1.10 2000/06/27 16:14:39 pbrown
* many changes for searching, bugfixes etc.
*
* Revision 1.9 2000/06/02 21:52:55 pbrown
* many changes for searching..more to come
*
* Revision 1.8 2000/05/25 22:25:09 pbrown
* many changes for item pages including building list of associated items
*
* Revision 1.7 2000/05/22 15:22:30 pbrown
* changes reference to TcpDatabaseConnectionMgr, now located in edu.umass.ckc.database
* package and called JdbcConnectionMgr
*
* Revision 1.6 2000/05/18 18:53:51 pbrown
* added mrSidArchive_ instance variable
*
* Revision 1.5 2000/05/18 02:32:53 pbrown
* changes due to moved packages
*
* Revision 1.4 2000/05/15 18:27:29 pbrown
* removed old vj++ and forte4j project files, added jbuilder files
*
* Revision 1.3 2000/05/12 22:47:54 pbrown
* many changes, rewritten for sprinta db driver
*
* Revision 1.2 2000/05/09 13:28:54 pbrown
* fixed db connection in jsp base class
*
* Revision 1.1 2000/05/05 21:21:32 pbrown
* rebuilt repository
*
* Revision 1.3 2000/05/04 14:13:32 pbrown
* uses JspInitParams instead of InitParams...added cvs info
*
* Revision 1.2 2000/04/28 14:54:41 pbrown
* added documentation, cvs info
*
*/
/*
run jdb like-a this-a:
-Dtomcat.home=H:/Apache/tomcat-debug -classpathH:/Apache/tomcat/lib/servlet.jar;H:/Apache/tomcat/lib/xml.jar;H:/Apache/tomcat/lib/webserver.jar;H:/Apache/tomcat/lib/jasper.jar;H:/Apache/tomcat/webapps/pvma/WEB-INF/classes;E:/pvma/JavaSource/sprinta org.apache.tomcat.startup.Tomcat
Java (1.1.8) classpath:
.;H:\Java\jdk1.1.8\lib\classes.zip;H:\Java\JavaSoft\JRE\1.1\lib\rt.jar;E:\JavaSource\1.1collections\lib\collections.jar;E:\JavaSource\xml\lib-tr2\xml.jar
Java2 classpath:
.;H:\Java2\jdk1.2.2\lib\tools.jar;H:\Java2\jdk1.2.2\lib\dt.jar;H:\Java2\JavaSoft\JRE\1.2\lib\rt.jar;E:\JavaSource\1.1collections\lib\collections.jar;E:\JavaSource\xml\lib-tr2\xml.jar
*/
package edu.umass.ccbit.jsp;
import edu.umass.ccbit.database.NavigationBar;
import edu.umass.ccbit.util.JspInitParams;
import edu.umass.ccbit.util.SessionNavigation;
import edu.umass.ccbit.image.MrSidImage;
import edu.umass.ckc.database.JdbcConnectionMgr;
import edu.umass.ckc.database.BaseConnectionMgr;
import edu.umass.ckc.servlet.ServletParams;
import edu.umass.ckc.servlet.ServletParser;
import edu.umass.ckc.util.CkcException;
import java.io.IOException;
import java.lang.Exception;
import java.sql.Connection;
import javax.servlet.http.HttpServletRequest;
import org.apache.jasper.runtime.HttpJspBase;
import java.sql.SQLException;
import edu.umass.ckc.util.UserException;
public abstract class HttpDbJspBase extends HttpJspBase
{
// special parameter values common to each jsp
protected String tempDirectory=null;
protected int maxContentLength=1048576;
protected String URI_;
// parameter objects - init parameters (from xml), and servlet parameters
protected JspInitParams initParams_;
protected ServletParams servletParams_;
// database access
protected JdbcConnectionMgr connectionMgr_;
protected Connection connection_;
public static String mrSidRoot=null;
public static String mrSidInfoRoot=null;
/**
* initializes jsp page
*/
public void jspInit()
{
try
{
initParams_=new JspInitParams();
initParams_.storeParameters(getServletConfig());
if (mrSidRoot==null)
{
mrSidRoot=initParams_.getString("mrsid.root", "");
mrSidInfoRoot=initParams_.getString("mrsidinfo.root", "");
MrSidImage.setMrSidRoot(mrSidRoot, mrSidInfoRoot);
}
tempDirectory=initParams_.getString("temp.directory", "");
maxContentLength=initParams_.getInt("max.contentlength", 0);
connectionMgr_=(JdbcConnectionMgr) BaseConnectionMgr.getConnectionMgr(initParams_, null);
}
catch (Exception e)
{
// i will croak later (can't throw exception from here)
System.out.println("In HttpDbJspBase.java " + e.getMessage());
e.printStackTrace(System.out);
}
}
/**
* format request for inclusion in session history
*/
protected String formatRequest(HttpServletRequest request, ServletParams params) throws CkcException
{
StringBuffer buf=new StringBuffer();
String server=request.getServerName();
buf.append("http://");
buf.append(server);
buf.append(request.getRequestURI());
String query=params.getQueryString();
if (query.length() > 0)
{
buf.append("?").append(query);
}
return buf.toString();
}
/**
* add navigation item to session...trivially override to
* prevent item from being added (e.g., for error page)
*/
protected void addNavigationItem(HttpServletRequest request, ServletParams params) throws CkcException
{
SessionNavigation.addItem(request.getSession(), formatRequest(request, params));
}
/**
* get servlet request parameters into ServletParams object
* @param request the servlet request
*/
protected synchronized void parseRequestParameters(HttpServletRequest request) throws IOException, CkcException, UserException
{
// save this uri
URI_=request.getRequestURI();
servletParams_ = new ServletParams();
ServletParser parser=new ServletParser(maxContentLength, tempDirectory);
parser.parse(request, servletParams_);
// this is for debug only
addNavigationItem(request, servletParams_);
}
/**
* get database connection
*/
synchronized protected void getDbConnection() throws Exception
{
connection_=connectionMgr_.getConnection();
}
/**
* release database connection
*/
synchronized protected void releaseDbConnection() throws CkcException
{
connectionMgr_.releaseConnection(connection_);
}
}
| [
"[email protected]"
]
| |
1062aaf328e0645f1bee39fe936f476efa54686b | 1549fb89e31c7b55afaa38dec1cdc5f45e24361c | /my-shop-web-api/src/main/java/com/funtl/my/shop/web/api/dao/TbUserDao.java | f93d5ee1646ba4611565ed63576bf774aba69613 | [
"Apache-2.0"
]
| permissive | HeavenAndMe/github-test | 748a37a300ff5536915c93f11251675aec2c8dcf | e3a1438d157ed983c15565f207efa84cbb0b9b6d | refs/heads/master | 2022-12-21T19:51:12.625508 | 2019-08-28T00:07:13 | 2019-08-28T00:07:13 | 204,799,749 | 0 | 0 | Apache-2.0 | 2022-12-16T09:43:08 | 2019-08-27T22:18:26 | JavaScript | UTF-8 | Java | false | false | 343 | java | package com.funtl.my.shop.web.api.dao;
import com.funtl.my.shop.domain.TbUser;
import org.springframework.stereotype.Repository;
/**
* 会员管理
* @author Zhan
* @create 2019/8/25 - 10:55
*/
@Repository
public interface TbUserDao {
/**
* 登录
* @param tbUser
* @return
*/
TbUser login(TbUser tbUser);
}
| [
"[email protected]"
]
| |
9aba22bb3c3a06bde2c0a4d8ccc7d273421e360a | 004206ab2e7738967dd1b851e68e362d8796b25a | /src/conditions/LowerOrSame.java | 77bbf1025b454d07c2fca270e4d5978754c63ae1 | []
| no_license | jclort/ARM_Runner | d439b651ec642615dcf4bd3e595012ef7c7ab446 | 7402f3b41ea742d9bcc0daf98d2200bf3480e7ae | refs/heads/master | 2020-06-25T04:54:38.186274 | 2019-07-27T20:05:13 | 2019-07-27T20:05:13 | 199,207,439 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 327 | java | package conditions;
import driver.SystemState;
/**
* Unsigned lower or same
*
* @author Mark
*/
public class LowerOrSame implements Condition {
@Override
public String code() {
return "LS";
}
@Override
public boolean isTrue(SystemState systemState) {
return !systemState.getC() || systemState.getZ();
}
}
| [
"[email protected]"
]
| |
4c69bc5d5dc688bed314be0dc5d057163ad25ebd | 696942f3139141c6b0a8b1fff612b0e3770c1840 | /window/src/model/WindowManager.java | cbc7d211f874f66c1de346e484710bbf767e7b63 | []
| no_license | Shadoka/Aufgaben | 54e5bd48bc9d30bfeddf4e0ce37f358041a34b58 | d26381842f583ef3652f9d84663f9845bf4c4b09 | refs/heads/master | 2021-01-11T11:08:10.262798 | 2012-11-27T17:40:32 | 2012-11-27T17:40:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,346 | java | package model;
import java.util.Vector;
public class WindowManager {
private static WindowManager theWindowManager;
public static WindowManager getTheWindowManager() {
if (theWindowManager == null)
theWindowManager = new WindowManager();
return theWindowManager;
}
private Vector<Window> windowStack;
private WindowManager() {
this.setWindowStack(new Vector<Window>());
}
private void setWindowStack(Vector<Window> windowStack) {
this.windowStack = windowStack;
}
public Vector<Window> getWindowStack() {
return windowStack;
}
public Vector getVisibleParts() {
RectangularPartCollection result = new RectangularPartCollection();
for (Window current : this.getWindowStack()) {
result.add(current.getVisibleContext());
}
return result.toVector();
}
public void newWindow() {
Window newWindow = new Window();
for (Window current : this.getWindowStack()) {
current.newTop(newWindow);
}
this.setAsNewTopWindow(newWindow);
}
public void setAsNewTopWindow(Window window) {
this.getWindowStack().remove(window);
this.getWindowStack().add(0, window);
for (Window current : this.getWindowStack())
current.setAsTop(window);
}
public void dispose(Window window) {
window.dispose();
this.getWindowStack().remove(window);
}
}
| [
"[email protected]"
]
| |
72ca7be4bd1f21b65cb558cfe41d438d65402d38 | de2a9b1a8f42d4ba36653de66ea6e043e1612ab5 | /src/main/java/com/example/lesson27/controllers/UserController.java | b54ce8b58f5dc5f0630e337c573d38638cae1994 | []
| no_license | javatrap2020/lesson31 | 7e92cc15751bf5d61072d918db015509d628dd93 | 4dc6e73dcbfabd1cd71472f89aa6939f446da52e | refs/heads/master | 2023-02-26T09:18:28.343592 | 2021-02-05T10:43:48 | 2021-02-05T10:43:48 | 336,239,189 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 655 | java | package com.example.lesson27.controllers;
import com.example.lesson27.entites.User;
import com.example.lesson27.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/users")
public class UserController {
private final UserService userService;
public UserController(UserService userService) {
this.userService = userService;
}
@GetMapping
public List<User> getAll() {
return userService.getAll();
}
}
| [
"[email protected]"
]
| |
9bea72a2ba95b2762793d261ec88f1c9e8e10821 | c8757aa578e53b2ff0d94bc97b7cc2c0bd515e0d | /tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/XmlLineNumberParser.java | b214b1e7032e1dd346aa474e91e3c3a3ee4d1a49 | [
"Apache-2.0",
"LicenseRef-scancode-unknown",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | kaiserahmed-isu/camel | 3971b9ea03b289f0be8e9d8fa4534ff2e1440118 | 7b2a3ae36cb42184604c01195ed5499dc92ea1ff | refs/heads/master | 2021-04-03T01:05:16.526119 | 2018-03-08T12:05:27 | 2018-03-08T12:05:47 | 124,423,290 | 1 | 0 | Apache-2.0 | 2018-03-08T17:09:29 | 2018-03-08T17:09:29 | null | UTF-8 | Java | false | false | 8,302 | 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.parser.helper;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.Stack;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
/**
* An XML parser that uses SAX to include line and column number for each XML element in the parsed Document.
* <p/>
* The line number and column number can be obtained from a Node/Element using
* <pre>
* String lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER);
* String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END);
* String columnNumber = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER);
* String columnNumberEnd = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER_END);
* </pre>
*/
public final class XmlLineNumberParser {
public static final String LINE_NUMBER = "lineNumber";
public static final String COLUMN_NUMBER = "colNumber";
public static final String LINE_NUMBER_END = "lineNumberEnd";
public static final String COLUMN_NUMBER_END = "colNumberEnd";
private XmlLineNumberParser() {
}
/**
* Parses the XML.
*
* @param is the XML content as an input stream
* @return the DOM model
* @throws Exception is thrown if error parsing
*/
public static Document parseXml(final InputStream is) throws Exception {
return parseXml(is, null, null);
}
/**
* Parses the XML.
*
* @param is the XML content as an input stream
* @param rootNames one or more root names that is used as baseline for beginning the parsing, for example camelContext to start parsing
* when Camel is discovered. Multiple names can be defined separated by comma
* @param forceNamespace an optional namespace to force assign to each node. This may be needed for JAXB unmarshalling from XML -> POJO.
* @return the DOM model
* @throws Exception is thrown if error parsing
*/
public static Document parseXml(final InputStream is, final String rootNames, final String forceNamespace) throws Exception {
final Document doc;
SAXParser parser;
final SAXParserFactory factory = SAXParserFactory.newInstance();
parser = factory.newSAXParser();
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
// turn off validator and loading external dtd
dbf.setValidating(false);
dbf.setNamespaceAware(true);
dbf.setFeature("http://xml.org/sax/features/namespaces", false);
dbf.setFeature("http://xml.org/sax/features/validation", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
final DocumentBuilder docBuilder = dbf.newDocumentBuilder();
doc = docBuilder.newDocument();
final Stack<Element> elementStack = new Stack<Element>();
final StringBuilder textBuffer = new StringBuilder();
final DefaultHandler handler = new DefaultHandler() {
private Locator locator;
private boolean found;
@Override
public void setDocumentLocator(final Locator locator) {
this.locator = locator; // Save the locator, so that it can be used later for line tracking when traversing nodes.
this.found = rootNames == null;
}
private boolean isRootName(String qName) {
for (String root : rootNames.split(",")) {
if (qName.equals(root)) {
return true;
}
}
return false;
}
@Override
public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException {
addTextIfNeeded();
if (rootNames != null && !found) {
if (isRootName(qName)) {
found = true;
}
}
if (found) {
Element el;
if (forceNamespace != null) {
el = doc.createElementNS(forceNamespace, qName);
} else {
el = doc.createElement(qName);
}
for (int i = 0; i < attributes.getLength(); i++) {
el.setAttribute(attributes.getQName(i), attributes.getValue(i));
}
el.setUserData(LINE_NUMBER, String.valueOf(this.locator.getLineNumber()), null);
el.setUserData(COLUMN_NUMBER, String.valueOf(this.locator.getColumnNumber()), null);
elementStack.push(el);
}
}
@Override
public void endElement(final String uri, final String localName, final String qName) {
if (!found) {
return;
}
addTextIfNeeded();
final Element closedEl = elementStack.isEmpty() ? null : elementStack.pop();
if (closedEl != null) {
if (elementStack.isEmpty()) {
// Is this the root element?
doc.appendChild(closedEl);
} else {
final Element parentEl = elementStack.peek();
parentEl.appendChild(closedEl);
}
closedEl.setUserData(LINE_NUMBER_END, String.valueOf(this.locator.getLineNumber()), null);
closedEl.setUserData(COLUMN_NUMBER_END, String.valueOf(this.locator.getColumnNumber()), null);
}
}
@Override
public void characters(final char ch[], final int start, final int length) throws SAXException {
textBuffer.append(ch, start, length);
}
@Override
public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException {
// do not resolve external dtd
return new InputSource(new StringReader(""));
}
// Outputs text accumulated under the current node
private void addTextIfNeeded() {
if (textBuffer.length() > 0) {
final Element el = elementStack.isEmpty() ? null : elementStack.peek();
if (el != null) {
final Node textNode = doc.createTextNode(textBuffer.toString());
el.appendChild(textNode);
textBuffer.delete(0, textBuffer.length());
}
}
}
};
parser.parse(is, handler);
return doc;
}
}
| [
"[email protected]"
]
| |
6d8a0d4321530a010b79f7551d2d5521c0ba560e | b30283d04c8294c0e3bb61c4df3f88db29e8d32c | /OAuthTest/src/main/java/com/boxfish/lhb/security/conf/SecurityConfiguration.java | 5d80b402145ff129e73ef7d559e67eb85a528583 | []
| no_license | Lianghb/Test2 | e6065404715605da18e5d95f004cab805d404cf8 | b9c86f7c16b3b8471f3f2e7d91acb0b7d8982aa6 | refs/heads/master | 2021-01-10T16:57:44.808018 | 2015-12-26T14:37:31 | 2015-12-26T14:37:31 | 48,613,237 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,979 | java | package com.boxfish.lhb.security.conf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
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.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
/**
* Created by boxfish on 15/12/26.
*/
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
private Logger logger = LoggerFactory.getLogger(getClass());
/**
* 所有用户可访问
*/
private final String[] permitedUrls = {"/myplugins/**", "/dist/**"};
/**
* USER权限可访问
*/
private final String[] userUrls = {"/user/**"};
/**
* ADMIN权限可访问
*/
private final String[] adminUrls = {"/admin/**"};
/**
* DBA权限可以访问
*/
private final String[] dbaUrls = {"/dba/**"};
@Autowired
CustomUserDetailsService service;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
logger.debug("configure(AuthenticationManagerBuilder auth)");
PasswordEncoder passwordEncoder = NoOpPasswordEncoder.getInstance();
auth.userDetailsService(service).passwordEncoder(passwordEncoder);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
logger.debug("configure(HttpSecurity http)");
System.err.println("ssssssssssssssssss---------HttpSecurity:" + http);
http
// .httpBasic()
// .and()
.logout()
.logoutUrl("/logout")
.invalidateHttpSession(true)
.and()
.formLogin()
.loginProcessingUrl("/login")
.loginPage("/login").permitAll()
.and()
.authorizeRequests()
.antMatchers(permitedUrls).permitAll()
.anyRequest().authenticated()
.antMatchers(userUrls).hasRole("USER")
.antMatchers(adminUrls).hasRole("ADMIN")
.antMatchers(dbaUrls).hasRole("DBA")
.and()
.exceptionHandling()
.accessDeniedPage("/login?authorization_error=true") //异常处理页面
;
}
}
| [
"[email protected]"
]
| |
da6c427d40231ee7b0e862aa5c8d14fc92d5ad7a | a49cef4f6d1711405891f2b64c916ef48a8efb1b | /Code/FACES/src/java/core/gov/opm/scrd/entities/lookup/CalculationEndDateCalculationType.java | d7019a1a62b3c84f14d60c9645f94281db62df02 | [
"Apache-2.0"
]
| permissive | govtmirror/CoECI-OPM-Service-Credit-Redeposit-Deposit-Application | 0e4c8f2c6b6ef70a3cc0ab13c2c790c3a0c78e0e | 569d063b7df4b2a9e9054bea37edaa6455f1293e | refs/heads/master | 2021-01-12T07:47:26.029408 | 2014-07-30T22:44:15 | 2014-07-30T22:44:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,663 | java | /*
Copyright 2014 OPM.gov
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 gov.opm.scrd.entities.lookup;
/**
* <p>
* Represents the enumeration specifying the type of the chart to use for calculating the end date in chart calculation.
* It is used in AccountService.calculateEndDate method.
* </p>
*
* <p>
* <strong>Thread Safety: </strong> This enumeration is immutable and thread safe.
* </p>
*
* @author faeton, sparemax
* @version 1.0
*/
public enum CalculationEndDateCalculationType {
/**
* Represents HOUR_2000 type of the calculation chart.
*/
HOUR_2000,
/**
* Represents HOUR_2008 type of the calculation chart.
*/
HOUR_2008,
/**
* Represents HOUR_2016 type of the calculation chart.
*/
HOUR_2016,
/**
* Represents HOUR_2024 type of the calculation chart.
*/
HOUR_2024,
/**
* Represents HOUR_2080 type of the calculation chart.
*/
HOUR_2080,
/**
* Represents HOUR_2087 type of the calculation chart.
*/
HOUR_2087,
/**
* Represents DAY_260 type of the calculation chart.
*/
DAY_260
}
| [
"[email protected]"
]
| |
0281bdb7a5223ddc11617c6a1c125b56abadbec9 | 6e1805fbf3a949b583f77608e5d3ed5d5cb26233 | /Multhread/src/jurassicPark/JurassicPark.java | 604656286b77e4c9431dbee257a5f157bed85175 | []
| no_license | S213B/CourceWork | 8555b32c0079883c8cf00491401753ab0484327e | 1ae53acbb1be962601addbc95a219ceff6a0c6b7 | refs/heads/master | 2021-07-18T00:48:34.560697 | 2020-07-08T00:02:50 | 2020-07-08T00:02:50 | 34,657,858 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 541 | java | package jurassicPark;
public class JurassicPark {
public static final int peopleNum = 10, carNum = 3;
public static void main(String[] args) {
// TODO Auto-generated method stub
People[] people;
Car[] car;
SafariArea sa;
people = new People[peopleNum];
car = new Car[carNum];
sa = new SafariArea();
for(int i = 0; i < carNum; i++) {
car[i] = new Car("Car_#" + i, sa);
car[i].start();
}
for(int i = 0; i < peopleNum; i++) {
people[i] = new People("People_#" + i, sa);
people[i].start();
}
}
}
| [
"[email protected]"
]
| |
d893972704e2541c5394d3d0794b2fe53c570227 | f9b77b663229f7f60d0b0b113858058af96eec78 | /src/test/java/org/cru/redegg/it/EndToEndWithCdiIT.java | bf754d1c7c65b9139d00253944db9a9ea0d0e159 | []
| no_license | hlbraddock/red-egg | 8c49f931e9c40e1aa9614920f3c312ca749d8ea9 | df36cb90ed77172e0b6e2c9d927860fb926e8d46 | refs/heads/master | 2021-01-24T09:14:19.143186 | 2016-03-24T16:27:09 | 2016-03-24T16:27:09 | 54,724,189 | 0 | 0 | null | 2016-03-25T14:32:53 | 2016-03-25T14:32:53 | null | UTF-8 | Java | false | false | 1,507 | java | package org.cru.redegg.it;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.DefaultModelReader;
import org.cru.redegg.test.DefaultDeployment;
import org.cru.redegg.test.TestApplication;
import org.cru.redegg.test.WebTargetBuilder;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.runner.RunWith;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
/**
* @author Matt Drees
*/
@RunWith(Arquillian.class)
@RunAsClient
public class EndToEndWithCdiIT extends AbstractEndToEndIT
{
@Deployment
public static WebArchive deployment() {
return DefaultDeployment.withCdi("end-to-end-test.war")
.addAllRuntimeDependencies()
.getArchive()
.addAsLibraries(RedEggDistribution.getJarFile())
.addClass(TestApplication.class)
.addClass(WebTargetBuilder.class)
.addClass(AbstractApiThatErrors.class)
.addClass(ApiWithCdiThatErrors.class)
.addClass(DummyErrbitApi.class)
.addClass(TestParameterSanitizer.class)
.addClass(TestEntitySanitizer.class)
.addClass(ConfigProducer.class)
.addClass(AbstractEndToEndIT.class)
;
}
}
| [
"[email protected]"
]
| |
e2b649553087f82a79728f455fa4dc040efe2d42 | 04599028b63d70da96710bf5249924bad897301d | /yummyTest/src/main/java/edu/nju/yummy/controller/OrderController.java | f1604b149689212a0616296c96c6eaf47828bc8b | []
| no_license | Julia9803/Yummy | 3b48118d55dd4b8c5ab535d42a27aa917a6e1177 | 2fa22f81121ac9f90b3e0e28b1df1e55e7ff6de6 | refs/heads/master | 2020-04-24T10:50:23.012040 | 2019-03-11T16:48:52 | 2019-03-11T16:48:52 | 171,907,018 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,529 | java | package edu.nju.yummy.controller;
import edu.nju.yummy.dao.*;
import edu.nju.yummy.entity.Bank;
import edu.nju.yummy.entity.OrderForm;
import edu.nju.yummy.entity.Restaurant;
import edu.nju.yummy.entity.User;
import edu.nju.yummy.model.*;
import edu.nju.yummy.service.impl.UserOrderServiceBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@RestController
public class OrderController {
@Autowired
UserOrderServiceBean userOrderServiceBean;
@Autowired
AddressRepository addressRepository;
@Autowired
RestaurantRepository restaurantRepository;
@Autowired
UserRepository userRepository;
@Autowired
OrderRepository orderRepository;
@Autowired
BankRepository bankRepository;
@RequestMapping("/userMakeOrder/addBag")
public String addBag(HttpServletRequest req, HttpSession session) {
ArrayList<BagContent> bagContents = null;
if(session.getAttribute("bag") != null) {
bagContents = (ArrayList<BagContent>) session.getAttribute("bag");
} else {
bagContents = new ArrayList<>();
}
String idCode = req.getParameter("idCode");
int foodId = Integer.parseInt(req.getParameter("foodId"));
String name = req.getParameter("name");
String type = req.getParameter("type");
int orderNum = Integer.parseInt(req.getParameter("orderNum"));
double price = Double.parseDouble(req.getParameter("price"));
User user = (User) session.getAttribute("user");
String userPhone = user.getPhoneNumber();
BagContent bagContent = new BagContent(idCode,foodId,name,type,orderNum,price,userPhone);
bagContents.add(bagContent);
session.setAttribute("bag",bagContents);
session.setAttribute("user",user);
return "SUCCESS";
}
@RequestMapping("/order")
public String order(HttpServletRequest req, HttpSession session) {
double orderMoney = Double.parseDouble(req.getParameter("orderMoney"));
double discount = Double.parseDouble(req.getParameter("discount"));
double totalMoney = Double.parseDouble(req.getParameter("totalMoney"));
ArrayList<BagContent> bagContents = (ArrayList<BagContent>) session.getAttribute("bag");
User user = userRepository.findByPhoneNumber(bagContents.get(0).getUserPhone());
Restaurant restaurant = restaurantRepository.findByIdCode(bagContents.get(0).getIdCode());
OrderForm form = new OrderForm();
form.setDelivering(false);
form.setEnsureDelivered(false);
form.setDelivered(false);
form.setCancelled(false);
form.setPayed(false);
form.setTime(new Date());
form.setRestaurantIdCode(restaurant.getIdCode());
form.setUserPhone(user.getPhoneNumber());
form.setUserAddressId(addressRepository.findByCodeAndChosenTrue(user.getEmail()).getId());
form.setOrderMoney(orderMoney);
form.setDiscount(discount);
form.setTotalMoney(totalMoney);
userOrderServiceBean.orderMeal(form,bagContents);
session.setAttribute("bag",null);
return "SUCCESS";
}
@RequestMapping("/restaurantOrder/deliver")
public String deliver(HttpServletRequest req, HttpSession session) {
int oid = Integer.parseInt(req.getParameter("oid"));
OrderForm form = orderRepository.findByOrderId(oid);
form.setDelivering(true);
form.setDelivered(false);
orderRepository.save(form);
return "SUCCESS";
}
@RequestMapping("/restaurantOrder/delivered")
public String delivered(HttpServletRequest req) {
int oid = Integer.parseInt(req.getParameter("oid"));
OrderForm form = orderRepository.findByOrderId(oid);
form.setDelivering(false);
form.setDelivered(true);
form.setEnsureDelivered(true);
orderRepository.save(form);
return "SUCCESS";
}
@RequestMapping("/userOrder/cancel")
public String cancel(HttpServletRequest req,HttpSession session) {
int oid = Integer.parseInt(req.getParameter("oid"));
User user = (User) session.getAttribute("user");
HashMap<Message,Double> res = userOrderServiceBean.cancelMeal(oid,user.getBankAccount());
if(res.containsKey(Message.SUCCESS)) {
return "退款成功!退款金额: "+res.get(Message.SUCCESS);
} else if(res.containsKey(Message.DELIVERING)) {
return "正在配送中... 退款金额:"+res.get(Message.DELIVERING);
} else if(res.containsKey(Message.DELIVERED)) {
return "已配送... 退款金额: "+res.get(Message.DELIVERED);
} else if(res.containsKey(Message.OVERTIME)) {
return "超时 退款金额: "+res.get(Message.OVERTIME);
}
return "SUCCESS";
}
@RequestMapping("/userOrder/ensure")
public String ensureDelivered(HttpServletRequest req) {
int oid = Integer.parseInt(req.getParameter("oid"));
OrderForm form = orderRepository.findByOrderId(oid);
form.setEnsureDelivered(true);
orderRepository.save(form);
return "SUCCESS";
}
}
| [
"[email protected]"
]
| |
a1374e9466fd7065c819d4edfc23262a632a285b | d8fcc754fdc90338b0209c48a150d2d2a89b71f3 | /src/main/java/doctorw/classcircle/controller/activity/LauncherActivity.java | c9c21338bc2bd0a10457369a1897f023949ea929 | []
| no_license | reggie1996/ClassCircle | 3adc7f2b203993f46b1e55a27200c11ac86f8f2a | ab1f40881e7a4b7738bb9b9095696886318c2cba | refs/heads/master | 2021-03-27T11:48:31.489331 | 2017-12-26T15:22:30 | 2017-12-26T15:22:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,853 | java | package doctorw.classcircle.controller.activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import com.hyphenate.chat.EMClient;
import doctorw.classcircle.R;
import doctorw.classcircle.model.Model;
public class LauncherActivity extends BaseActivity {
private Handler handler = new Handler(){
public void handleMessage(Message msg){
//当前Ativity已经退出 不处理handler中的消息
if(isFinishing()){
return;
}
//判断进入主页面还是登陆页面
toMainOrLogin();
}
};
private void toMainOrLogin() {
Model.getInstance().getGlobalThreadPool().execute(new Runnable() {
@Override
public void run() {
//判断当前用户是否已经登录过
if(EMClient.getInstance().isLoggedInBefore()){
//获取到当前用户信息(待处理)
//判断用户信息是否存在
//(1)不存在 跳转到登录界面
//(2)存在 跳转到主界面
Intent intent = new Intent(LauncherActivity.this,MainActivity.class);
startActivity(intent);
}else {//没登陆过
//跳转到登陆界面
Intent intent = new Intent(LauncherActivity.this,LoginActivity.class);
startActivity(intent);
}
//结束当前界面
finish();
}
});
}
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_launcher);
//
// handler.sendMessageDelayed(Message.obtain(),2000);
//// new Handler().postDelayed(new Runnable() {
//// @Override
//// public void run() {
//// //在主线程中执行
//// startMainActivity();
//// }
//// }, 2000);
// }
@Override
protected void initListener() {
}
@Override
protected void initData() {
}
@Override
protected void initView() {
}
@Override
protected void onActivityCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_launcher);
handler.sendMessageDelayed(Message.obtain(),2000);
}
/**
* 启动主页面
*/
// private void startMainActivity() {
// Intent intent = new Intent(this,MainActivity.class);
// startActivity(intent);
// //关闭当前页面
// finish();
//
// }
@Override
protected void onDestroy() {
super.onDestroy();
handler.removeCallbacks(null);
}
}
| [
"[email protected]"
]
| |
6e9c9769e48fdab2cb2493475ca4e78a4c597402 | 6399de8f9dc5d595e434ef49969cb323947f38c6 | /gen/com/project/realwar/R.java | ac23d976b324afb5e87ff7934aa0f5f3ad7a3ea0 | []
| no_license | GabMar/realwar | 5584928ca908d94725ffaa867906cb6eb9f961b0 | 295f60972d2f3518adbc8c4d703651c680399674 | refs/heads/master | 2021-01-23T12:16:45.756340 | 2014-11-15T16:23:54 | 2014-11-15T16:23:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 567 | java | /* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.project.realwar;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class string {
public static final int app_name=0x7f040000;
}
public static final class xml {
public static final int config=0x7f030000;
}
}
| [
"[email protected]"
]
| |
7ad78c4ade68090e5fd1d2fa52cfb54243aaedee | 865b8dd0c4fd37860fd4c59d27bdad8f18dcc9ca | /app/src/main/java/com/example/xdyblaster/util/DataViewModel.java | a8f1bd459b401c330d5136df467c1943468dc144 | []
| no_license | xdy-yangli/XdyBlasterOld | 81776ec73385544cd871b9bfc42a43e1cb5c1a53 | d382308e6a89ea3d1d3cffa6d88c6999443cbf62 | refs/heads/master | 2023-07-02T05:14:07.682038 | 2020-09-23T13:47:24 | 2020-09-23T13:47:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,757 | java | package com.example.xdyblaster.util;
import android.app.Application;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;
import com.baidu.mapapi.model.LatLng;
import java.util.ArrayList;
import java.util.List;
public class DataViewModel extends AndroidViewModel {
public DetonatorSetting detonatorSetting = new DetonatorSetting();
public List<DetonatorData> detonatorDatas = new ArrayList<>();
public List<List<DetonatorData>> detonatorList = new ArrayList<>();
public List<MutableLiveData<Integer>> updateList;
//public Drawable drawableG, drawableR, drawableB, drawableGray;
//public Drawable icon4, icon4s, icon5, icon5s, icon6, icon6s;
public String fileName;
public boolean ok, dataChanged = false;
public boolean enMonitorVolt;
public boolean fileLoaded, fileReload = false;
public int battStatus;
public float[] vData = new float[4];
public int ver;
// public LatLng latLng;
public MutableLiveData<Integer> volt = new MutableLiveData<>();
public MutableLiveData<Integer> offline = new MutableLiveData<>();
public MutableLiveData<Float> batt = new MutableLiveData<>();
public MutableLiveData<Integer> overCurrent = new MutableLiveData<>();
public MutableLiveData<Integer> exit = new MutableLiveData<>();
public MutableLiveData<Integer> keyF1 = new MutableLiveData<>();
public MutableLiveData<Integer> keyF2 = new MutableLiveData<>();
public int keyF3;
public MutableLiveData<Integer> romErr = new MutableLiveData<>();
public MutableLiveData<Integer> updateStep = new MutableLiveData<>();
public MutableLiveData<Integer> totalCount = new MutableLiveData<>();
public Handler keyHandler = null;
public int[] idBuffer = new int[2048];
public int[] timerBuffer = new int[2048];
public int[] areaBuffer = new int[2048];
public int[] statusBuffer = new int[2048];
public byte[] uuidBuffer = new byte[1024 * 16];
public String devId, userId = "123456789012345678";
public String devVer;
public String htid, xmbh, dwdm, jd, wd, bpsj;
public int commErr = 0, countDown = 0, overStop = 0;
public int defaultVolt;
public int systemCount = 0;
public int battPercent;
public boolean top = false;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public void InitData(String fileName) {
updateList = new ArrayList<>();
if (!fileLoaded)
FileFunc.loadDetonatorSetting(fileName, detonatorSetting);
int count = detonatorSetting.getRow();
if (count == 0)
count = 1;
resetDataList();
// int r = 0;
// List<DetonatorData> tmp = new ArrayList<>();
// for (DetonatorData d : detonatorDatas) {
// if (d.getRowNum() != r) {
// {
// detonatorList.add(tmp);
// tmp = new ArrayList<>();
// r = d.getRowNum();
// }
// }
// tmp.add(d);
// }
// detonatorList.add(tmp);
MutableLiveData<Integer> data;
for (int i = 0; i < count; i++) {
data = new MutableLiveData<>();
data.setValue(-1);
updateList.add(data);
}
}
public void resetDataList() {
List<DetonatorData> tmp;
detonatorList.clear();
int count = detonatorSetting.getRow();
if (count == 0)
count = 1;
for (int i = 0; i < count; i++) {
tmp = new ArrayList<>();
detonatorList.add(tmp);
}
}
public void addDetonatorArea() {
List<DetonatorData> tmp;
tmp = new ArrayList<>();
detonatorList.add(tmp);
MutableLiveData<Integer> data;
data = new MutableLiveData<>();
data.setValue(-1);
updateList.add(data);
detonatorSetting.setRow(detonatorList.size());
}
public void setDataList() {
int count = detonatorSetting.getRow();
int r = 0;
for (DetonatorData d : detonatorDatas) {
if (d.getRowNum() != r) {
{
updateList.get(r).postValue(-1);
r = d.getRowNum();
}
}
detonatorList.get(r).add(d);
}
//updateList.get(r).postValue("1");
}
public DataViewModel(@NonNull Application application) {
super(application);
}
@Override
protected void onCleared() {
super.onCleared();
}
}
| [
"[email protected]"
]
| |
ae0b2d19400acdbd170ba190d38e1752a4e90f75 | c90a3634f7207969badbba8a844fe2ccfbb7aa29 | /src/main/java/local/tmall_springboot/web/ProductImageController.java | e39b2c578857e30e3c6c30a9fd69050d34c3ff2f | []
| no_license | mengweidong1/tmall_springboot | a0b4565ded57e763b05b274136f764a8701702e4 | d8849ac79f5465c6214f06982eab64d2082b6a31 | refs/heads/master | 2020-06-26T21:24:38.001787 | 2018-12-25T10:18:18 | 2018-12-25T10:18:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,983 | java | package local.tmall_springboot.web;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import local.tmall_springboot.pojo.Product;
import local.tmall_springboot.pojo.ProductImage;
import local.tmall_springboot.service.CategoryService;
import local.tmall_springboot.service.ProductImageService;
import local.tmall_springboot.service.ProductService;
import local.tmall_springboot.util.ImageUtil;
@RestController
public class ProductImageController {
@Autowired
ProductService productService;
@Autowired
ProductImageService productImageService;
@Autowired
CategoryService categoryService;
@GetMapping("/products/{pid}/productImages")
public List<ProductImage> list(@RequestParam("type") String type, @PathVariable("pid") int pid) throws Exception {
Product product = productService.get(pid);
if (ProductImageService.SINGLE.equals(type)) {
List<ProductImage> singles = productImageService.listSingleProductImages(product);
return singles;
} else if (ProductImageService.DETAIL.equals(type)) {
List<ProductImage> details = productImageService.listDetailProductImages(product);
return details;
} else {
return new ArrayList<>();
}
}
@PostMapping("/productImages")
public Object add(@RequestParam("pid") int pid, @RequestParam("type") String type, MultipartFile image,
HttpServletRequest request) throws Exception {
ProductImage bean = new ProductImage();
Product product = productService.get(pid);
bean.setProduct(product);
bean.setType(type);
productImageService.add(bean);
String folder = "img/";
if (ProductImageService.SINGLE.equals(bean.getType())) {
folder += "productSingle";
} else {
folder += "productDetail";
}
File imageFolder = new File(request.getServletContext().getRealPath(folder));
File file = new File(imageFolder, bean.getId() + ".jpg");
String fileName = file.getName();
if (!file.getParentFile().exists())
file.getParentFile().mkdirs();
try {
image.transferTo(file);
BufferedImage img = ImageUtil.change2jpg(file);
ImageIO.write(img, "jpg", file);
} catch (IOException e) {
e.printStackTrace();
}
if (ProductImageService.SINGLE.equals(bean.getType())) {
String imageFolder_small = request.getServletContext().getRealPath("img/productSingle_small");
String imageFolder_middle = request.getServletContext().getRealPath("img/productSingle_middle");
File f_small = new File(imageFolder_small, fileName);
File f_middle = new File(imageFolder_middle, fileName);
f_small.getParentFile().mkdirs();
f_middle.getParentFile().mkdirs();
ImageUtil.resizeImage(file, 56, 56, f_small);
ImageUtil.resizeImage(file, 217, 190, f_middle);
}
return bean;
}
@DeleteMapping("/productImages/{id}")
public String delete(@PathVariable("id") int id, HttpServletRequest request) throws Exception {
ProductImage bean = productImageService.get(id);
productImageService.delete(id);
String folder = "img/";
if (ProductImageService.SINGLE.equals(bean.getType()))
folder += "productSingle";
else
folder += "productDetail";
File imageFolder = new File(request.getServletContext().getRealPath(folder));
File file = new File(imageFolder, bean.getId() + ".jpg");
String fileName = file.getName();
file.delete();
if (ProductImageService.SINGLE.equals(bean.getType())) {
String imageFolder_small = request.getServletContext().getRealPath("img/productSingle_small");
String imageFolder_middle = request.getServletContext().getRealPath("img/productSingle_middle");
File f_small = new File(imageFolder_small, fileName);
File f_middle = new File(imageFolder_middle, fileName);
f_small.delete();
f_middle.delete();
}
return null;
}
} | [
"[email protected]"
]
| |
40336ee3261825c948b7b51633c229bf3aec4800 | 33b1e78c75586aa096e208bf3a88f45b71861e43 | /src/main/java/com/juanma/twitterCli/service/package-info.java | 3b41b1ad0f295b63bc18993d70228fea11fbd00d | []
| no_license | jhernandezdi/twitterCli | 90f4f79a5d2152394942dd85d5b00a60c1976d15 | 330cc7e1498bef44ac546a07602f5762a630e76a | refs/heads/main | 2023-06-12T08:01:16.353053 | 2021-06-28T18:03:38 | 2021-06-28T18:03:38 | 381,106,110 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 71 | java | /**
* Service layer beans.
*/
package com.juanma.twitterCli.service;
| [
"[email protected]"
]
| |
768b2401b045aa6e820d2d29bb89199dc9057fe2 | c99ca561cf6136bf8e5af58efb89509f998d5952 | /app/src/main/java/com/example/rupali/movieforest/MainActivity.java | 1f427c038a399862e20de343f539cafd5c60dac5 | []
| no_license | rupali186/Movie-Forest | aa6011e731d086c235c31cbeb58074ebcd48f31a | e12a4ec607e45666a7bf7aa03c3f13d59b2efab7 | refs/heads/master | 2020-03-12T04:33:21.256388 | 2018-04-21T06:41:24 | 2018-04-21T06:41:24 | 130,447,366 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,805 | java | package com.example.rupali.movieforest;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.facebook.AccessToken;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.GraphRequest;
import com.facebook.GraphResponse;
import com.facebook.HttpMethod;
import com.facebook.Profile;
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
import org.json.JSONException;
import org.json.JSONObject;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class MainActivity extends AppCompatActivity {
TextView skip;
ViewPager viewPager;
ViewPagerAdapter adapter;
LoginButton loginButton;
CallbackManager callbackManager;
String username=null;
String url=null;
String userId;
URL profilePicture;
String firstName;
private LinearLayout llPagerDots;
private ImageView[] ivArrayDotsPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
skip=findViewById(R.id.skip);
skip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SharedPreferences sharedPreferences=getSharedPreferences(Constants.SHARED_PREF_NAME,MODE_PRIVATE);
SharedPreferences.Editor editor=sharedPreferences.edit();
editor.putString(Constants.LOGIN_NAME,"Guest");
editor.putBoolean(Constants.CONNECT_WITH_FACEBOOK,false);
editor.putBoolean(Constants.PREVIOUSLY_STARTED,true);
editor.commit();
Intent intent=new Intent(MainActivity.this,HomeActivity.class);
startActivity(intent);
finish();
}
});
viewPager=findViewById(R.id.viewPager);
llPagerDots = (LinearLayout)findViewById(R.id.pager_dots);
adapter=new ViewPagerAdapter(this);
viewPager.setAdapter(adapter);
setupPagerIndidcatorDots();
ivArrayDotsPager[0].setImageResource(R.drawable.selected_dot);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener()
{
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
for (int i = 0; i < ivArrayDotsPager.length; i++) {
ivArrayDotsPager[i].setImageResource(R.drawable.unselected_dot);
}
ivArrayDotsPager[position].setImageResource(R.drawable.selected_dot);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
callbackManager = CallbackManager.Factory.create();
loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
loginButton.setReadPermissions(Arrays.asList("email","public_profile"));
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Bundle params = new Bundle();
params.putString("fields", "id,email,first_name,gender,cover,picture.type(large)");
new GraphRequest(loginResult.getAccessToken(), "me", params, HttpMethod.GET,
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
if (response != null) {
try {
String profilePicUrl=new String();
JSONObject data = response.getJSONObject();
if (data.has("picture")) {
profilePicUrl = data.getJSONObject("picture").getJSONObject("data").getString("url");
}
if(data.has("first_name")){
firstName=data.getString("first_name");
}
Log.d("New",firstName+" "+profilePicUrl);
SharedPreferences sharedPreferences=getSharedPreferences(Constants.SHARED_PREF_NAME,MODE_PRIVATE);
SharedPreferences.Editor editor=sharedPreferences.edit();
editor.putString(Constants.LOGIN_NAME,firstName);
editor.putBoolean(Constants.CONNECT_WITH_FACEBOOK,true);
editor.putString(Constants.LOGIN_PROFILE_URL,profilePicUrl);
editor.putBoolean(Constants.PREVIOUSLY_STARTED,true);
editor.commit();
Intent intent=new Intent(MainActivity.this,HomeActivity.class);
startActivity(intent);
Log.d("Fb","try");
finish();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}).executeAsync();
// App code
}
@Override
public void onCancel() {
// App code
}
@Override
public void onError(FacebookException exception) {
// App code
}
});
}
});
// LoginManager.getInstance().registerCallback(callbackManager,
// new FacebookCallback<LoginResult>() {
// @Override
// public void onSuccess(LoginResult loginResult) {
// // App code
// }
//
// @Override
// public void onCancel() {
// // App code
// }
//
// @Override
// public void onError(FacebookException exception) {
// // App code
// }
// });
// boolean loggedIn = AccessToken.getCurrentAccessToken() == null;
// LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile"));
}
private void setupPagerIndidcatorDots() {
ivArrayDotsPager = new ImageView[6];
for (int i = 0; i < ivArrayDotsPager.length; i++) {
ivArrayDotsPager[i] = new ImageView(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(5, 0, 5, 0);
ivArrayDotsPager[i].setLayoutParams(params);
ivArrayDotsPager[i].setImageResource(R.drawable.unselected_dot);
//ivArrayDotsPager[i].setAlpha(0.4f);
ivArrayDotsPager[i].setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view) {
view.setAlpha(1);
}
});
llPagerDots.addView(ivArrayDotsPager[i]);
//
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
callbackManager.onActivityResult(requestCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}
}
| [
"[email protected]"
]
| |
fb5dedba47a676f839a7a65f76a3f4f6406a1dd4 | 45f05c515e311d16eb48094b6d6617d6b6987397 | /lucihunt-lucene4.10/src/main/java/org/apache/lucene/search/similarities/DFRSimilarity.java | 29a616132c3032931e751c3f83b5d3dbca45eedf | [
"Apache-2.0"
]
| permissive | lemonJun/LuciHunt | 5328dd270e891e302bf985a1a2517dcaa95def9d | 08c71f80be580e5ebcbb519eb2aff1f3cfee55a8 | refs/heads/master | 2021-01-18T19:32:47.065466 | 2017-05-03T09:52:13 | 2017-05-03T09:52:13 | 86,899,911 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,264 | java | package org.apache.lucene.search.similarities;
/*
* 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.
*/
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.similarities.AfterEffect.NoAfterEffect;
import org.apache.lucene.search.similarities.Normalization.NoNormalization;
/**
* Implements the <em>divergence from randomness (DFR)</em> framework
* introduced in Gianni Amati and Cornelis Joost Van Rijsbergen. 2002.
* Probabilistic models of information retrieval based on measuring the
* divergence from randomness. ACM Trans. Inf. Syst. 20, 4 (October 2002),
* 357-389.
* <p>The DFR scoring formula is composed of three separate components: the
* <em>basic model</em>, the <em>aftereffect</em> and an additional
* <em>normalization</em> component, represented by the classes
* {@code BasicModel}, {@code AfterEffect} and {@code Normalization},
* respectively. The names of these classes were chosen to match the names of
* their counterparts in the Terrier IR engine.</p>
* <p>To construct a DFRSimilarity, you must specify the implementations for
* all three components of DFR:
* <ol>
* <li>{@link BasicModel}: Basic model of information content:
* <ul>
* <li>{@link BasicModelBE}: Limiting form of Bose-Einstein
* <li>{@link BasicModelG}: Geometric approximation of Bose-Einstein
* <li>{@link BasicModelP}: Poisson approximation of the Binomial
* <li>{@link BasicModelD}: Divergence approximation of the Binomial
* <li>{@link BasicModelIn}: Inverse document frequency
* <li>{@link BasicModelIne}: Inverse expected document
* frequency [mixture of Poisson and IDF]
* <li>{@link BasicModelIF}: Inverse term frequency
* [approximation of I(ne)]
* </ul>
* <li>{@link AfterEffect}: First normalization of information
* gain:
* <ul>
* <li>{@link AfterEffectL}: Laplace's law of succession
* <li>{@link AfterEffectB}: Ratio of two Bernoulli processes
* <li>{@link NoAfterEffect}: no first normalization
* </ul>
* <li>{@link Normalization}: Second (length) normalization:
* <ul>
* <li>{@link NormalizationH1}: Uniform distribution of term
* frequency
* <li>{@link NormalizationH2}: term frequency density inversely
* related to length
* <li>{@link NormalizationH3}: term frequency normalization
* provided by Dirichlet prior
* <li>{@link NormalizationZ}: term frequency normalization provided
* by a Zipfian relation
* <li>{@link NoNormalization}: no second normalization
* </ul>
* </ol>
* <p>Note that <em>qtf</em>, the multiplicity of term-occurrence in the query,
* is not handled by this implementation.</p>
* @see BasicModel
* @see AfterEffect
* @see Normalization
* @lucene.experimental
*/
public class DFRSimilarity extends SimilarityBase {
/** The basic model for information content. */
protected final BasicModel basicModel;
/** The first normalization of the information content. */
protected final AfterEffect afterEffect;
/** The term frequency normalization. */
protected final Normalization normalization;
/**
* Creates DFRSimilarity from the three components.
* <p>
* Note that <code>null</code> values are not allowed:
* if you want no normalization or after-effect, instead pass
* {@link NoNormalization} or {@link NoAfterEffect} respectively.
* @param basicModel Basic model of information content
* @param afterEffect First normalization of information gain
* @param normalization Second (length) normalization
*/
public DFRSimilarity(BasicModel basicModel, AfterEffect afterEffect, Normalization normalization) {
if (basicModel == null || afterEffect == null || normalization == null) {
throw new NullPointerException("null parameters not allowed.");
}
this.basicModel = basicModel;
this.afterEffect = afterEffect;
this.normalization = normalization;
}
@Override
protected float score(BasicStats stats, float freq, float docLen) {
float tfn = normalization.tfn(stats, freq, docLen);
return stats.getTotalBoost() * basicModel.score(stats, tfn) * afterEffect.score(stats, tfn);
}
@Override
protected void explain(Explanation expl, BasicStats stats, int doc, float freq, float docLen) {
if (stats.getTotalBoost() != 1.0f) {
expl.addDetail(new Explanation(stats.getTotalBoost(), "boost"));
}
Explanation normExpl = normalization.explain(stats, freq, docLen);
float tfn = normExpl.getValue();
expl.addDetail(normExpl);
expl.addDetail(basicModel.explain(stats, tfn));
expl.addDetail(afterEffect.explain(stats, tfn));
}
@Override
public String toString() {
return "DFR " + basicModel.toString() + afterEffect.toString() + normalization.toString();
}
/**
* Returns the basic model of information content
*/
public BasicModel getBasicModel() {
return basicModel;
}
/**
* Returns the first normalization
*/
public AfterEffect getAfterEffect() {
return afterEffect;
}
/**
* Returns the second normalization
*/
public Normalization getNormalization() {
return normalization;
}
}
| [
"[email protected]"
]
| |
6c51978bd25d3345377a15af22ec3cf39cf8475f | fed7a2f703447534ea5feff1d913c6a7f3e43fd3 | /mifosng-provider/src/main/java/org/mifosng/platform/exceptions/SavingAccountNotFoundException.java | 5e77dc8d0dfa477fe497a669af225357d3cb9e15 | []
| no_license | srilathan/mifosx | bf866e958a94b676fd5ac322a11a752c9a5c0986 | 7ac55812d6bdce4c3b6ab80637d8f860c62c8531 | refs/heads/master | 2021-01-17T22:31:35.323260 | 2012-11-30T16:35:01 | 2012-11-30T16:35:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 313 | java | package org.mifosng.platform.exceptions;
public class SavingAccountNotFoundException extends AbstractPlatformResourceNotFoundException {
public SavingAccountNotFoundException(final Long id) {
super("error.msg.saving.account.id.invalid", "Saving account with identifier " + id + " does not exist", id);
}
}
| [
"[email protected]"
]
| |
c2f219b2cb78c1ac74d0d35e711c202fbdb8ecc5 | 60dccf85afb1a2331e1a7ef6dcbd770b5cec079f | /app/src/main/java/com/weiping/InteProperty/trademark/activity/TradeMarkIntegratedResultListActivity.java | fb5137108fe2df9f1022ada99c1d6e7a064ede26 | []
| no_license | HZSF/WQAndroid | 69f1c62e67166dc8226bb22f576f3e956e1e720a | cc301d75e5f3c4ac4a9ebbe40c91c9023d47afdb | refs/heads/master | 2021-01-18T19:30:48.457958 | 2017-04-01T09:01:37 | 2017-04-01T09:01:37 | 86,895,874 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,381 | java | package com.weiping.InteProperty.trademark.activity;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import com.weiping.InteProperty.trademark.adapters.TrademarkIntegratedResultListAdapter;
import com.weiping.InteProperty.trademark.base.TrademarkIntegratedResultItem;
import com.weiping.InteProperty.trademark.core.Constants;
import java.util.ArrayList;
import platform.tyk.weping.com.weipingplatform.R;
public class TradeMarkIntegratedResultListActivity extends Activity {
private ArrayList<TrademarkIntegratedResultItem> itemArrayList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setCustomView(R.layout.actionbar_common);
((TextView)actionBar.getCustomView().findViewById(R.id.textView_screen_title)).setText(getString(R.string.title_activity_trade_mark_integrated_result_list));
actionBar.getCustomView().findViewById(R.id.linearLayout_actionbar_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
setContentView(R.layout.activity_trade_mark_integrated_result_list);
itemArrayList = (ArrayList<TrademarkIntegratedResultItem>)getIntent().getSerializableExtra("result_list");
final String sort_result_num = getIntent().getStringExtra("result_sort_num");
final String search_by = getIntent().getStringExtra("search_by");
TrademarkIntegratedResultListAdapter adapter = new TrademarkIntegratedResultListAdapter(this, itemArrayList);
ListView listView = (ListView)findViewById(R.id.listView_trademark_integrated_result);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ArrayList<TrademarkIntegratedResultItem> trademarkList = ((TrademarkIntegratedResultListAdapter)parent.getAdapter()).getItemArrayList();
String categoryNum = trademarkList.get(position).getCategoryNum();
String name = trademarkList.get(position).getName();
String link = trademarkList.get(position).getLink();
Intent intent = new Intent(getBaseContext(), TradeMarkIntegratedPrecisionResultListActivity.class);
intent.putExtra(Constants.SUBMIT_DATA_CATEGORYNUM, categoryNum);
intent.putExtra(Constants.SUBMIT_DATA_SEARCHCONTENT, name);
intent.putExtra(Constants.SUBMIT_DATA_RESULT_SORT_NUM, sort_result_num);
intent.putExtra(Constants.SUBMIT_DATA_SEARCHMETHOD, search_by);
intent.putExtra(Constants.SUBMIT_DATA_LINK, link);
startActivity(intent);
}
});
}
public void onClickActionBarBack(View view){
onBackPressed();
}
}
| [
"[email protected]"
]
| |
2fb3f574c2ca1c5427591687da6be59cd622e584 | 7878d6f07e2b1751911b694d88e1173ba767762d | /src/controllers/UpdateServlet.java | 904ea1b8373d42db75b68091df38b827259fbd31 | []
| no_license | kazuki-shibuya2/kadai-tasklist | ecc55c6089e58cad06357bb2f3f1caca43f9a50a | c6c7cf7a664030cc638e70a7f5fea09407ce00b9 | refs/heads/main | 2023-03-04T16:39:31.497369 | 2021-02-21T06:53:49 | 2021-02-21T06:53:49 | 340,805,260 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,885 | java | package controllers;
import java.io.IOException;
import java.sql.Timestamp;
import javax.persistence.EntityManager;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import models.Task;
import utils.DBUtil;
@WebServlet("/update")
public class UpdateServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public UpdateServlet() {
super();
// TODO Auto-generated constructor stub
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String _token = request.getParameter("_token");
if(_token != null && _token.equals(request.getSession().getId())) {
EntityManager em = DBUtil.createEntityManager();
Task t = em.find(Task.class, (Integer)(request.getSession().getAttribute("task_id")));
// フォームの内容を各フィールドに上書き
String title = request.getParameter("title");
t.setTitle(title);
String content = request.getParameter("content");
t.setContent(content);
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
t.setUpdated_at(currentTime); // 更新日時のみ上書き
// データベースを更新
em.getTransaction().begin();
em.getTransaction().commit();
em.close();
// セッションスコープ上の不要になったデータを削除
request.getSession().removeAttribute("task_id");
// indexページへリダイレクト
response.sendRedirect(request.getContextPath() + "/index");
}
}
}
| [
"[email protected]"
]
| |
138b82b5c5e18105e280349ef11374bd134e0a00 | 1ad7efd49103d9176969d65d0ecf9549e1702cb2 | /morlglue-clients/agents/TLO_Agent_Option.java | 938c8a8b98fb0c6e367efeefa5a684c2b69a1cef | [
"Apache-2.0"
]
| permissive | FedUni/MORL | d76cd2c1e9f8b842dcbc814fef1e9efba6f70876 | 59a71a1dee661e3948501e619c8110a8555fc818 | refs/heads/master | 2023-04-29T09:58:52.721818 | 2023-04-17T05:22:33 | 2023-04-17T05:22:33 | 83,627,441 | 29 | 2 | null | null | null | null | UTF-8 | Java | false | false | 13,985 | java | package agents;
import java.util.Stack;
import org.rlcommunity.rlglue.codec.AgentInterface;
import org.rlcommunity.rlglue.codec.taskspec.TaskSpecVRLGLUE3;
import org.rlcommunity.rlglue.codec.types.Action;
import org.rlcommunity.rlglue.codec.types.Observation;
import org.rlcommunity.rlglue.codec.types.Reward;
import org.rlcommunity.rlglue.codec.util.AgentLoader;
import tools.staterep.DummyStateConverter;
import tools.staterep.interfaces.StateConverter;
import tools.traces.StateActionIndexPair;
import tools.valuefunction.TLO_Option_LookupTable;
import tools.valuefunction.TLO_LookupTable;
import tools.valuefunction.interfaces.ActionSelector;
public class TLO_Agent_Option implements AgentInterface
{
double thresholds[];
int numThresholds;
int currentOption; // the current option been followed
TLO_Option_LookupTable vf = null;
Stack<StateActionIndexPair> tracingStack = null;
private boolean policyFrozen = false;
private int numActions = 0;
private int numStates = 0;
private int numOptions = 0;
private int numOfObjectives;
private int [][] getAction;
private final double initQValues[]={0,0,0};
int explorationStrategy; // flag used to indicate which type of exploration strategy is being used
//if using eGreedy exploration
double startingEpsilon;
double epsilonLinearDecay;
double epsilon;
// if using softmax selection
double startingTemperature;
double endingTemperature;
double temperatureDecayRatio;
double temperature;
double startingAlpha, alpha, alphaDecay;
double gamma;
double lambda;
final int MAX_STACK_SIZE = 20;
int numOfSteps;
int numEpisodes;
boolean greedyFlag;
StateConverter stateConverter = null;
@Override
public void agent_init(String taskSpecification) {
System.out.println("TLO_Agent_Option launched");
TaskSpecVRLGLUE3 theTaskSpec = new TaskSpecVRLGLUE3(taskSpecification);
numActions = theTaskSpec.getDiscreteActionRange(0).getMax() + 1;
numStates = theTaskSpec.getDiscreteObservationRange(0).getMax()+1;
numOfObjectives = theTaskSpec.getNumOfObjectives();
numThresholds = numOfObjectives-1;
thresholds = new double[numThresholds];
getAction = createOptionAction(numStates, numActions);
// we aren't creating the lookup table at this stage - need to defer that until we get the message telling us
// what the thresholds are - that needs to happen before the first trial is started
tracingStack = new Stack<>();
//set the model of converting MDP observation to an int state representation
stateConverter = new DummyStateConverter();
}
private void resetForNewTrial()
{
policyFrozen = false;
numOfSteps = 0;
numEpisodes = 0;
epsilon = startingEpsilon;
temperature = startingTemperature;
alpha = startingAlpha;
// reset Q-values
vf.resetQValues(initQValues);
}
private void resetForNewEpisode()
{
if (!policyFrozen){
numEpisodes++;
}
numOfSteps = 0;
// reset the tracingStack
tracingStack.clear();
}
@Override
public Action agent_start(Observation observation) {
resetForNewEpisode();
int state = stateConverter.getStateNumber( observation );
currentOption = getOption(state);
greedyFlag = isGreedy(state, currentOption);
int action = getAction[state][currentOption];
Action returnAction = new Action(1, 0, 0);
returnAction.intArray[0] = action;
Action returnOption = new Action(1, 0, 0);
returnOption.intArray[0] = currentOption;
tracingStack.add(new StateActionIndexPair(state, returnOption)); // put executed option on the stack
return returnAction;
}
@Override
public Action agent_step(Reward reward, Observation observation)
{
numOfSteps++;
int state = stateConverter.getStateNumber( observation );
int action = getAction[state][currentOption];
if (!policyFrozen) {
double currentLambda = lambda;
for (int i = tracingStack.size() - 1; i >= 0; i--) {
StateActionIndexPair pair = tracingStack.get(i);
int prevOption = pair.getAction().getInt(0);
int prevState = pair.getState();
if (i + 1 == tracingStack.size()) // this is the most recent action
{
vf.calculateErrors(prevOption, prevState, currentOption, state, gamma, reward);
vf.update(prevOption, prevState, 1.0, alpha);
}
else {
// if there is no more recent entry for this state-action pair then update it
// this is to implement replacing rather than accumulating traces
int index = tracingStack.indexOf(pair, i + 1);
if (index == -1) {
vf.update(prevOption, prevState, currentLambda, alpha);
}
currentLambda *= lambda;
}
}
}
Action returnOption = new Action(1, 0, 0);
returnOption.intArray[0] = currentOption;
// clear trace if this Option is not greedy, otherwise trim stack if neccesary
// if (greedyFlag)
// {
if( tracingStack.size() == MAX_STACK_SIZE )
{
tracingStack.remove(0);
}
// }
// else
// {
// tracingStack.clear();
// }
// in either case, can now add this state-action to the trace stack
tracingStack.add( new StateActionIndexPair(state, returnOption) );
Action returnAction = new Action(1, 0, 0);
returnAction.intArray[0] = action;
return returnAction;
}
@Override
public void agent_end(Reward reward)
{
numOfSteps++;
epsilon -= epsilonLinearDecay;
temperature *= temperatureDecayRatio;
alpha -= alphaDecay;
if (!policyFrozen) {
double currentLambda = lambda;
for (int i = tracingStack.size() - 1; i >= 0; i--) {
StateActionIndexPair pair = tracingStack.get(i);
int prevOption = pair.getAction().getInt(0);
int prevState = pair.getState();
if (i + 1 == tracingStack.size())
{
vf.calculateTerminalErrors(prevOption, prevState, gamma, reward);
vf.update(prevOption, prevState, 1.0, alpha);
}
else
{
// if there is no more recent entry for this state-action pair then update it
// this is to implement replacing rather than accumulating traces
int index = tracingStack.indexOf(pair, i + 1);
if (index == -1) {
vf.update(prevOption, prevState, currentLambda, alpha);
}
currentLambda *= lambda;
}
}
}
}
@Override
public void agent_cleanup() {
vf = null;
policyFrozen = false;
}
private int [] [] createOptionAction(int numStates, int numActions) {
// base, exponent
numOptions = (int) Math.pow(numActions, (numStates-1)); // don't count the terminal state
int[][] getAction = new int [numStates][numOptions];
for (int s=0; s<numStates-1; s++){
for (int o=0; o<numOptions; o++){
if(s==0){
getAction[s][o] = o/numActions;
}
if(s==1){
getAction[s][o] = o%numActions;
}
}
}
return getAction;
}
private int getOption(int state) {
int option;
if (!policyFrozen)
{
switch (explorationStrategy)
{
case TLO_LookupTable.EGREEDY:
option = vf.choosePossiblyExploratoryAction(epsilon, state);
break;
case TLO_LookupTable.SOFTMAX_TOURNAMENT:
//action = valueFunction.choosePossiblyExploratoryAction(temperature, state);
//break;
case TLO_LookupTable.SOFTMAX_ADDITIVE_EPSILON :
option = vf.choosePossiblyExploratoryAction(temperature, state);
break;
default:
option = -1; // this should never happen - if it does we'll return an invalid value to force the program to halt
}
}
else
{
option = vf.chooseGreedyAction(state);
}
return option;
}
// returns true if the specified option is amongst the greedy options for the
// specified state, false otherwise
private boolean isGreedy(int state, int option){
ActionSelector valueFunction = (ActionSelector) vf;
return valueFunction.isGreedy(state, option);
}
@Override
public String agent_message(String message) {
if (message.equals("get_agent_name")){
return "TLO_Agent_Option";
}
if (message.equals("freeze_learning")) {
policyFrozen = true;
System.out.println("Learning has been freezed");
return "message understood, policy frozen";
}
if (message.startsWith("change_weights")){
System.out.print("TLO_Agent_Option: Weights can not be changed");
return "TLO_Agent_Option: Weights can not be changed";
}
// This is a really important message as its sets the TLO parameters and allows for the creation of the LookUp Table at the
// right size for the augmented state - this must happen before a trial can be run
if (message.startsWith("set_TLO_parameters")){
System.out.println(message);
String[] parts = message.split(" ");
// iterate through the thresholded objectives, loading the discretisation and thresholding settings into the arrays
for (int i=0; i<numThresholds; i++)
{
thresholds[i] = Double.valueOf(parts[i+1]).doubleValue();
System.out.println("Objective " + i + " / " + thresholds[i]);
}
vf = new TLO_Option_LookupTable(numOfObjectives, numOptions, numStates, 0, thresholds);
System.out.println();
return "TLO parameters set";
}
if (message.startsWith("set_learning_parameters")){
System.out.println(message);
String[] parts = message.split(" ");
startingAlpha = Double.valueOf(parts[1]).doubleValue();
lambda = Double.valueOf(parts[2]).doubleValue();
gamma = Double.valueOf(parts[3]).doubleValue();
explorationStrategy = Integer.valueOf(parts[4]).intValue();
alphaDecay = Double.valueOf(parts[5]).doubleValue();
vf.setExplorationStrategy(explorationStrategy);
System.out.print("Alpha = " + startingAlpha + " Lambda = " + lambda + " Gamma = " + gamma + " exploration = " + TLO_LookupTable.explorationStrategyToString(explorationStrategy) + " alpha decay = " +alphaDecay);
System.out.println();
return "Learning parameters set";
}
//////
if (message.startsWith("print_lookup_table")){
for(int i=0;i<numStates;i++){
vf.printQValues(i);
}
return "Print the lookup table";
}
if(message.equals("print_policy")){
return "&"+ vf.chooseGreedyAction(0);
}
if(message.equals("get_q_value")){
String q_value_string = "";
for(int i=0; i< numOptions; i++){
q_value_string += "&" + vf.getQValues(i, 0)[0] + "&" + vf.getQValues(i, 0)[1];
}
return q_value_string;
}
if (message.startsWith("set_egreedy_parameters")){
String[] parts = message.split(" ");
startingEpsilon = Double.valueOf(parts[1]).doubleValue();
epsilonLinearDecay = startingEpsilon / Double.valueOf(parts[2]).doubleValue(); // 2nd param is number of online episodes over which e should decay to 0
System.out.println("Starting epsilon changed to " + startingEpsilon);
return "egreedy parameters changed";
}
if (message.startsWith("set_softmax_parameters")){
String[] parts = message.split(" ");
startingTemperature = Double.valueOf(parts[1]).doubleValue();
int numEpisodes = Integer.valueOf(parts[2]).intValue(); // 2nd param is number of online episodes over which temperature should decay to 0.01
endingTemperature = Double.valueOf(parts[3]).doubleValue();
temperatureDecayRatio = Math.pow(endingTemperature/startingTemperature,1.0/numEpisodes);
System.out.println("Starting temperature changed to " + startingTemperature + " Decay ratio = " + temperatureDecayRatio);
return "softmax parameters changed";
}
else if (message.equals("start_new_trial")){
resetForNewTrial();
System.out.println("New trial started: Q-values and other variables reset");
return "New trial started: Q-values and other variables reset";
}
else if (message.equals("start-debugging")){
return "Debugging enabled in agent";
}
else if (message.equals("stop-debugging")){
return "Debugging disabled in agent";
}
System.out.println("TLO_Agent_Option - unknown message: " + message);
return "TLO_Agent_Option does not understand your message.";
}
public static void main(String[] args) {
AgentLoader theLoader = new AgentLoader( new TLO_Agent_Option() );
theLoader.run();
}
}
| [
"[email protected]"
]
| |
154a403d6de4697874a9971bd205a1268fd92be6 | cfebfbc10e0c7a4a40718916bdf96b451068a414 | /app/src/main/java/com/ekeitho/github2/GithubApplication.java | f9af514920215d2e46a122207ca8ec068c3c2bab | []
| no_license | ekeitho/gitty | d5ac1d8a33ec206b81f7b86c3444b1ecc11c3cde | bab197b6004197fdbd478c287dc719cf0dab9934 | refs/heads/master | 2021-01-24T11:04:03.718812 | 2017-02-17T03:20:59 | 2017-02-17T03:20:59 | 70,270,802 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 618 | java | package com.ekeitho.github2;
import android.app.Application;
import com.ekeitho.github2.dagger.components.AppComponent;
import com.ekeitho.github2.dagger.components.DaggerAppComponent;
import com.ekeitho.github2.dagger.modules.AppModule;
public class GithubApplication extends Application {
private AppComponent appComponent;
@Override
public void onCreate() {
appComponent = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.build();
super.onCreate();
}
public AppComponent getAppComponent() {
return appComponent;
}
}
| [
"[email protected]"
]
| |
1a2eca053f599ad7e06c39655a7dca7a49140a23 | 398ef9e2f6d5e5a9fd727af8c08c68bac66900dd | /app/src/main/java/com/mooc/ppjoke/ui/binding_adpter/CommonBindingAdapter.java | 1abea7a902a3e3618048128c49843f332d520933 | []
| no_license | riomarksafk/Jetpack-MVVM-PPJoke | 165b83ab910d4b9bd0a623885e79ea7686deb941 | 36e2f2fd622e6953399270433cc45a13f40145de | refs/heads/master | 2023-05-21T15:03:22.648828 | 2021-06-08T07:39:43 | 2021-06-08T07:39:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,652 | java | package com.mooc.ppjoke.ui.binding_adpter;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.databinding.BindingAdapter;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2;
import com.bumptech.glide.Glide;
import com.github.chrisbanes.photoview.PhotoView;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.material.appbar.AppBarLayout;
import com.mooc.libarchitecture.utils.ClickUtils;
import com.mooc.libarchitecture.utils.Utils;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
public class CommonBindingAdapter {
@BindingAdapter(value = {"imageUrl"}, requireAll = false)
public static void setImageUrl(PhotoView photoView, String imageUrl) {
Glide.with(photoView.getContext()).load(imageUrl).into(photoView);
}
@BindingAdapter(value = {"player"}, requireAll = false)
public static void setPlayer(PlayerView playerview, SimpleExoPlayer player) {
playerview.setPlayer(player);
}
@BindingAdapter(value = {"offsetChangeListener"}, requireAll = false)
public static void setOffsetChangeListener(AppBarLayout appBarLayout, AppBarLayout.OnOffsetChangedListener offsetChangeListener) {
appBarLayout.addOnOffsetChangedListener(offsetChangeListener);
}
@BindingAdapter(value = {"onRefreshListener"}, requireAll = false)
public static void setOffsetChangeListener(SmartRefreshLayout refreshLayout, OnRefreshListener listener) {
refreshLayout.setOnRefreshListener(listener);
}
@BindingAdapter(value = {"onLoadMoreListener"}, requireAll = false)
public static void setOnLoadMoreListener(SmartRefreshLayout refreshLayout, OnLoadMoreListener listener) {
refreshLayout.setOnLoadMoreListener(listener);
}
@BindingAdapter(value = {"currentItem"}, requireAll = false)
public static void bindCurrentItem(ViewPager2 viewPager2, int currentItem) {
viewPager2.setCurrentItem(currentItem, true);
}
@BindingAdapter(value = {"onClickWithDebouncing"}, requireAll = false)
public static void onClickWithDebouncing(View view, View.OnClickListener clickListener) {
ClickUtils.applySingleDebouncing(view, clickListener);
}
@BindingAdapter(value = "showSoftInputMethod")
public static void showSoftInputMethod(AppCompatEditText editText, boolean show) {
if (show) {
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
//请求获得焦点
editText.requestFocus();
InputMethodManager manager = (InputMethodManager) Utils.getApp().getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
manager.showSoftInput(editText, 0);
}
}
@BindingAdapter(value = {"alpha"}, requireAll = false)
public static void setImageRes(ImageView imageView, int alpha) {
imageView.setAlpha(alpha);
}
@BindingAdapter(value = {"enabled"}, requireAll = false)
public static void setImageRes(ImageView imageView, boolean enabled) {
imageView.setEnabled(enabled);
}
@BindingAdapter(value = {"removedItemDecoration"}, requireAll = false)
public static void removeItemDecorationAt(RecyclerView recyclerView, int item) {
recyclerView.removeItemDecorationAt(item);
}
@BindingAdapter(value = {"scrollToPosition"}, requireAll = false)
public static void scrollToPosition(RecyclerView recyclerView, int position) {
recyclerView.scrollToPosition(position);
}
}
| [
"1025618933@qq,com"
]
| 1025618933@qq,com |
6f7c97f6aadf7a235e257bc7449291523b08d7d9 | a6cef8f362296087cfb8977599ae465e88b909f3 | /src/experiments/ParamsCreator.java | c6bc642c03e383d388ed826998aecacdd99939f3 | []
| no_license | eblyn/MagicSquare | 4b4211e402075cf762d52d963641e52f6cf733c7 | 54d88c9540b0658811146631c5ded5a969bb032a | refs/heads/master | 2020-03-15T07:52:09.622551 | 2019-12-08T15:50:14 | 2019-12-08T15:50:14 | 132,038,955 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,834 | java | package experiments;
import solvers.SolverName;
import apcs.ActionFactory;
import apcs.GAParams;
import apcs.IndiParams;
import apcs.RuleParams;
public class ParamsCreator {
protected ParamsReader params;
public ParamsCreator(ParamsReader params) {
this.params = params;
}
public IndiParams createIndiParams(ActionFactory actionFactory, int conditionSize) {
double wildProbability = Double.parseDouble(params.getParam("P_Wildcard"));
RuleParams ruleParams = new RuleParams(wildProbability, actionFactory, conditionSize);
int classifierNumber = Integer.parseInt(params.getParam("NB_Classifiers"));
int coveringTime = Integer.parseInt(params.getParam("CoveringTime"));
return new IndiParams(classifierNumber, coveringTime, ruleParams);
}
public GAParams createGAParams() {
double mutationProbability = Double.parseDouble(params.getParam("P_Mutation"));
double crossoverProbability = Double.parseDouble(params.getParam("P_Crossover"));
int eliteSize = Integer.parseInt(params.getParam("EliteSize"));
int populationSize = Integer.parseInt(params.getParam("PopulationSize"));
return new GAParams(mutationProbability, crossoverProbability, eliteSize, populationSize);
}
public SquareParams createSquareParams() {
int n = Integer.parseInt(params.getParam("N"));
int cycles = Integer.parseInt(params.getParam("NB_Cycles"));
int trials = Integer.parseInt(params.getParam("NB_Trials"));
return new SquareParams(n, cycles, trials);
}
public ExperimentsParams createExperimentParams() {
boolean twoStade = Boolean.parseBoolean(params.getParam("TwoStade"));
SolverName approach = SolverName.values()[Integer.parseInt(params.getParam("Approach"))];
String secondParamsFile = params.getParam("SecondParams").trim();
return new ExperimentsParams(twoStade, approach, secondParamsFile);
}
}
| [
"[email protected]"
]
| |
afed0810c104903126522aba94a14ff1cfceb8ed | 37e1c73a0544be477a702f55314634962a8e1290 | /src/main/java/com/berry_med/monitordemo/bluetooth/BluetoothChatService.java | 2ebd90f730286e0eb7da42f8f4e064886d2ba66d | []
| no_license | wordh/Personalized-Health-Monitoring-Assistance | f6931842f6469f395ff290b71f7c60a8c1744c46 | 790230ba1ae4ae9c11f245287b807ad71cf7c051 | refs/heads/master | 2021-04-27T10:30:34.054381 | 2018-04-12T18:32:43 | 2018-04-12T18:32:43 | 122,539,432 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 19,330 | java | /*
* Copyright (C) 2009 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.berry_med.monitordemo.bluetooth;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
/**
* This class does all the work for setting up and managing Bluetooth
* connections with other devices. It has a thread that listens for
* incoming connections, a thread for connecting with a device, and a
* thread for performing data transmissions when connected.
*/
public class BluetoothChatService {
// Debugging
private static final String TAG = "BluetoothChatService";
private static final boolean D = true;
// Name for the SDP record when creating server socket
private static final String NAME_SECURE = "BluetoothChatSecure";
private static final String NAME_INSECURE = "BluetoothChatInsecure";
// Unique UUID for this application
private static final UUID MY_UUID_INSECURE =
UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66");
//��������������ͨ�õ�UUID����Ҫ���
private static final UUID MY_UUID_SPP = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
// Member fields
private final BluetoothAdapter mAdapter;
private final Handler mHandler;
private AcceptThread mSecureAcceptThread;
private AcceptThread mInsecureAcceptThread;
private ConnectThread mConnectThread;
private ConnectedThread mConnectedThread;
private int mState;
private Context mContext;
// Constants that indicate the current connection state
public static final int STATE_NONE = 0; // we're doing nothing
public static final int STATE_LISTEN = 1; // now listening for incoming connections
public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection
public static final int STATE_CONNECTED = 3; // now connected to a remote device
/**
* Constructor. Prepares a new BluetoothChat session.
* @param context The UI Activity Context
* @param handler A Handler to send messages back to the UI Activity
*/
public BluetoothChatService(Context context, Handler handler) {
mAdapter = BluetoothAdapter.getDefaultAdapter();
mState = STATE_NONE;
mHandler = handler;
mContext = context;
}
/**
* Set the current state of the chat connection
* @param state An integer defining the current connection state
*/
private synchronized void setState(int state) {
if (D) Log.d(TAG, "setState() " + mState + " -> " + state);
mState = state;
// Give the new state to the Handler so the UI Activity can update
mHandler.obtainMessage(Const.MESSAGE_BLUETOOTH_STATE_CHANGE, state, -1).sendToTarget();
}
/**
* Return the current connection state. */
public synchronized int getState() {
return mState;
}
/**
* Start the chat service. Specifically start AcceptThread to begin a
* session in listening (server) mode. Called by the Activity onResume() */
public synchronized void start() {
if (D) Log.d(TAG, "start");
// Cancel any thread attempting to make a connection
if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
setState(STATE_LISTEN);
// Start the thread to listen on a BluetoothServerSocket
if (mSecureAcceptThread == null) {
mSecureAcceptThread = new AcceptThread(true);
mSecureAcceptThread.start();
}
if (mInsecureAcceptThread == null) {
mInsecureAcceptThread = new AcceptThread(false);
mInsecureAcceptThread.start();
}
}
/**
* Start the ConnectThread to initiate a connection to a remote device.
* @param device The BluetoothDevice to connect
* @param secure Socket Security type - Secure (true) , Insecure (false)
*/
public synchronized void connect(BluetoothDevice device, boolean secure) {
if (D) Log.d(TAG, "connect to: " + device);
// Cancel any thread attempting to make a connection
if (mState == STATE_CONNECTING) {
if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
// Start the thread to connect with the given device
mConnectThread = new ConnectThread(device, secure);
mConnectThread.start();
setState(STATE_CONNECTING);
}
/**
* Start the ConnectedThread to begin managing a Bluetooth connection
* @param socket The BluetoothSocket on which the connection was made
* @param device The BluetoothDevice that has been connected
*/
public synchronized void connected(BluetoothSocket socket, BluetoothDevice
device, final String socketType) {
if (D) Log.d(TAG, "connected, Socket Type:" + socketType);
// Cancel the thread that completed the connection
if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
// Cancel the accept thread because we only want to connect to one device
if (mSecureAcceptThread != null) {
mSecureAcceptThread.cancel();
mSecureAcceptThread = null;
}
if (mInsecureAcceptThread != null) {
mInsecureAcceptThread.cancel();
mInsecureAcceptThread = null;
}
// Start the thread to manage the connection and perform transmissions
mConnectedThread = new ConnectedThread(socket, socketType);
mConnectedThread.start();
// Send the name of the connected device back to the UI Activity
Message msg = mHandler.obtainMessage(Const.MESSAGE_BLUETOOTH_DEVICE_NAME);
Bundle bundle = new Bundle();
bundle.putString(Const.DEVICE_NAME, device.getName());
msg.setData(bundle);
mHandler.sendMessage(msg);
setState(STATE_CONNECTED);
}
/**
* Stop all threads
*/
public synchronized void stop() {
if (D) Log.d(TAG, "stop");
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
if (mConnectedThread != null) {
mConnectedThread.cancel();
mConnectedThread = null;
}
if (mSecureAcceptThread != null) {
mSecureAcceptThread.cancel();
mSecureAcceptThread = null;
}
if (mInsecureAcceptThread != null) {
mInsecureAcceptThread.cancel();
mInsecureAcceptThread = null;
}
setState(STATE_NONE);
}
/**
* Write to the ConnectedThread in an unsynchronized manner
* @param out The bytes to write
* @see ConnectedThread#write(byte[])
*/
public void write(byte[] out) {
// Create temporary object
ConnectedThread r;
// Synchronize a copy of the ConnectedThread
synchronized (this) {
if (mState != STATE_CONNECTED) return;
r = mConnectedThread;
}
// Perform the write unsynchronized
r.write(out);
}
/**
* Indicate that the connection attempt failed and notify the UI Activity.
*/
private void connectionFailed() {
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(Const.MESSAGE_BLUETOOTH_TOAST);
Bundle bundle = new Bundle();
bundle.putString(Const.TOAST, "Unable to connect device");
msg.setData(bundle);
mHandler.sendMessage(msg);
mHandler.obtainMessage(Const.MESSAGE_BLUETOOTH_CONNECT_FAIL).sendToTarget();
// Start the service over to restart listening mode
BluetoothChatService.this.start();
}
/**
* Indicate that the connection was lost and notify the UI Activity.
*/
private void connectionLost() {
// Send a failure message back to the Activity
Message msg = mHandler.obtainMessage(Const.MESSAGE_BLUETOOTH_TOAST);
Bundle bundle = new Bundle();
bundle.putString(Const.TOAST, "Device connection was lost");
msg.setData(bundle);
mHandler.sendMessage(msg);
// Start the service over to restart listening mode
BluetoothChatService.this.start();
}
/**
* This thread runs while listening for incoming connections. It behaves
* like a server-side client. It runs until a connection is accepted
* (or until cancelled).
*/
private class AcceptThread extends Thread {
// The local server socket
private final BluetoothServerSocket mmServerSocket;
private String mSocketType;
@SuppressLint("NewApi")
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SPP);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
public void run() {
if (D) Log.d(TAG, "Socket Type: " + mSocketType +
"BEGIN mAcceptThread" + this);
setName("AcceptThread" + mSocketType);
BluetoothSocket socket = null;
// Listen to the server socket if we're not connected
while (mState != STATE_CONNECTED) {
try {
// This is a blocking call and will only return on a
// successful connection or an exception
socket = mmServerSocket.accept();
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "accept() failed", e);
break;
}
// If a connection was accepted
if (socket != null) {
synchronized (BluetoothChatService.this) {
switch (mState) {
case STATE_LISTEN:
case STATE_CONNECTING:
// Situation normal. Start the connected thread.
connected(socket, socket.getRemoteDevice(),
mSocketType);
break;
case STATE_NONE:
case STATE_CONNECTED:
// Either not ready or already connected. Terminate new socket.
try {
socket.close();
} catch (IOException e) {
Log.e(TAG, "Could not close unwanted socket", e);
}
break;
}
}
}
}
if (D) Log.i(TAG, "END mAcceptThread, socket Type: " + mSocketType);
}
public void cancel() {
if (D) Log.d(TAG, "Socket Type" + mSocketType + "cancel " + this);
try {
mmServerSocket.close();
} catch (IOException e) {
Log.e(TAG, "Socket Type" + mSocketType + "close() of server failed", e);
}
}
}
/**
* This thread runs while attempting to make an outgoing connection
* with a device. It runs straight through; the connection either
* succeeds or fails.
*/
private class ConnectThread extends Thread {
private final BluetoothSocket mmSocket;
private final BluetoothDevice mmDevice;
private String mSocketType;
@SuppressLint("NewApi")
public ConnectThread(BluetoothDevice device, boolean secure) {
mmDevice = device;
BluetoothSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Get a BluetoothSocket for a connection with the
// given BluetoothDevice
try {
if (secure) {
tmp = device.createRfcommSocketToServiceRecord(
MY_UUID_SPP);
} else {
tmp = device.createInsecureRfcommSocketToServiceRecord(
MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
}
mmSocket = tmp;
}
public void run() {
Log.i(TAG, "BEGIN mConnectThread SocketType:" + mSocketType);
setName("ConnectThread" + mSocketType);
// Always cancel discovery because it will slow down a connection
mAdapter.cancelDiscovery();
// Make a connection to the BluetoothSocket
try {
// This is a blocking call and will only return on a
// successful connection or an exception
mmSocket.connect();
} catch (IOException e) {
// Close the socket
try {
mmSocket.close();
} catch (IOException e2) {
Log.e(TAG, "unable to close() " + mSocketType +
" socket during connection failure", e2);
}
connectionFailed();
return;
}
// Reset the ConnectThread because we're done
synchronized (BluetoothChatService.this) {
mConnectThread = null;
}
// Start the connected thread
connected(mmSocket, mmDevice, mSocketType);
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
Log.e(TAG, "close() of connect " + mSocketType + " socket failed", e);
}
}
}
/**
* This thread runs during a connection with a remote device.
* It handles all incoming and outgoing transmissions.
*/
private class ConnectedThread extends Thread {
private final BluetoothSocket mmSocket;
private final InputStream mmInStream;
private final OutputStream mmOutStream;
public ConnectedThread(BluetoothSocket socket, String socketType) {
Log.d(TAG, "create ConnectedThread: " + socketType);
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
// Get the BluetoothSocket input and output streams
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) {
Log.e(TAG, "temp sockets not created", e);
}
mmInStream = tmpIn;
mmOutStream = tmpOut;
}
public void run() {
Log.i(TAG, "BEGIN mConnectedThread");
// byte[] buffer = new byte[1024];
int bytes;
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
while (mState == STATE_CONNECTED) {
try {
byte[] buffer = new byte[256];
bytes = mmInStream.read(buffer);
//mDataParse.Add(buffer, bytes);
if(bytes > 0)
{
byte[] dat = new byte[bytes];
System.arraycopy(buffer, 0, dat, 0, bytes);
//Log.d("USB_SERIAL", "Read " + numBytesRead + " bytes.");
mHandler.obtainMessage(Const.MESSAGE_BLUETOOTH_DATA,dat).sendToTarget();
}
} catch (IOException e) {
Log.e(TAG, "disconnected", e);
connectionLost();
// Start the service over to restart listening mode
BluetoothChatService.this.start();
break;
}
try {
Thread.sleep(40);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* Write to the connected OutStream.
* @param buffer The bytes to write
*/
public void write(byte[] buffer) {
try {
mmOutStream.write(buffer);
// Share the sent message back to the UI Activity
mHandler.obtainMessage(Const.MESSAGE_BLUETOOTH_WRITE, -1, -1, buffer)
.sendToTarget();
} catch (IOException e) {
Log.e(TAG, "Exception during write", e);
}
}
public void cancel() {
try {
mmSocket.close();
} catch (IOException e) {
Log.e(TAG, "close() of connect socket failed", e);
}
}
}
}
| [
"[email protected]"
]
| |
baf3a330b82c7b3514add381a31d582d2cc59676 | f80f5ff7e213dad8dfe4acd8ac0bd1b6b407437b | /src/main/java/wiley_test_task/web/elements/SearchResultElement.java | a90d8d3a6841bd0556dc97cc7ccf7395bb99a78b | []
| no_license | rogzy/wiley_test_task | e6c33c465e9caa0b1caf4220576111e5508d7124 | 40919caa5d5c9ccee82c8701572d8255f864ce86 | refs/heads/master | 2020-12-14T22:27:49.520859 | 2020-01-20T19:00:45 | 2020-01-20T19:00:45 | 234,892,901 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 926 | java | package wiley_test_task.web.elements;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import java.util.concurrent.TimeUnit;
@FieldDefaults(level = AccessLevel.PRIVATE)
public class SearchResultElement {
By resultList = By.xpath("//aside[contains(@class, 'ui-widget')]/section/div/*");
WebDriver driver;
WebElement parentElement;
public SearchResultElement(WebDriver driver, WebElement parentElement) {
this.driver = driver;
this.parentElement = parentElement;
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
if (!parentElement.findElement(resultList).isDisplayed()) {
throw new RuntimeException("");
}
}
public WebElement getResult() {
return parentElement.findElement(resultList);
}
}
| [
"[email protected]"
]
| |
e13f1bcb8f48a82030800fe8f2a6425625c13a3d | 6f94d50e6e9fdd3f493c4be50107a30daee9e868 | /taglibs-standard-1.2.5/impl/src/test/java/org/apache/taglibs/standard/tag/common/xml/JSTLVariableStackTest.java | e5af695011ad87f4848c00f3ce2b6a7953d6c02e | [
"Apache-2.0"
]
| permissive | SY1245869619/CAKESHOP | bfb92031aaa2b20105f0181361c97fb5d8792983 | 8969eea922df517c11cf3caac783ee3193c4b445 | refs/heads/master | 2022-12-22T15:33:41.582473 | 2019-07-01T02:15:04 | 2019-07-01T02:15:04 | 194,573,190 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,458 | 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.taglibs.standard.tag.common.xml;
import org.apache.taglibs.standard.util.XmlUtil;
import org.apache.xml.utils.QName;
import org.apache.xpath.XPathContext;
import org.apache.xpath.objects.*;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import javax.servlet.ServletContext;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.PageContext;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import static org.easymock.EasyMock.*;
/**
*/
public class JSTLVariableStackTest {
private JSTLVariableStack stack;
private PageContext pageContext;
private XPathContext xpathContext;
private XString hello;
@Before
public void setup() {
pageContext = createMock(PageContext.class);
xpathContext = new XPathContext(false);
hello = (XString) XObjectFactory.create("Hello");
stack = new JSTLVariableStack(pageContext);
}
@Test
public void testNoPrefix() throws TransformerException {
expect(pageContext.findAttribute("foo")).andReturn("Hello");
replay(pageContext);
Assert.assertEquals(hello, stack.getVariableOrParam(xpathContext, new QName(null, "foo")));
verify(pageContext);
}
@Test
public void testParamPrefix() throws TransformerException {
HttpServletRequest request = createMock(HttpServletRequest.class);
expect(pageContext.getRequest()).andReturn(request);
expect(request.getParameter("foo")).andReturn("Hello");
replay(pageContext, request);
Assert.assertEquals(hello, stack.getVariableOrParam(xpathContext, new QName("param", "foo")));
verify(pageContext, request);
}
@Test
public void testHeaderPrefix() throws TransformerException {
HttpServletRequest request = createMock(HttpServletRequest.class);
expect(pageContext.getRequest()).andReturn(request);
expect(request.getHeader("foo")).andReturn("Hello");
replay(pageContext, request);
Assert.assertEquals(hello, stack.getVariableOrParam(xpathContext, new QName("header", "foo")));
verify(pageContext, request);
}
@Test
public void testCookiePrefix() throws TransformerException {
HttpServletRequest request = createMock(HttpServletRequest.class);
expect(pageContext.getRequest()).andReturn(request);
Cookie[] cookies = new Cookie[]{new Cookie("foo", "Hello")};
expect(request.getCookies()).andReturn(cookies);
replay(pageContext, request);
Assert.assertEquals(hello, stack.getVariableOrParam(xpathContext, new QName("cookie", "foo")));
verify(pageContext, request);
}
@Test
public void testInitParamPrefix() throws TransformerException {
ServletContext servletContext = createMock(ServletContext.class);
expect(pageContext.getServletContext()).andReturn(servletContext);
expect(servletContext.getInitParameter("foo")).andReturn("Hello");
replay(pageContext, servletContext);
Assert.assertEquals(hello, stack.getVariableOrParam(xpathContext, new QName("initParam", "foo")));
verify(pageContext, servletContext);
}
@Test
public void testPagePrefix() throws TransformerException {
expect(pageContext.getAttribute("foo", PageContext.PAGE_SCOPE)).andReturn("Hello");
replay(pageContext);
Assert.assertEquals(hello, stack.getVariableOrParam(xpathContext, new QName("pageScope", "foo")));
verify(pageContext);
}
@Test
public void testRequestPrefix() throws TransformerException {
expect(pageContext.getAttribute("foo", PageContext.REQUEST_SCOPE)).andReturn("Hello");
replay(pageContext);
Assert.assertEquals(hello, stack.getVariableOrParam(xpathContext, new QName("requestScope", "foo")));
verify(pageContext);
}
@Test
public void testSessionPrefix() throws TransformerException {
expect(pageContext.getAttribute("foo", PageContext.SESSION_SCOPE)).andReturn("Hello");
replay(pageContext);
Assert.assertEquals(hello, stack.getVariableOrParam(xpathContext, new QName("sessionScope", "foo")));
verify(pageContext);
}
@Test
public void testApplicationPrefix() throws TransformerException {
expect(pageContext.getAttribute("foo", PageContext.APPLICATION_SCOPE)).andReturn("Hello");
replay(pageContext);
Assert.assertEquals(hello, stack.getVariableOrParam(xpathContext, new QName("applicationScope", "foo")));
verify(pageContext);
}
@Test(expected = TransformerException.class)
public void testValueNotFound() throws TransformerException {
expect(pageContext.findAttribute("foo")).andReturn(null);
replay(pageContext);
stack.getVariableOrParam(xpathContext, new QName(null, "foo"));
Assert.fail();
}
@Test
public void verifyJavaToXPathTypeMapping() throws ParserConfigurationException {
Assert.assertTrue(XObjectFactory.create(Boolean.TRUE, xpathContext) instanceof XBoolean);
Assert.assertTrue(XObjectFactory.create(1234, xpathContext) instanceof XNumber);
Assert.assertTrue(XObjectFactory.create("Hello", xpathContext) instanceof XString);
Document d = XmlUtil.newEmptyDocument();
Element root = d.createElement("root");
XNodeSetForDOM xo = (XNodeSetForDOM) XObjectFactory.create(root, xpathContext);
Assert.assertEquals(root, xo.object());
}
}
| [
"[email protected]"
]
| |
c3bd6af5e60da4c228a9a2d59af892febaae8846 | c1504a609901a2a3ab234fc5dcc1588a14e54d19 | /src/Lab2/CodeChallenge1/Human.java | 5f6a4d79b103fb13d986c6e768ff5158d08cf94d | []
| no_license | motoc96/AtelierDigital2020 | c77abc8ff00e8e89a0d62b11b8bd9b1411e64286 | cb5f2f9ba33512935789eca35b69c4e45c8760d7 | refs/heads/master | 2023-02-07T02:48:23.722139 | 2020-07-04T23:55:56 | 2020-07-04T23:55:56 | 255,424,780 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 405 | java | package Lab2.CodeChallenge1;
public class Human {
private String name;
private int health;
public Human(String name, int health){
this.health = health;
this.name = name;
}
public String getName(){
return name;
}
public int getHealth(){
return health;
}
public void decreaseHealth(int damage){
health=health-damage;
}
}
| [
"[email protected]"
]
| |
cbd6789e4531ae46fe6605f559ac3896a1ab13c8 | 4f114484a7af6f3d12870053cf068688fb6e2716 | /component/src/main/java/com/seth/wx/Sha1Util.java | 586e1e92d9dc5ca7dc82b7a0b1025d1e3d22fee5 | [
"Apache-2.0"
]
| permissive | SethMessenger/webTemplate | 741831cec35841330d7df9a7c94170651985b9c4 | 7271512b4aa7b628047282493fce909f2ca16658 | refs/heads/master | 2020-03-28T20:59:06.860092 | 2018-11-23T11:47:11 | 2018-11-23T11:47:11 | 149,120,004 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,926 | java | package com.seth.wx;
import com.seth.utils.MD5Utils;
import java.security.MessageDigest;
import java.util.*;
/*
'============================================================================
'api说明:
'createSHA1Sign创建签名SHA1
'getSha1()Sha1签名
'============================================================================
'*/
public class Sha1Util {
public static String getNonceStr() {
Random random = new Random();
return MD5Utils.MD5Encode(String.valueOf(random.nextInt(10000)), "UTF-8");
}
public static String getTimeStamp() {
return String.valueOf(System.currentTimeMillis() / 1000);
}
//创建签名SHA1
public static String createSHA1Sign(SortedMap<String, String> signParams) throws Exception {
StringBuffer sb = new StringBuffer();
Set es = signParams.entrySet();
Iterator it = es.iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
String k = (String) entry.getKey();
String v = (String) entry.getValue();
sb.append(k + "=" + v + "&");
//要采用URLENCODER的原始值!
}
String params = sb.substring(0, sb.lastIndexOf("&"));
// System.out.println("sha1之前:" + params);
// System.out.println("SHA1签名为:"+getSha1(params));
return getSha1(params);
}
//Sha1签名
public static String getSha1(String str) {
if (str == null || str.length() == 0) {
return null;
}
char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f' };
try {
MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
mdTemp.update(str.getBytes("GBK"));
byte[] md = mdTemp.digest();
int j = md.length;
char buf[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
buf[k++] = hexDigits[byte0 >>> 4 & 0xf];
buf[k++] = hexDigits[byte0 & 0xf];
}
return new String(buf);
} catch (Exception e) {
return null;
}
}
}
| [
"[email protected]"
]
| |
c59f4056ecb03d4181cc556ef00fdaed0349188b | 272669aa958325b4733462ad858414d001435002 | /src/main/java/net/yevstaf/ConsoleBankApp/ConsoleBankAppCommander.java | 2a0a80b2be18e6aef00b3a8f53d65dafcc4edb22 | []
| no_license | Yevstaf/ConsoleBankApp | a0aa4e5deb7b29987fbf72c0092bcc7be2c90eb9 | 22357a8f6b37a48e7cc31e08996924ff463ca1e8 | refs/heads/master | 2020-03-22T16:20:23.184329 | 2018-07-09T17:38:42 | 2018-07-09T17:38:42 | 140,319,903 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,511 | java | package net.yevstaf.ConsoleBankApp;
import java.util.Scanner;
import org.json.JSONObject;
import com.beust.jcommander.JCommander;
import net.yevstaf.ConsoleBankApp.DataManagers.Storage;
import net.yevstaf.ConsoleBankApp.Dispatchers.JSONWebDispatcher;
import net.yevstaf.ConsoleBankApp.Parsers.JSONWebParser;
/**
* The class designed to work with output lines(e.g. TextArea, Console ...)*/
public class ConsoleBankAppCommander implements Commander{
private Settings settings;
public ConsoleBankAppCommander(String url) {
super();
JSONObject obj = new JSONWebDispatcher(new JSONWebParser())
.dispatch(url);
Storage storage = new Storage(obj);
settings = new ConsoleCommandsSettings(storage);
}
/**
* Run the command and get the answer
* @param String[] command - key words and arguments
* @return String - response*/
@Override
public String execute(String line) {
String[] command = line.split(" ");
JCommander.newBuilder()
.addObject(settings)
.build()
.parse(command);
return settings.execute();
}
/**
* receive user's commands in cycle using keyboard scanner as input*/
public void run(){
try{
while(true){
Scanner keyboard = new Scanner(System.in);
String line = keyboard.nextLine();
String[] command = line.split(" ");
System.out.println(execute(line));
}
}catch(Exception ex){
System.err.println("Incorrect command \"help\" for info");
ex.printStackTrace();
run();
}
}
}
| [
"[email protected]"
]
| |
451af2496143caf4c5dee356f56537d7948ca544 | bfcd3c3d2349a5a1ce67b307463f73dbd2f82364 | /leanengine/src/main/java/cn/leancloud/EngineHook.java | ed3ce345e2a53fc826a9d5286b66f55391d51225 | [
"Apache-2.0"
]
| permissive | leancloud/java-unified-sdk | 02bf727fdcde33d9172a2eac46976f8dd5e71f62 | 4dee5b1ff167493a001052b56fd817c8865fdd2b | refs/heads/master | 2023-06-26T05:10:08.906059 | 2023-06-14T08:04:54 | 2023-06-14T08:04:54 | 121,136,295 | 51 | 27 | Apache-2.0 | 2023-06-14T08:01:37 | 2018-02-11T15:20:02 | Java | UTF-8 | Java | false | false | 330 | java | package cn.leancloud;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface EngineHook {
String className();
EngineHookType type();
}
| [
"[email protected]"
]
| |
a3aa1b5ac2f409b08c6ecb289179a367d2941e74 | b428c45358cdf8a2731dc65d74fa7690eee8a028 | /aula4/src/aula4/funcionario.java | fa48a42336efb2e86c90cbe8511178ddc522dfe2 | []
| no_license | LiFendicol/cursoDoti | ce3963bd782023b1fe9122dc021e8c848308df9b | 71f66d746b31cf08d9193825b4d102ebad56290f | refs/heads/master | 2022-11-29T03:17:02.476642 | 2020-08-07T15:44:12 | 2020-08-07T15:44:12 | 273,233,606 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 174 | java | package aula4;
public class funcionario {
String nome, setor;
int idade, falta;
double salario;
void pagamento(){
}
void frequencia(){
}
void setor() {
}
}
| [
"[email protected]"
]
| |
ee31cbf0f0436e98502a10b35c2333fc62beb7c8 | 0b1834c202e29e51b3fa311e0c5908872ce42161 | /GetTitleSearchResult.java | a6226601fdd9d8bcc57a435c744323446161cec7 | []
| no_license | akash418/Advanced_Programming | 2a01f1f724a11423896224bd8fdafc003d2baea3 | 96de21f28fde96b136a4d207a593693066cd55ed | refs/heads/master | 2021-01-18T20:04:12.573082 | 2017-04-01T18:56:04 | 2017-04-01T18:56:04 | 86,934,337 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,031 | java | /**
* @author Nishant Gahlawat-2015151,Akash Kumar Gautam-2015011
*/
import java.io.*;
import java.util.*;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
/**Class to parse through XML in search of right title*/
public class GetTitleSearchResult {
/** Resulting Database*/
private ResultDatabase RDB;
/** Constructor and parser*/
GetTitleSearchResult(String tag){
try{
File inputFile = new File("dblp.xml");
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
RDB = new TitleSearchParser(tag);
long t=System.currentTimeMillis();
System.out.println("Start: "+t);
saxParser.parse(inputFile,RDB);
long t2=System.currentTimeMillis();
System.out.println("End: "+t2);
System.out.println("Time Taken: "+(t2-t)+"ms");
}
catch(Exception e){
e.printStackTrace();
}
}
//! return the result
public ArrayList<Publication> getResult(){
return RDB.getResult();
}
}
| [
"[email protected]"
]
| |
26d7ba9380ae747fee19632b4587d3a51f265b80 | dbfc9c2277429d599e069c6d552eaaaa56c1fc69 | /Solution.java | ebf41263133c6c362b9975c48e26d39706da9db5 | []
| no_license | surajkatkar/ripository1 | f9de87a4977fa5aa832bedf6d88c40cd7cdfeffc | c52b8d1b4692531341e0be6b34580eba39729ee1 | refs/heads/master | 2023-06-01T21:31:40.980460 | 2021-06-19T05:35:54 | 2021-06-19T05:35:54 | 369,187,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,079 | java | import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
Double d=scan.nextDouble();
String s=scan.nextString();
// Write your code here.
System.out.println("String: " + s);
System.out.println("Double: " + d);
System.out.println("Int: " + i);
}
}
/*
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int N = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
if(N%2==1 || (6<N && N<20))
{
System.out.println("Weired");
}
else if (N%2==0 ||(2<N && N<5))
{
System.out.println("Not Weired");
}
scanner.close();
}*/
| [
"[email protected]"
]
| |
4b66ed69f69a06401e21c70e33a6eafa176612d1 | c895053caf86046f383d489abeb4b4416ba83db6 | /Browser/src/test/java/vnu/hus/demo/browser/steps/BrowserScenarioSteps.java | 759a5cf4862333d511dc45fb96aa1f9360e44ff6 | []
| no_license | trinhvt/serenityBDD | 4fe1c89603a07619a669c16a782c9f746e47b0f1 | d6bb225eee76038858093fc4bc4d07e7463975e9 | refs/heads/master | 2021-01-19T06:36:29.867718 | 2016-07-06T03:10:49 | 2016-07-06T03:10:49 | 62,659,141 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,945 | java | package vnu.hus.demo.browser.steps;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import net.thucydides.core.annotations.Steps;
import vnu.hus.demo.browser.steps.serenity.BrowserSteps;
public class BrowserScenarioSteps {
@Steps
BrowserSteps brStep;
@Given("^the home page is visited$")
public void the_home_page_is_visited() throws Throwable {
}
@Given("^the page \"(.*?)\" is visited$")
public void the_page_is_visited(String website) throws Throwable {
brStep.visit_page(website);
}
@Given("^the page is refreshed$")
public void the_page_is_refreshed() throws Throwable {
brStep.page_is_refreshed();
}
@Given("^maximize the window$")
public void maximize_the_window1() throws Throwable {
brStep.maximize_window();
}
@Given("^go backward one page$")
public void go_backward_one_page() throws Throwable {
brStep.go_backward_page();
}
@Given("^go forward one page$")
public void go_forward_one_page() throws Throwable {
brStep.go_forward_page();
}
@Given("^the page \"([^\"]*)\" is opened on another window$")
public void the_page_is_opened_on_another_window(String http) throws Throwable {
brStep.page_open_on_another_window(http);
}
@Then("^assert that the \"([^\"]*)\" text is present$")
public void assert_that_the_text_is_present(String msg) throws Throwable {
brStep.assert_text_present(msg);
}
@Then("^assert that the \"([^\"]*)\" text is not present$")
public void assert_that_the_text_is_not_present(String msg) throws Throwable {
brStep.assert_not_present(msg);
}
@Then("^assert that the page title is \"([^\"]*)\"$")
public void assert_that_the_page_title_is(String msg) throws Throwable {
brStep.assert_page_title(msg);
}
@Then("^assert that the page title is not \"([^\"]*)\"$")
public void assert_that_the_page_title_is_not(String msg) throws Throwable {
brStep.assert_page_title_not(msg);
}
@Then("^assert that the page title has \"([^\"]*)\"$")
public void assert_that_the_page_title_has(String msg) throws Throwable {
brStep.assert_page_title_has(msg);
}
@Then("^assert that the page title does not have \"([^\"]*)\"$")
public void assert_that_the_page_title_does_not_have(String msg) throws Throwable {
brStep.page_title_does_not_have(msg);
}
@Then("^assert that the url is \"([^\"]*)\"$")
public void assert_that_the_url_is(String https) throws Throwable {
brStep.assert_url_is(https);
}
@Then("^assert that the url is not \"([^\"]*)\"$")
public void assert_that_the_url_is_not(String https) throws Throwable {
brStep.assert_url_is_not(https);
}
@When("^window dimension is changed with size \\((\\d+),(\\d+)\\)$")
public void window_dimension_is_changed_with_size(int no1, int no2) throws Throwable {
brStep.dimension_is_changed_size(no1,no2);
}
@When("^scroll up or down in screen with value \\((\\d+),(\\d+)\\)$")
public void scroll_up_or_down_in_screen_with_value(int no1, int no2) throws Throwable {
brStep.scroll_up_down_screen(no1,no2);
}
@When("^window is moved to location with coordinates \\((\\d+),(\\d+)\\)$")
public void window_is_moved_to_location_with_coordinates(int no1, int no2) throws Throwable {
brStep.window_is_moved(no1,no2);
}
@When("^close current window$")
public void close_current_window() throws Throwable {
brStep.close_current_window();
}
@When("^switch back to the original window$")
public void switch_back_to_the_original_window() throws Throwable {
brStep.back_original_window();
}
@When("^open \"([^\"]*)\" link in new window and switch to it$")
public void open_link_in_new_window_and_switch_to_it(String link) throws Throwable {
brStep.open_link_in_new_window(link);
}
@When("^open \"([^\"]*)\" dialog and switch to it$")
public void open_dialog_and_switch_to_it(String dialog) throws Throwable {
brStep.open_dialog_and_switch(dialog);
}
}
| [
"[email protected]"
]
| |
a5320fba92d1938674b2d57fae8d35c59c84b00b | 6d97db25f7c61fd64ac5ae672b34263454d61430 | /MysqlJDBC/day05_2/src/com/itheima/controller/ClassesController.java | 24bdffe1b95aec7ea8210394f78b774390674134 | []
| no_license | li-black/MysqlJDBC | 181b2275c1bc2122ac343d81f524380c01ac1975 | 8c691963c8a51d98b2a1116b06c872c1c648f408 | refs/heads/master | 2023-03-11T22:01:58.866772 | 2021-03-01T08:16:25 | 2021-03-01T08:16:25 | 341,398,452 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 618 | java | package com.itheima.controller;
//测试一对多查询
import com.itheima.bean.Classes;
import com.itheima.service.OneToManyService;
import com.itheima.service.impl.OneToManyServiceImpl;
import org.junit.Test;
import java.util.List;
public class ClassesController {
//创建业务层对象
private OneToManyService service = new OneToManyServiceImpl();
@Test
public void selectAll() {
final List<Classes> classes = service.selectAll();
// 与下面的语句作用一致classes.forEach(classes1 -> System.out.println(classes1));
classes.forEach(System.out::println);
}
}
| [
"[email protected]"
]
| |
cefde850dfb2146121a6a3575e2b9b3c1d9a6667 | fc803e7d7c24b372977128e34b23d630e29e444d | /wms -bak/src/main/java/com/_520it/wms/domain/Brand.java | 14cff4ecd32b29d7b137b2d0500e12a7a19f50f8 | []
| no_license | SmallJack/test | 6febd45c52153e3591dd5a5935c187885481cc42 | 446c4fa99962988c6000224c8b57ac6bfb62b051 | refs/heads/master | 2021-01-20T05:19:43.742110 | 2017-08-25T18:01:41 | 2017-08-25T18:01:41 | 101,428,566 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 226 | java | package com._520it.wms.domain;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Setter
@Getter
@ToString
public class Brand extends BaseDomain {
private String name;
private String sn;
}
| [
"[email protected]"
]
| |
f9d462738bec9da8501f8391cf72e6fbcbcb05e4 | 825a7c64e15ecb2e4b0777e66fb38576b9e9ebee | /admin-base-support/admin-base/src/main/java/com/gjb/admin/base/dict/AbstractDictMap.java | 717a0ea2f7af81b19e4737c0049e5579acd1bb7c | []
| no_license | gejinbiao/admin | c8effcb460a0b7c1918024c32eb375f4952ecec0 | 3d5ef3f10a72125d1314d4a1bc34b39a43cb773e | refs/heads/master | 2023-03-02T09:27:47.349289 | 2020-03-27T08:49:58 | 2020-03-27T08:49:58 | 250,479,757 | 0 | 0 | null | 2023-02-22T07:43:51 | 2020-03-27T08:25:43 | JavaScript | UTF-8 | Java | false | false | 1,910 | java | /**
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
* <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 com.gjb.admin.base.dict;
import java.util.HashMap;
/**
* 字典映射抽象类
*
* @author fengshuonan
* @date 2017-05-06 14:58
*/
public abstract class AbstractDictMap {
protected HashMap<String, String> dictory = new HashMap<>();
protected HashMap<String, String> fieldWarpperDictory = new HashMap<>();
public AbstractDictMap() {
put("id", "主键id");
init();
initBeWrapped();
}
/**
* 初始化字段英文名称和中文名称对应的字典
*
* @author stylefeng
* @Date 2017/5/9 19:39
*/
public abstract void init();
/**
* 初始化需要被包装的字段(例如:性别为1:男,2:女,需要被包装为汉字)
*
* @author stylefeng
* @Date 2017/5/9 19:35
*/
protected abstract void initBeWrapped();
public String get(String key) {
return this.dictory.get(key);
}
public void put(String key, String value) {
this.dictory.put(key, value);
}
public String getFieldWarpperMethodName(String key) {
return this.fieldWarpperDictory.get(key);
}
public void putFieldWrapperMethodName(String key, String methodName) {
this.fieldWarpperDictory.put(key, methodName);
}
}
| [
"[email protected]"
]
| |
810a479f8b0386e652b9c9012e7da3b0ea40fc55 | b51b43a330437fe064564bc155013ed9825da6bb | /src/core/Player.java | 348d88882ed00ddc4e1d6610e658bc672eec09d2 | []
| no_license | VijayEluri/Prototype | d64f9e4c047e76f4ef4ba91377e1d0f52af089bd | 68b1a1714bb5724d23fab2d8a93014a1ac4c6029 | refs/heads/master | 2020-05-20T11:10:26.284821 | 2015-05-26T19:12:26 | 2015-05-26T19:12:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,412 | java | package core;
import core.AutoPilot.SystemStatus;
import gamelib.Point2D;
import gamelib.Vector2D;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.geom.AffineTransform;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import ui.ViewFrame;
import util.ImageManager;
import weapon.*;
/**
* @author Yann Le Gall
* [email protected]
* Dec 2, 2009 8:06:05 PM
*/
public class Player extends GameObject implements KeyListener {
private Image image, boostingImage;
private double sin, cos, heading;
private Vector2D direction;
private boolean boosting, firing, breaking, wasHit;
private Rotation rotation;
private Rectangle rectangle;
private int shields, weaponIndex;
private ArrayList<Weapon> weapons;
private Weapon weapon;
private AutoPilot autoPilot;
private GameObject target;
public Player(Point2D p) {
super(p);
direction = new Vector2D(0, -1);
rotation = Rotation.NONE;
double rotationSpeed = 0.17;
sin = Math.sin(rotationSpeed);
cos = Math.cos(rotationSpeed);
boostingImage = ImageManager.getImage("boosting.png").getImage();
ImageIcon icon = ImageManager.getImage("player.png");
rectangle = new Rectangle(icon.getIconWidth(), icon.getIconHeight());
rectangle.setLocation(p.getPoint());
image = icon.getImage();
shields = 255;
weaponIndex = 0;
weapons = new ArrayList<Weapon>();
weapons.add(new SMP9(this));
weapons.add(new X2Vulcan(this));
weapons.add(new EM12Carbine(this));
weapons.add(new Stinger2(this));
weapons.add(new ALS22(this));
weapons.add(new Solaris(this));
weapon = weapons.get(weaponIndex);
autoPilot = new AutoPilot(this);
}
public final void setBoosting(boolean boosting) {
this.boosting = boosting;
}
public final void setBreaking(boolean breaking) {
this.breaking = breaking;
}
public final void setRotation(Rotation rotation) {
this.rotation = rotation;
}
public final void setWeapon(int weaponIndex) {
weapon = weapons.get(weaponIndex);
ViewFrame.getInstance().setWeapon(weapon.toString());
}
public final void setFiring(boolean firing) {
if(this.firing == firing) {
return;
} else {
this.firing = firing;
if (!firing) {
weapon.cock();
}
}
}
public final GameObject cycleTarget(boolean enemyFirst) {
Game game = ViewFrame.getInstance().getGame();
if(enemyFirst) {
target = game.getEnemy();
if (target != null) {
return target;
} else {
target = game.getItem();
}
} else {
target = game.getItem();
if (target != null) {
return target;
} else {
target = game.getEnemy();
}
}
return target;
}
public Enemy getEnemy() {
if(target instanceof Enemy) {
return (Enemy)target;
} else {
return null;
}
}
public final void slow() {
vel.scaleBy(0.8);
}
public final Vector2D getDirection() {
return direction;
}
public final void cycleWeapon(int direction) {
do {
weaponIndex += direction;
if (weaponIndex < 0) {
weaponIndex = weapons.size() - 1;
} else if (weaponIndex >= weapons.size()) {
weaponIndex = 0;
}
weapon = weapons.get(weaponIndex);
} while (weapon.getAmmo() + weapon.getRounds() == 0);
ViewFrame.getInstance().setWeapon(weapon.toString());
displayAmmo();
}
public final void reload() {
if(weapon.getAmmo() > 0) {
weapon.reload();
displayAmmo();
}
}
public Weapon getWeapon() {
return weapon;
}
public final Point2D getCenterPoint() {
return new Point2D(rectangle.getCenterX(), rectangle.getCenterY());
}
public boolean containsPoint(Point2D p) {
return rectangle.contains(p.x, p.y);
}
public final void damage(int amount) {
shields -= amount;
if(shields < 0) shields = 0;
wasHit = true;
if(shields < 50) {
autoPilot.setStatus(AutoPilot.SystemStatus.DAMAGED);
}
ViewFrame.getInstance().setHealth(shields);
}
public final int getShields() {
return shields;
}
public final void addShields(int amount) {
shields += amount;
if(shields > 255) shields = 255;
else if(shields > 50) {
if(autoPilot.getStatus() == AutoPilot.SystemStatus.DAMAGED) {
autoPilot.setStatus(AutoPilot.SystemStatus.OFF);
}
}
}
public final void addAmmo(int amount, Class weaponType) {
for(Weapon w : weapons) {
if(w.getClass().equals(weaponType)) {
w.addAmmo(amount);
}
}
}
public final boolean isFiring() {return firing;}
@Override
public boolean isDead() {
return false;
}
private void displayAmmo() {
ViewFrame.getInstance().setAmmo(weapon.getRounds(), weapon.getClipSize(), weapon.getAmmo());
}
@Override
public void draw(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
AffineTransform at = g2.getTransform();
heading = Math.atan2(direction.x, -direction.y);
g2.rotate(heading, rectangle.getCenterX(), rectangle.getCenterY());
if (boosting) {
g2.drawImage(boostingImage, (int) pos.x, (int) pos.y, null);
} else {
g2.drawImage(image, (int) pos.x, (int) pos.y, null);
}
g2.setTransform(at);
if (target != null) {
if (target.isDead()) {
target = null;
return;
}
if(target instanceof Enemy) {
g2.setColor(Color.RED);
g2.draw(((Enemy)target).getRectangle());
} else {
g2.setColor(Color.CYAN);
g2.draw(((Item)target).getRectangle());
}
}
if(wasHit) {
g2.setColor(new Color(0,shields>>1, shields));
g2.drawOval((int)pos.x, (int)pos.y, rectangle.width, rectangle.height);
wasHit = false;
}
// if(weapon instanceof Solaris) {
// g2.setColor(Color.DARK_GRAY);
// java.awt.Point p = getCenterPoint().getPoint();
// g2.drawLine(p.x, p.y, p.x + (int)(600*direction.x), p.y + (int)(600*direction.y));
// }
}
@Override
public void update() {
if (autoPilot.getStatus() == AutoPilot.SystemStatus.ON) {
autoPilot.update();
}
switch (rotation) {
case RIGHT:
direction.x = (direction.x * cos) - (direction.y * sin);
direction.y = (direction.x * sin) + (direction.y * cos);
break;
case LEFT:
direction.x = (direction.x * cos) + (direction.y * sin);
direction.y = -(direction.x * sin) + (direction.y * cos);
break;
}
direction = direction.direction();
if (boosting) {
vel.add(direction);
vel.x = (Math.abs(vel.x) > 35)? Math.signum(vel.x)*35 : vel.x;
vel.y = (Math.abs(vel.y) > 35)? Math.signum(vel.y)*35 : vel.y;
} else if(breaking) {
slow();
}
pos.x += vel.x;
pos.y += vel.y;
rectangle.setLocation(pos.getPoint());
// bounds checking:
if (pos.x < 0) {
pos.x = ViewFrame.size.width - 1;
} else if (pos.x > ViewFrame.size.width - 1) {
pos.x = 0;
}
if (pos.y < 0) {
pos.y = ViewFrame.size.height - 1;
} else if (pos.y > ViewFrame.size.height - 1) {
pos.y = 0;
}
if (firing) {
weapon.fire();
displayAmmo();
}
}
public void keyPressed(KeyEvent e)
{
int keyCode = e.getKeyCode();
if(keyCode == KeyEvent.VK_P) {
ViewFrame.getInstance().pause();
return;
}
else if(keyCode == KeyEvent.VK_A) {
SystemStatus status = autoPilot.getStatus();
switch(status) {
case ON:
autoPilot.setStatus(AutoPilot.SystemStatus.OFF);
boosting = firing = false;
rotation = Rotation.NONE;
break;
case OFF:
autoPilot.setStatus(AutoPilot.SystemStatus.ON);
break;
default:
return;
}
return;
}
if(autoPilot.getStatus() == AutoPilot.SystemStatus.ON) {
return;
}
switch (keyCode) {
case KeyEvent.VK_UP: {
if(!boosting) {
setBoosting(true);
}
break;
}
case KeyEvent.VK_DOWN: {
if(!breaking) {
setBreaking(true);
}
break;
}
case KeyEvent.VK_LEFT: {
setRotation(Player.Rotation.LEFT);
break;
}
case KeyEvent.VK_RIGHT: {
setRotation(Player.Rotation.RIGHT);
break;
}
case KeyEvent.VK_D: {
cycleTarget(true);
break;
}
case KeyEvent.VK_Q: {
cycleWeapon(-1);
break;
}
case KeyEvent.VK_E: {
cycleWeapon(1);
break;
}
case KeyEvent.VK_SPACE:
firing = true;
break;
case KeyEvent.VK_R:
reload();
break;
}
}
public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();
switch (keyCode) {
case KeyEvent.VK_E:
case KeyEvent.VK_Q:
// ViewFrame.getInstance().setWeapon(weapon.toString());
// displayAmmo();
break;
case KeyEvent.VK_UP:
setBoosting(false);
case KeyEvent.VK_DOWN:
setBreaking(false);
break;
case KeyEvent.VK_LEFT:
case KeyEvent.VK_RIGHT:
setRotation(Player.Rotation.NONE);
break;
case KeyEvent.VK_SPACE: {
firing = false;
new Thread(new Runnable() {
public void run() {
weapon.cock();
}
}).start();
break;
}
}
}
public void keyTyped(KeyEvent e) {
}
public static enum Rotation {
NONE,
LEFT,
RIGHT
}
}
| [
"[email protected]"
]
| |
66ded55e250c2ee3cd64dc9b5139ad403394a55d | d8cc9f54f9a1016f55b534570bbd45ea0ea714af | /team-110/phaseC/plagiarismdetector/src/main/java/edu/neu/msd/plagiarismdetector/PlagiarismDetectorSecurityConfig.java | 66a1a6667539f91484722c643520310a5df1e7a7 | []
| no_license | freniapinto/plagiarism-detector | 766cdb238ba6e1087389499c19b7b2e18143bad9 | c91f03741c96b22d0fceb19543850701f17df1ce | refs/heads/master | 2020-03-26T19:30:23.441079 | 2018-08-19T03:11:59 | 2018-08-19T03:11:59 | 133,425,792 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,190 | java | package edu.neu.msd.plagiarismdetector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
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.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
* PlagiarismDetectorSecurityConfig class ensures secure web application
* for the plagiarism detector
*
*/
@Configuration
@EnableWebSecurity
public class PlagiarismDetectorSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService;
/**
* @return BCryptPasswordEncoder
*/
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}
/**
* The function ensures only registration, login and logout endpoints
* to be accessed by all http requests
* @param http HttpSecurity
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/resources/**", "/registration").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
/**
* The function provides encoding to the user password
* @param auth
* @throws Exception
*/
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
}
} | [
"[email protected]"
]
| |
0bcbf36fa80ebbfad1adc2597b1e5b3709a06f04 | e1030ba56dee5fcb1679adf2ed6cecd8f7b2f216 | /src/main/java/com/axia/controller/SupplierController.java | 9dc492b65baeeec162342ee1e61bf5758f20f4e0 | []
| no_license | fikrialfarasyi/myProject | ba6aa1eea36722ac8959d9538bd6d20c607c1fc6 | fb3e9d2d8512bb6e859e0622ccabd56d302b9cfd | refs/heads/master | 2023-08-03T11:32:44.068019 | 2021-09-13T12:32:26 | 2021-09-13T12:32:26 | 405,963,098 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,014 | java | package com.axia.controller;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.axia.model.Barang;
import com.axia.model.Supplier;
import com.axia.service.SupplierService;
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping("/supplier")
public class SupplierController {
public SupplierService supplierService;
public SupplierController(SupplierService supplierService) {
super();
this.supplierService = supplierService;
}
// Add Supplier
@PostMapping("/add")
public Supplier addBarang(@RequestBody Supplier supplier) {
Supplier result = supplierService.addSupplier(supplier);
return result;
}
@GetMapping("/listSupplier")
public List<Supplier> getAllListSupplier(){
List<Supplier> result = supplierService.getAllListSupplier();
return result;
}
@GetMapping("/listSupplierById")
public Supplier getListSupplierById(@RequestParam Long id){
Supplier result = supplierService.getListSupplierById(id);
return result;
}
@PutMapping("/updateSupplier")
public Supplier updateSupplierById(@RequestBody Supplier supplier, @RequestParam Long id){
Supplier result = supplierService.updateSupplierById(supplier, id);
return result;
}
@DeleteMapping("/deleteSupplier")
public Long deleteSupplier(@RequestParam Long id){
Long result = supplierService.deleteSupplier(id);
return result;
}
}
| [
"[email protected]"
]
| |
d6369b42d6a3908c41cf83f004eaace56a3e8988 | adfb549d38e03741f15d3a2b37e232dfd5e69c81 | /demo/core/src/main/java/com/volunteer/demo/manager/ActivityManager.java | da6ba8f947b0ba734cc9b760d2a85edde99ef45e | []
| no_license | shengqiangyc/volunteer | 956c4cdac5f53e8ebdcf28bcfc5de2cc8296b5cd | 1fd613babeff801ca19e1783dcc9c06ee5a4bd36 | refs/heads/master | 2021-04-26T21:50:48.551614 | 2018-03-07T03:12:16 | 2018-03-07T03:12:16 | 124,165,488 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 703 | java | /**
* AllrightsReserved,DesignedBywww.maihaoche.com
* Package com.volunteer.demo.manager
* author: shengqiang ([email protected])
* date: 2018/2/26下午9:13
* Copyright:2017-2018www.maihaoche.comInc.Allrightsreserved.
* 注意:本内容仅限于卖好车内部传阅,禁止外泄以及用于其他的商业目的
*/
package com.volunteer.demo.manager;
import com.volunteer.demo.DO.YcActivity;
import com.volunteer.demo.vo.IndexActivityVO;
import java.util.List;
/**
* Description: 活动相关接口
* author: shengqiang ([email protected])
* date: 2018/2/26下午9:13
* sinceV1.0
*/
public interface ActivityManager {
List<IndexActivityVO> getIndexActivity();
}
| [
"[email protected]"
]
| |
1e09ca555810ea4a5b47349d67dc600c43ce9e8d | 8dcaa43cffa409c80e20630577dab744b65ff854 | /src/main/java/net/stoerr/functional/backus/AbstractValue.java | aeba4be868906fa5b0856fa03e026cc7b17ad785 | []
| no_license | stoerr/topcoder-euler-solutions | 2d5d2afafb670a44b2deb5793377b7e6cb57e848 | 13122897f552c231916c34ea83845997c8192ec5 | refs/heads/master | 2020-05-21T17:07:25.536181 | 2009-01-12T06:58:26 | 2009-01-12T06:58:26 | 186,116,736 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 660 | java | package net.stoerr.functional.backus;
/**
* Defines the various convenience methods of {@link Value}
*
* @author hps
* @since 26.11.2008
*/
public abstract class AbstractValue implements Value {
public final ListObject asList() {
return (ListObject) get();
}
public double asDouble() {
return ((Number) get()).doubleValue();
}
public String asString() {
return (String) get();
}
public boolean asBoolean() {
return (Boolean) get();
}
public int compareTo(Object arg0) {
return ((Comparable) get()).compareTo(((Value)arg0).get());
}
}
| [
"[email protected]"
]
| |
480b9b33ce53b559352f9aa51b4cd054a9d0a5e9 | 8e6f11e12c6db8e3c88d6b10591e287e3057aaf5 | /07-Java EE/Projets/TP/src/main/java/com/capgemini/designpattern/TPFactory/src/Rectangle.java | 3bac8d00a31e79086bc15c660e195840751e9f16 | []
| no_license | GuillaumeLD/Cours | 61ef8df3afd4f81dacda62f20c72a10c047fcb00 | b25bd9722c5a642cb5fc7cfe7e5e9ae1138fc923 | refs/heads/master | 2020-03-27T08:54:21.241026 | 2018-08-31T15:54:01 | 2018-08-31T15:54:01 | 146,296,940 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 282 | java | package com.capgemini.designpattern.TPFactory.src;
import java.util.*;
/**
*
*/
public class Rectangle implements Shape {
/**
* Default constructor
*/
public Rectangle() {
}
@Override
public void draw() {
// TODO Auto-generated method stub
}
} | [
"[email protected]"
]
| |
f5bb50332ce700767410b9a207cef5a363746dca | 790e13f76666574175c5a7b38280c8e22aecfbfd | /app/src/main/java/com/portablesalescounterapp/ui/manageqr/ProductQrViewState.java | 820e3a6de2507a8a4ac44f8f6f2edbca6ac31ec7 | []
| no_license | odysseus005/PortableSalesCounterApp | 3d6199660edead4bb9dcf65273f65831133dfa73 | f1c769ef6639dca1eeef69bf830f713f0a890906 | refs/heads/master | 2021-09-07T10:02:10.643038 | 2018-02-14T16:44:25 | 2018-02-14T16:44:25 | 112,454,583 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 559 | java | package com.portablesalescounterapp.ui.manageqr;
import android.os.Bundle;
import android.support.annotation.NonNull;
import com.hannesdorfmann.mosby.mvp.viewstate.RestorableViewState;
class ProductQrViewState implements RestorableViewState<ProductQrListView> {
@Override
public void saveInstanceState(@NonNull Bundle out) {
}
@Override
public RestorableViewState<ProductQrListView> restoreInstanceState(Bundle in) {
return this;
}
@Override
public void apply(ProductQrListView view, boolean retained) {
}
}
| [
"[email protected]"
]
| |
d2f6ade3955e837726faa9f38418be2488c0634a | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/34/34_f36c15ff02d4e3ef77a711ddcc96fb2a8aff4f99/Example/34_f36c15ff02d4e3ef77a711ddcc96fb2a8aff4f99_Example_s.java | daa4235eb03b86a5b69850997e9da7cde285062e | []
| 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 | 240 | java | package dummyclasses;
public class Example {
private int entero1 = 0;
private Integer entero2 = new Integer(0);
public static void test1(int a, int b, String c) {}
public int test2() {
return entero1 + entero2;
}
}
| [
"[email protected]"
]
| |
78cdba42f1e700c4ba84e796d05ea024d923ab4e | 8afb5afd38548c631f6f9536846039ef6cb297b9 | /_REPO/APRESS/jsp-examples-best-practices/SourceCode/JavaCode/jspbook/framework/request/Action.java | da1e41aad64b64eb5b7f1d8677090324139bd6ac | [
"MIT"
]
| permissive | bgoonz/UsefulResourceRepo2.0 | d87588ffd668bb498f7787b896cc7b20d83ce0ad | 2cb4b45dd14a230aa0e800042e893f8dfb23beda | refs/heads/master | 2023-03-17T01:22:05.254751 | 2022-08-11T03:18:22 | 2022-08-11T03:18:22 | 382,628,698 | 10 | 12 | MIT | 2022-10-10T14:13:54 | 2021-07-03T13:58:52 | null | UTF-8 | Java | false | false | 839 | java | package jspbook.framework.request;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
/**
* Interface for Action objects
*
* <p>This interface is used to provide a generic
* interface to Action objects, which are used to
* implement a request action.</p>
*
* @version 1.0
* @author Andrew Patzer
* @since JDK 1.3
*/
public interface Action {
/**
* Set local database connection
*/
public void setDatabase(Connection _db);
/**
* Execute business logic
*/
public boolean execute(HttpServletRequest _req, HttpServletResponse _res)
throws ServletException, IOException;
/**
* Return the page name (and path) to display the view
*/
public String getView();
/**
* Return a JavaBean containing the model (data)
*/
public Object getModel();
}
| [
"[email protected]"
]
| |
d26ce6c3099849126a0c5cb5ad7f829777455ba0 | e3df085da243b10d3acf2f398e00d49b7bc41bb5 | /lou-app/src/com/angeldsis/lou/allianceforum/ShowForum.java | edf21d63551daf16ac9c1507a3c0db4c39f8f2de | []
| no_license | cleverca22/lou | ae2d245d625c019068e1442fb17258e6d01c6491 | 1198b2380a683a684992277241f211dfb447f60a | refs/heads/master | 2021-01-20T19:59:47.688429 | 2014-03-03T22:10:58 | 2014-03-03T22:10:58 | 64,802,451 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,842 | java | package com.angeldsis.lou.allianceforum;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.angeldsis.lou.R;
import com.angeldsis.lou.SessionUser;
import com.angeldsis.louapi.RPC.GotForumThreads;
import com.angeldsis.louapi.data.ForumThread;
public class ShowForum extends SessionUser implements OnItemClickListener, GotForumThreads {
public class ThreadList extends ArrayAdapter<ForumThread> {
public ThreadList(ShowForum showForum, ForumThread[] out) {
super(showForum,0,out);
}
@Override public long getItemId(int index) {
return getItem(index).threadID;
}
@Override public View getView(int index,View out,ViewGroup parent) {
if (out == null) {
out = ShowForum.this.getLayoutInflater().inflate(R.layout.forum_thread_row, parent,false);
}
TextView topic = (TextView) out.findViewById(R.id.topic);
ImageView seen = (ImageView) out.findViewById(R.id.seen);
ForumThread t = getItem(index);
topic.setText(t.tt);
if(t.hup) seen.setImageResource(R.drawable.icon_new_post);
else seen.setImageResource(R.drawable.icon_old_post);
return out;
}
}
ForumThread[] forums = null;
private ListView list;
private long forumID;
private String forumName;
@Override public void onCreate(Bundle sis) {
super.onCreate(sis);
setContentView(R.layout.forum_threads);
list = (ListView) findViewById(R.id.list);
list.setOnItemClickListener(this);
Bundle b = this.getIntent().getExtras();
forumID = b.getLong("forumID");
forumName = b.getString("forumName");
((TextView)findViewById(R.id.forum)).setText(forumName);
}
@Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long rowid) {
Log.v("ShowForum",String.format("GetAllianceForumPosts(%d,%d)",forumID,rowid));
Intent i = new Intent(this,ShowPosts.class);
i.putExtras(acct.toBundle());
i.putExtra("forumID", forumID);
i.putExtra("forumName",forumName);
i.putExtra("threadID", rowid);
i.putExtra("threadName",((ThreadList)list.getAdapter()).getItem(arg2).tt);
startActivity(i);
}
@Override public void session_ready() {
//if ((forums == null) || (forums.length == 0))
refresh();
}
private void refresh() {
session.rpc.GetAllianceForumThreads(forumID,this);
}
@Override
public void done(ForumThread[] out) {
ThreadList a = new ThreadList(this,out);
forums = out;
list.setAdapter(a);
}
public void newThread(View v) {
Intent i = new Intent(this,NewThread.class);
i.putExtras(acct.toBundle());
i.putExtra("forumID", forumID);
startActivity(i);
}
}
| [
"[email protected]"
]
| |
980ac1b7d236173fbb3a2d0bb42fa54c69155acb | a44b58e94f12b671a0cd372a215f3a6daa9efb3e | /src/test/java/com/rentermentor/core/mvp/server/ServerApplicationTests.java | 0187400cfb3bc01bbb0e878c9e0de1d74adf7776 | []
| no_license | walterqmason3/base_server | 573c99d07e308aa7f30602864282e1b15e050751 | 1c77f507e4025277b84089f970d533d46e76ba7c | refs/heads/master | 2021-05-20T14:42:48.437503 | 2020-03-31T19:02:10 | 2020-03-31T19:02:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 224 | java | package com.rentermentor.core.mvp.server;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ServerApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
]
| |
e311f050472fbf557fca287790321aa6bc2c0174 | c4a14d70951d7ec5aac7fe7ebb2db891cfe6c0b1 | /modulos/apps/LOCALGIS-Workbench/src/main/java/com/geopista/ui/dialogs/GeopistaPreferencesPanel.java | acdafedb4930abef0298bc03a0ed706bef82446f | []
| no_license | pepeysusmapas/allocalgis | 925756321b695066775acd012f9487cb0725fcde | c14346d877753ca17339f583d469dbac444ffa98 | refs/heads/master | 2020-09-14T20:15:26.459883 | 2016-09-27T10:08:32 | 2016-09-27T10:08:32 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 24,215 | java | /**
* GeopistaPreferencesPanel.java
* © MINETUR, Government of Spain
* This program is part of LocalGIS
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.geopista.ui.dialogs;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.text.DecimalFormat;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.geopista.app.AppContext;
import com.geopista.app.UserPreferenceConstants;
import com.geopista.style.sld.model.impl.SLDStyleImpl;
import com.geopista.util.GeopistaFunctionUtils;
import com.geopista.util.config.UserPreferenceStore;
import com.vividsolutions.jump.workbench.ui.OptionsPanel;
/**
* GeopistaPreferencesPanel
* Panel que permite modificar preferencias de usuario respecto a fuente, tamaño, color de la selección, ... etc
*/
public class GeopistaPreferencesPanel extends JPanel implements OptionsPanel
{
/**
* Logger for this class
*/
private static final Log logger = LogFactory
.getLog(GeopistaPreferencesPanel.class);
private JPanel seleccionStylePanel = new JPanel();
private JPanel menuPanel = new JPanel();
private JLabel lblFuente = new JLabel();
private JLabel lblTamanno = new JLabel();
private JPanel pnlColor = new JPanel();
private JTextField pintadoEscalableTextField = new JTextField(8);
private Double pintadoEscalableValor = null;
private Double anchoMonitorValor = null;
AppContext appContext=(AppContext) AppContext.getApplicationContext();
private String temp = appContext.getI18nString("colores");
private String[] coloresArray = temp.split("\\,");
private String temp2 = appContext.getI18nString("coloresRGB");
private String[] coloresRGBArray = temp2.split("\\;");
private int colorSeleccion = Integer.parseInt(UserPreferenceStore.getUserPreference("color.feature.seleccion","3",true));
private double anchoMonitor = Double.parseDouble(UserPreferenceStore.getUserPreference("ancho.monitor","30.5",true));
private JComboBox cmbColorSeleccion = new JComboBox(coloresArray);
private JFormattedTextField txtTamanno = null;
private String temp3 = appContext.getI18nString("fuentes");
private String[] fuentesArray = temp3.split("\\,");
private JComboBox cmbFuente = new JComboBox(fuentesArray);
private JLabel lblEstilo = new JLabel();
private String temp4 = appContext.getI18nString("estilos");
private String[] estilosArray = temp4.split("\\,");
private JComboBox cmbEstilo = new JComboBox(estilosArray);
private int fuente = Integer.parseInt(UserPreferenceStore.getUserPreference(UserPreferenceConstants.DEFAULT_MENU_FONT,"0",true));
private String tamanno = UserPreferenceStore.getUserPreference(UserPreferenceConstants.DEFAULT_MENU_SIZE,"12",true);
private int estilo = Integer.parseInt(UserPreferenceStore.getUserPreference(UserPreferenceConstants.DEFAULT_MENU_STYLE,"0",true));
private JPanel appIconStylePanel = new JPanel();
private JButton btnFile = new JButton();
private File file = null;
private JLabel lblFile = null;
private String appIcon;
private JCheckBox pintadoEscalableCheckBox = null;
private JPanel jPanel = null;
private JTextField unitTextField = null;
private JFormattedTextField equivalenceTextField1 = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private DecimalFormat decimalFormat = new DecimalFormat();
private JPanel visorDataJPanel;
private JLabel anchoMonitorJLabel = null;
private JTextField anchoMonitorTextField = null;
/**
* This method initializes pintadoEscalableCheckBox
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getPintadoEscalableCheckBox() {
if (pintadoEscalableCheckBox == null) {
pintadoEscalableCheckBox = new JCheckBox();
pintadoEscalableCheckBox.setComponentOrientation(java.awt.ComponentOrientation.RIGHT_TO_LEFT);
pintadoEscalableCheckBox.setText("escalado");
pintadoEscalableCheckBox.addItemListener(new java.awt.event.ItemListener() {
String escala="";
public void itemStateChanged(java.awt.event.ItemEvent e) {
if (getPintadoEscalableCheckBox().isSelected())
{
pintadoEscalableTextField.setText(escala);
pintadoEscalableTextField.setEnabled(true);
}
else
{
escala=pintadoEscalableTextField.getText();
pintadoEscalableTextField.setText("");
pintadoEscalableTextField.setEnabled(false);
}
}
});
}
return pintadoEscalableCheckBox;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel2 = new JLabel();
jLabel1 = new JLabel();
jLabel = new JLabel();
GridBagConstraints gridBagConstraints23 = new GridBagConstraints();
GridBagConstraints gridBagConstraints221 = new GridBagConstraints();
GridBagConstraints gridBagConstraints241 = new GridBagConstraints();
GridBagConstraints gridBagConstraints251 = new GridBagConstraints();
GridBagConstraints gridBagConstraints261 = new GridBagConstraints();
jPanel = new JPanel();
jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Conversión Unidades", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
jPanel.setLayout(new GridBagLayout());
gridBagConstraints221.gridx = 0;
gridBagConstraints221.gridy = 1;
gridBagConstraints221.weightx = 1.0;
gridBagConstraints221.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints221.insets = new java.awt.Insets(5,5,0,5);
gridBagConstraints23.gridx = 1;
gridBagConstraints23.gridy = 1;
gridBagConstraints23.weightx = 1.0;
gridBagConstraints23.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints23.insets = new java.awt.Insets(5,5,0,5);
gridBagConstraints241.gridx = 2;
gridBagConstraints241.gridy = 1;
gridBagConstraints241.insets = new java.awt.Insets(5,5,0,5);
jLabel.setText("m2 por Unidad");
gridBagConstraints251.gridx = 0;
gridBagConstraints251.gridy = 0;
jLabel1.setText("Unidad");
gridBagConstraints261.gridx = 1;
gridBagConstraints261.gridy = 0;
jLabel2.setText("Equivalencia");
jPanel.add(getUnitTextField(), gridBagConstraints221);
jPanel.add(getEquivalenceTextField1(), gridBagConstraints23);
jPanel.add(jLabel, gridBagConstraints241);
jPanel.add(jLabel1, gridBagConstraints251);
jPanel.add(jLabel2, gridBagConstraints261);
}
return jPanel;
}
/**
* This method initializes unitTextField
*
* @return javax.swing.JTextField
*/
private JTextField getUnitTextField() {
if (unitTextField == null) {
unitTextField = new JTextField();
}
return unitTextField;
}
/**
* This method initializes equivalenceTextField1
*
* @return javax.swing.JTextField
*/
private JTextField getEquivalenceTextField1() {
if (equivalenceTextField1 == null) {
equivalenceTextField1 = new JFormattedTextField(decimalFormat);
}
return equivalenceTextField1;
}
public static void main(String[] args)
{
JFrame fr = new JFrame("Test"); //$NON-NLS-1$
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fr.setSize(500,500);
fr.getContentPane().add(new GeopistaPreferencesPanel());
fr.setVisible(true);
}
public GeopistaPreferencesPanel()
{
decimalFormat.setGroupingUsed(false);
txtTamanno = new JFormattedTextField(decimalFormat);
jbInit();
}
private void setTexts()
{
((TitledBorder)seleccionStylePanel.getBorder()).setTitle(appContext.getI18nString("lblColorSeleccion"));
((TitledBorder)menuPanel.getBorder()).setTitle(appContext.getI18nString("lblMenu"));
((TitledBorder)appIconStylePanel.getBorder()).setTitle(appContext.getI18nString("lblIconFile"));
lblFuente.setText(appContext.getI18nString("lblFuente"));
lblTamanno.setText(appContext.getI18nString("lblTamanno"));
txtTamanno.setText(tamanno);
lblEstilo.setText(appContext.getI18nString("lblEstilo"));
pintadoEscalableCheckBox.setText(appContext.getI18nString("lblPintadoEscalable"));
btnFile.setText(appContext.getI18nString("btnIconFile"));
anchoMonitorJLabel.setText(appContext.getI18nString("anchoMonitorJLabel"));
}
private void jbInit()
{
java.awt.GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
lblFile = new JLabel();
java.awt.GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints30 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints29 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints28 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints27 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints26 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints25 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints24 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
java.awt.GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setSize(new java.awt.Dimension(274,330));
seleccionStylePanel.setLayout(new GridBagLayout());
seleccionStylePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "SelectionStyle", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
menuPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "MenusStyle", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
menuPanel.setLayout(new GridBagLayout());
cmbColorSeleccion.setSelectedIndex(colorSeleccion);
String tempSeleccion = coloresRGBArray[colorSeleccion];
String[] rgb = tempSeleccion.split("\\,");
pnlColor.setBackground(new Color(Integer.parseInt(rgb[0]),Integer.parseInt(rgb[1]),Integer.parseInt(rgb[2])));
cmbColorSeleccion.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
cmbColorSeleccion_actionPerformed(e);
}
});
cmbFuente.setSelectedIndex(fuente);
cmbEstilo.setSelectedIndex(estilo);
appIconStylePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "logotipoStyle", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
appIconStylePanel.setLayout(new GridBagLayout());
pnlColor.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.SoftBevelBorder.LOWERED));
lblFile.setText("Default");
lblFile.setPreferredSize(new java.awt.Dimension(190,15));
lblFile.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.SoftBevelBorder.LOWERED));
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets(5,5,5,5);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
btnFile.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
btnFile_actionPerformed(e);
}
});
pnlColor.setOpaque(true);
pnlColor.setMinimumSize(new java.awt.Dimension(32,32));
pnlColor.setPreferredSize(new java.awt.Dimension(32,32));
gridBagConstraints21.gridx = 0;
gridBagConstraints21.gridy = 1;
gridBagConstraints21.gridwidth = 1;
gridBagConstraints21.ipady = 0;
gridBagConstraints21.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints21.insets = new java.awt.Insets(0,20,0,0);
gridBagConstraints22.gridx = 1;
gridBagConstraints22.gridy = 1;
gridBagConstraints22.weightx = 1.0;
gridBagConstraints22.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints22.ipadx = 0;
gridBagConstraints22.ipady = 0;
gridBagConstraints22.insets = new java.awt.Insets(0,5,0,20);
cmbColorSeleccion.setPreferredSize(new java.awt.Dimension(32,20));
gridBagConstraints24.gridx = 2;
gridBagConstraints24.gridy = 3;
gridBagConstraints24.weightx = 1.0;
gridBagConstraints24.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints24.ipadx = 104;
gridBagConstraints24.ipady = -1;
gridBagConstraints24.insets = new java.awt.Insets(5,5,5,5);
gridBagConstraints25.gridx = 0;
gridBagConstraints25.gridy = 3;
gridBagConstraints25.ipadx = 50;
gridBagConstraints25.ipady = 20;
gridBagConstraints25.insets = new java.awt.Insets(5,5,5,5);
gridBagConstraints25.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints25.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints26.gridx = 2;
gridBagConstraints26.gridy = 1;
gridBagConstraints26.weightx = 1.0;
gridBagConstraints26.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints26.ipadx = 104;
gridBagConstraints26.ipady = -1;
gridBagConstraints26.insets = new java.awt.Insets(5,5,0,5);
gridBagConstraints27.gridx = 2;
gridBagConstraints27.gridy = 2;
gridBagConstraints27.weightx = 1.0;
gridBagConstraints27.fill = java.awt.GridBagConstraints.NONE;
gridBagConstraints27.ipadx = 39;
gridBagConstraints27.ipady = -1;
gridBagConstraints27.insets = new java.awt.Insets(5,5,0,5);
gridBagConstraints27.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints28.gridx = 0;
gridBagConstraints28.gridy = 2;
gridBagConstraints28.gridwidth = 1;
gridBagConstraints28.ipadx = 60;
gridBagConstraints28.ipady = 20;
gridBagConstraints28.insets = new java.awt.Insets(5,5,0,5);
gridBagConstraints28.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints28.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints29.gridx = 0;
gridBagConstraints29.gridy = 1;
gridBagConstraints29.ipadx = 45;
gridBagConstraints29.ipady = 20;
gridBagConstraints29.insets = new java.awt.Insets(5,5,0,5);
gridBagConstraints29.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints29.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints31.gridx = 2;
gridBagConstraints31.gridy = 0;
gridBagConstraints31.ipadx = 0;
gridBagConstraints31.ipady = 0;
gridBagConstraints31.insets = new java.awt.Insets(5,5,5,5);
pintadoEscalableTextField.setColumns(8);
txtTamanno.setColumns(3);
gridBagConstraints11.gridx = 2;
gridBagConstraints11.gridy = 0;
gridBagConstraints11.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints11.insets = new java.awt.Insets(0,5,0,0);
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 0;
this.add(seleccionStylePanel, null);
seleccionStylePanel.add(pnlColor, gridBagConstraints21);
appIconStylePanel.add(btnFile, gridBagConstraints31);
menuPanel.add(cmbEstilo, gridBagConstraints24);
this.add(appIconStylePanel, null);
seleccionStylePanel.add(cmbColorSeleccion, gridBagConstraints22);
appIconStylePanel.add(lblFile, gridBagConstraints1);
menuPanel.add(lblEstilo, gridBagConstraints25);
this.add(menuPanel, null);
menuPanel.add(cmbFuente, gridBagConstraints26);
menuPanel.add(txtTamanno, gridBagConstraints27);
this.add (getVisorDataJPanel(), null);
getAnchoMonitorTextField().setText(String.valueOf(anchoMonitor));
this.add(getJPanel(), null);
menuPanel.add(lblTamanno, gridBagConstraints28);
menuPanel.add(lblFuente, gridBagConstraints29);
menuPanel.add(pintadoEscalableTextField, gridBagConstraints11);
menuPanel.add(getPintadoEscalableCheckBox(), gridBagConstraints3);
setTexts();
}
private JPanel getVisorDataJPanel() {
if (visorDataJPanel == null) {
visorDataJPanel = new JPanel();
visorDataJPanel.setLayout(new GridBagLayout());
visorDataJPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos para la visualización a escala",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
anchoMonitorJLabel = new JLabel();
anchoMonitorJLabel.setText("Ancho del monitor (cm)");
visorDataJPanel.add (anchoMonitorJLabel,
new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL, new Insets(0,5,0,0),0,0));
visorDataJPanel.add (getAnchoMonitorTextField(),
new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),0,0));
}
return visorDataJPanel;
}
private JTextField getAnchoMonitorTextField() {
if (anchoMonitorTextField == null) {
anchoMonitorTextField = new JFormattedTextField(decimalFormat);
}
return anchoMonitorTextField;
}
public String validateInput() {
//Comprobamos que el numero introducido sea un Double
pintadoEscalableValor = null;
String localEscalableValor = pintadoEscalableTextField.getText();
if (!"".equals(localEscalableValor))
{
try
{
pintadoEscalableValor = new Double(localEscalableValor);
}
catch(NumberFormatException e)
{
logger.error("validateInput()", e);
return appContext.getI18nString("lblEscalaErronea");
}
}
anchoMonitorValor = null;
String localAnchoMonitorValor = anchoMonitorTextField.getText();
if ("".equals(localAnchoMonitorValor))
return null;
try
{
anchoMonitorValor = new Double(localAnchoMonitorValor.replaceFirst(",", "."));
}
catch(NumberFormatException e)
{
logger.error("validateInput()", e);
return appContext.getI18nString("lblAnchoErroneo");
}
return null;
}
/**
* okPressed()
* Método que se activa cuando se presiona el botón de Aceptar. Escribe las
* propiedades modificadas en el Geopista18n.properties. Es necesario reiniciar
* la aplicación para que los cambios surtan efecto.
*/
public void okPressed() {
validateInput();// asegura que se evaluan los campos locales
UserPreferenceStore.setUserPreference(UserPreferenceConstants.DEFAULT_FEATURE_SELECTED_COLOR,String.valueOf(cmbColorSeleccion.getSelectedIndex()));
UserPreferenceStore.setUserPreference(UserPreferenceConstants.DEFAULT_MENU_FONT,String.valueOf(cmbFuente.getSelectedIndex()));
UserPreferenceStore.setUserPreference(UserPreferenceConstants.DEFAULT_MENU_STYLE,String.valueOf(cmbEstilo.getSelectedIndex()));
UserPreferenceStore.setUserPreference(UserPreferenceConstants.DEFAULT_MENU_SIZE,txtTamanno.getText());
UserPreferenceStore.setUserPreference(UserPreferenceConstants.DEFAULT_UNIT_NAME,unitTextField.getText());
UserPreferenceStore.setUserPreference(UserPreferenceConstants.DEFAULT_UNIT_EQUIVALENCE,equivalenceTextField1.getText());
UserPreferenceStore.setUserPreference(SLDStyleImpl.SYMBOLIZER_SIZES_REFERENCE_SCALE,String.valueOf(pintadoEscalableValor));
appContext.getBlackboard().put(SLDStyleImpl.SYMBOLIZER_SIZES_REFERENCE_SCALE,pintadoEscalableValor);
UserPreferenceStore.setUserPreference(UserPreferenceConstants.DEFAULT_SCREEN_WEIGHT,String.valueOf(anchoMonitorValor));
if (file!=null)// el usuario ha elegido un fichero específico
{
String path = UserPreferenceStore.getUserPreference(UserPreferenceConstants.PREFERENCES_DATA_PATH_KEY,UserPreferenceConstants.DEFAULT_DATA_PATH,false)+file.getName();
GeopistaFunctionUtils.copyFile(new File(path),file);
UserPreferenceStore.setUserPreference(UserPreferenceConstants.PREFERENCES_APPICON_KEY,file.getName());
//appContext.getMainFrame().setIconImage(Toolkit.getDefaultToolkit().getImage(file.getAbsolutePath()));
}
}
public void init() {
appIcon=UserPreferenceStore.getUserPreference(UserPreferenceConstants.PREFERENCES_APPICON_KEY,null,false);
if (appIcon==null)//icono por defecto
lblFile.setText(AppContext.getMessage("GeopistaPreferencesPanel.DefaultIcon"));
lblFile.setText(UserPreferenceStore.getUserPreference(UserPreferenceConstants.PREFERENCES_DATA_PATH_KEY,UserPreferenceConstants.DEFAULT_DATA_PATH,false)+
UserPreferenceStore.getUserPreference(UserPreferenceConstants.PREFERENCES_APPICON_KEY,"",false));
String escala=UserPreferenceStore.getUserPreference(SLDStyleImpl.SYMBOLIZER_SIZES_REFERENCE_SCALE,"null",false);
if ("null".equals(escala))
{
getPintadoEscalableCheckBox().setSelected(false);
pintadoEscalableTextField.setEnabled(false);
pintadoEscalableTextField.setText("");
}
else
{
getPintadoEscalableCheckBox().setSelected(true);
pintadoEscalableTextField.setEnabled(true);
pintadoEscalableTextField.setText(escala);
}
String unitName = UserPreferenceStore.getUserPreference(UserPreferenceConstants.DEFAULT_UNIT_NAME,"",true);
String unitEquivalence = UserPreferenceStore.getUserPreference(UserPreferenceConstants.DEFAULT_UNIT_EQUIVALENCE,"",true);
equivalenceTextField1.setText(unitEquivalence);
unitTextField.setText(unitName);
}
private void cmbColorSeleccion_actionPerformed(ActionEvent e)
{
JComboBox cb = (JComboBox)e.getSource();
int index = cb.getSelectedIndex();
updateColor(index);
}
/**
* updateColor(int index)
* Método que actualiza el cuadro de color
*/
protected void updateColor(int index) {
String temp = coloresRGBArray[index];
String[] rgb = temp.split("\\,");
pnlColor.setBackground(new Color(Integer.parseInt(rgb[0]),Integer.parseInt(rgb[1]),Integer.parseInt(rgb[2])));
}
private void btnFile_actionPerformed(ActionEvent e)
{
boolean status = false;
status = openFile();
}
/**
* openFile()
* Método que abre el cuadro de dialogo para cargar ficheros
*/
boolean openFile()
{
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Open File");
// Choose only files, not directories
fc.setFileSelectionMode( JFileChooser.FILES_ONLY);
// Start in current directory
fc.setCurrentDirectory(new File(UserPreferenceStore.getUserPreference(UserPreferenceConstants.PREFERENCES_LAST_IMAGE_FOLDER_KEY,".",false)));
// Set filter for Java source files.
//fc.setFileFilter(javaFilter);
// Now open chooser
int result = fc.showOpenDialog(this);
if( result == JFileChooser.CANCEL_OPTION)
{
return true;
}else if( result == JFileChooser.APPROVE_OPTION)
{
file = fc.getSelectedFile();
lblFile.setText(file.getAbsolutePath());
UserPreferenceStore.setUserPreference(UserPreferenceConstants.PREFERENCES_LAST_IMAGE_FOLDER_KEY,file.getPath());
}else
{
return false;
}
return true;
}
} // @jve:decl-index=0:visual-constraint="10,10" | [
"[email protected]"
]
| |
c0aaf2b4248cc65b6952c4d62d64176d9a9c58fb | b3c1ddb6e23f1d4c3423dbc5e1d41de7c766cc01 | /app/src/main/java/com/example/ducng/mvp_rx_di/adapter/MainAdapter.java | cadd9ccb97aac08c88799f710e004d76ad39103f | []
| no_license | ducnguyenbk/MVP-RX-Dagger | d8220714dbf34698a80a57799f7cf46ec0973c67 | 0bea23b42e2a5047a02f7495c3326b1687a97551 | refs/heads/master | 2021-03-27T20:11:12.486278 | 2017-10-06T10:08:45 | 2017-10-06T10:08:45 | 105,991,362 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,056 | java | package com.example.ducng.mvp_rx_di.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.example.ducng.mvp_rx_di.R;
import com.example.ducng.mvp_rx_di.model.DataItemList;
import com.example.ducng.mvp_rx_di.model.ListResponse;
import java.util.ArrayList;
import java.util.List;
/**
* Created by ducng on 10/6/2017.
*/
public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
private Context mContext;
private List<DataItemList> listResponses = new ArrayList<>();
public MainAdapter(Context context, List<DataItemList> list) {
mContext = context;
listResponses = list;
}
@Override
public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View view = inflater.inflate(R.layout.item_image, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {
holder.tvCity.setText(listResponses.get(position).getName());
holder.tvDesc.setText(listResponses.get(position).getDescription());
Glide.with(mContext)
.load(listResponses.get(position).getBackground())
.into(holder.background);
}
@Override
public int getItemCount() {
return listResponses.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView tvCity, tvDesc;
ImageView background;
public ViewHolder(View itemView) {
super(itemView);
tvCity = (TextView) itemView.findViewById(R.id.city);
tvDesc = (TextView) itemView.findViewById(R.id.hotel);
background = (ImageView) itemView.findViewById(R.id.image);
}
}
}
| [
"[email protected]"
]
| |
33f53bf7454565e72349512aed873fc8625ae70f | a00b0718cddaade024c0e79efdb5f9a00503df98 | /thb/rrpo-java/src/main/java/com/jiebao/platfrom/check/service/IGradeService.java | dfe2bfc61655b801fd44a67073f9178c1521eec9 | []
| no_license | wwwK/applet | 872c7798a9e7ac0146abfe2ddaff2f251b194f01 | 50e57f5c40655af0797d9c3aafa1d3ca1619d7f9 | refs/heads/master | 2023-08-11T06:33:35.918519 | 2021-01-21T06:38:59 | 2021-01-21T06:38:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,035 | java | package com.jiebao.platfrom.check.service;
import com.jiebao.platfrom.check.domain.Grade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jiebao.platfrom.common.domain.JiebaoResponse;
import io.swagger.models.auth.In;
import java.util.Date;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author qta
* @since 2020-07-28
*/
public interface IGradeService extends IService<Grade> {
JiebaoResponse addGrade(String gradeId, Double number, String message, Integer type); //自评第一次
JiebaoResponse commit(String yearDate, String deptId, Integer status);//最后提交 分数统计生成表
JiebaoResponse selectByUserIdOrDateYear(String dateYear, String DeptId); //查询对应考试情况
JiebaoResponse putZz(String gradeId, String[] ids);//上传佐证操作
JiebaoResponse checkStatus(String gradeId, Integer status);//审核 考核项是否存在问题
JiebaoResponse checkStatusZZ(String zzId, Integer status);//审核 考核项是否存在问题
}
| [
"[email protected]"
]
| |
90b0a26ebe9fec89f6b1c6a193e3b150a68011b7 | 974dba189a8eabe2abb87040d6f691b6322648e9 | /baselibrary/src/main/java/com/yunmayi/app/baselibrary/api/RequestParameter.java | 09175461d106b4ac02491ca30c1d97dfdce9c1df | []
| no_license | gsyangs/modular | 1f3565307011fe39696928c58710b9ead70af4d6 | 0e11939d5028bcd65c1f66f92fc17311e84351cc | refs/heads/master | 2023-05-31T03:52:42.852795 | 2021-05-31T08:59:18 | 2021-05-31T08:59:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,680 | java | package com.yunmayi.app.baselibrary.api;
import com.google.gson.Gson;
import com.yunmayi.app.baselibrary.utils.TextUtils;
import java.util.HashMap;
import java.util.Map;
/**
* 封装用于网络请求的网络地址和网络地址, 并按照格式输出 注意自己保证数据的完整性
*/
public class RequestParameter {
/** 保存网络请求的参数及值 */
private Map<String,Object> mParams = null;
/**
* 网络请求的参数中默认自带某些接口参数
* boolean isSetName 是否设置用户名
*/
public RequestParameter() {
this.mParams = new HashMap<String ,Object>();
}
/**
* 设置用于网络请求的参数及参数值
* @param name 参数名称
* @param value 参数值
*/
public void setParam(String name, Object value) {
if(value instanceof String){
if (!TextUtils.isEmpty((String)value)){
mParams.put(name, value);
}
}else{
mParams.put(name, value);
}
}
/**
* 设置公共参数
*/
private void setCommonParams(){
mParams.put("app_id", Configure.AppId);
mParams.put("timestamp", Signature.currentTimeSecond());
String sign = Signature.getSign(mParams,Configure.Secret);
mParams.put("sign",sign);
}
/**
* post参数
* @return
*/
public String postParams() {
setCommonParams();
String postInfoStr = new Gson().toJson(mParams);
return postInfoStr;
}
/**
* get参数
* @return
*/
public Map getMapParams() {
setCommonParams();
return mParams;
}
}
| [
"[email protected]"
]
| |
9ce7f45a4a3e26cca506f1989f1b544f78702fae | 04587278e938cfd533a59ebfcc3dcd04861e6887 | /School Projects/CSE-545-Software_Security/BankApplication/src/com/spring/dao/RefUserRoleDAO.java | 651cf49923bb47bec845af3923a4df9eafb4e6fc | []
| no_license | ssangani/Projects | 4dfc2c679388158815cb19a9a300229045d3739c | a2fd967a50344d6f6762f6c97fe6b346476fbcee | refs/heads/master | 2021-01-18T02:30:30.720818 | 2016-01-05T04:47:41 | 2016-01-05T04:47:41 | 48,260,488 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 526 | java | package com.spring.dao;
/**
* @author Sagar Sangani
* @date Oct 8, 2015
*/
import java.util.List;
import org.springframework.stereotype.Repository;
import com.spring.model.RefUserRole;
import com.spring.util.CustomHibernateDAOSupport;
@Repository("refUserRoleDao")
public class RefUserRoleDAO extends CustomHibernateDAOSupport {
public RefUserRole findByName(String roleName){
List list = getHibernateTemplate().find("from RefUserRole where bankUserRoleName = ?", roleName);
return (RefUserRole)list.get(0);
}
}
| [
"[email protected]"
]
| |
6d34a61478db07cd51375cc3dfe72c0ad073d29b | f0a3e4bb044c0afd7dff30d27f3383d530fc69cc | /src/main/java/WebService/Resource.java | 09240bfa0395895d7974dfdb7223f69b77612ab0 | []
| no_license | AmKord/Spring-Demo | eab933405944f0373252c89701629b97ed375173 | 71253062398ddd1ba339848ce977f049506ba6c9 | refs/heads/master | 2020-03-08T10:39:16.631337 | 2018-04-05T09:11:59 | 2018-04-05T09:11:59 | 128,078,515 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 285 | java | package WebService;
public class Resource {
private final int id;
private final String content;
public Resource(int id,String content)
{
this.id=id;
this.content=content;
}
public int getId() {
return id;
}
public String getContent() {
return content;
}
}
| [
"[email protected]"
]
| |
00558e472fb2b8c79b916e03a12e22ddaa0b8963 | 7f8577aed090977d2d3606f53c91187941eab33f | /travelPlanWebService/src/main/java/com/lsm/travelPlan/ws/starHotelWs/StarHotelWebServiceNew68.java | de84fb96b25ab249dd7dd7b5b177b8ea282834fb | []
| no_license | KevinINGitHub/WebserviceSelected-MasterThesisProject- | 817389a149ef1701248681bf205331a5ce14f15d | 20f2038d087fff236afdbfe46a478b78c09c9726 | refs/heads/master | 2021-01-20T11:50:51.209628 | 2017-03-19T11:21:33 | 2017-03-19T11:23:28 | 85,469,980 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,274 | java | package com.lsm.travelPlan.ws.starHotelWs;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import com.lsm.perfAnalysis.GenerateQos;
import com.lsm.travelPlan.scenicSpotWsSet.ScenicSpotWebService;
import com.lsm.travelPlan.service.ReceiveDataFRestful;
import com.lsm.travelPlan.ws.scenicSpotWs.ScenicSpotWebServiceNew;
public class StarHotelWebServiceNew68 {
public String getStarHotelListInfo(){
String className=this.getClass().getSimpleName();
GenerateQos.generateReliab(className);
GenerateQos.generateResponseT(className);
String httpUrl="http://localhost:8080/justTest/rest/hotelInfo/hotelDetailList";
String result=ReceiveDataFRestful.request(httpUrl,"");
return result;
}
public String getSearchStarHotelInfo(String destination){
String className=this.getClass().getSimpleName();
GenerateQos.generateReliab(className);
GenerateQos.generateResponseT(className);
try {
destination = URLEncoder.encode(destination, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String httpArg="destination="+destination;
String httpUrl="http://localhost:8080/justTest/rest/hotelInfo/hotelDetailListRev";
String result=ReceiveDataFRestful.request(httpUrl,httpArg);
return result;
}
}
| [
"[email protected]"
]
| |
b9fec7e214666f602097449d8550e98e378f9275 | 4dc162bcc8d834865746063531e6298b2a18bf20 | /yflLibrary/src/main/java/com/backpacker/yflLibrary/java/asyn/SingleAsyncTask.java | b9796c14c8fac39af4e39a8b00975ffb7c5a6b6e | []
| no_license | yufeilong92/yfl | 3cf1017196667e842470510f79afe39bd9ca101e | c0f122fb9d76f982e425a1cfca81ad327b4522d9 | refs/heads/master | 2021-06-12T19:58:24.851850 | 2020-12-08T08:27:05 | 2020-12-08T08:27:05 | 254,385,526 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,136 | java | package com.backpacker.yflLibrary.java.asyn;
import android.os.Binder;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.annotation.MainThread;
import androidx.annotation.WorkerThread;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* @Author : YFL is Creating a porject in My Application
* @Package com.example.myapplication.asynctaskscheduler
* @Email : [email protected]
* @Time :2020/11/10 16:16
* @Purpose : 异步线程
*/
public abstract class SingleAsyncTask<Progress,Result> {
private final AtomicBoolean mIsCancelled = new AtomicBoolean();
private final static Handler sUIHandler = new InternalHandler();
private static final int SINGLE_TASK_EXECUTED_RESULT = 0x1;
private static final int SINGLE_TASK_EXECUTED_PROGRESS = 0x2;
private FutureTask<Result> mFutureResult;
protected SingleAsyncTask() {
Callable<Result> taskCallable = new Callable<Result>() {
@Override
public Result call() throws Exception {
Binder.flushPendingCommands();
return doInBackground();
}
};
mFutureResult = new FutureTask<Result>(taskCallable) {
@Override
protected void done() {
super.done();
try {
postResult(get());
} catch (Exception e) {
onExecuteFailed(e);
}
}
};
}
public void executeSingle() {
Thread workThread= new Thread(mFutureResult);
workThread.start();
}
private void postResult(Result result) {
if(mIsCancelled.get()) {
return;
}
sUIHandler.obtainMessage(SINGLE_TASK_EXECUTED_RESULT,new AsyncTaskResult<Result>(this,result)).sendToTarget();
}
FutureTask<Result> getFutureTask() {
return mFutureResult;
}
@WorkerThread
protected abstract Result doInBackground();
@MainThread
protected void onProgressUpdate(Progress values) {
}
@MainThread
protected void onExecuteSucceed(Result result){
}
@WorkerThread
protected void onExecuteFailed(Exception exception){
}
@MainThread
protected void onExecuteCancelled(Result result){
}
@WorkerThread
protected final void publishProgress(Progress values) {
if (!isCancelled()) {
sUIHandler.obtainMessage(SINGLE_TASK_EXECUTED_PROGRESS,
new AsyncTaskResult<Progress>(this, values)).sendToTarget();
}
}
private void finish(Result result) {
if (isCancelled()) {
onExecuteCancelled(result);
} else {
onExecuteSucceed(result);
}
}
public final boolean cancel(boolean mayInterruptIfRunning) {
mIsCancelled.set(true);
return mFutureResult.cancel(mayInterruptIfRunning);
}
public boolean isCancelled() {
return mIsCancelled.get();
}
private static class AsyncTaskResult<Data> {
final SingleAsyncTask mSingleAsyncTask;
final Data mData;
AsyncTaskResult(SingleAsyncTask singleAsyncTask, Data data) {
mSingleAsyncTask = singleAsyncTask;
mData = data;
}
}
private static class InternalHandler extends Handler {
InternalHandler() {
super(Looper.getMainLooper());
}
@SuppressWarnings({"unchecked", "RawUseOfParameterizedType"})
@Override
public void handleMessage(Message msg) {
AsyncTaskResult<?> asyncTaskResult = (AsyncTaskResult<?>) msg.obj;
switch (msg.what) {
case SINGLE_TASK_EXECUTED_RESULT:
asyncTaskResult.mSingleAsyncTask.finish(asyncTaskResult.mData);
break;
case SINGLE_TASK_EXECUTED_PROGRESS:
asyncTaskResult.mSingleAsyncTask.onProgressUpdate(asyncTaskResult.mData);
break;
}
}
}
}
| [
"[email protected]"
]
| |
b5eef3e0e20182c0dcd206244bf8e5215f8c2315 | d63baac4f7548a1eb7dad8d9ac924f28ea8e63b9 | /src/it/algos/vaadbio/liste/ListaAntroponimo.java | d6936b4ba3e38347ebbf6add0695aa240e884fcf | []
| no_license | GuidoCeresa/vaadbio | 1ec023555ad069825c81cf661426d74fb56c8b56 | 0286830c0bd49367d7757027c6628afef773bd4a | refs/heads/master | 2020-04-16T23:45:29.259482 | 2018-02-08T12:40:23 | 2018-02-08T12:40:23 | 46,733,460 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,449 | java | package it.algos.vaadbio.liste;
import it.algos.vaadbio.bio.Bio;
import it.algos.vaadbio.lib.CostBio;
import it.algos.vaadbio.lib.LibBio;
import it.algos.webbase.domain.pref.Pref;
/**
* Created by gac on 31 ott 2016.
* <p>
* Crea la lista antroponima
* <p>
* Crea la lista dei nomi e la carica sul server wiki
* Crea la lista dei cognomi e la carica sul server wiki
*/
public abstract class ListaAntroponimo extends ListaBio {
/**
* Costruttore senza parametri
*/
protected ListaAntroponimo() {
}// fine del costruttore
/**
* Costruttore completo
*/
public ListaAntroponimo(Object oggetto) {
super(oggetto);
}// fine del costruttore
/**
* Regola alcuni (eventuali) parametri specifici della sottoclasse
* <p>
* Nelle sottoclassi va SEMPRE richiamata la superclasse PRIMA di regolare localmente le variabili <br>
* Sovrascritto
*/
@Override
protected void elaboraParametri() {
super.elaboraParametri();
// head
usaHeadTocIndice = true;
usaHeadIncipit = true;
tagHeadTemplateProgetto = "antroponimi";
// body
usaSuddivisioneParagrafi = true;
usaBodyRigheMultiple = false;
usaBodyDoppiaColonna = false;
usaSottopagine = true;
usaTitoloParagrafoConLink = true;
usaTaglioVociPagina = true;
maxVociPagina = Pref.getInt(CostBio.TAGLIO_NOMI_PAGINA, 100);
// footer
usaFooterPortale = Pref.getBool(CostBio.USA_FOOTER_PORTALE_NOMI, true);
if (Pref.getBool(CostBio.USA_DEBUG, false)) {
usaFooterCategorie = false;
} else {
usaFooterCategorie = Pref.getBool(CostBio.USA_FOOTER_CATEGORIE_NOMI, true);
}// end of if/else cycle
}// fine del metodo
/**
* Costruisce la chiave del paragrafo
* Sovrascritto
*/
@Override
protected String getChiave(Bio bio) {
return LibBio.getChiavePerAttivita(bio, tagParagrafoNullo);
}// fine del metodo
/**
* Piede della pagina
* Sovrascritto
*/
@Override
protected String elaboraFooter() {
String text = CostBio.VUOTO;
boolean usaInclude = usaFooterPortale || usaFooterCategorie;
if (usaFooterPortale) {
text += CostBio.A_CAPO;
text += "{{Portale|antroponimi}}";
}// end of if cycle
if (usaFooterCategorie) {
text += CostBio.A_CAPO;
text += elaboraCategorie();
}// end of if cycle
if (usaInclude) {
text = CostBio.A_CAPO + LibBio.setNoIncludeMultiRiga(text);
}// end of if cycle
return text;
}// fine del metodo
/**
* Categorie al piede della pagina
* Sovrascritto
*/
protected String elaboraCategorie() {
return "";
}// fine del metodo
/**
* Controlla che la modifica sia sostanziale
* Se il flag è false, registra sempre
* Se il flag è vero, controlla la differenza del testo
* Sovrascritto
*/
@Override
protected boolean checkPossoRegistrare(String titolo, String testo) {
if (Pref.getBool(CostBio.USA_REGISTRA_SEMPRE_PERSONA, false)) {
return true;
} else {
return LibBio.checkModificaSostanziale(titolo, testo, tagHeadTemplateAvviso, "}}");
}// end of if/else cycle
}// fine del metodo
}// fine della classe
| [
"[email protected]"
]
| |
2bb305edd4d9e8d03aa121755113e106ba979191 | 4603098a03b049a9aca6951d5c5fd776aaaf3826 | /src/main/java/com/leetcode/algorithms/cache/LRUCache.java | 37c247b3b1dafa199d28b277b25026bc26b737f8 | []
| no_license | shenxiangshx/leecodeProblem | 982b31f7007628883416fe1814230e46fed048e6 | bda6125cad74bd2eeccd967c8d3d55d097a50759 | refs/heads/master | 2022-06-26T07:24:49.531493 | 2019-08-27T02:38:42 | 2019-08-27T02:38:42 | 142,537,829 | 0 | 0 | null | 2022-06-17T01:45:34 | 2018-07-27T06:36:28 | Java | UTF-8 | Java | false | false | 1,989 | java | package com.leetcode.algorithms.cache;
import com.leetcode.bean.LRUNode;
import java.util.HashMap;
public class LRUCache<T,E> {
private LRUNode<T,E> head;
private LRUNode<T,E> end;
private int capacity;
private HashMap<T, LRUNode<T,E>> cacheMap;
public LRUCache(int capacity){
this.capacity=capacity;
cacheMap=new HashMap<>();
}
public E get(T key){
LRUNode<T,E> node=cacheMap.get(key);
if (node==null){
return null;
}
refreshNode(node);
return node.val;
}
public void put(T key, E value){
LRUNode<T,E> node=cacheMap.get(key);
if (node==null){
if (cacheMap.size()>=capacity){
T oldKey = (T) removeNode(head);
cacheMap.remove(oldKey);
}
node=new LRUNode<T,E>(key,value);
addNode(node);
cacheMap.put(key, node);
}else {
node.val=value;
refreshNode(node);
}
}
public void remove(T key){
LRUNode<T,E> node=cacheMap.get(key);
removeNode(node);
cacheMap.remove(key);
}
private void refreshNode(LRUNode<T,E> node){
if (node==end){
return;
}
removeNode(node);
addNode(node);
}
private T removeNode(LRUNode<T,E> node){
if (node==head&&node==end){
head=null;
end=null;
}else if (node==end){
end=end.pre;
end.next=null;
}else if (node==head){
head=head.next;
head.pre=null;
}else {
node.pre.next=node.next;
node.next.pre=node.pre;
}
return node.key;
}
private void addNode(LRUNode<T,E> node){
if (end!=null){
end.next=node;
node.pre=end;
node.next=null;
}
end=node;
if (head==null){
head=node;
}
}
}
| [
"[email protected]"
]
| |
1159f7d6cb40b8226b83632816f9559051169469 | f45643311f616d569b6233464f2954c696d0e9a2 | /pgi-lab/src/com/pgi/test/patient/GetAllPatientTest.java | 0faebdee388c0624938e5b46c6ef2b84b94eec11 | []
| no_license | techesachin/pgi-lab | 3af1a25646390b0214b67316af418da2c0b25da3 | d7f8dadf0f93383e4b99f082115d2ac6ea8b9d77 | refs/heads/master | 2021-05-23T17:56:54.827184 | 2020-04-13T14:38:29 | 2020-04-13T14:38:29 | 253,408,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 667 | java | package com.pgi.test.patient;
import com.pgi.dao.PatientDAO;
import com.pgi.dao.impl.PatientDAOImpl;
import com.pgi.domain.Patient;
import java.util.List;
public class GetAllPatientTest {
public static void main(String[] args) {
PatientDAO patientDAO = new PatientDAOImpl();
final List<Patient> patients = patientDAO.getPatients();
/*for (Patient p : patients) {
System.out.println(p);
}*/
patients.stream().forEach(patient -> {
System.out.println(patient);
});
/*for (int i = 0; i < patients.size(); i++) {
System.out.println(patients.get(i));
}*/
}
}
| [
"[email protected]"
]
| |
75e1c7e97b1ec893cccd0d5816f5c5648362f5b2 | 8844df73f5e0a666850ea22bdc7439ac6f284db8 | /hisDomestic/Hospital/src/main/java/com/hisd/domestic/databean/TenderCorrigendumDocumentDtBean.java | cc3f61f015527a11884ebc09a33eefeb4933c22b | []
| no_license | HELLYVIHAANINDIA/his_domestic | ffa15f8c7f057bd8210302c0de7ac2165e57b0e4 | f59528917d265b0678ab89bf01950a846a848d40 | refs/heads/master | 2021-01-22T23:53:44.325720 | 2017-09-22T11:20:50 | 2017-09-22T11:20:50 | 85,677,899 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,510 | java | package com.hisd.domestic.databean;
/**
*/
public class TenderCorrigendumDocumentDtBean {
private int officerDocMappingId;
private String docName;
private String description;
private String fileSize;
private String mappedOn;
private String cstatus;
private String downloadUrl;
public int getOfficerDocMappingId() {
return officerDocMappingId;
}
public void setOfficerDocMappingId(int officerDocMappingId) {
this.officerDocMappingId = officerDocMappingId;
}
public String getDocName() {
return docName;
}
public void setDocName(String docName) {
this.docName = docName;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getFileSize() {
return fileSize;
}
public void setFileSize(String fileSize) {
this.fileSize = fileSize;
}
public String getMappedOn() {
return mappedOn;
}
public void setMappedOn(String mappedOn) {
this.mappedOn = mappedOn;
}
public String getCstatus() {
return cstatus;
}
public void setCstatus(String cstatus) {
this.cstatus = cstatus;
}
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(String downloadUrl) {
this.downloadUrl = downloadUrl;
}
} | [
"[email protected]"
]
| |
a28f67cc007a9b073b8edd42c2993988b5ab73bb | 6a649709010f35916b58ad639eb24dc9d7452344 | /AL-Game/src/com/aionemu/gameserver/model/templates/item/actions/RemodelAction.java | 3d18b72291f6f9151c68998ec5b74fe541979a4e | []
| no_license | soulxj/aion-cn | 807860611e746d8d4c456a769a36d3274405fd7e | 8a0a53cf8f99233cbee82f341f2b5c33be0364fa | refs/heads/master | 2016-09-11T01:12:19.660692 | 2014-08-11T14:59:38 | 2014-08-11T14:59:38 | 41,342,802 | 2 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,525 | java | /*
* This file is part of aion-lightning <aion-lightning.com>.
*
* aion-lightning 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.
*
* aion-lightning 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 aion-lightning. If not, see <http://www.gnu.org/licenses/>.
*/
package com.aionemu.gameserver.model.templates.item.actions;
import javax.xml.bind.annotation.XmlAttribute;
import com.aionemu.gameserver.model.gameobjects.Item;
import com.aionemu.gameserver.model.gameobjects.player.Player;
/**
* @author Rolandas
*/
public class RemodelAction extends AbstractItemAction {
@XmlAttribute(name = "type")
private int extractType;
@XmlAttribute(name = "minutes")
private int expireMinutes;
@Override
public boolean canAct(Player player, Item parentItem, Item targetItem) {
return false;
}
@Override
public void act(Player player, Item parentItem, Item targetItem) {
}
public int getExpireMinutes() {
return expireMinutes;
}
public int getExtractType() {
return extractType;
}
}
| [
"[email protected]"
]
| |
d6d98db4e6cd43f6cff01594b09674d4099b8446 | bc583f93bd407c2ed91262f5c2ddcc46c9d875f2 | /World Editor 2/src/CSprite.java | 28d3b2e813f865229a07b25028fe33c37bd917e1 | []
| no_license | kumorikarasu/Java_Master_Exploder | cfce87cf1f90d38989d9ff332395f5ee2c2dce05 | 7d09adf5d2835166c979969d409885ae8af938fe | refs/heads/master | 2021-01-10T07:57:01.686915 | 2010-07-26T12:13:08 | 2010-07-26T12:13:08 | 55,943,281 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,477 | java | import java.awt.Color;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.RGBImageFilter;
import javax.swing.ImageIcon;
class CSprite {
String filename;
Image img;
ImageObserver observer;
int width, height;
CSprite(String _filename){
filename=_filename;
img = new ImageIcon(filename).getImage();
width = img.getWidth(null);
height = img.getHeight(null);
}
CSprite(String _filename, final Color _transparent){
filename=_filename;
img = new ImageIcon(filename).getImage();
width = img.getWidth(null);
height = img.getHeight(null);
ImageFilter filter = new RGBImageFilter() {
// the color we are looking for... Alpha bits are set to opaque
public int markerRGB = _transparent.getRGB() | 0xFF000000;
public final int filterRGB(int x, int y, int rgb) {
if ( ( rgb | 0xFF000000 ) == markerRGB ) {
// Mark the alpha bits as zero - transparent
return 0x00FFFFFF & rgb;
}
else {
// nothing to do
return rgb;
}
}
};
ImageProducer ip = new FilteredImageSource(img.getSource(), filter);
img = Toolkit.getDefaultToolkit().createImage(ip);
}
public Image getImg(){
return img;
}
} | [
"Sean Stacey@localhost"
]
| Sean Stacey@localhost |
38d59db3748588c843a04d8d56c8ceb9d72fcd39 | 5d19e5fc967fa77d3d40a7a7e8552479171db59c | /ReadCardDemo.java | 5ad558bc62af5e4a562e630051b0dc201bce84c9 | []
| no_license | nancy403501/1062-java-G15 | 534622516f24ed58519f390de8593018c02affeb | 55ed4e33a85de3ffa3cc133c44fd99c76c2546e5 | refs/heads/master | 2020-03-17T09:50:13.670651 | 2018-06-21T06:43:17 | 2018-06-21T06:43:17 | 133,490,273 | 0 | 0 | null | 2018-06-09T16:04:09 | 2018-05-15T09:08:16 | Java | UTF-8 | Java | false | false | 1,440 | java | package testLoadingCard;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class ReadCardDemo {
public static void main(String[] args) {
try {
Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
} catch (Exception ex) {
// handle the error
}
Connection conn = null;
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost/databased?"
+ "user=root&password=0000&serverTimezone=UTC&useSSL=false");
Statement stmt = conn.createStatement();
//ResultSet rs = stmt.executeQuery("select a.num, subject, verb, object, action, cardname, card" + " from action a, cards c" + " where c.cardnum = a.cardname");
ResultSet rs = stmt.executeQuery("select c.cardnum, card" + " from cards c");
while (rs.next()) {
System.out.println(
//rs.getInt(1) + "\t" + rs.getString(2) + "\t" + rs.getString(3) + "\t" + rs.getString(4) + "\t" + rs.getString(5) + "\t" + rs.getString(6) + "\t" + rs.getString(7));
rs.getInt(1) + "\t" + rs.getString(2) + "\t");
}
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
}
}
| [
"[email protected]"
]
| |
c33ac387f63bfe3174f2562d39b493685b6d204c | d076be4549302da9401c1af122b150b65b1f6c4f | /Hackarejo/app/src/main/java/io/github/hackarejo/equipe9/ShopActivity.java | 38e4dfd7a272af515c5ac817459e10855142d651 | []
| no_license | jltafarel/hackarejo | 827ef0845a888f4f7d75bc2be54eca16736ab9ba | ce90090d66d86391200a65aab7853d2baf6ad0fe | refs/heads/master | 2016-09-12T22:22:26.779571 | 2016-04-17T10:35:03 | 2016-04-17T10:35:03 | 56,383,054 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,472 | java | package io.github.hackarejo.equipe9;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.ButterKnife;
import io.github.hackarejo.equipe9.model.Shop;
import io.github.hackarejo.equipe9.rest.RestClient;
import io.github.hackarejo.equipe9.util.UserPreferences;
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;
public class ShopActivity extends AppCompatActivity {
int shopId;
@Bind(R.id.shop_name)
TextView tvShopName;
@Bind(R.id.shop_info)
TextView tvShopInfo;
@Bind(R.id.shop_credits_container)
LinearLayout containerShopCredits;
@Bind(R.id.shop_credits)
TextView tvShopCredits;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shop);
ButterKnife.bind(this);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Loja");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
shopId = getIntent().getIntExtra("shop_id", 0);
UserPreferences preferences = new UserPreferences(getApplicationContext());
RestClient.api().getShopBy(preferences.getUser().getAccessToken(), String.valueOf(shopId), shopCallback);
}
Callback<Shop> shopCallback = new Callback<Shop>() {
@Override
public void success(Shop shop, Response response) {
tvShopName.setText(shop.getName());
tvShopInfo.setText(shop.getInfo());
if (shop.getCredits() != null) {
containerShopCredits.setVisibility(View.VISIBLE);
tvShopCredits.setText(String.valueOf(shop.getCredits()));
}
}
@Override
public void failure(RetrofitError error) {
}
};
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
default:
return super.onOptionsItemSelected(item);
}
}
}
| [
"[email protected]"
]
| |
6dfb3112a31bee7e11a00c844522704610a2ab8c | 2eb6afc1a5c4c43258132b2a81747da008915dde | /src/tk/mwacha/abstractfactory/factories/BoatTransport.java | 9be7901e5aba37f40954fdd80c190b7ea3d72bbb | []
| no_license | mwacha/design_patterns | 7412e6f6311604fe78d3d89a3b8e9c0db64681f8 | 62112ad28e702724530afff2f94aa2ce348eabdf | refs/heads/main | 2023-07-26T11:10:28.348791 | 2021-09-05T23:11:20 | 2021-09-05T23:11:20 | 403,429,837 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 703 | java | package tk.mwacha.abstractfactory.factories;
import tk.mwacha.abstractfactory.aircraft.Airplane;
import tk.mwacha.abstractfactory.aircraft.IAircraft;
import tk.mwacha.abstractfactory.boats.Boat;
import tk.mwacha.abstractfactory.boats.IBoat;
import tk.mwacha.abstractfactory.landvehicles.Car;
import tk.mwacha.abstractfactory.landvehicles.ILandVehicle;
public class BoatTransport implements ITransportFactory {
@Override
public ILandVehicle createTransportVehicle() {
return new Car();
}
@Override
public IAircraft createTransportAircraft() {
return new Airplane();
}
@Override
public IBoat createTransportBoat() {
return new Boat();
}
}
| [
"[email protected]"
]
| |
44f0ab94ba70d2c068c46aa6bbca646ef31cda16 | 92200837f52030018044ffd03acf49357e8735d5 | /src/main/java/fr/kervegan/vues/HelloAction.java | bda43148dc009bdb73d1995ab105dc946efdd4f4 | []
| no_license | aureliad22/HuilesEssentielles | 7ccc849a94132b2ecfcb8533f74443c003ba179b | 889f8b24a35dc17c97fb624dc9a42cdf34c5fc15 | refs/heads/master | 2021-05-07T07:47:10.005985 | 2017-12-20T20:09:59 | 2017-12-20T20:09:59 | 109,266,640 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,224 | java | package fr.kervegan.vues;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class HelloAction
*/
@WebServlet("/Hello")
public class HelloAction extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public HelloAction() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| [
"[email protected]"
]
| |
197343b04befd3cdc068894221b0a0e8fb58cc6f | c6a265de454037535828cbb57730391982117c38 | /Canting/src/main/java/cn/caimatou/canting/utils/GLEditTextUtil.java | d8337517afbc9ae723bc7919f2704329c3d26cf3 | []
| no_license | huluhaziqi/Canting | 0c418c98b8bd64c58683217d9e2fbd62ea696e13 | cf6ee129e3b59477a244c56c247a66a99de1ae56 | refs/heads/master | 2016-09-06T01:16:02.837402 | 2015-09-10T12:22:46 | 2015-09-10T12:22:46 | 42,242,802 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,028 | java | package cn.caimatou.canting.utils;
import android.widget.EditText;
import cn.caimatou.canting.common.GLConst;
/**
* Description:
* <br/><br/>Created by Fausgoal on 15/9/8.
* <br/><br/>
*/
public class GLEditTextUtil {
private GLEditTextUtil() {
}
/**
* 将光标移动到指定的EditText中
*
* @param editText editText
* @param isSetEmpty true 并将editText设置为空
*/
public static void setEditTextFocus(final EditText editText, final boolean isSetEmpty) {
if (null == editText) {
return;
}
if (isSetEmpty)
editText.setText("");
// 设置光标到指定文本框内
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
editText.requestFocusFromTouch();
if (editText.getText().length() != GLConst.NONE) {
editText.setSelection(editText.getText().length()); // 将光标移动到输入内容的最后
}
}
}
| [
"[email protected]"
]
| |
83d652b717fb0eef13c74d03f2dfb182292b190e | 23c0515cd00423acb364c633c46702b21c0c1ce5 | /src/gossipingAppendOnlyLogs/models/FrontierItem.java | 27c93c7bee1222975a3492ad2e0784f28595ca90 | []
| no_license | davidezanella/DS2-GossipingAppendOnlyLogs | ea4713ac6ab8cf4fac63bb89c5bd84b05f121467 | 5185eefd8b943ee5b80269750bec4b08da3c3651 | refs/heads/master | 2023-02-12T13:36:12.733097 | 2021-01-04T08:48:13 | 2021-01-04T08:48:13 | 318,483,047 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 222 | java | package gossipingAppendOnlyLogs.models;
public class FrontierItem {
public final PersonPublicKey id;
public final int last;
public FrontierItem(PersonPublicKey id, int last) {
this.id = id;
this.last = last;
}
}
| [
"[email protected]"
]
| |
4d901f86e04b9ce62a4ebd1ed464550b6e39acce | c8e897afbb493483ddb5b98d8ee4d90ed34288be | /src/main/java/org/mimos/gateway/security/jwt/JWTFilter.java | c61157cee7c68dfa26646afa4e70895678ae7c4f | []
| no_license | mohannaidu/gateway | 44d03dd72c7491417ef1906e25be789672e4b416 | 06aabb9d69142d15f74a4975371d5217d1038c0f | refs/heads/master | 2021-04-27T00:12:04.531778 | 2018-04-11T03:16:40 | 2018-04-11T03:16:40 | 123,769,002 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,959 | java | package org.mimos.gateway.security.jwt;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.GenericFilterBean;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
* Filters incoming requests and installs a Spring Security principal if a header corresponding to a valid user is
* found.
*/
public class JWTFilter extends GenericFilterBean {
private TokenProvider tokenProvider;
public JWTFilter(TokenProvider tokenProvider) {
this.tokenProvider = tokenProvider;
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
String jwt = resolveToken(httpServletRequest);
if (StringUtils.hasText(jwt) && this.tokenProvider.validateToken(jwt)) {
Authentication authentication = this.tokenProvider.getAuthentication(jwt);
SecurityContextHolder.getContext().setAuthentication(authentication);
}
filterChain.doFilter(servletRequest, servletResponse);
}
private String resolveToken(HttpServletRequest request){
String bearerToken = request.getHeader(JWTConfigurer.AUTHORIZATION_HEADER);
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) {
return bearerToken.substring(7, bearerToken.length());
}
String jwt = request.getParameter(JWTConfigurer.AUTHORIZATION_TOKEN);
if (StringUtils.hasText(jwt)) {
return jwt;
}
return null;
}
}
| [
"[email protected]"
]
| |
1dc5c8031c97b07f9e8acfa921e7b66f9e6820f2 | 0205c7a1e9d64cea74b8d9308a42a73bff30d9d2 | /COCOON-2217/cocoon-2.2.0/pipeline-impl/src/org/apache/cocoon/reading/ServiceableReader.java | 39a983313102f8c52446b0ba00ba80fe0e983adc | [
"Apache-2.0"
]
| permissive | ZhuofuChen/Apache_Contribution | 329de187c3a9ed0b158f7b06da0b2b4174aaabb2 | cedf844b4df218cbf0519972ab2d2902f3945f4a | refs/heads/master | 2021-08-26T06:40:45.363568 | 2017-11-21T23:25:16 | 2017-11-21T23:25:16 | 110,313,367 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,676 | 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.cocoon.reading;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
/**
* The serviceable reader will allow any {@link Reader} implementation that
* extends this to access other Avalon components.
*
* @version $Id: ServiceableReader.java 587751 2007-10-24 02:41:36Z vgritsenko $
*/
public abstract class ServiceableReader
extends AbstractReader
implements Serviceable {
protected ServiceManager manager;
/**
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(ServiceManager manager)
throws ServiceException {
this.manager = manager;
}
}
| [
"[email protected]"
]
| |
21220176e43979143c57655594f12578ba10dd9b | ef0e3bfeb7e33151fcf239e6e11d13c16611a698 | /src/main/java/br/com/frwk/redesocial/repository/UsuarioRepository.java | efdb1dc2fe9aae84b196f181674e51c00db948f6 | []
| no_license | Luciano2380/redesocial-api | 899fd30f9ae7dbd4d2d4787b03f85bfca6d22a13 | d6b2c1bce1c60bfa0a6de9615135c5432ce51bfc | refs/heads/master | 2022-11-28T23:34:18.098993 | 2020-07-27T01:24:02 | 2020-07-27T01:24:02 | 282,121,299 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 330 | java | package br.com.frwk.redesocial.repository;
import br.com.frwk.redesocial.domain.Usuario;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UsuarioRepository extends JpaRepository<Usuario,Long> {
Usuario findByLogin(String login);
}
| [
"[email protected]"
]
| |
5483dec304251269596237307c8cfe1e0bbea1e2 | f456d7825b53836bfc5e2e66e7201d38a64010f0 | /readHTU21DF/src/Main.java | 62b320771e4e84a2dcde816fb018e74d4f0fefc9 | []
| no_license | alapisco/IoT_Environmental_Monitoring_Device | 375d43b6e9a2ab553ca3e1f3f0f29e6ed1f891bd | 12a5081f17cad5b19933ee337aa27d809c19c259 | refs/heads/master | 2021-06-08T15:53:51.389753 | 2016-09-28T21:31:03 | 2016-09-28T21:31:03 | 49,120,354 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,265 | java |
import i2c.HTU21DF;
import java.text.DecimalFormat;
import utils.FileUtils;
import utils.M2X;
import utils.PropertyFileReader;
public class Main {
public static void main(String[] args) {
// Read property file
PropertyFileReader reader = new PropertyFileReader("sensors.properties");
int measurementInterval = Integer.parseInt(reader.getPropertyValue(reader.HTU21DF_MEASUREMENT_INTERVAL_SECONDS));
boolean sendHumToM2X = reader.getPropertyValue(reader.HTU21DF_SEND_HUM_TO_M2X).equalsIgnoreCase("true");
boolean sendTempToM2X = reader.getPropertyValue(reader.HTU21DF_SEND_TEMP_TO_M2X).equalsIgnoreCase("true");
boolean displayTempInConsole = reader.getPropertyValue(reader.HTU21DF_DISPLAY_TEMP_IN_CONSOLE).equalsIgnoreCase("true");
boolean displayHumInConsole = reader.getPropertyValue(reader.HTU21DF_DISPLAY_HUM_IN_CONSOLE).equalsIgnoreCase("true");
boolean readTemp = reader.getPropertyValue(reader.HTU21DF_READ_TEMP).equalsIgnoreCase("true");
boolean readHum = reader.getPropertyValue(reader.HTU21DF_READ_HUM).equalsIgnoreCase("true");
boolean writeTempToFile = reader.getPropertyValue(reader.HTU21DF_WRITE_TEMP_TO_FILE).equalsIgnoreCase("true");
boolean writeHumToFile = reader.getPropertyValue(reader.HTU21DF_WRITE_HUM_TO_FILE).equalsIgnoreCase("true");
String tempFile = reader.getPropertyValue(reader.HTU21DF_TEMP_FILE);
String humFile = reader.getPropertyValue(reader.HTU21DF_HUM_FILE);
String htFile = reader.getPropertyValue(reader.HTU21DF_HEAT_INDEX_FILE);
boolean displayHTInConsole = reader.getPropertyValue(reader.HTU21DF_DISPLAY_HEAT_INDEX_IN_CONSOLE).equalsIgnoreCase("true");
// m2x settings
String deviceID = reader.getPropertyValue(reader.DEVICE_ID);
String humStream = reader.getPropertyValue(reader.HUMIDITY_STREAM);
String tempStream = reader.getPropertyValue(reader.TEMPERATURE_STREAM);
String htStream = reader.getPropertyValue(reader.HEAT_INDEX_STREAM);
String m2xKey = reader.getPropertyValue(reader.M2X_KEY);
try {
HTU21DF device = new HTU21DF();
device.initialize();
DecimalFormat df = new DecimalFormat(".##");
double temperature = 0, humidity = 0;
while (true) {
if (readTemp) {
temperature = device.getTemperature();
String temperatureStr = df.format(temperature);
// temperatureStr += Double.toString(temperature);
if (displayTempInConsole) {
System.out.println(temperature);
}
if (writeTempToFile) {
FileUtils.writeSrtToFile(temperatureStr, tempFile, false);
}
if (sendTempToM2X) {
M2X.sendValueToStream(temperatureStr, deviceID, tempStream, m2xKey);
}
}
if (readHum) {
humidity = device.getHumidity();
String humidityStr = df.format(humidity);
//humidityStr += Double.toString(humidity);
if (displayHumInConsole) {
System.out.println(humidity);
}
if (writeHumToFile) {
FileUtils.writeSrtToFile(humidityStr, humFile, false);
}
if (sendTempToM2X) {
M2X.sendValueToStream(humidityStr, deviceID, humStream, m2xKey);
}
}
//A heat index value cannot be calculated for temperatures less than 26.7 degrees Celsius
if (readHum && readTemp && temperature>=26.7) {
double heatIndex = Main.calculateHeatIndex(temperature, humidity);
String heatIndexStr = df.format(heatIndex);
if (displayHTInConsole) {
System.out.println(heatIndexStr);
}
if (writeHumToFile) {
FileUtils.writeSrtToFile(heatIndexStr, htFile, false);
}
if (sendTempToM2X) {
M2X.sendValueToStream(heatIndexStr, deviceID, htStream, m2xKey);
}
}
Thread.sleep(measurementInterval * 1000);
}
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}
//according to http://www.srh.noaa.gov/images/epz/wxcalc/heatIndex.pdf
private static double calculateHeatIndex(double temperature, double rh) {
double F = 1.8 * temperature + 32;
double ht;
ht = -42.379 + 2.04901523 * F + 10.14333127 * rh
- 0.22475541 * F * rh - 6.83783 * Math.pow(10, -3) * F * F
- 5.481717 * Math.pow(10, -2) * rh * rh
+ 1.22874 * Math.pow(10, -3) * F * F * rh
+ 8.5282 * Math.pow(10, -4) * F * rh * rh
- 1.99 * Math.pow(10, -6) * F * F * rh * rh;
return ht;
}
}
| [
"[email protected]"
]
| |
73b43593e2e1a074e995eecf4bbc14d5ec31c4c3 | 3110616c435d1f12417e378406a41eac2a53bbdd | /p1_vaje02/SteviloStevk.java | fce715a89bd1979b8116cbcab333e95f42a8c7a6 | []
| no_license | DrejcPesjak/Programming1-class | 6e616e296a1cfd8eaaf4aaadb307e76d8389089f | b44ed2cbd08b81466fb0883e13097ffbbc2ee883 | refs/heads/master | 2020-06-15T16:52:04.395558 | 2019-07-05T06:14:23 | 2019-07-05T06:14:23 | 195,345,844 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 429 | java | import java.util.Scanner;
public class SteviloStevk {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int stevilo = sc.nextInt();
int stStevk = 0;
while(stevilo>0) {
stevilo /= 10;
stStevk++;
}
System.out.println(stStevk);
/*int stevec = 1000000000;
do{
int celiDel = stevilo/stevec;
} while(celiDel == 0);*/
}
} | [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.