blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
7
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
684M
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
132 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
28 values
content
stringlengths
3
9.45M
authors
listlengths
1
1
author_id
stringlengths
0
352
2a27d771d5b091485bde7c6e574b0d8336aec2a6
791d41aa8c6312449e11f67044009418323c85be
/src/main/java/com/ppf/springboot/controller/MessageController.java
ff00c91120a563bb53cca1b18e8f6d246ae1b870
[]
no_license
pupufu/springboot
f196d633b2c976c3284d7b98691de7ae7dd6a399
3b97f35833ac324f5b9cf1b0b31cbe638728f7c6
refs/heads/master
2023-03-05T21:19:22.172347
2021-03-12T05:32:32
2021-03-12T05:32:32
156,690,524
0
0
null
null
null
null
UTF-8
Java
false
false
744
java
package com.ppf.springboot.controller; import com.ppf.springboot.entity.User; import com.ppf.springboot.listener.DataMessage; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import java.lang.reflect.Method; @RestController public class MessageController { @GetMapping("/message/user") public Object getMessage() { DataMessage DataMessage = new DataMessage(); Method method = null; try { method = UserController.class.getMethod("getUserList"); } catch (NoSuchMethodException e) { e.printStackTrace(); } long message = DataMessage.getMessage(method); return message; } }
[ "pupufu@163.com" ]
pupufu@163.com
e92766da6e5fc10d81985ebeb312b312a3e337be
47e4d883a939b4b9961ba2a9387b1d4616bbc653
/src/org/sxb/mail/mock/MockFetchMailPro.java
b7138ff24c0e37013462cb4e186d21eb7b7271c0
[]
no_license
jeffson1985/sxb
196f5e4e29072bf060467f2f8cd312b76b2af124
addf8debad2449cf1bc5920c7fd7ea87ab0855f0
refs/heads/master
2020-05-29T16:56:44.582291
2015-09-09T01:18:04
2015-09-09T01:18:04
42,148,048
0
0
null
null
null
null
UTF-8
Java
false
false
7,025
java
package org.sxb.mail.mock; import java.util.ArrayList; import java.util.List; import javax.mail.internet.MimeMessage; import org.sxb.log.Logger; import org.sxb.mail.MailException; import org.sxb.mail.NotConnectedException; import org.sxb.mail.fetch.FetchMailPro; import org.sxb.mail.fetch.ReceivedMail; /** * FetchMailProImplクラスのMock。 * * @since 1.2 * @author Jeffson (jeffson.app@gmail.com) * @version $Id: MockFetchMailPro.java,v 1.1.2 */ public class MockFetchMailPro implements FetchMailPro { private static Logger log = Logger.getLogger(MockFetchMailPro.class); /** デフォルトのSMTPサーバ。「localhost」 */ public static final String DEFAULT_HOST = "localhost"; /** デフォルトのプロトコル。「pop3」 */ public static final String DEFAULT_PROTOCOL = "pop3"; /** * デフォルトのポート。「-1」<br> * -1はプロトコルに応じた適切なポートを設定する特別な値。 */ public static final int DEFAULT_PORT = -1; @SuppressWarnings("unused") private static final String INBOX_NAME = "INBOX"; private String host = DEFAULT_HOST; private String protocol = DEFAULT_PROTOCOL; private int port = DEFAULT_PORT; private String username; private String password; private boolean javaMailLogEnabled; private boolean connected = false; private List<ReceivedMail> receivedMails; /** * コンストラクタ。 */ public MockFetchMailPro() { super(); receivedMails = new ArrayList<ReceivedMail>(); } /** * @see org.sxb.mail.fetch.FetchMailPro#connect() */ public synchronized void connect() throws MailException { if (isConnected()) { log.warn("既にサーバ[" + host + "]に接続されています。再接続するには先に接続を切断する必要があります。"); return; } log.debug(protocol.toUpperCase() + "サーバ[" + host + "]に接続するフリ。"); connected = true; log.info(protocol.toUpperCase() + "サーバ[" + host + "]に接続したフリ。"); } /** * @see org.sxb.mail.fetch.FetchMailPro#disconnect() */ public synchronized void disconnect() throws MailException { if (isConnected()) { log.debug(protocol.toUpperCase() + "サーバ[" + host + "]との接続を切断するフリ。"); connected = false; log.debug(protocol.toUpperCase() + "サーバ[" + host + "]との接続を切断したフリ。"); } } /** * <code>MockFetchMailPro</code>の<code>getMails()</code>メソッドが返す * <code>ReceivedMail</code>インスタンスをセットします。 * * @param mail <code>getMails()</code>メソッドが返す<code>ReceivedMail</code>インスタンス */ public void setupGetMails(ReceivedMail mail) { receivedMails.add(mail); } /** * <code>MockFetchMailPro</code>の<code>getMails()</code>メソッドが返す * <code>ReceivedMail</code>インスタンスをセットします。 * * @param mails <code>getMails()</code>メソッドが返す<code>ReceivedMail</code>インスタンス配列 */ public void setupGetMails(ReceivedMail[] mails) { for (int i = 0; i < mails.length; i++) { ReceivedMail mail = mails[i]; setupGetMails(mail); } } /** * @see org.sxb.mail.fetch.FetchMailPro#getMailCount() */ public int getMailCount() throws MailException { return receivedMails.size(); } /** * @see org.sxb.mail.fetch.FetchMailPro#getMail(int) */ public synchronized ReceivedMail getMail(int num) throws MailException { return getMail(num, false); } /** * @see org.sxb.mail.fetch.FetchMailPro#getMail(int, boolean) */ public synchronized ReceivedMail getMail(int num, boolean delete) throws MailException { if (isConnected()) { if (delete) { return (ReceivedMail)receivedMails.remove(num - 1); } else { return (ReceivedMail)receivedMails.get(num - 1); } } else { throw new NotConnectedException(protocol.toUpperCase() + "サーバ[" + host + "]に接続されていません。"); } } /** * @see org.sxb.mail.fetch.FetchMailPro#getMails(boolean) */ public synchronized ReceivedMail[] getMails(boolean delete) throws MailException { if (isConnected()) { ReceivedMail[] results = (ReceivedMail[])receivedMails .toArray(new ReceivedMail[receivedMails.size()]); if (delete) { receivedMails.clear(); } return results; } else { throw new NotConnectedException(protocol.toUpperCase() + "サーバ[" + host + "]に接続されていません。"); } } /** * @see org.sxb.mail.fetch.FetchMailPro#getMessage(int) */ public MimeMessage getMessage(int num) throws MailException { throw new UnsupportedOperationException("申し訳ございません。MockFetchMailProでは、このメソッドをサポートしていません。"); } /** * @see org.sxb.mail.fetch.FetchMailPro#getMessages(boolean) */ public MimeMessage[] getMessages(boolean delete) throws MailException { throw new UnsupportedOperationException("申し訳ございません。MockFetchMailProでは、このメソッドをサポートしていません。"); } /** * @see org.sxb.mail.fetch.FetchMailPro#changeFolder(java.lang.String) */ public synchronized void changeFolder(String folderName) throws MailException { if (!isConnected()) { log.warn("メールサーバに接続されていません。"); return; } log.debug("メッセージフォルダ[" + folderName + "]をオープンするフリ。"); log.debug("メッセージフォルダ[" + folderName + "]をオープンしたフリ。"); } /** * @see org.sxb.mail.fetch.FetchMailPro#isConnected() */ public boolean isConnected() { return connected; } /** * @return Returns the host. */ public String getHost() { return host; } /** * @param host The host to set. */ public void setHost(String host) { this.host = host; } /** * @return Returns the javaMailLogEnabled. */ public boolean isJavaMailLogEnabled() { return javaMailLogEnabled; } /** * @param javaMailLogEnabled The javaMailLogEnabled to set. */ public void setJavaMailLogEnabled(boolean javaMailLogEnabled) { this.javaMailLogEnabled = javaMailLogEnabled; } /** * @return Returns the password. */ public String getPassword() { return password; } /** * @param password The password to set. */ public void setPassword(String password) { this.password = password; } /** * @return Returns the port. */ public int getPort() { return port; } /** * @param port The port to set. */ public void setPort(int port) { this.port = port; } /** * @return Returns the protocol. */ public String getProtocol() { return protocol; } /** * @param protocol The protocol to set. */ public void setProtocol(String protocol) { this.protocol = protocol; } /** * @return Returns the username. */ public String getUsername() { return username; } /** * @param username The username to set. */ public void setUsername(String username) { this.username = username; } }
[ "kevionsun@gmail.com" ]
kevionsun@gmail.com
c328db300411826a2434ac5c7a4a82aae4c4a278
fa91b5ac5696472434a6492562ca1d368febd1d0
/MacauAirPort5/andbase/com/ab/view/pullview/AbPullListView.java
22a057f5d8486f97b461c49f2b9dda8055179a7a
[]
no_license
zhourihu5/zhourihu-android
49b9927b9817c38280582245be36cfd662a6c170
b9825d3b2f5bd6000f4cd3ae53a2506b22e5f03b
refs/heads/master
2021-01-25T07:34:33.434174
2015-04-15T08:58:07
2015-04-15T08:58:07
24,479,559
0
1
null
null
null
null
UTF-8
Java
false
false
9,690
java
/* * Copyright (C) 2015 www.amsoft.cn * * 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.ab.view.pullview; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; import android.view.animation.DecelerateInterpolator; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.ProgressBar; import android.widget.Scroller; import com.ab.view.listener.AbOnListViewListener; // TODO: Auto-generated Javadoc /** * The Class AbPullListView. */ public class AbPullListView extends ListView implements OnScrollListener { /** The m last y. */ private float mLastY = -1; /** The m scroller. */ private Scroller mScroller; /** The m list view listener. */ private AbOnListViewListener mListViewListener; /** The m header view. */ private AbListViewHeader mHeaderView; /** The m footer view. */ private AbListViewFooter mFooterView; /** The m header view height. */ private int mHeaderViewHeight; /** The m footer view height. */ private int mFooterViewHeight; /** The m enable pull refresh. */ private boolean mEnablePullRefresh = true; /** The m enable pull load. */ private boolean mEnablePullLoad = true; /** The m pull refreshing. */ private boolean mPullRefreshing = false; /** The m pull loading. */ private boolean mPullLoading; /** The m is footer ready. */ private boolean mIsFooterReady = false; /** 总条数. */ private int mTotalItemCount; /** The m scroll back. */ private int mScrollBack; /** The Constant SCROLLBACK_HEADER. */ private final static int SCROLLBACK_HEADER = 0; /** The Constant SCROLLBACK_FOOTER. */ private final static int SCROLLBACK_FOOTER = 1; /** The Constant SCROLL_DURATION. */ private final static int SCROLL_DURATION = 200; /** The Constant OFFSET_RADIO. */ private final static float OFFSET_RADIO = 1.8f; /** 数据相关. */ private ListAdapter mAdapter = null; /**上一次的数量*/ private int count = 0; /** * 构造. * @param context the context */ public AbPullListView(Context context) { super(context); initView(context); } /** * 构造. * @param context the context * @param attrs the attrs */ public AbPullListView(Context context, AttributeSet attrs) { super(context, attrs); initView(context); } /** * 初始化View. * @param context the context */ private void initView(Context context) { mScroller = new Scroller(context, new DecelerateInterpolator()); super.setOnScrollListener(this); // init header view mHeaderView = new AbListViewHeader(context); // init header height mHeaderViewHeight = mHeaderView.getHeaderHeight(); mHeaderView.setGravity(Gravity.BOTTOM); addHeaderView(mHeaderView); // init footer view mFooterView = new AbListViewFooter(context); mFooterViewHeight= mFooterView.getFooterHeight(); //默认是打开刷新与更多 setPullRefreshEnable(true); setPullLoadEnable(true); //先隐藏 mFooterView.hide(); } /** * 描述:设置适配器 */ @Override public void setAdapter(ListAdapter adapter) { mAdapter = adapter; if (mIsFooterReady == false) { mIsFooterReady = true; mFooterView.setGravity(Gravity.TOP); addFooterView(mFooterView); } super.setAdapter(adapter); } /** * 打开或者关闭下拉刷新功能. * @param enable 开关标记 */ public void setPullRefreshEnable(boolean enable) { mEnablePullRefresh = enable; if (!mEnablePullRefresh) { mHeaderView.setVisibility(View.INVISIBLE); } else { mHeaderView.setVisibility(View.VISIBLE); } } /** * 打开或者关闭加载更多功能. * @param enable 开关标记 */ public void setPullLoadEnable(boolean enable) { mEnablePullLoad = enable; if (!mEnablePullLoad) { mFooterView.hide(); mFooterView.setOnClickListener(null); } else { mPullLoading = false; mFooterView.setState(AbListViewFooter.STATE_READY); //load more点击事件. mFooterView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startLoadMore(); } }); } } /** * 停止刷新并重置header的状态. */ public void stopRefresh() { if (mPullRefreshing == true) { mPullRefreshing = false; resetHeaderHeight(); } count = mAdapter.getCount(); //判断有没有数据 if(count>0){ mFooterView.setState(AbListViewFooter.STATE_READY); }else{ mFooterView.setState(AbListViewFooter.STATE_EMPTY); } } /** * 更新header的高度. * * @param delta 差的距离 */ private void updateHeaderHeight(float delta) { int newHeight = (int) delta + mHeaderView.getVisiableHeight(); mHeaderView.setVisiableHeight(newHeight); if (mEnablePullRefresh && !mPullRefreshing) { if (mHeaderView.getVisiableHeight() >= mHeaderViewHeight) { mHeaderView.setState(AbListViewHeader.STATE_READY); } else { mHeaderView.setState(AbListViewHeader.STATE_NORMAL); } } setSelection(0); } /** * 根据状态设置Header的位置. */ private void resetHeaderHeight() { //当前下拉到的高度 int height = mHeaderView.getVisiableHeight(); if (height < mHeaderViewHeight || !mPullRefreshing) { //距离短 隐藏 mScrollBack = SCROLLBACK_HEADER; mScroller.startScroll(0, height, 0, -1*height, SCROLL_DURATION); }else if(height > mHeaderViewHeight || !mPullRefreshing){ //距离多的 弹回到mHeaderViewHeight mScrollBack = SCROLLBACK_HEADER; mScroller.startScroll(0, height, 0, -(height-mHeaderViewHeight), SCROLL_DURATION); } invalidate(); } /** * 开始加载更多. */ private void startLoadMore() { Log.d("TAG", "startLoadMore"); mFooterView.show(); mPullLoading = true; mFooterView.setState(AbListViewFooter.STATE_LOADING); if (mListViewListener != null) { //开始下载数据 mListViewListener.onLoadMore(); } } /** * 停止加载更多并重置footer的状态. * */ public void stopLoadMore() { mFooterView.hide(); mPullLoading = false; int countNew = mAdapter.getCount(); //判断有没有更多数据了 if(countNew > count){ mFooterView.setState(AbListViewFooter.STATE_READY); }else{ mFooterView.setState(AbListViewFooter.STATE_NO); } } /** * 描述:onTouchEvent */ @Override public boolean onTouchEvent(MotionEvent ev) { if (mLastY == -1) { mLastY = ev.getRawY(); } switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: mLastY = ev.getRawY(); break; case MotionEvent.ACTION_MOVE: final float deltaY = ev.getRawY() - mLastY; mLastY = ev.getRawY(); if (mEnablePullRefresh && getFirstVisiblePosition() == 0 && (mHeaderView.getVisiableHeight() > 0 || deltaY > 0)) { updateHeaderHeight(deltaY / OFFSET_RADIO); } else if (mEnablePullLoad && !mPullLoading && getLastVisiblePosition() == mTotalItemCount - 1 && deltaY<-5) { startLoadMore(); } break; case MotionEvent.ACTION_UP: mLastY = -1; if (getFirstVisiblePosition() == 0) { //需要刷新的条件 if (mEnablePullRefresh && mHeaderView.getVisiableHeight() >= mHeaderViewHeight) { mPullRefreshing = true; mHeaderView.setState(AbListViewHeader.STATE_REFRESHING); if (mListViewListener != null) { //刷新 mListViewListener.onRefresh(); } } if(mEnablePullRefresh){ //弹回 resetHeaderHeight(); } } break; default: break; } return super.onTouchEvent(ev); } /** * 描述:TODO * @see android.view.View#computeScroll() */ @Override public void computeScroll() { if (mScroller.computeScrollOffset()) { if (mScrollBack == SCROLLBACK_HEADER) { mHeaderView.setVisiableHeight(mScroller.getCurrY()); } postInvalidate(); } super.computeScroll(); } /** * 描述:设置ListView的监听器. * * @param listViewListener */ public void setAbOnListViewListener(AbOnListViewListener listViewListener) { mListViewListener = listViewListener; } /** * 描述:TODO */ @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } /** * 描述:TODO */ @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { mTotalItemCount = totalItemCount; } /** * * 描述:获取Header View * @return * @throws */ public AbListViewHeader getHeaderView() { return mHeaderView; } /** * * 描述:获取Footer View * @return * @throws */ public AbListViewFooter getFooterView() { return mFooterView; } /** * * 描述:获取Header ProgressBar,用于设置自定义样式 * @return * @throws */ public ProgressBar getHeaderProgressBar() { return mHeaderView.getHeaderProgressBar(); } /** * * 描述:获取Footer ProgressBar,用于设置自定义样式 * @return * @throws */ public ProgressBar getFooterProgressBar() { return mFooterView.getFooterProgressBar(); } }
[ "604377569@qq.com" ]
604377569@qq.com
6408ebfe71d3a1bd64a4ecf317b1fcac6b333ca2
9bbf0d1cb1a013e5f6835d34b7e2063f609a8030
/src/cn/shuo/myco/Test5.java
fb3b3dff83287455b212c1ae725192175e324821
[]
no_license
xiaoshuogege/yichang
a173f36232404f29f4a3ab14be473cd028a13e39
572e87938126510c27b19dc7138d5b56e126dd38
refs/heads/master
2020-09-21T00:48:58.574630
2019-11-28T10:54:08
2019-11-28T10:54:08
224,632,491
0
0
null
null
null
null
UTF-8
Java
false
false
2,236
java
package cn.shuo.myco; public class Test5<E> { private Object[] elementData; private int size; private static final int DEFALT_CAPACITY = 10; public Test5() { elementData = new Object[DEFALT_CAPACITY]; } public Test5(int capacity) { if (capacity < 0) { throw new RuntimeException("不能为负数"); } else if (capacity == 0) { elementData = new Object[DEFALT_CAPACITY]; } else { elementData = new Object[capacity]; } } public void add(E element) { if (size == elementData.length) { Object[] newArray = new Object[elementData.length + (elementData.length >> 1)]; System.arraycopy(elementData, 0, newArray, 0, elementData.length); elementData = newArray; } elementData[size++] = element; } public E get(int index) { cheak(index); return (E) elementData[index]; } public void set(E element, int index) { cheak(index); elementData[index] = element; } public void cheak(int index) { if (index < 0 || index > size - 1) { throw new RuntimeException("索引不合法:" + index); } } public void remove(E element) { for (int i = 0; i < size; i++) { if (element.equals(get(i))) { remove(i); } } } public void remove(int index) { int numMoved = elementData.length - 1 - index; if (numMoved > 0) { System.arraycopy(elementData, index + 1, elementData, index, numMoved); } elementData[--size] = null; } public String toString() { StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < size; i++) { sb.append(elementData[i] + ","); } sb.setCharAt(sb.length() - 1, ']'); return sb.toString(); } public static void main(String[] args) { Test5 t = new Test5(20); for (int i = 0; i < 40; i++) { t.add("wang" + i); } System.out.println(t); t.set("wangshuo", 10); System.out.println(t.get(10)); } }
[ "shuaixiaoshuo@outlook.com" ]
shuaixiaoshuo@outlook.com
14f687c8f37eaff010a81788f4dce37de4ae2ffb
dd43915d036195d5925c5b49e1ede767b6eb82c7
/CodingLanguage/Java/HeadFirstJava/src/ch16_SetAndGeneric/Jukebox8.java
9d9932b3a24ed9b26761210b54d4017eab9e53ae
[]
no_license
cwray01/BigDataLearning
12a1f6368a61e5aeeb0963384d4cfc217c38f190
7738ca32e30bab141ed0e267bfb7870323ef9a5d
refs/heads/master
2021-07-01T01:40:09.539739
2019-04-16T23:56:31
2019-04-16T23:56:31
114,504,107
2
0
null
2017-12-17T03:38:37
2017-12-17T02:31:08
null
UTF-8
Java
false
false
1,338
java
package ch16_SetAndGeneric; /** * This program demonstrates TreeSet */ import java.util.*; import java.io.*; public class Jukebox8 { ArrayList<Song> songList = new ArrayList<Song>(); int val; public static void main(String[] args){ new Jukebox8().go(); } public void go(){ getSongs(); System.out.println(songList); Collections.sort(songList); System.out.println(songList); TreeSet<Song> songSet = new TreeSet<Song>(); //调用没有参数的构造函数来用TreeSet取代HashSet意味着以对象的compareTo()方法来进行排序 songSet.addAll(songList); //使用addAll()可以把对象全部加入 System.out.println(songSet); } void getSongs(){ try{ File file = new File("resource/SongListMore.txt"); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while((line = reader.readLine()) != null ){ addSong(line); } }catch(Exception ex){ ex.printStackTrace(); } } void addSong(String lineToParse){ String[] tokens = lineToParse.split("/"); Song nextSong = new Song(tokens[0], tokens[1], tokens[2], tokens[3]); songList.add(nextSong); } }
[ "kingveyray@gmail.com" ]
kingveyray@gmail.com
d97fa239917e3e83dad6902a26390cfdc9ec4386
4c90528fa86e4f4271311df88c4ea55ed7ea6c07
/src/de/fhb/maus/android/todolist/database/CustomHttpClient.java
20558063a8c33c82d545f4d94b9a250d03444ff2
[]
no_license
kwoxer/ToDoList
53aef0b9d79e29a366e3ca8b3796b22b7cb815bd
76b5bb810b0e6040f2c556366a66657848f9ecd9
refs/heads/master
2016-09-05T19:07:19.130675
2012-02-15T15:03:21
2012-02-15T15:03:21
3,178,858
0
0
null
null
null
null
UTF-8
Java
false
false
3,723
java
package de.fhb.maus.android.todolist.database; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URI; import java.util.ArrayList; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.params.ConnManagerParams; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; public class CustomHttpClient { /** The time it takes for our client to timeout */ public static final int HTTP_TIMEOUT = 5 * 1000; /** Single instance of our HttpClient */ private static HttpClient mHttpClient; /** * Get our single instance of our HttpClient object. * * @return an HttpClient object with connection parameters set */ private static HttpClient getHttpClient() { if (mHttpClient == null) { mHttpClient = new DefaultHttpClient(); final HttpParams params = mHttpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT); HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT); ConnManagerParams.setTimeout(params, HTTP_TIMEOUT); } return mHttpClient; } /** * Performs an HTTP Post request to the specified url with the specified * parameters. * * @param url * The web address to post the request to * @param postParameters * The parameters to send via the request * @return The result of the request * @throws Exception */ public static String executeHttpPost(String url, ArrayList<NameValuePair> postParameters) throws Exception { BufferedReader in = null; //System.out.println(url); try { HttpClient client = getHttpClient(); HttpPost request = new HttpPost(url); UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity( postParameters); request.setEntity(formEntity); HttpResponse response = client.execute(request); in = new BufferedReader(new InputStreamReader(response.getEntity() .getContent())); StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); String result = sb.toString(); return result; } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } } /** * Performs an HTTP GET request to the specified url. * * @param url * The web address to post the request to * @return The result of the request * @throws Exception */ public static String executeHttpGet(String url) throws Exception { BufferedReader in = null; try { HttpClient client = getHttpClient(); HttpGet request = new HttpGet(); request.setURI(new URI(url)); HttpResponse response = client.execute(request); in = new BufferedReader(new InputStreamReader(response.getEntity() .getContent())); StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); String result = sb.toString(); return result; } finally { if (in != null) { try { in.close(); } catch (IOException e) { e.printStackTrace(); } } } } }
[ "kwoxer@kwoxer-lappy" ]
kwoxer@kwoxer-lappy
5918a233f77135aea20285f9fd288017d0adde63
0fcd0d7e8d4c376d4b265a94a854b73b722c7c97
/PIM_Tool_BE/src/main/java/com/elca/vn/transform/BaseTransformService.java
f09f29a6c91523da7ffecc835057e290c41d5270
[]
no_license
chuongnguyen1512/PIM_Tool_Assignment
f77f886f0c5be6a68510e71f2523de7061a4c65a
e8de61352b46440ebef00a3b3135b6d35aed65c8
refs/heads/master
2022-11-07T07:58:05.733261
2020-06-11T05:53:53
2020-06-11T05:53:53
266,030,710
0
0
null
null
null
null
UTF-8
Java
false
false
611
java
package com.elca.vn.transform; /** * Transform form {@code I} model to {@code O} model in 2 ways * * @param <I> input model * @param <O> output model */ public interface BaseTransformService<I, O> { /** * Transform form {@code I} model to {@code O} * * @param sourceObject input object * @return transformed object */ O transformFromSourceToDes(I sourceObject); /** * Transform form {@code O} model to {@code I} * * @param destinationObject input object * @return transformed object */ I transformFromDesToSource(O destinationObject); }
[ "chuongnguyen1512@gmail.com" ]
chuongnguyen1512@gmail.com
d16eda000cf6a2a496b738eee86761a58e7ecacc
66e0d9f22485381c98a1852fb3ff7505b0a385c1
/CoreJavaModule/MutliThreading/src/com/training/janbask/sychronization/MyThread2.java
7ffe6dfd05b71642704fa02638cd0a3b41c6c021
[]
no_license
avinashkumar5/CoreJavaProjects
bfa21739b0a78e5e47f47480e4c4700cd0ac1a5a
adc6890135644682e24a6b5eccde14f0b3ebb324
refs/heads/master
2020-09-11T11:02:08.936644
2017-06-18T02:17:20
2017-06-18T02:17:20
94,455,588
0
0
null
null
null
null
UTF-8
Java
false
false
218
java
package com.training.janbask.sychronization; public class MyThread2 extends Thread{ TableResource t; public MyThread2(TableResource t){ this.t = t; } @Override public void run(){ t.printTable(100); } }
[ "avinashhunt5@gmail.com" ]
avinashhunt5@gmail.com
4384fb7f4b9bf2a511c4c9f796a16a449d57633a
3c651a2faa0cec2cd2f2f07b2dea5fa843577457
/app/src/main/java/com/example/helloworld/SettingsDatabase.java
66e089193099c1fc89f88bb64131a03bf46d058a
[]
no_license
vjaydeshmukh/AndroidAppDevelopment
b65ab8a2158964e563d2b73e8496afbc9bf827ea
99e4bd7292ee835eb0b60e0557de0eafbd7e98b3
refs/heads/master
2022-10-22T02:34:25.508485
2020-06-19T02:14:59
2020-06-19T02:14:59
null
0
0
null
null
null
null
UTF-8
Java
false
false
285
java
package com.example.helloworld; import androidx.room.Database; import androidx.room.RoomDatabase; @Database(entities = {Settings.class}, version = 2, exportSchema = false) public abstract class SettingsDatabase extends RoomDatabase { public abstract SettingsDao settingsDao(); }
[ "ashuraliev@gmail.com" ]
ashuraliev@gmail.com
ef6af8c0b0b725dbe59207dca75ff5b7cd49f0f6
c6e81fe2a7b56ce7bf0cab44939cee33d0171bdd
/src/main/java/org/mybatis/knowledges/web/actions/KnowledgeActionBean.java
3b330ef9a6225ae148afdea27c38241aa638688e
[]
no_license
takesy/knowledges
0e7f755c1f57a7b49d41480392ec5249e8c2ea5e
26c22793fe29e7aa69bb18dc0087fa56d43bd329
refs/heads/master
2021-01-01T05:59:31.761424
2015-03-11T21:41:03
2015-03-11T21:41:03
32,038,505
0
0
null
null
null
null
UTF-8
Java
false
false
2,918
java
package org.mybatis.knowledges.web.actions; import javax.servlet.http.HttpSession; import net.sourceforge.stripes.action.DefaultHandler; import net.sourceforge.stripes.action.ForwardResolution; import net.sourceforge.stripes.action.RedirectResolution; import net.sourceforge.stripes.action.Resolution; import net.sourceforge.stripes.action.SessionScope; import net.sourceforge.stripes.integration.spring.SpringBean; import net.sourceforge.stripes.validation.Validate; import org.mybatis.knowledges.domain.Knowledge; import org.mybatis.knowledges.service.KnowledgeService; @SessionScope public class KnowledgeActionBean extends AbstractActionBean { private static final long serialVersionUID = 1L; private static final String NEW_KNOWLEDGE = "/WEB-INF/jsp/knowledge/NewKnowledgeForm.jsp"; private static final String EDIT_KNOWLEDGE = "/WEB-INF/jsp/knowledge/EditKnowledgeForm.jsp"; private static final String SEARCH = "/WEB-INF/jsp/knowledge/SerchForm.jsp"; @SpringBean private transient KnowledgeService knowledgeService; private Knowledge knowledge = new Knowledge(); public Knowledge getKnowledge() { return this.knowledge; } public String getTitle() { return knowledge.getTitle(); } @Validate(required=true, on={"newKnowledge", "editKnowledge"}) public void setTitle(String title) { knowledge.setTitle(title); } public String getSort() { return knowledge.getSort(); } @Validate(required=true, on={"newKnowledge", "editKnowledge"}) public void setSort(String sort) { knowledge.setSort(sort); } public Resolution newKnowledgeForm() { return new ForwardResolution(NEW_KNOWLEDGE); } public Resolution newKnowledge() { knowledgeService.insertKnowledge(knowledge); knowledge = knowledgeService.getKnowledge(knowledge.getTitle()); return new RedirectResolution(SEARCH); } public Resolution editKnowledgeForm() { return new ForwardResolution(EDIT_KNOWLEDGE); } public Resolution editKnowledge() { knowledgeService.updateKnowledge(knowledge); knowledge = knowledgeService.getKnowledge(knowledge.getTitle()); return new RedirectResolution(SEARCH); } @DefaultHandler public Resolution searchForm() { return new ForwardResolution(SEARCH); } public Resolution search() { knowledge = knowledgeService.getKnowledge(knowledge.getTitle()); if (knowledge == null) { String value = "Invalid title. Search failed."; setMessage(value); clear(); return new ForwardResolution(SEARCH); } else { HttpSession s = context.getRequest().getSession(); s.setAttribute("knowledgeBean", this); return new RedirectResolution(EDIT_KNOWLEDGE); } } public Resolution exit() { context.getRequest().getSession().invalidate(); clear(); return new RedirectResolution(SEARCH); } public void clear() { knowledge = new Knowledge(); } }
[ "takesy.8455@gmail.com" ]
takesy.8455@gmail.com
41ccc82ba8f419be58caea417de2f55ccef8eb4b
02c41e5c3677abcae65fb228a13ed21a3bc87f8c
/shenma/src/main/java/com/cubead/clm/io/shenma/data/realTime/RealTimeInvalidClickReport.java
353bbdefe0dda81c53f7a05756dd31da360b056e
[]
no_license
ZBHdd/clm
c6952019c7b25c65a6a5e97dc5cf4062f49cf638
aa1b1ae03f2abe6a87e6f63c1a0cc0ef001022e5
refs/heads/master
2020-03-06T23:52:44.613807
2017-08-11T08:37:08
2017-08-11T08:37:08
null
0
0
null
null
null
null
UTF-8
Java
false
false
926
java
package com.cubead.clm.io.shenma.data.realTime; public class RealTimeInvalidClickReport { private String time; private Long beforeFilterClickNum; private Long afterFilterClickNum; private Float filterMoney; public RealTimeInvalidClickReport() {} public String getTime() { return time; } public void setTime(String time) { this.time = time; } public Long getBeforeFilterClickNum() { return beforeFilterClickNum; } public void setBeforeFilterClickNum(Long beforeFilterClickNum) { this.beforeFilterClickNum = beforeFilterClickNum; } public Long getAfterFilterClickNum() { return afterFilterClickNum; } public void setAfterFilterClickNum(Long afterFilterClickNum) { this.afterFilterClickNum = afterFilterClickNum; } public Float getFilterMoney() { return filterMoney; } public void setFilterMoney(Float filterMoney) { this.filterMoney = filterMoney; } }
[ "852717333@qq.com" ]
852717333@qq.com
de7ffbf8e8933fc8d8ad5cb4d0f1990912ee47c2
9f1768d88e343aab3c8a351ade5059e7a73af30c
/nfsdb-core/src/main/java/com/nfsdb/journal/column/SymbolTable.java
137d8c58631f1e8e75b048786feea7460dfcbda9
[]
no_license
gitter-badger/nfsdb
46bd260a176139684faf2c81e3a9d591de275f31
67b4cfb8bb39956e1238ee2eae1c58dcc83188c8
refs/heads/master
2021-01-18T00:01:48.128654
2014-12-10T16:14:33
2014-12-10T16:14:33
null
0
0
null
null
null
null
UTF-8
Java
false
false
7,503
java
/* * Copyright (c) 2014-2015. Vlad Ilyushchenko * * 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.nfsdb.journal.column; import com.nfsdb.journal.JournalMode; import com.nfsdb.journal.collections.AbstractImmutableIterator; import com.nfsdb.journal.collections.ObjIntHashMap; import com.nfsdb.journal.exceptions.JournalException; import com.nfsdb.journal.exceptions.JournalInvalidSymbolValueException; import com.nfsdb.journal.exceptions.JournalRuntimeException; import com.nfsdb.journal.index.Cursor; import com.nfsdb.journal.index.KVIndex; import com.nfsdb.journal.utils.ByteBuffers; import com.nfsdb.journal.utils.Checksum; import com.nfsdb.journal.utils.Lists; import java.io.Closeable; import java.io.File; import java.util.ArrayList; public class SymbolTable implements Closeable { public static final int VALUE_NOT_FOUND = -2; public static final int VALUE_IS_NULL = -1; private static final String DATA_FILE_SUFFIX = ".symd"; private static final String INDEX_FILE_SUFFIX = ".symi"; private static final String HASH_INDEX_FILE_SUFFIX = ".symr"; private static final double CACHE_LOAD_FACTOR = 0.2; private final int hashKeyCount; private final String column; private final ObjIntHashMap<String> valueCache; private final ArrayList<String> keyCache; private final boolean noCache; private VariableColumn data; private KVIndex index; private int size; public SymbolTable(int keyCount, int avgStringSize, int txCountHint, File directory, String column, JournalMode mode, int size, long indexTxAddress, boolean noCache) throws JournalException { // number of hash keys stored in index // assume it is 20% of stated capacity this.hashKeyCount = Math.max(1, (int) (keyCount * CACHE_LOAD_FACTOR)); this.column = column; this.noCache = noCache; JournalMode m; switch (mode) { case BULK_APPEND: m = JournalMode.APPEND; break; case BULK_READ: m = JournalMode.READ; break; default: m = mode; } MappedFile dataFile = new MappedFileImpl(new File(directory, column + DATA_FILE_SUFFIX), ByteBuffers.getBitHint(avgStringSize * 2 + 4, keyCount), m); MappedFile indexFile = new MappedFileImpl(new File(directory, column + INDEX_FILE_SUFFIX), ByteBuffers.getBitHint(8, keyCount), m); this.data = new VariableColumn(dataFile, indexFile); this.size = size; this.index = new KVIndex(new File(directory, column + HASH_INDEX_FILE_SUFFIX), this.hashKeyCount, keyCount, txCountHint, mode, indexTxAddress); this.valueCache = new ObjIntHashMap<>(noCache ? 0 : keyCount, VALUE_NOT_FOUND); this.keyCache = new ArrayList<>(noCache ? 0 : keyCount); } public void applyTx(int size, long indexTxAddress) { this.size = size; this.index.setTxAddress(indexTxAddress); } public void alignSize() { this.size = (int) data.size(); } public int put(String value) { int key = getQuick(value); if (key == VALUE_NOT_FOUND) { key = (int) data.putStr(value); data.commit(); index.add(hashKey(value), key); size++; cache(key, value); } return key; } public int getQuick(String value) { if (!noCache) { int key = value == null ? VALUE_IS_NULL : this.valueCache.get(value); if (key != VALUE_NOT_FOUND) { return key; } } int hashKey = hashKey(value); if (!index.contains(hashKey)) { return VALUE_NOT_FOUND; } Cursor cursor = index.cachedCursor(hashKey); while (cursor.hasNext()) { int key; if (data.cmpStr((key = (int) cursor.next()), value)) { cache(key, value); return key; } } return VALUE_NOT_FOUND; } public int get(String value) { int result = getQuick(value); if (result == VALUE_NOT_FOUND) { throw new JournalInvalidSymbolValueException("Invalid value %s for symbol %s", value, column); } else { return result; } } public boolean valueExists(String value) { return getQuick(value) != VALUE_NOT_FOUND; } public String value(int key) { if (key >= size) { throw new JournalRuntimeException("Invalid symbol key: " + key); } String value = key < keyCache.size() ? keyCache.get(key) : null; if (value == null) { cache(key, value = data.getStr(key)); } return value; } public Iterable<String> values() { return new AbstractImmutableIterator<String>() { private final long size = SymbolTable.this.size(); private long current = 0; @Override public boolean hasNext() { return current < size; } @Override public String next() { return data.getStr(current++); } }; } public int size() { return size; } public void close() { if (data != null) { data.close(); } if (index != null) { index.close(); } index = null; data = null; } public void truncate() { truncate(0); } public void truncate(int size) { if (size() > size) { data.truncate(size); index.truncate(size); data.commit(); clearCache(); this.size = size; } } public void updateIndex(int oldSize, int newSize) { if (oldSize < newSize) { for (int i = oldSize; i < newSize; i++) { index.add(hashKey(data.getStr(i)), i); } } } public VariableColumn getDataColumn() { return data; } public SymbolTable preLoad() { for (int key = 0, size = (int) data.size(); key < size; key++) { String value = data.getStr(key); valueCache.putIfAbsent(value, key); keyCache.add(value); } return this; } public long getIndexTxAddress() { return index.getTxAddress(); } public void commit() { data.commit(); index.commit(); } public void force() { data.force(); index.force(); } private void cache(int key, String value) { if (noCache) { return; } valueCache.put(value, key); Lists.advance(keyCache, key); keyCache.set(key, value); } private void clearCache() { valueCache.clear(); keyCache.clear(); } private int hashKey(String value) { return Checksum.hash(value, hashKeyCount); } }
[ "bluestreak@gmail.com" ]
bluestreak@gmail.com
ec32ebc3bc709603126661656dd8d4969248eb1b
1fc6412873e6b7f6df6c9333276cd4aa729c259f
/ThinkingInJava/src/com/thinking4/initialization/Mugs.java
d2f7ec4592fe26f9cf4e26324ee864311dc10c14
[]
no_license
youzhibicheng/ThinkingJava
dbe9bec5b17e46c5c781a98f90e883078ebbd996
5390a57100ae210dc57bea445750c50b0bfa8fc4
refs/heads/master
2021-01-01T05:29:01.183768
2016-05-10T01:07:58
2016-05-10T01:07:58
58,379,014
1
2
null
null
null
null
WINDOWS-1252
Java
false
false
936
java
package com.thinking4.initialization; //: initialization/Mugs.java // Java "Instance Initialization." import static com.thinking4.util.Print.*; // mug n. Á³£»±­×Ó£»¿à¶ÁÕß class Mug { Mug(int marker) { print("Mug(" + marker + ")"); } void f(int marker) { print("f(" + marker + ")"); } } public class Mugs { Mug mug1; Mug mug2; { mug1 = new Mug(1); mug2 = new Mug(2); print("mug1 & mug2 initialized"); } Mugs() { print("Mugs()"); } Mugs(int i) { print("Mugs(int)"); } public static void main(String[] args) { print("Inside main()"); new Mugs(); print("new Mugs() completed"); new Mugs(1); print("new Mugs(1) completed"); } } /* Output: Inside main() Mug(1) Mug(2) mug1 & mug2 initialized Mugs() new Mugs() completed Mug(1) Mug(2) mug1 & mug2 initialized Mugs(int) new Mugs(1) completed *///:~
[ "youzhibicheng@163.com" ]
youzhibicheng@163.com
0cd86a6a6729a7b6cdb1547d7149d769df2d4dd2
5d4bcf345bc66af9046535b8079a9e51b30927ec
/frame-service/frame-system/src/main/java/com/snaker/system/service/impl/SysMenuServiceImpl.java
874ad6732f8098f1f51d40c1f23faf89d8c1a1ee
[ "MIT" ]
permissive
snakerfor/sanker-cloud
8237086a794d72bec962f7fc61f4b968d98c6591
c3919cdae40cac8c37a3641a74476d4e979ec521
refs/heads/main
2023-08-27T06:42:21.599575
2021-11-11T09:31:21
2021-11-11T09:31:21
426,943,498
1
0
null
null
null
null
UTF-8
Java
false
false
10,112
java
package com.snaker.system.service.impl; import com.snaker.common.constant.UserConstants; import com.snaker.common.core.domain.Ztree; import com.snaker.common.redis.annotation.RedisCache; import com.snaker.common.utils.StringUtils; import com.snaker.system.domain.SysMenu; import com.snaker.system.domain.SysRole; import com.snaker.system.domain.SysUser; import com.snaker.system.mapper.SysMenuMapper; import com.snaker.system.mapper.SysRoleMenuMapper; import com.snaker.system.service.ISysMenuService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.MessageFormat; import java.util.*; /** * 菜单 业务层处理 * * @author sfd */ @Service public class SysMenuServiceImpl implements ISysMenuService { public static final String PREMISSION_STRING = "perms[\"{0}\"]"; @Autowired private SysMenuMapper menuMapper; @Autowired private SysRoleMenuMapper roleMenuMapper; /** * 根据用户查询菜单 * * @param user 用户信息 * @return 菜单列表 */ @Override public List<SysMenu> selectMenusByUser(SysUser user) { List<SysMenu> menus = new LinkedList<SysMenu>(); // 管理员显示所有菜单信息 if (user.isAdmin()) { menus = menuMapper.selectMenuNormalAll(); } else { menus = menuMapper.selectMenusByUserId(user.getUserId()); } return menus; // 前端自行构造菜单树 // return getChildPerms(menus, 0); } /** * 查询菜单集合 * * @return 所有菜单信息 */ @Override public List<SysMenu> selectMenuList(SysMenu menu) { return menuMapper.selectMenuList(menu); } /** * 查询菜单集合 * * @return 所有菜单信息 */ @Override public List<SysMenu> selectMenuAll() { return menuMapper.selectMenuAll(); } /** * 根据用户ID查询权限 * * @param userId 用户ID * @return 权限列表 */ @Override @RedisCache(key = "user_perms", fieldKey = "#userId") public Set<String> selectPermsByUserId(Long userId) { List<String> perms = menuMapper.selectPermsByUserId(userId); Set<String> permsSet = new HashSet<>(); for (String perm : perms) { if (StringUtils.isNotEmpty(perm)) { permsSet.addAll(Arrays.asList(perm.trim().split(","))); } } return permsSet; } @Override public Boolean isExistPermByUserId(String perm, Long userId) { Set<String> perms = selectPermsByUserId(userId); // 判断是否为管理员 if (userId == 1l) { return true; } for (String p : perms) { if (p.equals(perm)) { return true; } } return false; } @Override public List<SysMenu> selectMenuIdsByRoleId(Long roleId) { return menuMapper.selectMenuIdsByRoleId(roleId); } /** * 根据角色ID查询菜单 * * @param role 角色对象 * @return 菜单列表 */ @Override public List<Ztree> roleMenuTreeData(SysRole role) { Long roleId = role.getRoleId(); List<Ztree> ztrees = new ArrayList<Ztree>(); List<SysMenu> menuList = menuMapper.selectMenuAll(); if (StringUtils.isNotNull(roleId)) { List<String> roleMenuList = menuMapper.selectMenuTree(roleId); ztrees = initZtree(menuList, roleMenuList, true); } else { ztrees = initZtree(menuList, null, true); } return ztrees; } /** * 查询所有菜单 * * @return 菜单列表 */ @Override public List<Ztree> menuTreeData() { List<SysMenu> menuList = menuMapper.selectMenuAll(); List<Ztree> ztrees = initZtree(menuList); return ztrees; } /** * 查询系统所有权限 * * @return 权限列表 */ @Override public LinkedHashMap<String, String> selectPermsAll() { LinkedHashMap<String, String> section = new LinkedHashMap<>(); List<SysMenu> permissions = menuMapper.selectMenuAll(); if (StringUtils.isNotEmpty(permissions)) { for (SysMenu menu : permissions) { section.put(menu.getMenuName(), MessageFormat.format(PREMISSION_STRING, menu.getPerms())); } } return section; } /** * 对象转菜单树 * * @param menuList 菜单列表 * @return 树结构列表 */ public List<Ztree> initZtree(List<SysMenu> menuList) { return initZtree(menuList, null, false); } /** * 对象转菜单树 * * @param menuList 菜单列表 * @param roleMenuList 角色已存在菜单列表 * @param permsFlag 是否需要显示权限标识 * @return 树结构列表 */ public List<Ztree> initZtree(List<SysMenu> menuList, List<String> roleMenuList, boolean permsFlag) { List<Ztree> ztrees = new ArrayList<Ztree>(); boolean isCheck = StringUtils.isNotNull(roleMenuList); for (SysMenu menu : menuList) { Ztree ztree = new Ztree(); ztree.setId(menu.getMenuId()); ztree.setpId(menu.getParentId()); ztree.setName(transMenuName(menu, roleMenuList, permsFlag)); ztree.setTitle(menu.getMenuName()); if (isCheck) { ztree.setChecked(roleMenuList.contains(menu.getMenuId() + menu.getPerms())); } ztrees.add(ztree); } return ztrees; } public String transMenuName(SysMenu menu, List<String> roleMenuList, boolean permsFlag) { StringBuffer sb = new StringBuffer(); sb.append(menu.getMenuName()); if (permsFlag) { sb.append("<font color=\"#888\">&nbsp;&nbsp;&nbsp;" + menu.getPerms() + "</font>"); } return sb.toString(); } /** * 删除菜单管理信息 * * @param menuId 菜单ID * @return 结果 */ @Override public int deleteMenuById(Long menuId) { return menuMapper.deleteMenuById(menuId); } /** * 根据菜单ID查询信息 * * @param menuId 菜单ID * @return 菜单信息 */ @Override public SysMenu selectMenuById(Long menuId) { return menuMapper.selectMenuById(menuId); } public SysMenu selectMenuByPerms(String perms) { return menuMapper.selectMenuByPerms(perms); } /** * 查询子菜单数量 * * @param parentId 父级菜单ID * @return 结果 */ @Override public int selectCountMenuByParentId(Long parentId) { return menuMapper.selectCountMenuByParentId(parentId); } /** * 查询菜单使用数量 * * @param menuId 菜单ID * @return 结果 */ @Override public int selectCountRoleMenuByMenuId(Long menuId) { return roleMenuMapper.selectCountRoleMenuByMenuId(menuId); } /** * 新增保存菜单信息 * * @param menu 菜单信息 * @return 结果 */ @Override public int insertMenu(SysMenu menu) { return menuMapper.insertMenu(menu); } /** * 修改保存菜单信息 * * @param menu 菜单信息 * @return 结果 */ @Override public int updateMenu(SysMenu menu) { return menuMapper.updateMenu(menu); } /** * 校验菜单名称是否唯一 * * @param menu 菜单信息 * @return 结果 */ @Override public String checkMenuNameUnique(SysMenu menu) { Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { return UserConstants.MENU_NAME_NOT_UNIQUE; } return UserConstants.MENU_NAME_UNIQUE; } /** * 根据父节点的ID获取所有子节点 * * @param list 分类表 * @param parentId 传入的父节点ID * @return String */ public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) { List<SysMenu> returnList = new ArrayList<SysMenu>(); for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext(); ) { SysMenu t = (SysMenu) iterator.next(); // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 if (t.getParentId() == parentId) { recursionFn(list, t); returnList.add(t); } } return returnList; } /** * 递归列表 * * @param list * @param t */ private void recursionFn(List<SysMenu> list, SysMenu t) { // 得到子节点列表 List<SysMenu> childList = getChildList(list, t); t.setChildren(childList); for (SysMenu tChild : childList) { if (hasChild(list, tChild)) { // 判断是否有子节点 Iterator<SysMenu> it = childList.iterator(); while (it.hasNext()) { SysMenu n = (SysMenu) it.next(); recursionFn(list, n); } } } } /** * 得到子节点列表 */ private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) { List<SysMenu> tlist = new ArrayList<SysMenu>(); Iterator<SysMenu> it = list.iterator(); while (it.hasNext()) { SysMenu n = (SysMenu) it.next(); if (n.getParentId().longValue() == t.getMenuId().longValue()) { tlist.add(n); } } return tlist; } /** * 判断是否有子节点 */ private boolean hasChild(List<SysMenu> list, SysMenu t) { return getChildList(list, t).size() > 0 ? true : false; } }
[ "15838351618@163.com" ]
15838351618@163.com
28e355df986db5f761734465c534f9ac806cc041
5e224ff6d555ee74e0fda6dfa9a645fb7de60989
/database/src/main/java/adila/db/zm1_infocus20m808i.java
d2bed4535ec67a74417b1bd5f7a250ec5cc7eae8
[ "MIT" ]
permissive
karim/adila
8b0b6ba56d83f3f29f6354a2964377e6197761c4
00f262f6d5352b9d535ae54a2023e4a807449faa
refs/heads/master
2021-01-18T22:52:51.508129
2016-11-13T13:08:04
2016-11-13T13:08:04
45,054,909
3
1
null
null
null
null
UTF-8
Java
false
false
218
java
// This file is automatically generated. package adila.db; /* * InFocus M808i * * DEVICE: ZM1 * MODEL: InFocus M808i */ final class zm1_infocus20m808i { public static final String DATA = "InFocus|M808i|"; }
[ "keldeeb@gmail.com" ]
keldeeb@gmail.com
393326394592e1c39b38db0747f0e5f55a9f2913
1c64ac5fb5addea8c9a3a73598d77f77931f6be0
/app/src/main/java/com/qf/util/MyJSONUtil.java
334d518c578ffa6384ed806ebf87717d71b2c85a
[]
no_license
luckeystronglu/QRCoderZX
91f88293b826da95a4e4e9444bf8805f9e898476
41625e6e2d8ed23e02d44299e35bd6eb84dd9cbb
refs/heads/master
2020-04-11T03:00:02.053623
2016-09-14T02:16:35
2016-09-14T02:16:35
68,165,169
0
0
null
null
null
null
UTF-8
Java
false
false
964
java
package com.qf.util; import android.text.TextUtils; import com.qf.entity.ContactEntity; import java.util.List; public class MyJSONUtil { public static String getJSONByList(List<ContactEntity> datas){ StringBuilder stringBuilder = new StringBuilder(); if(datas != null && datas.size() > 0){ stringBuilder.append("["); for(int i = 0; i < datas.size(); i++){ if(i != 0){ stringBuilder.append(","); } //{"name":"Lucy", "phone":"182316821"} // stringBuilder.append("{"); stringBuilder.append("\"name\":"); stringBuilder.append("\"" + datas.get(i).getName() + "\""); //ƴ�ӵ绰 if(!TextUtils.isEmpty(datas.get(i).getPhone())){ stringBuilder.append(","); stringBuilder.append("\"phone\":"); stringBuilder.append("\"" + datas.get(i).getPhone() + "\""); } stringBuilder.append("}"); } stringBuilder.append("]"); return stringBuilder.toString(); } return "[]"; } }
[ "903804013@qq.com" ]
903804013@qq.com
f30423e8a7c44b1834e07f62992c944b72bcb058
7d51064e739304e9b8413929af6ca1f70cb45fbc
/wts/src/cn/dao/ResaveDao.java
ae6933fa2ca7f5ee64dc7a29b7a274de829310dd
[]
no_license
nelsonnick/wts
3dab38338b6c643006f4ab3356cedd73cd672e65
a3ed48fbc577eb39979949f2043312497ad99651
refs/heads/master
2020-06-29T03:35:31.984885
2016-11-22T08:49:52
2016-11-22T08:49:52
58,301,822
0
0
null
null
null
null
UTF-8
Java
false
false
131
java
package cn.dao; import cn.base.BaseDao; import cn.entity.Resave; public interface ResaveDao extends BaseDao<Resave> { }
[ "admin@FWQ" ]
admin@FWQ
dcdd721858f4a5794913bd47ec053578c22b5966
14822fc611c3b155249e5994f0f0166905debf34
/src/java/co/matisses/bcs/b1ws/client/goodsissue/GoodsIssueServiceException.java
4986dd01db604f23b3473c22eb0efcafa38db02b
[ "MIT" ]
permissive
matisses/BCS
ea0008c6a9abb8c922de4901e4070128c512b022
93e4cf4e37cb0a567f5e9575f25b9d19eb5c8016
refs/heads/master
2021-01-25T09:04:08.366035
2018-05-09T15:31:47
2018-05-09T15:31:47
93,775,443
0
0
null
null
null
null
UTF-8
Java
false
false
278
java
package co.matisses.bcs.b1ws.client.goodsissue; /** * * @author dbotero */ public class GoodsIssueServiceException extends Exception { public GoodsIssueServiceException() { } public GoodsIssueServiceException(String message) { super(message); } }
[ "dbotero@matisses.co" ]
dbotero@matisses.co
e12089f75ac85ea982858e901a61782d44afe6e0
77d00edc74e72093c3809230da067b54c299f670
/app.core/src/app/core/service/impl/FunctionServiceImpl.java
7039ede13bffb220f24f14845ea468235c163bc8
[]
no_license
sobrikiki89/cmsJava
377203d9671a517523700a330ce039c7d29ff0a2
cf5075006e317f533ca672a4ea7130461acdf69d
refs/heads/master
2022-06-18T07:38:39.167207
2020-05-07T15:05:59
2020-05-07T15:05:59
262,080,826
0
0
null
null
null
null
UTF-8
Java
false
false
4,215
java
package app.core.service.impl; import java.lang.reflect.Field; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import app.core.annotation.Permission; import app.core.registry.Module; import app.core.service.FunctionService; @Service public class FunctionServiceImpl implements FunctionService { private static final Logger logger = LoggerFactory.getLogger(FunctionServiceImpl.class); @Autowired private SessionFactory sessionFactory; @Transactional @SuppressWarnings("rawtypes") public void updateFunctions(Module module) { Class clazz = module.getClass(); Session session = sessionFactory.getCurrentSession(); Query query; String code; int rowUpdated; for (Field field : clazz.getFields()) { // NOTE : Permission will only be picked up when field is String // type if (field.isAnnotationPresent(Permission.class) && String.class.equals(field.getType())) { Permission permission = field.getAnnotation(Permission.class); try { code = (String) field.get(clazz); logger.info("Function found in module [" + module.getModuleName() + "], code = [" + code + "], name = [" + permission.name() + "], path = [" + permission.path() + "]"); query = session.createSQLQuery("SELECT f.code FROM app_function f WHERE f.code = :code"); query.setParameter("code", code); if (query.uniqueResult() != null) { // Function found in database, update it query = session .createSQLQuery("UPDATE app_function SET name = :name, path = :path WHERE code = :code"); query.setParameter("name", permission.name()).setParameter("path", permission.path()) .setParameter("code", code); rowUpdated = query.executeUpdate(); if (logger.isDebugEnabled()) { logger.debug("Update function [" + code + "], row updated [" + rowUpdated + "]"); } } else { // Function not found, insert a new function query = session .createSQLQuery("INSERT INTO app_function (code, name, description, path) VALUES (:code, :name, :description, :path)"); query.setParameter("code", code).setParameter("name", permission.name()) .setParameter("description", permission.name()).setParameter("path", permission.path()); rowUpdated = query.executeUpdate(); if (logger.isDebugEnabled()) { logger.debug("Insert function [" + code + "], row updated [" + rowUpdated + "]"); } } } catch (Exception e) { logger.error("Error on getting field with @Permission annotation", e); } } } } @Transactional(readOnly = true) public boolean isAuthorizedByPath(Long roleId, String path) { StringBuffer sql = new StringBuffer(); sql.append("SELECT DISTINCT f.code "); sql.append("FROM role_function rf"); sql.append(" INNER JOIN app_function f"); sql.append(" ON rf.function_code = f.code "); sql.append("WHERE rf.role_id = ?"); sql.append(" AND f.path like ? "); Session session = sessionFactory.getCurrentSession(); Query query = session.createSQLQuery(sql.toString()).setParameter(0, roleId).setParameter(1, path); @SuppressWarnings("rawtypes") List result = query.list(); if (result != null && result.size() > 0) { return true; } return false; } @Transactional(readOnly = true) public boolean isAuthorizedByCode(Long roleId, String code) { StringBuffer sql = new StringBuffer(); sql.append("SELECT DISTINCT f.code "); sql.append("FROM role_function rf"); sql.append(" INNER JOIN app_function f"); sql.append(" ON rf.function_code = f.code "); sql.append("WHERE rf.role_id = ?"); sql.append(" AND f.code = ?"); Session session = sessionFactory.getCurrentSession(); Query query = session.createSQLQuery(sql.toString()).setParameter(0, roleId).setParameter(1, code); @SuppressWarnings("rawtypes") List result = query.list(); if (result != null && result.size() > 0) { return true; } return false; } }
[ "ahmadsobriharis@gmail.com" ]
ahmadsobriharis@gmail.com
1069f418139bdab67f87113d32d3d7986348d534
03ff067958d8cf38e9a218c021e510a1dd5efef1
/selenium/src/main/java/teste/selenium/App.java
f44d6f26deb51bbdbd838e53ae33c39f97ba67cf
[]
no_license
JulianneSantos/Selenium
ad2c6f2aca8c6962320220ad5e7fa4c8709d24b7
16cf0370362ab0f2a40d64d9425774afd7b4b2de
refs/heads/master
2021-01-02T22:05:46.679189
2020-02-19T01:45:03
2020-02-19T01:45:03
239,820,533
0
0
null
2020-10-13T19:30:10
2020-02-11T17:18:11
Java
UTF-8
Java
false
false
177
java
package teste.selenium; /** * Hello world! * */ public class App { public static void main( String[] args ) { System.out.println( "Hello World!" ); } }
[ "julianne.dos.santos@accenture.com" ]
julianne.dos.santos@accenture.com
2b25300c527009991eb232d299e955f956550d96
645e6414fb28f00da37004244efa1d690a041640
/mine/src/main/java/com/tsu/mine/activity/MineActivity.java
c25bc9c76516f2641d5d5ce3d463ee83ef3293d9
[]
no_license
Tsu2014/TestMu
0378c23ab2163d756462f0236a50e347bf3aca0a
88e5fa12951b57107b65d8d1a9bc096b7744f5c9
refs/heads/master
2023-02-21T09:49:38.955885
2021-01-25T15:44:26
2021-01-25T15:44:26
319,973,101
0
0
null
null
null
null
UTF-8
Java
false
false
513
java
package com.tsu.mine.activity; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import com.alibaba.android.arouter.facade.annotation.Route; import com.tsu.annotation.BindPath; import com.tsu.mine.R; //@Route(path = "/mine/main") @BindPath("/mine/main") public class MineActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mine_main); } }
[ "l66566@126.com" ]
l66566@126.com
ee52e1b20df5fa53ee3daa5d7efbb51b3306cf5f
dc5e617967abc5eb623eabc8f765dac6d01f19fe
/app/src/androidTest/java/com/example/tanutk/internetconnectioncheck/ApplicationTest.java
8b938c7066f1972d6a0ccc26486ceb8d37297f58
[]
no_license
kowchong/InternetConnectionCheck
3538ef972c33a3c03a4b039e2406bd2ba623272c
e860938acde1c3047943da2a15b2167d8b7ee55d
refs/heads/master
2021-01-01T05:21:49.527441
2016-05-11T09:39:20
2016-05-11T09:39:20
58,532,412
0
0
null
null
null
null
UTF-8
Java
false
false
373
java
package com.example.tanutk.internetconnectioncheck; import android.app.Application; import android.test.ApplicationTestCase; /** * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> */ public class ApplicationTest extends ApplicationTestCase<Application> { public ApplicationTest() { super(Application.class); } }
[ "sc.kowchong@gmail.com" ]
sc.kowchong@gmail.com
0a4970159117fc21eb391bd8b02343ac741a27a4
48146231c53d8f4dce256bd82839829fa5c68b2b
/src/main/java/com/fasterxml/jackson/databind/util/TokenBufferReadContext.java
208eb82a205522f9f594146fccf0bcd35b9a816c
[ "LicenseRef-scancode-generic-cla", "Apache-2.0" ]
permissive
kislay2004/jackson-databind
1f6f14d5c9a3f24c7a9b7b3ec60640578286e32f
5950f3f009ae23113b3878d41ebf4025029eb33b
refs/heads/master
2020-07-29T11:06:36.848996
2019-09-20T06:37:52
2019-09-20T06:37:52
209,773,431
1
0
Apache-2.0
2019-09-20T11:19:32
2019-09-20T11:19:32
null
UTF-8
Java
false
false
4,429
java
package com.fasterxml.jackson.databind.util; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.json.JsonReadContext; /** * Implementation of {@link TokenStreamContext} used by {@link TokenBuffer} * to link back to the original context to try to keep location information * consistent between source location and buffered content when it's re-read * from the buffer. * * @since 2.9 */ public class TokenBufferReadContext extends TokenStreamContext { protected final TokenStreamContext _parent; protected final JsonLocation _startLocation; // Benefit for reusing? // protected JsonReadContext _child; /* /********************************************************** /* Location/state information (minus source reference) /********************************************************** */ protected String _currentName; protected Object _currentValue; protected TokenBufferReadContext(TokenStreamContext base, Object srcRef) { super(base); _parent = base.getParent(); _currentName = base.currentName(); _currentValue = base.getCurrentValue(); if (base instanceof JsonReadContext) { JsonReadContext rc = (JsonReadContext) base; _startLocation = rc.getStartLocation(srcRef); } else { _startLocation = JsonLocation.NA; } } protected TokenBufferReadContext(TokenStreamContext base, JsonLocation startLoc) { super(base); _parent = base.getParent(); _currentName = base.currentName(); _currentValue = base.getCurrentValue(); _startLocation = startLoc; } /** * Constructor for case where there is no real surrounding context: just create * virtual ROOT */ protected TokenBufferReadContext() { super(TYPE_ROOT, -1); _parent = null; _startLocation = JsonLocation.NA; } protected TokenBufferReadContext(TokenBufferReadContext parent, int type, int index) { super(type, index); _parent = parent; _startLocation = parent._startLocation; } @Override public Object getCurrentValue() { return _currentValue; } @Override public void setCurrentValue(Object v) { _currentValue = v; } /* /********************************************************** /* Factory methods /********************************************************** */ public static TokenBufferReadContext createRootContext(TokenStreamContext origContext) { // First: possible to have no current context; if so, just create bogus ROOT context if (origContext == null) { return new TokenBufferReadContext(); } return new TokenBufferReadContext(origContext, null); } public TokenBufferReadContext createChildArrayContext() { return new TokenBufferReadContext(this, TYPE_ARRAY, -1); } public TokenBufferReadContext createChildObjectContext() { return new TokenBufferReadContext(this, TYPE_OBJECT, -1); } /** * Helper method we need to handle discontinuity between "real" contexts buffer * creates, and ones from parent: problem being they are of different types. */ public TokenBufferReadContext parentOrCopy() { // 30-Apr-2017, tatu: This is bit awkward since part on ancestor stack is of different // type (usually `JsonReadContext`)... and so for unbalanced buffers (with extra // END_OBJECT / END_ARRAY), we may need to create if (_parent instanceof TokenBufferReadContext) { return (TokenBufferReadContext) _parent; } if (_parent == null) { // unlikely, but just in case let's support return new TokenBufferReadContext(); } return new TokenBufferReadContext(_parent, _startLocation); } /* /********************************************************** /* Abstract method implementation /********************************************************** */ @Override public String currentName() { return _currentName; } @Override public boolean hasCurrentName() { return _currentName != null; } @Override public TokenStreamContext getParent() { return _parent; } public void setCurrentName(String name) throws JsonProcessingException { _currentName = name; } }
[ "tatu.saloranta@iki.fi" ]
tatu.saloranta@iki.fi
28cc309c79dca030e43a7f82530724c66314b134
e2e3574cee73775ecc5db8d6ebf366f478cbbdae
/pinyougou_parent/pinyougou_seckill_service/src/main/java/com/pinyougou/seckill/service/impl/SeckillServiceImpl.java
5d81c75c238a7980e3bc6b3059cea46104b60fe3
[]
no_license
nrbwGzm/pyg
b536a8943bc336ff7a0dc52a28521e484e529c53
de8b37c64cb958d8ac4902e5e05cdd1ab55deeae
refs/heads/master
2020-03-24T07:03:54.803714
2018-08-25T14:16:55
2018-08-25T14:16:55
142,551,295
0
0
null
null
null
null
UTF-8
Java
false
false
3,010
java
package com.pinyougou.seckill.service.impl; import com.alibaba.dubbo.config.annotation.Service; import com.pinyougou.mapper.TbSeckillGoodsMapper; import com.pinyougou.mapper.TbSeckillOrderMapper; import com.pinyougou.pojo.TbSeckillGoods; import com.pinyougou.seckill.service.SeckillService; import entity.UserIdAndSeckillGoodsId; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import utils.IdWorker; import java.util.List; @Service public class SeckillServiceImpl implements SeckillService { @Autowired private RedisTemplate redisTemplate; @Autowired private TbSeckillOrderMapper seckillOrderMapper; @Autowired private TbSeckillGoodsMapper seckillGoodsMapper; @Autowired private IdWorker idWorker; @Autowired private CreateOrder createOrder; @Autowired private ThreadPoolTaskExecutor executor; @Override public List<TbSeckillGoods> findAllSeckillGoodsFromRedis() { List<TbSeckillGoods> seckill_goods = redisTemplate.boundHashOps("SECKILL_GOODS").values(); return seckill_goods; } @Override public TbSeckillGoods findOneSeckillGoodsFromRedis(Long seckillGoodsId) { TbSeckillGoods seckillGoods = (TbSeckillGoods) redisTemplate.boundHashOps("SECKILL_GOODS").get(seckillGoodsId); return seckillGoods; } @Override public void saveSeckillOrder(Long seckillGoodsId, String userId) { Boolean member = redisTemplate.boundSetOps("SECKILL_PAY_LOG" + seckillGoodsId).isMember(userId); if(member){ throw new RuntimeException("请先支付您已买到的商品!"); } //---------------------------------------- TbSeckillGoods seckillGoods = (TbSeckillGoods) redisTemplate.boundHashOps("SECKILL_GOODS").get(seckillGoodsId); // 需要判断是否有库存 if(seckillGoods==null || seckillGoods.getStockCount()<=0 ){ throw new RuntimeException("商品已售罄!"); } // 从Redis队列中判断是否有此商品 Object obj = redisTemplate.boundListOps("SECKILL_GOODS_QUEUE"+seckillGoodsId).leftPop(); if(obj==null){ throw new RuntimeException("商品已售罄!"); } Long count_order_queue = redisTemplate.boundValueOps("SECKILL_COUNT_ORDER_QUEUE").size(); if(count_order_queue+10>seckillGoods.getStockCount()){ throw new RuntimeException("排队人数较多!"); } redisTemplate.boundValueOps("SECKILL_COUNT_ORDER_QUEUE").increment(0);//排队人数加1 // 操作mysql数据库 // 把需要下单的任务放到Redis中 redisTemplate.boundListOps("SECKILL_ORDER_QUEUE").leftPush(new UserIdAndSeckillGoodsId(userId,seckillGoodsId)); executor.execute(createOrder);//执行线程的任务 } }
[ "349383562@qq.com" ]
349383562@qq.com
1ddd3b1adade2f4ac98f07304893812802a523e3
6bcfe181bc6aefeca202fc23993dd920906e9747
/concept/core/src_extra/Designpattern/src/com/sun/designpattern/behavior/strategy/StrategyExample.java
eea7cfb3b0702e148f197b655b032237ad28b6f5
[]
no_license
sks40gb/zunk
18f54cc07f658521897f8bd7769e2ab7608ed334
13dd01f77675446ed69ac677fee3d545f7c41679
refs/heads/master
2021-07-08T18:28:01.255526
2021-03-14T12:03:23
2021-03-14T12:03:23
50,577,509
0
0
null
null
null
null
UTF-8
Java
false
false
2,260
java
package com.sun.designpattern.behavior.strategy; /** * For instance, a class that performs validation on incoming data may use a strategy pattern to select a validation * algorithm based on the type of data, the source of the data, user choice, or other discriminating factors. These * factors are not known for each case until run-time, and may require radically different validation to be performed * * @author Sunil */ /** * The classes that implement a concrete strategy should implement this. The Context class uses this to call the * concrete strategy. */ interface Strategy { int execute(int a, int b); } /** * Implements the algorithm using the strategy interface */ class Add implements Strategy { public int execute(int a, int b) { System.out.println("Called Add's execute()"); return a + b; // Do an addition with a and b } } class Subtract implements Strategy { public int execute(int a, int b) { System.out.println("Called Subtract's execute()"); return a - b; // Do a subtraction with a and b } } class Multiply implements Strategy { public int execute(int a, int b) { System.out.println("Called Multiply's execute()"); return a * b; // Do a multiplication with a and b } } // Configured with a ConcreteStrategy object and maintains // a reference to a Strategy object class Context { private Strategy strategy; public Context(Strategy strategy) { this.strategy = strategy; } public int executeStrategy(int a, int b) { return this.strategy.execute(a, b); } } /** * Tests the pattern */ class StrategyExample { public static void main(String[] args) { Context context; // Three contexts following different strategies context = new Context(new Add()); int resultA = context.executeStrategy(3, 4); context = new Context(new Subtract()); int resultB = context.executeStrategy(3, 4); context = new Context(new Multiply()); int resultC = context.executeStrategy(3, 4); System.out.println("Result A : " + resultA); System.out.println("Result B : " + resultB); System.out.println("Result C : " + resultC); } }
[ "sunsingh@adobe.com" ]
sunsingh@adobe.com
2c122f96a693031d7e27b75e90fc26335d340329
dd6bf2eb86136aff1e04276f73fe305330e5c804
/src/main/java/cn/yapin/gzh/model/sendMsg/NewsMessage.java
2e8f9b3d9fe028ce4fc77ca7f0148d5da9ecc501
[ "MIT" ]
permissive
lixinrongNokia/yapingzh
752697d8030ec614cb4c0b41f147790332975693
07f38a8260ebbd93d60f107fee15047de869eb07
refs/heads/master
2022-12-24T18:28:46.595137
2019-07-15T04:27:09
2019-07-15T04:27:09
196,922,390
0
0
MIT
2022-12-16T09:42:51
2019-07-15T04:12:51
Java
UTF-8
Java
false
false
895
java
package cn.yapin.gzh.model.sendMsg; import java.util.List; import cn.yapin.gzh.model.container.ArticleDescriptionContainer; public class NewsMessage extends BaseMessage { private List<ArticleDescriptionContainer> Articles; private int ArticleCount; public NewsMessage() { super(); } public NewsMessage(String toUserName, String fromUserName, Long createTime, String msgType, List<ArticleDescriptionContainer> articles, int articleCount) { super(toUserName, fromUserName, createTime, msgType); Articles = articles; ArticleCount = articleCount; } public int getArticleCount() { return ArticleCount; } public void setArticleCount(int articleCount) { ArticleCount = articleCount; } public List<ArticleDescriptionContainer> getArticles() { return Articles; } public void setArticles(List<ArticleDescriptionContainer> articles) { Articles = articles; } }
[ "lixinrongnokia@outlook.ocm" ]
lixinrongnokia@outlook.ocm
33c218de5887cb5ffd83b206b6f541c9276ca6fd
e98f959cdb3492dbae5329f777a466c1553ee561
/ArmasMongo/src/com/fer/componentes/beans/JPanelPersonajes.java
09065ba0968abcf0a400998728e9af8654623383
[]
no_license
voidMuyTofu/ProyectoMongo
3237b467e5d9b3996375fcef948e29b71b41ca31
ba29edeb1237d9bf0e1f3312978cb41d7f598557
refs/heads/master
2020-04-26T21:54:09.690014
2019-03-05T02:12:38
2019-03-05T02:12:38
173,855,351
0
0
null
null
null
null
UTF-8
Java
false
false
7,275
java
package com.fer.componentes.beans; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.swing.DefaultListModel; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; import com.fer.base.Arma; import com.fer.base.Personaje; import javax.swing.JButton; public class JPanelPersonajes extends JPanel implements ActionListener, MouseListener{ public JBotonesCrud botonesCrud; public JLabel lbNombre; public JLabel lbDescripcion; public JTextField tfNombre; public JTextField tfDescripcion; public JLabel lbVida; public JLabel lbAtaque; public JTextField tfVida; public JTextField tfAtaque; public JScrollPane scrollPane; public JComboPlus comboArmas; public JListaBusqueda listaBusqueda; public JList listaPersonajes; public DefaultListModel<Personaje> modeloLista; private boolean activo; public JButton btRecuperar; public JButton btEliminarTodo; Personaje pers; /** * Create the panel. */ public JPanelPersonajes() { setLayout(null); botonesCrud = new JBotonesCrud(); botonesCrud.setBounds(23, 179, 216, 110); add(botonesCrud); lbNombre = new JLabel("Nombre"); lbNombre.setBounds(10, 11, 46, 14); add(lbNombre); lbDescripcion = new JLabel("Descripcion"); lbDescripcion.setBounds(10, 36, 79, 14); add(lbDescripcion); tfNombre = new JTextField(); tfNombre.setBounds(99, 8, 140, 20); add(tfNombre); tfNombre.setColumns(10); tfDescripcion = new JTextField(); tfDescripcion.setBounds(99, 33, 140, 20); add(tfDescripcion); tfDescripcion.setColumns(10); lbVida = new JLabel("Vida"); lbVida.setBounds(10, 59, 46, 14); add(lbVida); lbAtaque = new JLabel("Ataque"); lbAtaque.setBounds(10, 84, 46, 14); add(lbAtaque); tfVida = new JTextField(); tfVida.setBounds(99, 56, 140, 20); add(tfVida); tfVida.setColumns(10); tfAtaque = new JTextField(); tfAtaque.setBounds(99, 81, 140, 20); add(tfAtaque); tfAtaque.setColumns(10); scrollPane = new JScrollPane(); scrollPane.setBounds(10, 109, 229, 61); add(scrollPane); modeloLista = new DefaultListModel<>(); listaPersonajes = new JList(); scrollPane.setViewportView(listaPersonajes); listaPersonajes.setModel(modeloLista); listaBusqueda = new JListaBusqueda(); listaBusqueda.setBounds(249, 8, 204, 281); add(listaBusqueda); btRecuperar =new JButton("Recuperar ultimo borrado"); btRecuperar.setBounds(23, 308, 198, 23); add(btRecuperar); btRecuperar.setActionCommand("recuperar"); btRecuperar.addActionListener(this); btEliminarTodo = new JButton("Eliminar Todo"); btEliminarTodo.setBounds(244, 308, 198, 23); add(btEliminarTodo); btEliminarTodo.setActionCommand("eliminar todo"); btEliminarTodo.addActionListener(this); inicializar(); refrescarLista(); modoEdicion(false); } public void actionPerformed(ActionEvent e) { String comando = e.getActionCommand(); switch (comando) { case "nuevo": modoEdicion(true); activo = false; break; case "guardar": String nombre = tfNombre.getText(); String descripcion = tfDescripcion.getText(); int ataque = Integer.parseInt(tfAtaque.getText()); int vida = Integer.parseInt(tfVida.getText()); if(!activo) { Personaje personaje = new Personaje(); personaje.setNombre(nombre); personaje.setDescripcion(descripcion); personaje.setVida(vida); personaje.setAtaque(ataque); List<Arma> armas = listaBusqueda.getListadoArmas(); personaje.setArmas(armas); Modelo modelo = new Modelo(); modelo.guardarPersonaje(personaje); refrescarLista(); } else { pers.setNombre(nombre); pers.setDescripcion(descripcion); pers.setVida(vida); pers.setAtaque(ataque); List<Arma> listaArmas = listaBusqueda.getListadoArmas(); pers.setArmas(listaArmas); Modelo modelo = new Modelo(); modelo.guardarPersonaje(pers); refrescarLista(); } break; case "eliminar": Personaje pers= (Personaje) listaPersonajes.getSelectedValue(); Modelo modelo = new Modelo(); modelo.eliminarPersonaje(pers); refrescarLista(); break; case "cancelar": modoEdicion(false); blanquearCajas(); break; case "modificar": activo = true; modoEdicion(true); break; } } public void modoEdicion(boolean activo) { if(activo) { botonesCrud.btNuevo.setEnabled(false); botonesCrud.btModificar.setEnabled(false); botonesCrud.btEliminar.setEnabled(false); botonesCrud.btGuardar.setEnabled(true); botonesCrud.btCancelar.setEnabled(true); apagarCajas(true); }else { botonesCrud.btNuevo.setEnabled(true); botonesCrud.btModificar.setEnabled(false); botonesCrud.btEliminar.setEnabled(false); botonesCrud.btCancelar.setEnabled(false); botonesCrud.btGuardar.setEnabled(false); apagarCajas(false); } } public void apagarCajas(boolean activo) { if (activo) { tfNombre.setEditable(true); tfVida.setEditable(true); tfDescripcion.setEditable(true); tfAtaque.setEditable(true); }else { tfNombre.setEditable(false); tfVida.setEditable(false); tfDescripcion.setEditable(false); tfAtaque.setEditable(false); } } private void cargar (Personaje pers) { tfNombre.setText(pers.getNombre()); tfDescripcion.setText(pers.getDescripcion()); tfAtaque.setText(String.valueOf(pers.getAtaque())); tfVida.setText(String.valueOf(pers.getVida())); } private void blanquearCajas() { tfNombre.setText(""); tfDescripcion.setText(""); tfAtaque.setText(""); tfVida.setText(""); } private void inicializar() { botonesCrud.addListeners(this); listaPersonajes.addMouseListener(this); } public void modificar(Personaje personaje, ArrayList<Arma> armas) { Session sesion = HibernateUtil.getCurrentSession(); sesion.beginTransaction(); armas.clear(); sesion.save(personaje); for (Arma arma : armas) { arma.setPersonaje(personaje); sesion.save(arma); } sesion.getTransaction().commit(); sesion.close(); } private void refrescarLista() { modeloLista.clear(); Modelo modelo = new Modelo(); for (Personaje personaje : modelo.getPersonajes()) { modeloLista.addElement(personaje); } } @Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { if(e.getSource() == listaPersonajes) { pers = (Personaje) listaPersonajes.getSelectedValue(); cargar(pers); modoEdicion(false); listaBusqueda.refrescarLista(pers.getArmas()); botonesCrud.btNuevo.setEnabled(false); botonesCrud.btCancelar.setEnabled(true); botonesCrud.btEliminar.setEnabled(true); botonesCrud.btModificar.setEnabled(true); } } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } }
[ "fernandoperezdelatorremunoz@gmail.com" ]
fernandoperezdelatorremunoz@gmail.com
78dde7b1d99ecdc1703e48783d2f6ab9961defb1
a6e79844fd708f1691bbf521e9fbfa6bde282596
/jdk8-learn/src/main/java/com/yzd/design_pattern/观察者/Observer.java
5519e45ffac55352f9f867777710d57b4f22fcc2
[]
no_license
Y-zd/jdk8
6da8cd74dc953865010b8638dba9959623dc1fe5
c0433a85194f457c4982bcdf9cf06ffa2223b2c6
refs/heads/master
2022-10-26T17:56:35.136119
2020-09-22T06:36:18
2020-09-22T06:36:18
208,734,747
1
0
null
2022-10-12T20:43:21
2019-09-16T07:15:56
Java
UTF-8
Java
false
false
222
java
package com.yzd.design_pattern.观察者; /*** * * @author : yanzhidong * @date : 2020/9/7 * @version : V1.0 * */ public abstract class Observer { protected Subject subject; public abstract void update(); }
[ "yanzhidong@sm.vvip-u.com" ]
yanzhidong@sm.vvip-u.com
0528f05c6883f9931081441058ea0fc5090003bf
f3e500f013854b23552e0488550c18fb0ac65613
/src/main/java/ivan/vatlin/dto/CarInfo.java
d60af0e696222f821d3578bece1e0702ae38c271
[]
no_license
MadVodka/MVC_app
d8594940bfc164694a1bf91825fb734ffb24f797
ce775866ae5f7fcf397aafbcf6d58ef00b661249
refs/heads/master
2020-09-04T09:27:51.499260
2019-12-20T07:25:24
2019-12-20T07:25:24
219,702,192
0
0
null
2019-12-20T07:25:25
2019-11-05T09:07:43
null
UTF-8
Java
false
false
782
java
package ivan.vatlin.dto; public class CarInfo { private long carId; private String brand; private String model; private String year; public long getCarId() { return carId; } public CarInfo setCarId(long carId) { this.carId = carId; return this; } public String getBrand() { return brand; } public CarInfo setBrand(String brand) { this.brand = brand; return this; } public String getModel() { return model; } public CarInfo setModel(String model) { this.model = model; return this; } public String getYear() { return year; } public CarInfo setYear(String year) { this.year = year; return this; } }
[ "ivan_valtin@epam.com" ]
ivan_valtin@epam.com
a9422b8390c8147940019cd672bd4c25d6015aca
79d7a9115b22c413f5edaad211fe180c9f819c29
/Ftc2016FirstResQ/FtcRobotController/src/main/java/hallib/HalSpeedController.java
e481b7149cbac28c04114585ed48e914e049c975
[]
no_license
trc492git/Ftc2016FirstResQ
898510967b96623b3f8efa2043b437c8d8bae081
151b802cd6b01623a57b0b9aa1f6284464bd82d1
refs/heads/master
2021-01-10T01:59:21.780598
2015-10-18T21:47:48
2015-10-18T21:47:48
44,495,347
0
0
null
null
null
null
UTF-8
Java
false
false
1,013
java
package hallib; import com.qualcomm.robotcore.hardware.DcMotor; public class HalSpeedController { private DcMotor motor; private int zeroPosition; public HalSpeedController(DcMotor motor) { this.motor = motor; zeroPosition = motor.getCurrentPosition(); } //HalSpeedController public void setPower(double power) { motor.setPower(power); } //set public void setInverted(boolean isInverted) { if (isInverted) { motor.setDirection(DcMotor.Direction.REVERSE); } else { motor.setDirection(DcMotor.Direction.FORWARD); } } //setInverted public int getCurrentPosition() { return motor.getCurrentPosition() - zeroPosition; } //getCurrentPosition public void resetCurrentPosition() { zeroPosition = motor.getCurrentPosition(); } //resetCurrentPosition } //class HalSpeedController
[ "jzheng@JZHENG9.redmond.corp.microsoft.com" ]
jzheng@JZHENG9.redmond.corp.microsoft.com
ba7bf4a63216f1e582bd731a241957db5c720c3d
8db89cd77222f4dcba9e65a1839263b83dc68c33
/src/main/java/github/meifans/inTesting/leetcode/abilitycode/RemoveDuplicatesFromSortedArray.java
892f698f72c0bf90bca49ff25f977108b4f3cbdb
[]
no_license
ZY-Avengers/learn-inTesting
b7d4690d707ed7d6553422ffa3e7a71a735c5f01
bb2473dddcae27c20a8be9dd96e3a54e5112263c
refs/heads/master
2021-01-19T11:16:30.496757
2019-05-30T14:22:34
2019-05-30T14:22:34
87,950,705
1
0
null
null
null
null
UTF-8
Java
false
false
405
java
package github.meifans.inTesting.leetcode.abilitycode; /** * @author pengfei.zhao */ public class RemoveDuplicatesFromSortedArray { public int removeDuplicates(int[] nums) { int cur = 0; for (int i = 1; i < nums.length;i++) { if (nums[cur] != nums[i]) { cur++; nums[cur] = nums[i]; } } return cur + 1; } }
[ "916109363@qq.com" ]
916109363@qq.com
e13b8f7908ffb2a3f0512d439d7bbef9ef326ed2
74788cee57d81a38aaa0e6432917ead5265fa6f7
/aufgabe08/src/liste/Liste.java
e7cb159ad1b277e30c04253e8c82b89996217f78
[]
no_license
saenglert/tutprogmib
73294a51c21a146e7922beae7ec3722a923ed1c2
544fae088c662c9547085b1360ce39dcc688bcdc
refs/heads/master
2021-01-21T04:50:30.919483
2016-06-27T16:40:32
2016-06-27T16:40:32
54,458,686
0
0
null
null
null
null
UTF-8
Java
false
false
1,451
java
package liste; public class Liste { public int element; public Liste next; public Liste(int element) { this.element = element; this.next = null; } public void append(int element) { if (next == null) next = new Liste(element); else next.append(element); } public int length() { int counter = 1; Liste next = this.next; while (next != null) { counter++; next = next.next; } return counter; } public void remove() { if (this.next != null) { if (this.next.next == null) this.next = null; else this.next.remove(); } } public String toString() { StringBuffer out = new StringBuffer(); out.append(this.element); if (this.next != null) out.append(", ") .append(this.next.toString()); return out.toString(); } public int summ() { /*int summ = this.element; Liste next = this.next; while (next != null) { summ += next.element; next = next.next; } return summ; */ if (this.next != null) return this.element + this.next.summ(); else return this.element; } public void add(int value) { this.element += value; if (this.next != null) this.next.add(value); } }
[ "sascha@englerts.de" ]
sascha@englerts.de
86d13a785827143b7d4af8a2b932944bce22134e
4afba7613e987352d6ed540efb9d069564aad3be
/family_map_server/src/main/java/serviceClasses/Services.java
899db2ce211f0781e70e2743861637c7a67dc039
[]
no_license
clintrf/CS_240
b5eee80025cb3a7c569fb2b86d62d205980c7ea8
42ea546beeb9e7d79fae52e5d686c299be81162f
refs/heads/master
2022-12-08T14:16:53.260953
2020-09-07T22:06:45
2020-09-07T22:06:45
280,521,594
0
1
null
null
null
null
UTF-8
Java
false
false
1,417
java
package main.java.serviceClasses; import main.java.daoClasses.*; import java.lang.*; public class Services { private DatabaseDatabase database = new DatabaseDatabase(); public ResponseRegister register(RequestRegister request) { return ResponseRegister.register(request, database.getConnection()); } public ResponseLogin login(RequestLogin request){ return ResponseLogin.login(request,database.getConnection()); } public ResponseClear clear(){ return ResponseClear.clear(database.getConnection()); } public ResponseFill fill(String username, int generations) { return ResponseFill.fill(username,generations,database.getConnection()); } public ResponseLoad load(RequestLoad request){ return ResponseLoad.load(request,database.getConnection()); } public ResponsePerson person(String auth_token, String personID){ return ResponsePerson.person(auth_token,personID,database.getConnection()); } public ResponsePeople people(String auth_token){ return ResponsePeople.people(auth_token,database.getConnection()); } public ResponseEvent event(String auth_token, String eventID){ return ResponseEvent.event(auth_token,eventID,database.getConnection()); } public ResponseEvents events(String auth_token){ return ResponseEvents.events(auth_token,database.getConnection()); } }
[ "clint.frandsen@gmail.com" ]
clint.frandsen@gmail.com
edae455ec3652793d6359c25b3c07321f7be58e7
e4abce9e986ea3bc82b7a9857a86d2911de91417
/src/main/java/one/digitalinnovation/personapi/entity/Person.java
676d7528208f93decd37a35d4a551391911b1f45
[]
no_license
cfcmagalhaes/personapi
e3fb0a6413e9dc09bb37fe1652cc6101fbbca437
e58cb0173d6a9888a85665b0bcc6068be46c28c9
refs/heads/master
2023-08-12T07:20:13.979296
2021-10-13T17:03:56
2021-10-13T17:03:56
413,939,065
0
0
null
2021-10-08T02:52:14
2021-10-05T18:41:05
Java
UTF-8
Java
false
false
835
java
package one.digitalinnovation.personapi.entity; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import javax.persistence.*; import java.time.LocalDate; import java.util.List; @Entity @Data @Builder @AllArgsConstructor @NoArgsConstructor public class Person { @Id @GeneratedValue( strategy = GenerationType.IDENTITY ) private Long id; @Column( nullable = false ) private String firstName; @Column( nullable = false ) private String lastName; @Column( nullable = false, unique = true ) private String cpf; private LocalDate birthDate; @OneToMany( fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE } ) private List<Phone> phones; }
[ "cfcmagalhaes@yahoo.com.br" ]
cfcmagalhaes@yahoo.com.br
aafa06ea7ff0530ab579e4e885e1f52262e17bc8
4a1a0bdc67afe904b3e15a53e4a7d676326ef6e5
/src/abstraction/Outer.java
9b5a67d927e1a3a4c50a7e8187c90a8f7d1b9b1e
[]
no_license
automationtrainingcenter/anil_java
3a7dcf3654b251ba24a0eab05d8a78c3359af0ba
230f52a79a839d452d0a19e889dfc640e1608291
refs/heads/master
2020-09-16T18:31:06.369306
2020-01-10T04:33:02
2020-01-10T04:33:02
223,853,648
0
0
null
null
null
null
UTF-8
Java
false
false
128
java
package abstraction; public interface Outer { void omethod(); Inner method(); interface Inner { void imethod(); } }
[ "atcsurya@gmail.com" ]
atcsurya@gmail.com
cac947bf0ab52f9b44794c5d2da7c90e0d08783c
e73139e9063bdb8fc65a18a87cc998e2bfef8b6a
/jizdnirady-common/src/main/java/jizdnirady/jdf/dto/JdfSpoj.java
79224dcbcbb22dd9f770cecc8fb359c7d51ac925
[]
no_license
terramexx/jizdnirady
c89724b8a0e3df9391993bd4831cddcfca99037c
dd18337358848e254b443691bfb156c4bd6c948e
refs/heads/master
2021-01-17T05:27:06.105131
2015-11-29T00:59:33
2015-11-29T00:59:33
42,068,957
0
0
null
null
null
null
UTF-8
Java
false
false
4,034
java
package jizdnirady.jdf.dto; public class JdfSpoj extends JdfObject { private Long cisloLinky; private Long cisloSpoje; private String pevnyKod1; private String pevnyKod2; private String pevnyKod3; private String pevnyKod4; private String pevnyKod5; private String pevnyKod6; private String pevnyKod7; private String pevnyKod8; private String pevnyKod9; private String pevnyKod10; private Long kodSkupinySpoju; private Long rozliseniLinky; public Long getCisloLinky() { return cisloLinky; } public void setCisloLinky(Long cisloLinky) { this.cisloLinky = cisloLinky; } public void setCisloLinky(String str) { this.cisloLinky = parseLong(str); } public Long getCisloSpoje() { return cisloSpoje; } public void setCisloSpoje(Long cisloSpoje) { this.cisloSpoje = cisloSpoje; } public void setCisloSpoje(String str) { this.cisloSpoje = parseLong(str); } public String getPevnyKod1() { return pevnyKod1; } public void setPevnyKod1(String pevnyKod1) { this.pevnyKod1 = pevnyKod1; } public String getPevnyKod2() { return pevnyKod2; } public void setPevnyKod2(String pevnyKod2) { this.pevnyKod2 = pevnyKod2; } public String getPevnyKod3() { return pevnyKod3; } public void setPevnyKod3(String pevnyKod3) { this.pevnyKod3 = pevnyKod3; } public String getPevnyKod4() { return pevnyKod4; } public void setPevnyKod4(String pevnyKod4) { this.pevnyKod4 = pevnyKod4; } public String getPevnyKod5() { return pevnyKod5; } public void setPevnyKod5(String pevnyKod5) { this.pevnyKod5 = pevnyKod5; } public String getPevnyKod6() { return pevnyKod6; } public void setPevnyKod6(String pevnyKod6) { this.pevnyKod6 = pevnyKod6; } public String getPevnyKod7() { return pevnyKod7; } public void setPevnyKod7(String pevnyKod7) { this.pevnyKod7 = pevnyKod7; } public String getPevnyKod8() { return pevnyKod8; } public void setPevnyKod8(String pevnyKod8) { this.pevnyKod8 = pevnyKod8; } public String getPevnyKod9() { return pevnyKod9; } public void setPevnyKod9(String pevnyKod9) { this.pevnyKod9 = pevnyKod9; } public String getPevnyKod10() { return pevnyKod10; } public void setPevnyKod10(String pevnyKod10) { this.pevnyKod10 = pevnyKod10; } public Long getKodSkupinySpoju() { return kodSkupinySpoju; } public void setKodSkupinySpoju(Long kodSkupinySpoju) { this.kodSkupinySpoju = kodSkupinySpoju; } public void setKodSkupinySpoju(String str) { this.kodSkupinySpoju = parseLong(str); } public Long getRozliseniLinky() { return rozliseniLinky; } public void setRozliseniLinky(Long rozliseniLinky) { this.rozliseniLinky = rozliseniLinky; } public void setRozliseniLinky(String str) { this.rozliseniLinky = parseLong(str); } @Override public String toString() { return "JdfSpoj{" + "cisloLinky=" + cisloLinky + ", cisloSpoje=" + cisloSpoje + ", pevnyKod1='" + pevnyKod1 + '\'' + ", pevnyKod2='" + pevnyKod2 + '\'' + ", pevnyKod3='" + pevnyKod3 + '\'' + ", pevnyKod4='" + pevnyKod4 + '\'' + ", pevnyKod5='" + pevnyKod5 + '\'' + ", pevnyKod6='" + pevnyKod6 + '\'' + ", pevnyKod7='" + pevnyKod7 + '\'' + ", pevnyKod8='" + pevnyKod8 + '\'' + ", pevnyKod9='" + pevnyKod9 + '\'' + ", pevnyKod10='" + pevnyKod10 + '\'' + ", kodSkupinySpoju=" + kodSkupinySpoju + ", rozliseniLinky=" + rozliseniLinky + '}'; } }
[ "rhal@email.cz" ]
rhal@email.cz
e9330efc0cb6e23cb4437825a1b732ab6edc3b17
5148293c98b0a27aa223ea157441ac7fa9b5e7a3
/Method_Scraping/xml_scraping/NicadOutputFile_t1_beam_new2/Nicad_t1_beam_new2402.java
a96f052f9a31576a86c686416bf414bcf5428f7d
[]
no_license
ryosuke-ku/TestCodeSeacherPlus
cfd03a2858b67a05ecf17194213b7c02c5f2caff
d002a52251f5461598c7af73925b85a05cea85c6
refs/heads/master
2020-05-24T01:25:27.000821
2019-08-17T06:23:42
2019-08-17T06:23:42
187,005,399
0
0
null
null
null
null
UTF-8
Java
false
false
531
java
// clone pairs:2784:80% // 3034:beam/runners/flink/src/main/java/org/apache/beam/runners/flink/translation/wrappers/streaming/state/FlinkStateInternals.java public class Nicad_t1_beam_new2402 { public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } FlinkMapState<?, ?> that = (FlinkMapState<?, ?>) o; return namespace.equals(that.namespace) && stateId.equals(that.stateId); } }
[ "naist1020@gmail.com" ]
naist1020@gmail.com
4adf78e2f18ac273d7b94f459832b07b1e54d9dc
115b5da7e2750ab9d5c0958706dffb9649595a16
/src/main/java/com/hightml/scanman/cannibals/converters/source/SourceConfigurationRegistry.java
539abd1f1c6e2d9e929a79fe9605be52f09d4a95
[]
no_license
HighTML/scan-man-web
236f5d02527191302de82692fac48d545bda6048
985a1dcb65de5e2b50495fd2e1819592b7270752
refs/heads/master
2020-05-28T08:58:52.350198
2015-03-03T23:24:07
2015-03-03T23:24:07
30,766,617
0
1
null
null
null
null
UTF-8
Java
false
false
2,377
java
package com.hightml.scanman.cannibals.converters.source; import lombok.NonNull; import java.util.*; /** * Keeps a registry of sources and their {@link nl.ing.web.documents.source.SourceConfiguration configurations}. * * @author Teun van Vegchel <teun.van.vegchel@ing.nl> */ public class SourceConfigurationRegistry { private final Map<String, SourceConfiguration> sources; /** * Create a new source registry. */ public SourceConfigurationRegistry() { sources = new HashMap<String, SourceConfiguration>(); } /** * Register a {@link nl.ing.web.documents.source.SourceConfiguration} in the registry using its * {@link nl.ing.web.documents.source.SourceDefinition definition} class. * * @param sourceDefinition the source to register. * @return the registry. */ public SourceConfigurationRegistry register(@NonNull final SourceDefinition sourceDefinition) { final SourceConfiguration source = sourceDefinition.defineConfiguration().build(); sources.put(source.getName(), source); return this; } /** * Register a {@link nl.ing.web.documents.source.SourceConfiguration} in the registry. * * @param source the source to register. * @return the registry. */ public SourceConfigurationRegistry register(@NonNull final SourceConfiguration source) { sources.put(source.getName(), source); return this; } /** * Retrieve a {@link nl.ing.web.documents.source.SourceConfiguration} from the registry using its name. * * @param name The source's name. * @return The source configuration * @throws UnknownSourceException When there's no source registered with the given name. */ public SourceConfiguration getByName(@NonNull final String name) { if (!sources.containsKey(name)) { final String message = String.format("The source '%s' is not known.", name); throw new UnknownSourceException(message); } return sources.get(name); } /** * Get the registered source configurations. * * @return The source configurations. */ public Set<SourceConfiguration> getSourceConfigurations() { return Collections.unmodifiableSet( new HashSet<SourceConfiguration>(sources.values()) ); } }
[ "marcel.heemskerk@gmail.com" ]
marcel.heemskerk@gmail.com
2723ed709d5b59243ca97c0bfc95822d318b5db5
b69f79e124e793b409c00695bbd99ef86157add8
/publisher/src/main/java/com/emi/demo/publisher/controller/SensorDataPublishController.java
71f58b015da838a2accc2c158606588e0a2617ef
[]
no_license
emanuelneculai/outlier-detection
f65a933c5d7e840860d85aca9677c899326638d5
a7fe6f3a338cf1bff3c68871f7dc11b55d1c3987
refs/heads/develop
2022-05-04T05:52:54.767521
2020-01-13T11:47:04
2020-01-13T11:47:04
233,006,956
0
0
null
2023-09-05T22:02:32
2020-01-10T08:58:55
Java
UTF-8
Java
false
false
950
java
package com.emi.demo.publisher.controller; import com.emi.demo.publisher.service.SensorDataPublishService; import com.emi.demo.publisher.model.SensorDataDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @RestController public class SensorDataPublishController { @Autowired private SensorDataPublishService sensorDataPublishService; @RequestMapping(value = "/sensorData",method = RequestMethod.POST,consumes = APPLICATION_JSON_VALUE,produces = APPLICATION_JSON_VALUE) public void createSensorData(@RequestBody SensorDataDTO sensorData) { sensorDataPublishService.publishSensorData(sensorData); } }
[ "neculai.emanuel@gmail.com" ]
neculai.emanuel@gmail.com
2586151ca9ffc2f426e53dd6b3358d81bda037ae
37f01c0d04319f9fce75a27f5adec118e241727f
/app/src/main/java/com/naxa/nepal/sudurpaschimanchal/model/NewsAndEventsModel.java
d1b1b153ca1eb154db9f6982d0890f6b4c021361
[]
no_license
cmFodWx5YWRhdjEyMTA5/Sudur-Paschhim-App
14e69350ebb3bac48a45c987e2c1f3ce2098df1e
9b9a078f6daab49898af3694e1cb03bae1d5ba85
refs/heads/master
2022-01-24T05:09:08.235418
2017-08-30T11:58:21
2017-08-30T11:58:21
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,019
java
package com.naxa.nepal.sudurpaschimanchal.model; /** * Created by User on 11/7/2016. */ public class NewsAndEventsModel { public String mThumbnail; public String news_title_en; public String news_title_np; public String news_desc_en ; public String news_desc_np; public String news_time_en; public String news_time_np; public String news_date_en; public String news_date_np; public String getNews_title_en() { return news_title_en; } public void setNews_title_en(String news_title_en) { this.news_title_en = news_title_en; } public String getNews_title_np() { return news_title_np; } public void setNews_title_np(String news_title_np) { this.news_title_np = news_title_np; } public String getNews_desc_en() { return news_desc_en; } public void setNews_desc_en(String news_desc_en) { this.news_desc_en = news_desc_en; } public String getNews_desc_np() { return news_desc_np; } public void setNews_desc_np(String news_desc_np) { this.news_desc_np = news_desc_np; } public String getNews_time_en() { return news_time_en; } public void setNews_time_en(String news_time_en) { this.news_time_en = news_time_en; } public String getNews_time_np() { return news_time_np; } public void setNews_time_np(String news_time_np) { this.news_time_np = news_time_np; } public String getNews_date_en() { return news_date_en; } public void setNews_date_en(String news_date_en) { this.news_date_en = news_date_en; } public String getNews_date_np() { return news_date_np; } public void setNews_date_np(String news_date_np) { this.news_date_np = news_date_np; } public String getmThumbnail() { return mThumbnail; } public void setmThumbnail(String mThumbnail) { this.mThumbnail = mThumbnail; } }
[ "Samir Dangal" ]
Samir Dangal
e5ccc7fa898c081e18d4b981b9265e367aecd81f
b98d30f244cc1186a30be078ed878c026211d2b5
/app/src/main/java/com/example/ebm/posts/PostsFragment.java
b5bf90cc88f52082d0c94e0aa811d725a922050e
[]
no_license
ubrisson/Android-App-ProductHunt
5906f5b33a41774152b5220f86beae1bac1c4dd3
431ff53913074b2bf819b7cd8891dfb85727b1cf
refs/heads/master
2020-06-04T22:05:07.810903
2019-06-20T06:34:26
2019-06-20T06:34:26
192,208,547
0
0
null
null
null
null
UTF-8
Java
false
false
8,985
java
package com.example.ebm.posts; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.example.ebm.API.APIClient; import com.example.ebm.API.APIInterface; import com.example.ebm.R; import com.example.ebm.comments.CommentsActivity; import com.example.ebm.database.PostDB; import com.example.ebm.database.PostsDatabase; import com.example.ebm.posts.models.CollecResponse; import com.example.ebm.posts.models.Post; import com.example.ebm.posts.models.PostsList; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; /** * A fragment representing a list of Items. * <p/> * Activities containing this fragment MUST implement the {@link OnListFragmentInteractionListener} * interface. */ public class PostsFragment extends Fragment implements PostsAdapter.onClickPostListener{ private PostsAdapter adapter; private static final String ARG_ID_COLLEC = "idCollec"; private PostsDatabase database; private ArrayList<PostDB> postsList; private int mIdCollection = -1; private SwipeRefreshLayout swipeContainer; private String TAG = "PostsFragment"; private OnListFragmentInteractionListener mListener; private ExecutorService dbExecutor = Executors.newSingleThreadExecutor(); /** * Mandatory empty constructor for the fragment manager to instantiate the * fragment (e.g. upon screen orientation changes). */ public PostsFragment() { } public static PostsFragment newInstance(int idCollection) { PostsFragment fragment = new PostsFragment(); Bundle args = new Bundle(); args.putInt(ARG_ID_COLLEC, idCollection); fragment.setArguments(args); Log.i("fragment", "newInstance"); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { mIdCollection = getArguments().getInt(ARG_ID_COLLEC); } postsList = new ArrayList<>(); adapter = new PostsAdapter(postsList,PostsFragment.this); if (mIdCollection == -1) { database = PostsDatabase.getInstance(getContext()); recupererPostsDB(); } else{ recupererCollectionPosts(); } Log.i(TAG, "onCreate: idCollec " + mIdCollection); } @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootview = inflater.inflate(R.layout.posts_list, container, false); DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(Objects.requireNonNull(getContext()), LinearLayoutManager.VERTICAL); dividerItemDecoration.setDrawable( this.getResources().getDrawable(R.drawable.sk_line_divider, Objects.requireNonNull(getActivity()).getTheme())); RecyclerView recyclerView = rootview.findViewById(R.id.list); recyclerView.addItemDecoration(dividerItemDecoration); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapter); swipeContainer = (SwipeRefreshLayout) rootview; swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { recupererPostsAPI(); } }); swipeContainer.setRefreshing(true); return rootview; } @Override public void onAttach(Context context) { super.onAttach(context); if (context instanceof OnListFragmentInteractionListener) { mListener = (OnListFragmentInteractionListener) context; } else { throw new RuntimeException(context.toString() + " must implement OnListFragmentInteractionListener"); } } @Override public void onDetach() { super.onDetach(); mListener = null; } public interface OnListFragmentInteractionListener { void onListFragmentInteraction(PostDB post); } //Debut de region API private void recupererPostsAPI(){ if(mIdCollection == -1) recupererPostsList(); else recupererCollectionPosts(); } private void recupererCollectionPosts() { APIInterface api = APIClient.createService(APIInterface.class); Call<CollecResponse> call = api.appelPostsCollec(mIdCollection); Log.i(TAG, "recupererCollectionPosts: " + call.request().url()); call.enqueue(new Callback<CollecResponse>() { @Override public void onResponse(@NonNull Call<CollecResponse> call, @NonNull Response<CollecResponse> response) { if (response.isSuccessful()) { assert response.body() != null; ArrayList<Post> posts = (ArrayList<Post>) response.body().getCollection().getPosts(); if (postsList != null) postsList.clear(); else postsList = new ArrayList<>(); for (Post p : posts) { postsList.add(new PostDB(p)); } showPosts(); Log.i(TAG, "onResponse: succesful"); } else { Log.i(TAG, "onResponse: not that succesful"); } } @Override public void onFailure(@NonNull Call<CollecResponse> call, @NonNull Throwable t) { Log.i(TAG, "onFailure: Posts call Failed" + " "+ t.getMessage());} }); } private void recupererPostsList(){ APIInterface api = APIClient.createService(APIInterface.class); Call<PostsList> call; call = api.appelPosts(); Log.i(TAG, "recupererPostsList: " + call.request().url()); call.enqueue(new Callback<PostsList>() { @Override public void onResponse(@NonNull Call<PostsList> call, @NonNull Response<PostsList> response) { if (response.isSuccessful()) { assert response.body() != null; updateDBwithAPI(response.body().getPosts()); Log.i(TAG, "onResponse: succesful"); } else { Log.i(TAG, "onResponse: not that succesful"); } } @Override public void onFailure(@NonNull Call<PostsList> call, @NonNull Throwable t) { Log.i(TAG, "onFailure: Posts call Failed" + t.getMessage());} }); } //Fin de region API @Override public void clickPost(int position) { Log.i(TAG, "clickPost: Clicked post"); mListener.onListFragmentInteraction(postsList.get(position)); } @Override public void clickComm(int position) { Log.i(TAG, "clickComm: Clicked comm"); Intent intent = new Intent(getActivity(), CommentsActivity.class); intent.putExtra("idPost",postsList.get(position).getId()); intent.putExtra("titlePost",postsList.get(position).getTitle()); startActivity(intent); } //Start region database private void recupererPostsDB() { dbExecutor.execute(new Runnable() { @Override public void run() { postsList.addAll(database.postDAO().getPostsList()); showPosts(); } }); } private void updateDBwithAPI(final List<Post> posts){ dbExecutor.execute(new Runnable() { @Override public void run() { for (Post p : posts) { database.postDAO().insertPost(new PostDB(p)); } postsList.clear(); postsList.addAll(database.postDAO().getPostsList()); showPosts(); } }); } //End region database private void showPosts(){ Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() { @Override public void run() { adapter.show(postsList); swipeContainer.setRefreshing(false); } }); } public void updatePosts(){ swipeContainer.setRefreshing(true); recupererPostsAPI(); } }
[ "50323620+ubrisson@users.noreply.github.com" ]
50323620+ubrisson@users.noreply.github.com
c0d874b040baab423fcc4ab42ecfe369b309243f
50ee38df75527aceab702d966490122c4c2f03d6
/config/stereo-autoconfig/src/main/java/soundsystem/A.java
bc6c24a02ac685fcb213f3b696288df8c6a10a0a
[]
no_license
lalwr/FastCampusJavaWebMaster
b021e8f096fbf2da8a569bdb59faa4d32cc77a5e
ff7637d5511f466e14b50f5b11c0829c098fa761
refs/heads/master
2021-04-09T16:29:13.004111
2018-06-11T07:52:29
2018-06-11T07:52:29
125,794,707
7
1
null
null
null
null
UTF-8
Java
false
false
213
java
package soundsystem; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class A { @Autowired B b; @Autowired C c; }
[ "lalwrj@gmail.com" ]
lalwrj@gmail.com
b31986d9879edbc95a8759dda29191283f8678fa
4364cd6916e3e5cd8caab5e2fdcdb420eda4e86b
/app/src/main/java/com/fiuba/apredazzi/tp_taller2_android/adapter/TracksRecommendedAdapter.java
dcd0093063570e79daf02a580776e8f02e25d8e6
[]
no_license
colopreda/Tp-Taller2-Android
37b5302c841de60951cc2a6baacf55b114703230
cf071133ea372c33f95180becae01c307e7be06b
refs/heads/develop
2021-01-19T05:22:44.999408
2017-06-25T20:46:17
2017-06-25T20:46:17
87,429,203
0
0
null
2017-06-25T20:46:18
2017-04-06T12:53:41
Java
UTF-8
Java
false
false
2,639
java
package com.fiuba.apredazzi.tp_taller2_android.adapter; import android.content.Context; import android.content.Intent; 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.fiuba.apredazzi.tp_taller2_android.R; import com.fiuba.apredazzi.tp_taller2_android.activities.SongActivity; import com.fiuba.apredazzi.tp_taller2_android.model.Song; import com.squareup.picasso.Picasso; import java.util.List; /** * Created by apredazzi on 6/21/17. */ public class TracksRecommendedAdapter extends RecyclerView.Adapter<TracksRecommendedAdapter.SimpleViewHolder> { private Context context; private List<Song> songs; public TracksRecommendedAdapter(Context context, List<Song> songs) { this.context = context; this.songs = songs; } public static class SimpleViewHolder extends RecyclerView.ViewHolder { public final TextView cancion; public final ImageView imagen; public SimpleViewHolder(View view) { super(view); cancion = (TextView) view.findViewById(R.id.text_grid_view); imagen = (ImageView) view.findViewById(R.id.image_grid_view); } } @Override public SimpleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final View view = LayoutInflater.from(this.context).inflate(R.layout.item_grid_view, parent, false); return new SimpleViewHolder(view); } @Override public void onBindViewHolder(SimpleViewHolder holder, final int position) { holder.cancion.setText(songs.get(position).getTitle()); if (songs.get(position).getAlbum() != null && songs.get(position).getAlbum().getImages() != null && !songs.get(position).getAlbum().getImages().isEmpty()) { Picasso.with(context).load(songs.get(position).getAlbum().getImages().get(0)).into(holder.imagen); } holder.imagen.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent intent = new Intent(context, SongActivity.class); intent.putExtra("artists", true); intent.putExtra("songid", String.valueOf(getItemId(position))); context.startActivity(intent); } }); } @Override public long getItemId(int position) { return songs.get(position).getId(); } @Override public int getItemCount() { return this.songs.size(); } }
[ "apredazzi@gmail.com" ]
apredazzi@gmail.com
51218175e00139611ab5938b510c501baa08d470
1929ddc73fc036c945f4538e3900fc611007f261
/springgoods/src/main/java/com/jk/util/JsonUtil.java
a2b52e4cd602e6d8983c247d04f4019ccd4feed4
[]
no_license
renzhiwei001/test
e373447bbabad29e264411dbb46c8251cc48b28c
fce5549175fc782aa87dc7071ef4b06cb5786892
refs/heads/master
2020-04-09T13:12:19.552795
2018-12-05T09:42:11
2018-12-05T09:42:11
160,368,318
0
0
null
null
null
null
UTF-8
Java
false
false
1,646
java
package com.jk.util; import java.io.IOException; import com.alibaba.fastjson.JSON; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; public class JsonUtil { /** * 将字符串转成实体类,允许斜杠等字符串 */ public static <T> T jsonToEntity(String json, Class<T> clazz) throws IOException { ObjectMapper mapper = new ObjectMapper(); // 允许反斜杆等字符 mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS,true); return mapper.readValue(json, clazz); } /** * 实体类转JSON字符串 */ public static String entityToJson(Object entity){ return JSON.toJSONString(entity); } /** * 将字符串转成JsonNode,允许斜杠等字符串 */ public static JsonNode jsonToJsonNode(String json) { ObjectMapper mapper = new ObjectMapper(); // 允许反斜杆等字符 mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS,true); //允许单引号 mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES,true); try { return mapper.readValue(json, JsonNode.class); } catch (Exception e) { e.printStackTrace(); return null; } } public static <T> String objectToJson(Object object, Class<T> cls)throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerSubtypes(cls); String reqJson = mapper.writeValueAsString(object); return reqJson; } }
[ "619345105@qq.com" ]
619345105@qq.com
d643e3b6a2753ea3d3cc75004d20f93fcc88a783
81b81f27ace765d7df7cf549d084ec4d728edad0
/src/gui/view/StartPaneController.java
0231d50ae42e0051955d1b1bc9c2b45563b1f2d0
[]
no_license
tylerliu/Sudoku_Solver_FX
8f9ce58786cc90d4273edb613263c0b51589942d
2bcfad1c1b920a6fcc35fafe94a2e5576778430d
refs/heads/master
2020-03-11T01:06:46.780918
2018-04-16T03:56:26
2018-04-16T03:56:26
129,681,905
0
0
null
null
null
null
UTF-8
Java
false
false
2,880
java
package gui.view; import Generator.Difficulty.Level; import Generator.ProblemGen; import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Platform; import javafx.concurrent.Task; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.scene.control.Toggle; import javafx.scene.control.ToggleGroup; import javafx.scene.input.MouseEvent; import javafx.util.Duration; import jfoenix.controls.JFXButton; import jfoenix.controls.JFXRadioButton; import jfoenix.controls.JFXSpinner; public class StartPaneController { @FXML private JFXRadioButton relaxButton; @FXML private JFXRadioButton easyButton; @FXML private JFXRadioButton normalButton; @FXML private JFXRadioButton hardButton; @FXML private JFXRadioButton insaneButton; @FXML private JFXButton startButton; @FXML private JFXSpinner spinner; private ToggleGroup levelGroup; private GameController gameController; public void initialize(){ spinner.setVisible(false); levelGroup = new ToggleGroup(); relaxButton.setToggleGroup(levelGroup); easyButton.setToggleGroup(levelGroup); normalButton.setToggleGroup(levelGroup); hardButton.setToggleGroup(levelGroup); insaneButton.setToggleGroup(levelGroup); } public void setGameController(GameController gameController){ this.gameController = gameController; } public void startGame(MouseEvent e){ spinner.setVisible(true); startButton.setDisable(true); GenerateGame g = new GenerateGame(); Toggle t = levelGroup.getSelectedToggle(); if (t == relaxButton) g.setLevel(Level.RELAX); if (t == easyButton) g.setLevel(Level.EASY); if (t == normalButton) g.setLevel(Level.NORMAL); if (t == hardButton) g.setLevel(Level.HARD); if (t == insaneButton) g.setLevel(Level.INSANE); if (t == null){ spinner.setVisible(false); startButton.setDisable(false); return; } Thread th = new Thread(g); th.setDaemon(true); th.start(); Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(5),new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { if (g.isRunning()){ th.stop(); startGame(new MouseEvent(null, 0, 0, 0, 0, null, 0, false, false, false, false, false, false, false, false, false, false, null)); } } })); timeline.playFromStart(); } public class GenerateGame extends Task<Void>{ Level level; public void setLevel(Level level) { this.level = level; } @Override protected Void call() throws Exception { int[][] i = ProblemGen.generateProblem(level); Platform.runLater(new Runnable(){ public void run(){ gameController.startGame(i); spinner.setVisible(false); startButton.setDisable(false); } }); return null; } } }
[ "tylersiqi@163.com" ]
tylersiqi@163.com
779ba6d170d6eedc739585d7a7d7810e7f892745
2190cc8144f42178067c0aad0408adf87db1fe27
/app/src/com.y/component/DialogComponent.java
64de23b69a103ec1da1b74984f57035b77063915
[]
no_license
vpractical/Cat-Dog
f4565f4367326cf39f36d58a2803204398bc1bf7
2e0a91f749383ee809cc5d0b2e6c0b1f4c626e49
refs/heads/master
2021-07-25T04:37:04.417956
2018-11-23T01:24:58
2018-11-23T01:24:58
145,060,712
0
0
null
2018-11-02T08:19:55
2018-08-17T02:16:01
Java
UTF-8
Java
false
false
233
java
package com.y.component; import com.y.mvp.component.AppComponent; import com.y.mvp.scope.CustomizeScope; import dagger.Component; @CustomizeScope @Component(dependencies = AppComponent.class) public interface DialogComponent { }
[ "574264083@qq.com" ]
574264083@qq.com
77da5f809de4212e7b2c2da5e78e7c4557060298
646ef6cccccf12467c17da53a182f7e54e97e535
/app/src/main/java/com/example/bhbh_behealthybehappy/Constants_Enums/Enums.java
3286d3099c65d0300994ee08cbf41d58cc27ef00
[]
no_license
roeeavir/BHBH_BeHealthyBeHappy
2b126004deafb376f72f71e008086c059e4d9a4c
a3c4d8918ac45e0f2705dc2fcc41fb44e0dd3811
refs/heads/master
2023-03-06T23:45:51.383643
2021-02-21T17:09:39
2021-02-21T17:09:39
325,785,376
0
0
null
null
null
null
UTF-8
Java
false
false
308
java
package com.example.bhbh_behealthybehappy.Constants_Enums; public class Enums { public enum ITEM_THEME { // Enum for item types/themes DRINK, ACTIVITY, FOOD } public enum SCORE { // Enum for score types RED_HEART, BLACK_HEART, GREEN_STAR } }
[ "roeeavir@gmail.com" ]
roeeavir@gmail.com
ea73ec7739e6d76b394febfed64f23751056c777
d82bb74125c7a31ed323609e6076e4aaef20da91
/vasja-ui/src/main/java/org/sanjose/validator/TwoPasswordfieldsValidator.java
9d9c757388d9fabed131cdaf0b0973223ce26df3
[]
no_license
sanjosedelamazonas/nvasja
ed27fdba44df498dee157f841f0cc23133235616
ca010147167f3dcca0bd3cea554d38d00675d366
refs/heads/master
2023-07-23T06:09:44.946632
2023-07-04T23:33:17
2023-07-04T23:39:35
67,847,671
0
0
null
null
null
null
UTF-8
Java
false
false
1,258
java
package org.sanjose.validator; import com.vaadin.data.Validator; import com.vaadin.external.org.slf4j.Logger; import com.vaadin.external.org.slf4j.LoggerFactory; import com.vaadin.ui.AbstractField; import com.vaadin.ui.PasswordField; import org.sanjose.util.GenUtil; /** * VASJA class * User: prubach */ public class TwoPasswordfieldsValidator implements Validator { private static final Logger log = LoggerFactory.getLogger(TwoPasswordfieldsValidator.class); private final AbstractField field; private final String message; private final boolean isPermitEmpty; public TwoPasswordfieldsValidator(PasswordField field, boolean isPermitEmpty, String message) { if (message!=null) message = "Los dos claves tienen que ser identicos"; this.field = field; this.message = message; this.isPermitEmpty = isPermitEmpty; } @Override public void validate(Object value) throws InvalidValueException { if (!GenUtil.objNullOrEmpty(value) || !GenUtil.objNullOrEmpty(field.getValue())) { if (((String)value).compareTo(((String)field.getValue()))!=0) { field.markAsDirty(); throw new InvalidValueException(message); } } } }
[ "pawel.rubach@gmail.com" ]
pawel.rubach@gmail.com
d067b8a01671f78eaa647f25309956d2a51fc3cc
a05bbe5ecc9f1f0c3987c52fdb873dba59be4a59
/src/main/java/models/CardList.java
527ec1bd92505543f6ed4319979e5c82ce71d5eb
[]
no_license
markbackhouse/Landlord
dcc361ea5c6cfe3a8f00cdd5343eb3b7106197a9
645729e88f2c6f3970fa7e1aa7ac78812e1d489b
refs/heads/master
2020-04-16T10:10:20.553144
2019-06-11T21:41:54
2019-06-11T21:41:54
165,493,924
0
0
null
null
null
null
UTF-8
Java
false
false
1,469
java
package models; import lombok.Getter; import lombok.Setter; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @Setter @Getter public class CardList { List<Card> cards; public CardList(List<Card> cards) { this.cards = cards; } public Card get(int index) { return cards.get(index); } public int size() { return cards.size(); } public Map<Integer, Long> getFrequencies() { return cards.stream() .collect(Collectors.groupingBy(Card::getValue, Collectors.counting())); } public boolean containsBothJokers() { return cards.stream() .filter(Card::isJoker) .count() == 2; } public int getJokerCount() { return (int) cards.stream() .filter(Card::isJoker) .count(); } public boolean containsJoker() { return cards.stream() .anyMatch(Card::isJoker); } public void sort() { Comparator<Card> comparator = new CardsComparer(); Collections.sort(cards, comparator); } protected class CardsComparer implements Comparator<Card> { @Override public int compare(Card o1, Card o2) { return compare(o1.getValue(), o2.getValue()); } int compare(int a, int b) { return a - b; } } }
[ "markbackhouse@skyscanner.net" ]
markbackhouse@skyscanner.net
852803c2b34657a529e123b7f9023f13f50d78f8
1d26343455c94ebb9d0c5333f826ace1d470e970
/SWT/exams/Desktop Search Engine/src/DesktopSearch.java
e204178d0e51d165dbc01fd08fa029ff501b9cfa
[]
no_license
Laschoking/Bingo
dad47c65d8a8828b96eddb1ba73c1219af3ac2ea
8a4dfc2b063e1f1c990db1b3d4058077d1579498
refs/heads/master
2020-03-27T00:26:56.889805
2018-09-17T13:47:15
2018-09-17T13:47:15
145,623,887
0
0
null
null
null
null
UTF-8
Java
false
false
897
java
import java.util.HashMap; import java.util.List; import java.util.Map; public class DesktopSearch { private Map<String, ResourceType> types; Index index; public DesktopSearch(){ types = new HashMap<>(); index = new Index(); }; public void registerType (String extension, ResourceType type){ if (extension == null || type == null)throw new NullPointerException(); types.put(extension,type); } public ResourceType getType(String extension){ return types.get(extension); } public void unregisterType(String extension){ if (extension == null )throw new NullPointerException(); types.remove(extension); } public void registerResource(Resource type){ index.add(type); } public List<Resource> processRequest(String request) { return index.getResources(request); } }
[ "knut.berling@gmx.de" ]
knut.berling@gmx.de
ea929b381b16b0c258f619ab14f0e217ece164e4
879340a3aa9e34eed182c4ef82d456eebe18e7db
/kthSmallestInBST.java
80d6151502795651c7e43625935d384431463921
[]
no_license
codeVirtuoso21/MySolutions-codesignal
423a75b578441512a1b1cb7c110e611219005089
0af3bade2405108abe673d71cece4c36dcbcd7e1
refs/heads/main
2023-06-22T03:19:30.160390
2021-06-25T14:54:53
2021-06-25T14:54:53
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,168
java
/* Note: Your solution should have only one BST traversal and O(1) extra space complexity, since this is what you will be asked to accomplish in an interview. A tree is considered a binary search tree (BST) if for each of its nodes the following is true: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and the right subtrees must also be binary search trees. Given a binary search tree t, find the kth smallest element in it. Note that kth smallest element means kth element in increasing order. See examples for better understanding. */ // // Definition for binary tree: // class Tree<T> { // Tree(T x) { // value = x; // } // T value; // Tree<T> left; // Tree<T> right; // } ArrayList<Integer> treeList; int kthSmallestInBST(Tree<Integer> t, int k) { treeList = new ArrayList<>(); makeList(t); return treeList.get(k-1); } void makeList(Tree<Integer> t){ if(t.left != null){ makeList(t.left); } treeList.add(t.value); if(t.right != null){ makeList(t.right); } }
[ "athena.spaceboy21@gmail.com" ]
athena.spaceboy21@gmail.com
bb44eb0a9a1a4b773650499d346f7625125e2bef
8c944934fb578017a228107ea1a1baa01503d239
/src/Tutorial_0_2_EnemyAI/Simple_AI_Pathfinding.java
cbcf01ac1a486128a0a41aadba0fe7ed6c28d844
[]
no_license
rojr/GameEngineTutorials
65d71e6db9187c060aa37e88d25c8f03efc72ce0
12b7b3ee5fd4e91c5a7fa0613b662968e5edb73c
refs/heads/master
2020-04-10T12:12:41.451708
2013-09-25T21:38:26
2013-09-25T21:38:26
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,362
java
package Tutorial_0_2_EnemyAI; import com.gmail.robmadeyou.Engine; import com.gmail.robmadeyou.Screen; import com.gmail.robmadeyou.Screen.GameType; import com.gmail.robmadeyou.Entity.Npc; import com.gmail.robmadeyou.Entity.Player; public class Simple_AI_Pathfinding { /* * Algorithm isn't perfected yet with the current Engine (as of v0.1.2) * The path finding works a lot better in RPG mode as it was intended to be * used on that game type */ public static void main(String[] args) { Screen.create(640, 640, "AI_Demo", GameType.SIDE_SCROLLER, false); Player player = new Player(40, 40, 32, 64); Engine.addEntity(player); Npc enemy = new Npc(40,40, 20, 40); /* * Here we tell the enemy that it's going to be following the Entity Player */ enemy.setLogic(true); /* * For the A star algorithm we tell the enemy who to target, in this case it's going * to be player */ enemy.setTargetPlayer(player); /* * Here we actually enable the A star algorithm for enemy to make sure it follows player */ enemy.setAStar(true); Engine.addEntity(enemy); Screen.setUpWorld(); while(!Screen.isAskedToClose()){ Screen.update(60); /* * Nothing really needed in the loop as path finding is being run with the Engine */ Screen.refresh(); } Screen.destroy(); } }
[ "robmadeyou@gmail.com" ]
robmadeyou@gmail.com
cfe9a913fae9868e8b29491406b24d66623a2c2c
53dbb77019f0876fa5d1ac1e72dbb7800d2115ad
/ReaderAndLoop/src/KeyWord/SuperCar.java
18399473ce48e62c2799a133e1e27a7e0a85b99e
[]
no_license
smhoque/CodingExamSmHoqueNov
ac3e143601214aaab7a4df31b1b78ad0c937c282
b9319941daf24476169a24e526f5732036822214
refs/heads/master
2021-01-12T06:16:06.657051
2017-02-22T17:06:21
2017-02-22T17:06:21
77,333,673
0
0
null
null
null
null
UTF-8
Java
false
false
198
java
package KeyWord; /** * Created by riponctg on 12/15/2016. */ public class SuperCar extends Car { public void SuperCarEngine(){ System.out.println("This is super car engine"); } }
[ "eriponctg@gmail.com" ]
eriponctg@gmail.com
9f96681f6c034a584e779a72c7e6be627a333a58
373260b933193f5451666ec3b0f7818a36a51a0e
/yfk-base/src/main/java/com/yfker/common/valid/constraints/TelePhoneValidator.java
f51fc41b82469757af15aa8452797eed65940c58
[]
no_license
JerryLi57/yfker
9c26f4c8c4cdfff85b8c9ee9b458ba553f2693b0
e68040baea0d5ebcdb26fdb16957d54a551b2986
refs/heads/main
2023-04-30T16:36:32.074733
2021-05-21T03:11:03
2021-05-21T03:11:03
361,969,719
0
0
null
null
null
null
UTF-8
Java
false
false
1,031
java
package com.yfker.common.valid.constraints; import cn.hutool.core.util.StrUtil; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @description: 手机号的验证器 * @author: lijiayu * @date: 2020-04-09 11:31 **/ public class TelePhoneValidator implements ConstraintValidator<TelePhone, String> { private boolean required; @Override public void initialize(TelePhone constraintAnnotation) { required = constraintAnnotation.required(); } @Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StrUtil.isBlank(value)) { // 必输项为空时校验失败 return !required; } boolean isValid; String regex = "^1[3|4|5|7|8][0-9]\\d{4,8}$"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(value); isValid = m.matches(); return isValid; } }
[ "Li123456" ]
Li123456
93225573fba85182e10da7bfaa0e3afab2c12842
43e03e7e2c065a0aa34ff1b94c716ae186f2ca1a
/src/DAO/DanhMucDAO.java
bad13cf0dec0768871ea682e527f2ee0462eb304
[]
no_license
hoangminh122/web
785cc18c6bbf9130628090108d13b6791fd242d4
330a2d4b30f8652332cd0f2ee9b9da052854e27e
refs/heads/master
2020-05-06T15:23:50.634746
2019-06-13T13:58:58
2019-06-13T13:58:58
180,187,833
0
0
null
2019-05-13T07:07:33
2019-04-08T16:18:59
JavaScript
UTF-8
Java
false
false
1,339
java
package DAO; import java.sql.SQLException; import java.util.ArrayList; import com.mysql.jdbc.Connection; import com.mysql.jdbc.PreparedStatement; import com.mysql.jdbc.ResultSet; import com.sun.org.apache.xml.internal.resolver.Catalog; import model.type_products; import web.DBConnnect; public class DanhMucDAO implements IDanhMucDAO{ @Override public ArrayList<type_products> getTypeProduct(String sql) { // TODO Auto-generated method stub Connection conn=DBConnnect.getConnnection(); ArrayList<type_products> temp=new ArrayList<type_products>(); try { PreparedStatement ps=conn.clientPrepareStatement(sql); ResultSet rs=(ResultSet) ps.executeQuery(); while(rs.next()) { type_products temp1=new type_products(); temp1.setId(rs.getInt("id")); temp1.setName(rs.getString("name")); temp1.setImage(rs.getString("image")); temp1.setDescription(rs.getString("description")); temp1.setCreated_up(rs.getTimestamp("created_at")); temp1.setUpdate_up(rs.getTimestamp("updated_at")); temp.add(temp1); } return temp; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } //public static void main(String[] args) { // // System.out.print(new DanhMucDAO().getTypeProduct("SELECT * FROM type_products").size()); //} }
[ "36332084+hoangminh122@users.noreply.github.com" ]
36332084+hoangminh122@users.noreply.github.com
556a2d2f91ef967342ab6a0ee8128f79d56934de
560083c3213bff0649ccb0adfc0a66f47fb66199
/src/main/java/com/codeoftheweb/salvo/ShipRepository.java
ffce7c1939396b705ba41f0e3ea61c5cb3b0ae19
[]
no_license
Facurv8714/Salvo-Application
3535c424aaa0bb881354995e3a70a34d01c7c178
1d8e5250fe523688377a7e25271deb508b2dd841
refs/heads/master
2020-07-24T22:22:44.431160
2019-10-11T17:50:45
2019-10-11T17:50:45
208,067,830
1
0
null
null
null
null
UTF-8
Java
false
false
243
java
package com.codeoftheweb.salvo; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; public interface ShipRepository extends JpaRepository<Ship, Long>{ }
[ "facurv8714@gmail.com" ]
facurv8714@gmail.com
578ae7ede3c527e479e735fb6a796b6678db392a
508247b72af274d482bcf5c55a7a63cb39906f9e
/src/ReversiGame.java
84c4f8667ae61c291698f3d40d9d50214d0ed2b2
[]
no_license
achiya80/Reversi
6122377b611d227098b1bde73b709c273d8d1942
6d019ca0ccf413446bccf6655938f8a3ae8b80de
refs/heads/master
2023-06-29T02:09:23.207123
2021-07-25T11:21:30
2021-07-25T11:21:30
389,329,227
0
0
null
null
null
null
UTF-8
Java
false
false
6,339
java
import java.util.LinkedList; import java.util.List; public class ReversiGame { private Board board; private int [][] boardArr; private static final int GRAY = 0; private static final int RED = 1; private static final int BLUE = 2; private boolean helpIsOn = false; private static List<Pair<Integer, Integer>> pairs = new LinkedList<>(){ { add(new Pair<>(1,0)); add(new Pair<>(0,1)); add(new Pair<>(1,1)); add(new Pair<>(-1, -1)); add(new Pair<>(-1, 0)); add(new Pair<>(0 , -1)); add(new Pair<>(-1, 1)); add(new Pair<>(1, -1)); } }; private int turn; public ReversiGame(){ this(10); } public ReversiGame(int length){ boardArr = new int[length][length]; board = new Board(boardArr); init(); } public void buttonClick(int x){ if (isLegal()) { int row, col; col = board.getCellCol(); row = board.getCellRow(); List<Pair<Pair<Integer, Integer>, Pair<Integer,Integer>>> toPaint = toPaint(); for (Pair<Pair<Integer, Integer>, Pair<Integer,Integer>> p : toPaint){ paint(p); } updateCounters(); board.updateBoard(boardArr); switchTurn(); if(helpIsOn){ board.updateHelp(getHelp()); } } } private void switchTurn(){ turn = (turn == 1) ? 2 : 1; if(searchLegalMoves().size() == 0){ turn = (turn == 1) ? 2 : 1; } if(searchLegalMoves().size() == 0){ updateCounters(); board.whoWins(); } board.setTurn(turn); } private void updateCounters(){ Pair<Integer, Integer> p = countColors(); board.setReds(p.left); board.setBlues(p.right); board.updateLabels(); } private boolean isLegal(){ return isLegal(board.getCellRow(), board.getCellCol()); } private boolean isLegal(int row, int col){ return toPaint(row,col).size() != 0; } private List<Pair<Pair<Integer, Integer>, Pair<Integer,Integer>>> toPaint(){ return toPaint(board.getCellRow(), board.getCellCol()); } private List<Pair<Pair<Integer, Integer>, Pair<Integer,Integer>>> toPaint(int row, int col){ if (boardArr[row][col] != GRAY) return new LinkedList<>(); List<Pair<Pair<Integer, Integer>, Pair<Integer,Integer>>> res = new LinkedList<>(); for (Pair<Integer, Integer> p : pairs){ if(check(p.left, p.right, row, col)){ res.add(new Pair<>(p ,findLegalMove(p.left, p.right, row, col))); } } return res; } private Pair<Integer, Integer> findLegalMove(int moveRow, int moveCol){ return findLegalMove(moveRow, moveCol, board.getCellRow(), board.getCellCol()); } private Pair<Integer, Integer> findLegalMove(int moveRow, int moveCol, int row, int col){ int counter = 0; if (boardArr[row][col] != GRAY) return null; for (int i = row + moveRow, j = col + moveCol; i >= 0 && i < boardArr.length && j >= 0 && j < boardArr[0].length; i += moveRow, j+= moveCol){ if(boardArr[i][j] == GRAY){ return null; } else if(boardArr[i][j] == turn){ return (counter != 0) ? new Pair<>(i, j) : null; } else{ counter++; } } return null; } private boolean check(int moveRow, int moveCol){ return check(moveRow, moveCol, board.getCellRow(), board.getCellCol()); } private boolean check(int moveRow, int moveCol, int row, int col){ return findLegalMove(moveRow, moveCol, row, col) != null; } private void paint(Pair<Pair<Integer, Integer>, Pair<Integer,Integer>> p){ int col = board.getCellCol(), row = board.getCellRow(); for(int i = row , j = col;i != p.right.left || j != p.right.right;i += p.left.left, j+= p.left.right){ boardArr[i][j] = turn; } boardArr[p.right.left][p.right.right] = turn; } private void init(){ for (int row=0;row<boardArr.length;row++){ for (int col=0;col<boardArr[0].length;col++){ boardArr[row][col] = GRAY; } } boardArr[boardArr.length/2-1][boardArr.length/2] = RED; boardArr[boardArr.length/2][boardArr.length/2-1] = RED; boardArr[boardArr.length/2-1][boardArr.length/2-1] = BLUE; boardArr[boardArr.length/2][boardArr.length/2] = BLUE; board.init(boardArr); turn = 1; board.dansMethod(0, x -> buttonClick(x)); board.setHelpMovesCallback(() -> getHelp()); board.setBoardCallback(() -> getBoardArr()); board.setSizeChangeCallback(i -> { boardArr = new int[i][i];init(); }); } public static class Pair<K, V>{ private K left; private V right; public Pair(K left, V right){ this.left = left; this.right = right; } public K getLeft(){ return left; } public V getRight(){ return right; } } private List<Pair<Integer, Integer>> getHelp(){ helpIsOn = true; return searchLegalMoves(); } public int[][] getBoardArr(){ helpIsOn = false; return boardArr; } private List<Pair<Integer, Integer>> searchLegalMoves(){ List<Pair<Integer, Integer>> res = new LinkedList<>(); for (int i = 0;i < boardArr.length; i++){ for (int j = 0;j < boardArr[0].length; j++){ if(boardArr[i][j] == GRAY && isLegal(i, j)){ res.add(new Pair<>(i, j)); } } } return res; } private Pair<Integer, Integer> countColors(){ int blue = 0, red = 0; for (int i = 0; i< boardArr.length; i++){ for (int j = 0;j < boardArr[0].length;j++){ blue += (boardArr[i][j] == BLUE) ? 1 : 0; red += (boardArr[i][j] == RED) ? 1 : 0; } } return new Pair<>(red, blue); } }
[ "achiyane@post.bgu.ac.il" ]
achiyane@post.bgu.ac.il
aba7de86dca2170fc959ea18a1e6fc523c971625
b267e472cbf99310ed7ad38d82f714a1891da688
/coolybot-framework/src/main/java/io/github/coolys/domain/util/package-info.java
5b2fbf202e9b1e1e02e869f2944d8e4bd377ec9a
[ "Apache-2.0" ]
permissive
coolys/coolybot-lib
6a063cc15f9e5d8429e0101e0d243eb767e68eda
c6759d6eb895c8a52c6cf42800a76d5c147b3481
refs/heads/master
2020-05-17T14:16:15.898759
2019-04-27T10:56:47
2019-04-27T10:56:47
183,758,693
0
0
null
null
null
null
UTF-8
Java
false
false
88
java
/** * Utilities for Coolybot domain objects. */ package io.github.coolys.domain.util;
[ "nguyendanghung2008@gmail.com" ]
nguyendanghung2008@gmail.com
1d574fb68f4564f4ae34fc1afe45868d4caa5da8
844f2c117dd7d15656f1ee6156f3160f7721239f
/subprojects/gradle-core/src/main/groovy/org/gradle/api/internal/CompositeDynamicObject.java
88675a33b0b47e98d5b89d7e000becbd68b6a148
[]
no_license
peron/gradle
7546f5ad1d1db0130534f81a227cc14bdbace839
47ba5551a5976b14dbe14380ef086324aeec501d
refs/heads/master
2021-01-16T20:33:14.132858
2010-03-31T11:31:15
2010-03-31T11:31:15
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,537
java
/* * Copyright 2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.gradle.api.internal; import groovy.lang.*; import groovy.lang.MissingMethodException; import java.util.HashMap; import java.util.Map; public abstract class CompositeDynamicObject extends AbstractDynamicObject { private DynamicObject[] objects = new DynamicObject[0]; private DynamicObject[] updateObjects = new DynamicObject[0]; protected void setObjects(DynamicObject... objects) { this.objects = objects; updateObjects = objects; } protected void setObjectsForUpdate(DynamicObject... objects) { this.updateObjects = objects; } @Override public boolean hasProperty(String name) { for (DynamicObject object : objects) { if (object.hasProperty(name)) { return true; } } return super.hasProperty(name); } @Override public Object getProperty(String name) throws MissingPropertyException { for (DynamicObject object : objects) { if (object.hasProperty(name)) { return object.getProperty(name); } } return super.getProperty(name); } @Override public void setProperty(String name, Object value) throws MissingPropertyException { for (DynamicObject object : updateObjects) { if (object.hasProperty(name)) { object.setProperty(name, value); return; } } updateObjects[updateObjects.length - 1].setProperty(name, value); } @Override public Map<String, Object> getProperties() { Map<String, Object> properties = new HashMap<String, Object>(); for (int i = objects.length - 1; i >= 0; i--) { DynamicObject object = objects[i]; properties.putAll(object.getProperties()); } properties.put("properties", properties); return properties; } @Override public boolean hasMethod(String name, Object... arguments) { for (DynamicObject object : objects) { if (object.hasMethod(name, arguments)) { return true; } } return super.hasMethod(name, arguments); } @Override public Object invokeMethod(String name, Object... arguments) throws MissingMethodException { for (DynamicObject object : objects) { if (object.hasMethod(name, arguments)) { return object.invokeMethod(name, arguments); } } if (hasProperty(name)) { Object property = getProperty(name); if (property instanceof Closure) { Closure closure = (Closure) property; return closure.call(arguments); } } return super.invokeMethod(name, arguments); } }
[ "Adam@Adam-PC.(none)" ]
Adam@Adam-PC.(none)
373e6fb0b3876f4a9e1113d868d1c2d7feed4737
844fb4e71f126cbf36696a4c2a6e06dd2183074f
/java/dev-utils/src/main/java/com/github/jerryxia/devutil/dataobject/web/response/SimpleRes.java
bb58c488f7d63d1cd6d0aa7a5fdc725c26ec5c12
[]
no_license
JerryXia/CodeFragment
d877bf5fbc55f51888c06e49f0a0b70680252f11
fdc702bdc0ca1941bfd331d5ba02ea3e188ff2bc
refs/heads/master
2023-06-23T20:42:01.424111
2023-06-11T01:21:26
2023-06-11T01:21:26
12,993,938
4
0
null
2023-06-10T13:11:20
2013-09-21T11:17:54
C#
UTF-8
Java
false
false
1,684
java
/** * */ package com.github.jerryxia.devutil.dataobject.web.response; import java.util.HashMap; import java.util.Map; /** * @author Administrator * */ public class SimpleRes { private int code; private String msg; private Map<String, Object> data; private Exception exception; public SimpleRes() { this.code = SimpleResCode.Ok.getValue(); this.msg = ""; this.data = new HashMap<String, Object>(8); } public SimpleRes(int c, String message, Map<String, Object> d) { this.code = c; this.msg = message == null ? "" : message; this.data = d; } public SimpleRes fail() { this.code = SimpleResCode.Fail.getValue(); return this; } public SimpleRes msg(String message) { this.msg = message == null ? "" : message; return this; } public SimpleRes failWithMsg(String message) { return fail().msg(message == null ? "" : message); } public int getCode() { return code; } public void setCode(int code) { this.code = code; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg == null ? "" : msg; } public Map<String, Object> getData() { return data; } public void setData(Map<String, Object> data) { this.data = data; } public Exception getException() { return exception; } public void setException(Exception exception) { this.exception = exception; } }
[ "gqkzwy@gmail.com" ]
gqkzwy@gmail.com
add54731349ae53485442f18c9541ade66873d9f
d3cd3212e077b2e04a16fee87680819396cf5b4d
/src/main/java/com/qaplus/mapper/QaScoreMapperExt.java
8ea805d383823773c4924a5097d644b7ee717cf8
[ "Apache-2.0" ]
permissive
zcgitzc/qaplus
061492048191f1a542be1a215811dfc5f4167288
1f5143376205100645284ff862438183a31975da
refs/heads/master
2022-12-23T15:34:43.915831
2017-07-11T14:20:19
2017-07-11T14:20:19
263,204,502
0
0
Apache-2.0
2022-12-16T04:29:16
2020-05-12T01:49:26
JavaScript
UTF-8
Java
false
false
431
java
package com.qaplus.mapper; import java.util.List; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; import com.qaplus.entity.QaScore; @Repository public interface QaScoreMapperExt extends QaScoreMapper { void updateStuPaperScore(@Param("paperId") Long paperId, @Param("stuId") Long stuId, @Param("score") int score); List<QaScore> queryTopThree(@Param("paperId") Long paperId); }
[ "486289410@qq.com" ]
486289410@qq.com
bff9a31ec3837843482ba5c42f634d018046baf9
f12713cf222b73b0c3f672de877a418ff7689f95
/src/hooks/auf-sync/src/main/java/com/savoirfairelinux/auf/hook/util/ThemeUtil.java
652998a0cb2eb0cb8f11abe283768d79ef9f6d44
[]
no_license
auf/intranet
311003340cb6d989f9d8f6916f4c6baf6cc1d8ef
dbbd606e1f98bc7b9b300008457452e3c38a437c
refs/heads/master
2021-01-25T05:10:53.234414
2016-12-19T18:52:45
2016-12-19T18:52:45
13,392,896
0
0
null
null
null
null
UTF-8
Java
false
false
3,310
java
package com.savoirfairelinux.auf.hook.util; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.util.MethodKey; import com.liferay.portal.kernel.util.PortalClassInvoker; import com.liferay.portal.model.Group; import com.liferay.portal.model.LayoutSet; import com.liferay.portal.model.LayoutSetPrototype; import com.liferay.portal.service.GroupLocalServiceUtil; import com.liferay.portal.service.LayoutSetLocalServiceUtil; import com.liferay.portal.service.LayoutSetPrototypeLocalServiceUtil; public class ThemeUtil { private static final Log _log = LogFactoryUtil.getLog(ThemeUtil.class); public static void setupSitesFromSiteTemplate(long groupId, long publicSiteTemplateId, long privateSiteTemplateId) throws PortalException, SystemException { Group group = GroupLocalServiceUtil.getGroup(groupId); if (publicSiteTemplateId != 0) setSiteTemplate(group, publicSiteTemplateId, false); if (privateSiteTemplateId != 0) setSiteTemplate(group, privateSiteTemplateId, true); } public static void setSiteTemplate(Group group, long siteTemplateId, boolean isPrivateLayout) throws PortalException, SystemException { long groupId = group.getGroupId(); LayoutSetPrototype prototype = LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototype(siteTemplateId); boolean layoutSetPrototypeLinkEnabled = true; LayoutSetLocalServiceUtil.updateLayoutSetPrototypeLinkEnabled(groupId, isPrivateLayout, layoutSetPrototypeLinkEnabled, prototype.getUuid()); try { LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, isPrivateLayout); mergeLayoutSetProtypeLayouts(group, layoutSet); } catch (Exception e) { if (_log.isWarnEnabled()) { String privatePublic = isPrivateLayout ? "private" : "public"; _log.warn(String.format("Could not merge %s layouts for group[%d] from template[%d]", privatePublic, groupId, siteTemplateId)); e.printStackTrace(); } } } public static void mergeLayoutSetProtypeLayouts(Group group, LayoutSet layoutSet) throws Exception { MethodKey key = SitesUtilMethodKey("mergeLayoutSetProtypeLayouts", Group.class, LayoutSet.class); invokePortalClassMethod(key, group, layoutSet); } /* * copied from * http://www.liferay.com/community/forums/-/message_boards/view_message /10488983#_19_message_10488983 * post by Jelmer Kuperus * * key: key of method to be called, e.g. com.liferay.portlet.sites.util.SitesUtil * arguments: arguments to be passed to the invoked method * returns: result of the invoked method */ private static Object invokePortalClassMethod(MethodKey key, Object... arguments) throws PortalException { try { // noinspection unchecked return PortalClassInvoker.invoke(false, key, arguments); } catch (PortalException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } } private static final String SITES_UTIL_CLASS_NAME = "com.liferay.portlet.sites.util.SitesUtil"; private static MethodKey SitesUtilMethodKey(String methodName, Class<?>... parameterTypes) { return new MethodKey(SITES_UTIL_CLASS_NAME, methodName, parameterTypes); } }
[ "stefan.langenmaier@savoirfairelinux.com" ]
stefan.langenmaier@savoirfairelinux.com
5f11e3ea4a49318a1e269b60f329669272b67e98
fdb8593e5eefbb2058699fef41e1a3b644c73c35
/src/ast/ListaComando.java
5ea15e6f861ab35beee66fa3e9a19f1003cd4725
[]
no_license
MarceloRavache/CompilerQPlusPlus_Voyager
52b55db2845e88f8a630d388dfa021a17cb02666
3df7e58904b5965ac4d4b643f31ea881c64ba4a3
refs/heads/master
2020-06-06T15:56:55.649062
2019-06-26T03:18:39
2019-06-26T03:18:39
192,784,606
0
0
null
null
null
null
UTF-8
Java
false
false
69
java
package ast; public abstract class ListaComando extends TreeNode{ }
[ "jm.ravache@outlook.com" ]
jm.ravache@outlook.com
756cf5887a50c3aaba35fa4986e170d247747930
e36f9cbb19cb197a3a04a93a46cc38f0d578519e
/src/edu/rutgers/winlab/sim/aggregation/AccessPoint.java
e5945752e8de9ce680e97c28c848e335ef26288a
[]
no_license
sugangli/Simulator
cf98f77c3975ba9277b420e1d65ab083708da668
a4bfda802cb167180475f7308983bb076df4f68f
refs/heads/master
2020-06-10T09:52:16.569596
2018-05-21T17:40:28
2018-05-21T17:40:28
75,972,290
0
2
null
null
null
null
UTF-8
Java
false
false
2,004
java
package edu.rutgers.winlab.sim.aggregation; import java.util.Map; import org.apache.commons.math3.distribution.PoissonDistribution; import edu.rutgers.winlab.sim.aggregation.ComputeNode.AggregatedData; import edu.rutgers.winlab.sim.core.Action; import edu.rutgers.winlab.sim.core.EventQueue; import edu.rutgers.winlab.sim.core.MACPacket; import edu.rutgers.winlab.sim.core.Node; public class AccessPoint extends Node { double dataRate = 0; Node first_anode; public Node getFirstANode() { return first_anode; } public void setFirstANnode(Node first_anode) { this.first_anode = first_anode; } public AccessPoint(String name) { super(name); // TODO Auto-generated constructor stub } public double getDataRate() { return dataRate; } public void setDataRate(double dataRate) { this.dataRate = dataRate; } public void generateTrafficByID(int object_id) { if(this.dataRate > 0) { PoissonDistribution pd = new PoissonDistribution(this.dataRate); EventQueue.AddEvent(EventQueue.Now(), send_after_interval, pd, object_id); } } private Action send_after_interval = new Action() { @Override public void execute(Object... args) { PoissonDistribution pd = (PoissonDistribution)args[0]; double occurs = pd.sample(); if(occurs != 0) { int object_id = (int) args[1]; for(Map.Entry<Node, Node.LinkState> entry: AccessPoint.this.getNeighbors().entrySet()) { MACPacket new_packet = new MACPacket(AccessPoint.this, entry.getKey(), new AggregatedData(AccessPoint.this.getName() + "," + getFirstANode().getName() + "," + object_id + "," + EventQueue.Now()));; AccessPoint.this.sendPacket(new_packet, false); // System.out.printf("Now=%f Node=%s Packet=%s, occurs=%f%n", EventQueue.Now(), AccessPoint.this, new_packet, occurs); if(1/occurs == 0) { System.err.println("Lost accuracy!!"); } EventQueue.AddEvent(EventQueue.Now() + 1/occurs, send_after_interval, pd, object_id); } } } }; }
[ "sugang.li718@gmail.com" ]
sugang.li718@gmail.com
0b41de6eb46bb4c6713c193823837598665a1286
ce18f0ef90887ab48dafc85e58ef42e9275955d6
/src/main/java/com/worksap/stm2016/service/CurrentUserService.java
a93a1b5691635bca58b5d9f617fa94097a196ab0
[]
no_license
firmsnail/WTest2
f6a976d3e78687846ed95964755b558d17cb7c16
6d85315002af27c93d1d093b623360dc48e025dc
refs/heads/master
2021-01-09T20:53:37.275705
2016-12-15T08:14:06
2016-12-15T08:14:06
56,464,623
0
0
null
null
null
null
UTF-8
Java
false
false
1,403
java
package com.worksap.stm2016.service; import com.worksap.stm2016.model.CurrentUser; import com.worksap.stm2016.service.CurrentUserService; public interface CurrentUserService { boolean canAccessUser(CurrentUser currentUser, Long userId); boolean canAccessDepartment(CurrentUser currentUser, Long departmentId); boolean canAddRequirement(CurrentUser currentUser); boolean canAccessStaffRequirement(CurrentUser currentUser, Long requirementId); boolean canDeleteStaffRequirement(CurrentUser currentUser, Long requirementId); boolean canAccessRecruitingPlan(CurrentUser currentUser, Long planId); boolean canApplyRecruitingPlan(CurrentUser currentUser, Long planId); boolean canDeletePlan(CurrentUser currentUser, Long planId); boolean canPostPlan(CurrentUser currentUser, Long planId); boolean canAccessHire(CurrentUser currentUser, Long hireId); boolean canAddDismission(CurrentUser currentUser); boolean canAccessDismission(CurrentUser currentUser, Long dismissionId); boolean canDeleteDismission(CurrentUser currentUser, Long dismissionId); boolean canAddLeave(CurrentUser currentUser); boolean canAccessLeave(CurrentUser currentUser, Long leaveId); boolean canDeleteLeave(CurrentUser currentUser, Long leaveId); boolean canOperateApplicant(CurrentUser currentUser, Long applicantId); boolean hasLogIn(CurrentUser currentUser); boolean isHiredEmployee(CurrentUser currentUser); }
[ "ascorpior@gmail.com" ]
ascorpior@gmail.com
cb36b367958625270056fbd07ed38b8287d1ab2d
2f11f3da7bcdac54957d05b36a7a92f9bb84fd32
/app/src/main/java/com/indusfo/edzn/scangon/db/DbOpenHelper.java
fa96001793ef456dda8456711f7f0472ed78aa27
[]
no_license
xuz10086/EDSF_scangon
31021aeda2af106cc29a613b0d0a4b4871020e74
bcf1725decdd29fa4973044559ffc644e1091b24
refs/heads/master
2020-05-20T02:13:39.259006
2019-05-07T05:30:36
2019-05-07T05:30:36
185,326,391
0
0
null
null
null
null
UTF-8
Java
false
false
1,766
java
package com.indusfo.edzn.scangon.db; import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.support.annotation.Nullable; import com.indusfo.edzn.scangon.cons.AppParams; /** * 数据库帮助类 * * @author xuz * @date 2019/1/11 9:21 AM */ public class DbOpenHelper extends SQLiteOpenHelper { public DbOpenHelper(@Nullable Context context) { super(context, AppParams.DB_NAME, null, AppParams.DB_VERSION); } @Override public void onCreate(SQLiteDatabase db) { // 创建用户表 db.execSQL("CREATE TABLE "+AppParams.USER_TABLE_NAME+"("+AppParams.USER_TABLE_NAME+" integer PRIMARY KEY AUTOINCREMENT, "+ AppParams.USERNAME+" text, "+AppParams.PASSWORD+" text, "+AppParams.IFSAVE+" integer, "+AppParams.USERID+" text)"); // 创建扫描结果表 db.execSQL("CREATE TABLE "+AppParams.SCANNING_TABLE_NAME+"("+AppParams.SCANNING_ID+" integer PRIMARY KEY AUTOINCREMENT, "+ AppParams.QR+" text, "+AppParams.VC_MATERIALS_CODE+" text, "+AppParams.VC_SEAT_CODE+" text, "+AppParams.VC_MATERIALS_BATCH+" text, "+ AppParams.D_SCANNING_TIME+" text, "+AppParams.L_VALID+" integer, "+AppParams.IF_ROW+" Integer)"); // 创建设备设置表 db.execSQL("CREATE TABLE "+AppParams.DEVICE_TABLE_NAME+"("+AppParams._ID+" integer PRIMARY KEY AUTOINCREMENT, "+ AppParams.L_DEVICE_ID+" text, "+AppParams.VC_DEVICE_CODE+" text, "+AppParams.VC_DEVICE_NAME+" text, "+AppParams.VC_DEVICE_MODE+" text, "+ AppParams.IF_CHECKED+" text)"); } @Override public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) { } }
[ "xuz10086@icloud.com" ]
xuz10086@icloud.com
22395e1327554245af19e80371422ec9217e4d52
aac5aab8d733f7ee207bf8d0d4e64030aa593d37
/proj_200_catalina副本/src/org/apache/catalina/servlets/WebdavServlet.java
3a7978aeea2d500833db46235bb9079f753625d7
[]
no_license
lichsword/Tomcat
6be5f2b501cb7a262e2189cf288e342380db03c4
278aabcb370fb8b61d5571f4944b61f4c36fb2e0
refs/heads/master
2021-01-17T14:32:30.725094
2014-04-22T07:19:14
2014-04-22T07:19:14
17,353,207
0
2
null
null
null
null
UTF-8
Java
false
false
108,780
java
/* * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/WebdavServlet.java,v 1.28 2002/04/01 18:12:38 remm Exp $ * $Revision: 1.28 $ * $Date: 2002/04/01 18:12:38 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.catalina.servlets; import java.io.IOException; import java.io.StringWriter; import java.io.Writer; import java.util.Date; import java.util.Enumeration; import java.util.Vector; import java.util.Stack; import java.util.Locale; import java.util.Hashtable; import java.util.TimeZone; import java.text.SimpleDateFormat; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Element; import org.w3c.dom.Document; import org.xml.sax.InputSource; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.naming.NamingException; import javax.naming.NamingEnumeration; import javax.naming.NameClassPair; import javax.naming.directory.DirContext; import org.apache.naming.resources.Resource; import org.apache.catalina.util.XMLWriter; import org.apache.catalina.util.DOMWriter; import org.apache.catalina.util.RequestUtil; /** * Servlet which adds support for WebDAV level 2. All the basic HTTP requests * are handled by the DefaultServlet. * * @author Remy Maucherat * @version $Revision: 1.28 $ $Date: 2002/04/01 18:12:38 $ */ public class WebdavServlet extends DefaultServlet { // -------------------------------------------------------------- Constants private static final String METHOD_HEAD = "HEAD"; private static final String METHOD_PROPFIND = "PROPFIND"; private static final String METHOD_PROPPATCH = "PROPPATCH"; private static final String METHOD_MKCOL = "MKCOL"; private static final String METHOD_COPY = "COPY"; private static final String METHOD_MOVE = "MOVE"; private static final String METHOD_LOCK = "LOCK"; private static final String METHOD_UNLOCK = "UNLOCK"; /** * Default depth is infite. */ private static final int INFINITY = 3; // To limit tree browsing a bit /** * PROPFIND - Specify a property mask. */ private static final int FIND_BY_PROPERTY = 0; /** * PROPFIND - Display all properties. */ private static final int FIND_ALL_PROP = 1; /** * PROPFIND - Return property names. */ private static final int FIND_PROPERTY_NAMES = 2; /** * Create a new lock. */ private static final int LOCK_CREATION = 0; /** * Refresh lock. */ private static final int LOCK_REFRESH = 1; /** * Default lock timeout value. */ private static final int DEFAULT_TIMEOUT = 3600; /** * Maximum lock timeout. */ private static final int MAX_TIMEOUT = 604800; /** * Default namespace. */ protected static final String DEFAULT_NAMESPACE = "DAV:"; /** * Simple date format for the creation date ISO representation (partial). */ protected static final SimpleDateFormat creationDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); static { creationDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); } // ----------------------------------------------------- Instance Variables /** * Repository of the locks put on single resources. * <p> * Key : path <br> * Value : LockInfo */ private Hashtable resourceLocks = new Hashtable(); /** * Repository of the lock-null resources. * <p> * Key : path of the collection containing the lock-null resource<br> * Value : Vector of lock-null resource which are members of the * collection. Each element of the Vector is the path associated with * the lock-null resource. */ private Hashtable lockNullResources = new Hashtable(); /** * Vector of the heritable locks. * <p> * Key : path <br> * Value : LockInfo */ private Vector collectionLocks = new Vector(); /** * Secret information used to generate reasonably secure lock ids. */ private String secret = "catalina"; // --------------------------------------------------------- Public Methods /** * Initialize this servlet. */ public void init() throws ServletException { super.init(); String value = null; try { value = getServletConfig().getInitParameter("secret"); if (value != null) secret = value; } catch (Throwable t) { ; } } // ------------------------------------------------------ Protected Methods /** * Return JAXP document builder instance. */ protected DocumentBuilder getDocumentBuilder() throws ServletException { DocumentBuilder documentBuilder = null; try { documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch(ParserConfigurationException e) { throw new ServletException (sm.getString("webdavservlet.jaxpfailed")); } return documentBuilder; } /** * Handles the special WebDAV methods. */ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String method = req.getMethod(); if (debug > 0) { String path = getRelativePath(req); System.out.println("[" + method + "] " + path); } if (method.equals(METHOD_PROPFIND)) { doPropfind(req, resp); } else if (method.equals(METHOD_PROPPATCH)) { doProppatch(req, resp); } else if (method.equals(METHOD_MKCOL)) { doMkcol(req, resp); } else if (method.equals(METHOD_COPY)) { doCopy(req, resp); } else if (method.equals(METHOD_MOVE)) { doMove(req, resp); } else if (method.equals(METHOD_LOCK)) { doLock(req, resp); } else if (method.equals(METHOD_UNLOCK)) { doUnlock(req, resp); } else { // DefaultServlet processing super.service(req, resp); } } /** * Check if the conditions specified in the optional If headers are * satisfied. * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param resourceInfo File object * @return boolean true if the resource meets all the specified conditions, * and false if any of the conditions is not satisfied, in which case * request processing is stopped */ protected boolean checkIfHeaders(HttpServletRequest request, HttpServletResponse response, ResourceInfo resourceInfo) throws IOException { if (!super.checkIfHeaders(request, response, resourceInfo)) return false; // TODO : Checking the WebDAV If header return true; } /** * OPTIONS Method. */ protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String path = getRelativePath(req); resp.addHeader("DAV", "1,2"); String methodsAllowed = null; // Retrieve the resources DirContext resources = getResources(); if (resources == null) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } boolean exists = true; Object object = null; try { object = resources.lookup(path); } catch (NamingException e) { exists = false; } if (!exists) { methodsAllowed = "OPTIONS, MKCOL, PUT, LOCK"; resp.addHeader("Allow", methodsAllowed); return; } methodsAllowed = "OPTIONS, GET, HEAD, POST, DELETE, TRACE, " + "PROPFIND, PROPPATCH, COPY, MOVE, LOCK, UNLOCK"; if (!(object instanceof DirContext)) { methodsAllowed += ", PUT"; } resp.addHeader("Allow", methodsAllowed); resp.addHeader("MS-Author-Via", "DAV"); } /** * PROPFIND Method. */ protected void doPropfind(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (!listings) { resp.sendError(WebdavStatus.SC_METHOD_NOT_ALLOWED); return; } String path = getRelativePath(req); if (path.endsWith("/")) path = path.substring(0, path.length() - 1); if ((path.toUpperCase().startsWith("/WEB-INF")) || (path.toUpperCase().startsWith("/META-INF"))) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } // Properties which are to be displayed. Vector properties = null; // Propfind depth int depth = INFINITY; // Propfind type int type = FIND_ALL_PROP; String depthStr = req.getHeader("Depth"); if (depthStr == null) { depth = INFINITY; } else { if (depthStr.equals("0")) { depth = 0; } else if (depthStr.equals("1")) { depth = 1; } else if (depthStr.equals("infinity")) { depth = INFINITY; } } Node propNode = null; DocumentBuilder documentBuilder = getDocumentBuilder(); try { Document document = documentBuilder.parse (new InputSource(req.getInputStream())); // Get the root element of the document Element rootElement = document.getDocumentElement(); NodeList childList = rootElement.getChildNodes(); for (int i=0; i < childList.getLength(); i++) { Node currentNode = childList.item(i); switch (currentNode.getNodeType()) { case Node.TEXT_NODE: break; case Node.ELEMENT_NODE: if (currentNode.getNodeName().endsWith("prop")) { type = FIND_BY_PROPERTY; propNode = currentNode; } if (currentNode.getNodeName().endsWith("propname")) { type = FIND_PROPERTY_NAMES; } if (currentNode.getNodeName().endsWith("allprop")) { type = FIND_ALL_PROP; } break; } } } catch(Exception e) { // Most likely there was no content : we use the defaults. // TODO : Enhance that ! } if (type == FIND_BY_PROPERTY) { properties = new Vector(); NodeList childList = propNode.getChildNodes(); for (int i=0; i < childList.getLength(); i++) { Node currentNode = childList.item(i); switch (currentNode.getNodeType()) { case Node.TEXT_NODE: break; case Node.ELEMENT_NODE: String nodeName = currentNode.getNodeName(); String propertyName = null; if (nodeName.indexOf(':') != -1) { propertyName = nodeName.substring (nodeName.indexOf(':') + 1); } else { propertyName = nodeName; } // href is a live property which is handled differently properties.addElement(propertyName); break; } } } // Retrieve the resources DirContext resources = getResources(); if (resources == null) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } boolean exists = true; Object object = null; try { object = resources.lookup(path); } catch (NamingException e) { exists = false; int slash = path.lastIndexOf('/'); if (slash != -1) { String parentPath = path.substring(0, slash); Vector currentLockNullResources = (Vector) lockNullResources.get(parentPath); if (currentLockNullResources != null) { Enumeration lockNullResourcesList = currentLockNullResources.elements(); while (lockNullResourcesList.hasMoreElements()) { String lockNullPath = (String) lockNullResourcesList.nextElement(); if (lockNullPath.equals(path)) { resp.setStatus(WebdavStatus.SC_MULTI_STATUS); resp.setContentType("text/xml; charset=UTF-8"); // Create multistatus object XMLWriter generatedXML = new XMLWriter(resp.getWriter()); generatedXML.writeXMLHeader(); generatedXML.writeElement (null, "multistatus" + generateNamespaceDeclarations(), XMLWriter.OPENING); parseLockNullProperties (req, generatedXML, lockNullPath, type, properties); generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING); generatedXML.sendData(); return; } } } } } if (!exists) { resp.sendError(HttpServletResponse.SC_NOT_FOUND, path); return; } resp.setStatus(WebdavStatus.SC_MULTI_STATUS); resp.setContentType("text/xml; charset=UTF-8"); // Create multistatus object XMLWriter generatedXML = new XMLWriter(resp.getWriter()); generatedXML.writeXMLHeader(); generatedXML.writeElement(null, "multistatus" + generateNamespaceDeclarations(), XMLWriter.OPENING); if (depth == 0) { parseProperties(req, resources, generatedXML, path, type, properties); } else { // The stack always contains the object of the current level Stack stack = new Stack(); stack.push(path); // Stack of the objects one level below Stack stackBelow = new Stack(); while ((!stack.isEmpty()) && (depth >= 0)) { String currentPath = (String) stack.pop(); parseProperties(req, resources, generatedXML, currentPath, type, properties); try { object = resources.lookup(currentPath); } catch (NamingException e) { continue; } if ((object instanceof DirContext) && (depth > 0)) { try { NamingEnumeration enum = resources.list(currentPath); while (enum.hasMoreElements()) { NameClassPair ncPair = (NameClassPair) enum.nextElement(); String newPath = currentPath; if (!(newPath.endsWith("/"))) newPath += "/"; newPath += ncPair.getName(); stackBelow.push(newPath); } } catch (NamingException e) { resp.sendError (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, path); return; } // Displaying the lock-null resources present in that // collection String lockPath = currentPath; if (lockPath.endsWith("/")) lockPath = lockPath.substring(0, lockPath.length() - 1); Vector currentLockNullResources = (Vector) lockNullResources.get(lockPath); if (currentLockNullResources != null) { Enumeration lockNullResourcesList = currentLockNullResources.elements(); while (lockNullResourcesList.hasMoreElements()) { String lockNullPath = (String) lockNullResourcesList.nextElement(); parseLockNullProperties (req, generatedXML, lockNullPath, type, properties); } } } if (stack.isEmpty()) { depth--; stack = stackBelow; stackBelow = new Stack(); } generatedXML.sendData(); } } generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING); generatedXML.sendData(); } /** * PROPPATCH Method. */ protected void doProppatch(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } /** * MKCOL Method. */ protected void doMkcol(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } String path = getRelativePath(req); if ((path.toUpperCase().startsWith("/WEB-INF")) || (path.toUpperCase().startsWith("/META-INF"))) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } // Retrieve the resources DirContext resources = getResources(); if (resources == null) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } boolean exists = true; Object object = null; try { object = resources.lookup(path); } catch (NamingException e) { exists = false; } // Can't create a collection if a resource already exists at the given // path if (exists) { resp.sendError(WebdavStatus.SC_METHOD_NOT_ALLOWED); return; } boolean result = true; try { resources.createSubcontext(path); } catch (NamingException e) { result = false; } if (!result) { resp.sendError(WebdavStatus.SC_CONFLICT, WebdavStatus.getStatusText (WebdavStatus.SC_CONFLICT)); } else { resp.setStatus(WebdavStatus.SC_CREATED); // Removing any lock-null resource which would be present lockNullResources.remove(path); } } /** * DELETE Method. */ protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } deleteResource(req, resp); } /** * Process a POST request for the specified resource. * * @param request The servlet request we are processing * @param response The servlet response we are creating * * @exception java.io.IOException if an input/output error occurs * @exception javax.servlet.ServletException if a servlet-specified error occurs */ protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } super.doPut(req, resp); String path = getRelativePath(req); // Removing any lock-null resource which would be present lockNullResources.remove(path); } /** * COPY Method. */ protected void doCopy(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } copyResource(req, resp); } /** * MOVE Method. */ protected void doMove(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } String path = getRelativePath(req); if (copyResource(req, resp)) { deleteResource(path, req, resp); } } /** * LOCK Method. */ protected void doLock(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } LockInfo lock = new LockInfo(); // Parsing lock request // Parsing depth header String depthStr = req.getHeader("Depth"); if (depthStr == null) { lock.depth = INFINITY; } else { if (depthStr.equals("0")) { lock.depth = 0; } else { lock.depth = INFINITY; } } // Parsing timeout header int lockDuration = DEFAULT_TIMEOUT; String lockDurationStr = req.getHeader("Timeout"); if (lockDurationStr == null) { lockDuration = DEFAULT_TIMEOUT; } else { if (lockDurationStr.startsWith("Second-")) { lockDuration = (new Integer(lockDurationStr.substring(7))).intValue(); } else { if (lockDurationStr.equalsIgnoreCase("infinity")) { lockDuration = MAX_TIMEOUT; } else { try { lockDuration = (new Integer(lockDurationStr)).intValue(); } catch (NumberFormatException e) { lockDuration = MAX_TIMEOUT; } } } if (lockDuration == 0) { lockDuration = DEFAULT_TIMEOUT; } if (lockDuration > MAX_TIMEOUT) { lockDuration = MAX_TIMEOUT; } } lock.expiresAt = System.currentTimeMillis() + (lockDuration * 1000); int lockRequestType = LOCK_CREATION; Node lockInfoNode = null; DocumentBuilder documentBuilder = getDocumentBuilder(); try { Document document = documentBuilder.parse(new InputSource (req.getInputStream())); // Get the root element of the document Element rootElement = document.getDocumentElement(); lockInfoNode = rootElement; } catch(Exception e) { lockRequestType = LOCK_REFRESH; } if (lockInfoNode != null) { // Reading lock information NodeList childList = lockInfoNode.getChildNodes(); StringWriter strWriter = null; DOMWriter domWriter = null; Node lockScopeNode = null; Node lockTypeNode = null; Node lockOwnerNode = null; for (int i=0; i < childList.getLength(); i++) { Node currentNode = childList.item(i); switch (currentNode.getNodeType()) { case Node.TEXT_NODE: break; case Node.ELEMENT_NODE: String nodeName = currentNode.getNodeName(); if (nodeName.endsWith("lockscope")) { lockScopeNode = currentNode; } if (nodeName.endsWith("locktype")) { lockTypeNode = currentNode; } if (nodeName.endsWith("owner")) { lockOwnerNode = currentNode; } break; } } if (lockScopeNode != null) { childList = lockScopeNode.getChildNodes(); for (int i=0; i < childList.getLength(); i++) { Node currentNode = childList.item(i); switch (currentNode.getNodeType()) { case Node.TEXT_NODE: break; case Node.ELEMENT_NODE: String tempScope = currentNode.getNodeName(); if (tempScope.indexOf(':') != -1) { lock.scope = tempScope.substring (tempScope.indexOf(':') + 1); } else { lock.scope = tempScope; } break; } } if (lock.scope == null) { // Bad request resp.setStatus(WebdavStatus.SC_BAD_REQUEST); } } else { // Bad request resp.setStatus(WebdavStatus.SC_BAD_REQUEST); } if (lockTypeNode != null) { childList = lockTypeNode.getChildNodes(); for (int i=0; i < childList.getLength(); i++) { Node currentNode = childList.item(i); switch (currentNode.getNodeType()) { case Node.TEXT_NODE: break; case Node.ELEMENT_NODE: String tempType = currentNode.getNodeName(); if (tempType.indexOf(':') != -1) { lock.type = tempType.substring(tempType.indexOf(':') + 1); } else { lock.type = tempType; } break; } } if (lock.type == null) { // Bad request resp.setStatus(WebdavStatus.SC_BAD_REQUEST); } } else { // Bad request resp.setStatus(WebdavStatus.SC_BAD_REQUEST); } if (lockOwnerNode != null) { childList = lockOwnerNode.getChildNodes(); for (int i=0; i < childList.getLength(); i++) { Node currentNode = childList.item(i); switch (currentNode.getNodeType()) { case Node.TEXT_NODE: lock.owner += currentNode.getNodeValue(); break; case Node.ELEMENT_NODE: strWriter = new StringWriter(); domWriter = new DOMWriter(strWriter, true); domWriter.print(currentNode); lock.owner += strWriter.toString(); break; } } if (lock.owner == null) { // Bad request resp.setStatus(WebdavStatus.SC_BAD_REQUEST); } } else { lock.owner = new String(); } } String path = getRelativePath(req); lock.path = path; // Retrieve the resources DirContext resources = getResources(); if (resources == null) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } boolean exists = true; Object object = null; try { object = resources.lookup(path); } catch (NamingException e) { exists = false; } Enumeration locksList = null; if (lockRequestType == LOCK_CREATION) { // Generating lock id String lockTokenStr = req.getServletPath() + "-" + lock.type + "-" + lock.scope + "-" + req.getUserPrincipal() + "-" + lock.depth + "-" + lock.owner + "-" + lock.tokens + "-" + lock.expiresAt + "-" + System.currentTimeMillis() + "-" + secret; String lockToken = md5Encoder.encode(md5Helper.digest(lockTokenStr.getBytes())); if ( (exists) && (object instanceof DirContext) && (lock.depth == INFINITY) ) { // Locking a collection (and all its member resources) // Checking if a child resource of this collection is // already locked Vector lockPaths = new Vector(); locksList = collectionLocks.elements(); while (locksList.hasMoreElements()) { LockInfo currentLock = (LockInfo) locksList.nextElement(); if (currentLock.hasExpired()) { resourceLocks.remove(currentLock.path); continue; } if ( (currentLock.path.startsWith(lock.path)) && ((currentLock.isExclusive()) || (lock.isExclusive())) ) { // A child collection of this collection is locked lockPaths.addElement(currentLock.path); } } locksList = resourceLocks.elements(); while (locksList.hasMoreElements()) { LockInfo currentLock = (LockInfo) locksList.nextElement(); if (currentLock.hasExpired()) { resourceLocks.remove(currentLock.path); continue; } if ( (currentLock.path.startsWith(lock.path)) && ((currentLock.isExclusive()) || (lock.isExclusive())) ) { // A child resource of this collection is locked lockPaths.addElement(currentLock.path); } } if (!lockPaths.isEmpty()) { // One of the child paths was locked // We generate a multistatus error report Enumeration lockPathsList = lockPaths.elements(); resp.setStatus(WebdavStatus.SC_CONFLICT); XMLWriter generatedXML = new XMLWriter(); generatedXML.writeXMLHeader(); generatedXML.writeElement (null, "multistatus" + generateNamespaceDeclarations(), XMLWriter.OPENING); while (lockPathsList.hasMoreElements()) { generatedXML.writeElement(null, "response", XMLWriter.OPENING); generatedXML.writeElement(null, "href", XMLWriter.OPENING); generatedXML .writeText((String) lockPathsList.nextElement()); generatedXML.writeElement(null, "href", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML .writeText("HTTP/1.1 " + WebdavStatus.SC_LOCKED + " " + WebdavStatus .getStatusText(WebdavStatus.SC_LOCKED)); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "response", XMLWriter.CLOSING); } generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING); Writer writer = resp.getWriter(); writer.write(generatedXML.toString()); writer.close(); return; } boolean addLock = true; // Checking if there is already a shared lock on this path locksList = collectionLocks.elements(); while (locksList.hasMoreElements()) { LockInfo currentLock = (LockInfo) locksList.nextElement(); if (currentLock.path.equals(lock.path)) { if (currentLock.isExclusive()) { resp.sendError(WebdavStatus.SC_LOCKED); return; } else { if (lock.isExclusive()) { resp.sendError(WebdavStatus.SC_LOCKED); return; } } currentLock.tokens.addElement(lockToken); lock = currentLock; addLock = false; } } if (addLock) { lock.tokens.addElement(lockToken); collectionLocks.addElement(lock); } } else { // Locking a single resource // Retrieving an already existing lock on that resource LockInfo presentLock = (LockInfo) resourceLocks.get(lock.path); if (presentLock != null) { if ((presentLock.isExclusive()) || (lock.isExclusive())) { // If either lock is exclusive, the lock can't be // granted resp.sendError(WebdavStatus.SC_PRECONDITION_FAILED); return; } else { presentLock.tokens.addElement(lockToken); lock = presentLock; } } else { lock.tokens.addElement(lockToken); resourceLocks.put(lock.path, lock); // Checking if a resource exists at this path exists = true; try { object = resources.lookup(path); } catch (NamingException e) { exists = false; } if (!exists) { // "Creating" a lock-null resource int slash = lock.path.lastIndexOf('/'); String parentPath = lock.path.substring(0, slash); Vector lockNulls = (Vector) lockNullResources.get(parentPath); if (lockNulls == null) { lockNulls = new Vector(); lockNullResources.put(parentPath, lockNulls); } lockNulls.addElement(lock.path); } } } } if (lockRequestType == LOCK_REFRESH) { String ifHeader = req.getHeader("If"); if (ifHeader == null) ifHeader = ""; // Checking resource locks LockInfo toRenew = (LockInfo) resourceLocks.get(path); Enumeration tokenList = null; if (lock != null) { // At least one of the tokens of the locks must have been given tokenList = toRenew.tokens.elements(); while (tokenList.hasMoreElements()) { String token = (String) tokenList.nextElement(); if (ifHeader.indexOf(token) != -1) { toRenew.expiresAt = lock.expiresAt; lock = toRenew; } } } // Checking inheritable collection locks Enumeration collectionLocksList = collectionLocks.elements(); while (collectionLocksList.hasMoreElements()) { toRenew = (LockInfo) collectionLocksList.nextElement(); if (path.equals(toRenew.path)) { tokenList = toRenew.tokens.elements(); while (tokenList.hasMoreElements()) { String token = (String) tokenList.nextElement(); if (ifHeader.indexOf(token) != -1) { toRenew.expiresAt = lock.expiresAt; lock = toRenew; } } } } } // Set the status, then generate the XML response containing // the lock information XMLWriter generatedXML = new XMLWriter(); generatedXML.writeXMLHeader(); generatedXML.writeElement(null, "prop" + generateNamespaceDeclarations(), XMLWriter.OPENING); generatedXML.writeElement(null, "lockdiscovery", XMLWriter.OPENING); lock.toXML(generatedXML, true); generatedXML.writeElement(null, "lockdiscovery", XMLWriter.CLOSING); generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); resp.setStatus(WebdavStatus.SC_OK); resp.setContentType("text/xml; charset=UTF-8"); Writer writer = resp.getWriter(); writer.write(generatedXML.toString()); writer.close(); } /** * UNLOCK Method. */ protected void doUnlock(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return; } if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); return; } String path = getRelativePath(req); String lockTokenHeader = req.getHeader("Lock-Token"); if (lockTokenHeader == null) lockTokenHeader = ""; // Checking resource locks LockInfo lock = (LockInfo) resourceLocks.get(path); Enumeration tokenList = null; if (lock != null) { // At least one of the tokens of the locks must have been given tokenList = lock.tokens.elements(); while (tokenList.hasMoreElements()) { String token = (String) tokenList.nextElement(); if (lockTokenHeader.indexOf(token) != -1) { lock.tokens.removeElement(token); } } if (lock.tokens.isEmpty()) { resourceLocks.remove(path); // Removing any lock-null resource which would be present lockNullResources.remove(path); } } // Checking inheritable collection locks Enumeration collectionLocksList = collectionLocks.elements(); while (collectionLocksList.hasMoreElements()) { lock = (LockInfo) collectionLocksList.nextElement(); if (path.equals(lock.path)) { tokenList = lock.tokens.elements(); while (tokenList.hasMoreElements()) { String token = (String) tokenList.nextElement(); if (lockTokenHeader.indexOf(token) != -1) { lock.tokens.removeElement(token); break; } } if (lock.tokens.isEmpty()) { collectionLocks.removeElement(lock); // Removing any lock-null resource which would be present lockNullResources.remove(path); } } } resp.setStatus(WebdavStatus.SC_NO_CONTENT); } // -------------------------------------------------------- Private Methods protected String getETagValue(ResourceInfo resourceInfo) { return resourceInfo.length + "-" + resourceInfo.date; } /** * Generate the namespace declarations. */ private String generateNamespaceDeclarations() { return " xmlns=\"" + DEFAULT_NAMESPACE + "\""; } /** * Check to see if a resource is currently write locked. The method * will look at the "If" header to make sure the client * has give the appropriate lock tokens. * * @param req Servlet request * @return boolean true if the resource is locked (and no appropriate * lock token has been found for at least one of the non-shared locks which * are present on the resource). */ private boolean isLocked(HttpServletRequest req) { String path = getRelativePath(req); String ifHeader = req.getHeader("If"); if (ifHeader == null) ifHeader = ""; String lockTokenHeader = req.getHeader("Lock-Token"); if (lockTokenHeader == null) lockTokenHeader = ""; return isLocked(path, ifHeader + lockTokenHeader); } /** * Check to see if a resource is currently write locked. * * @param path Path of the resource * @param ifHeader "If" HTTP header which was included in the request * @return boolean true if the resource is locked (and no appropriate * lock token has been found for at least one of the non-shared locks which * are present on the resource). */ private boolean isLocked(String path, String ifHeader) { // Checking resource locks LockInfo lock = (LockInfo) resourceLocks.get(path); Enumeration tokenList = null; if ((lock != null) && (lock.hasExpired())) { resourceLocks.remove(path); } else if (lock != null) { // At least one of the tokens of the locks must have been given tokenList = lock.tokens.elements(); boolean tokenMatch = false; while (tokenList.hasMoreElements()) { String token = (String) tokenList.nextElement(); if (ifHeader.indexOf(token) != -1) tokenMatch = true; } if (!tokenMatch) return true; } // Checking inheritable collection locks Enumeration collectionLocksList = collectionLocks.elements(); while (collectionLocksList.hasMoreElements()) { lock = (LockInfo) collectionLocksList.nextElement(); if (lock.hasExpired()) { collectionLocks.removeElement(lock); } else if (path.startsWith(lock.path)) { tokenList = lock.tokens.elements(); boolean tokenMatch = false; while (tokenList.hasMoreElements()) { String token = (String) tokenList.nextElement(); if (ifHeader.indexOf(token) != -1) tokenMatch = true; } if (!tokenMatch) return true; } } return false; } /** * Copy a resource. * * @param req Servlet request * @param resp Servlet response * @return boolean true if the copy is successful */ private boolean copyResource(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Parsing destination header String destinationPath = req.getHeader("Destination"); if (destinationPath == null) { resp.sendError(WebdavStatus.SC_BAD_REQUEST); return false; } int protocolIndex = destinationPath.indexOf("://"); if (protocolIndex >= 0) { // if the Destination URL contains the protocol, we can safely // trim everything upto the first "/" character after "://" int firstSeparator = destinationPath.indexOf("/", protocolIndex + 4); if (firstSeparator < 0) { destinationPath = "/"; } else { destinationPath = destinationPath.substring(firstSeparator); } } else { String hostName = req.getServerName(); if ((hostName != null) && (destinationPath.startsWith(hostName))) { destinationPath = destinationPath.substring(hostName.length()); } int portIndex = destinationPath.indexOf(":"); if (portIndex >= 0) { destinationPath = destinationPath.substring(portIndex); } if (destinationPath.startsWith(":")) { int firstSeparator = destinationPath.indexOf("/"); if (firstSeparator < 0) { destinationPath = "/"; } else { destinationPath = destinationPath.substring(firstSeparator); } } } String contextPath = req.getContextPath(); if ((contextPath != null) && (destinationPath.startsWith(contextPath))) { destinationPath = destinationPath.substring(contextPath.length()); } String pathInfo = req.getPathInfo(); if (pathInfo != null) { String servletPath = req.getServletPath(); if ((servletPath != null) && (destinationPath.startsWith(servletPath))) { destinationPath = destinationPath .substring(servletPath.length()); } } destinationPath = RequestUtil.URLDecode(normalize(destinationPath), "UTF8"); if (debug > 0) System.out.println("Dest path :" + destinationPath); if ((destinationPath.toUpperCase().startsWith("/WEB-INF")) || (destinationPath.toUpperCase().startsWith("/META-INF"))) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return false; } String path = getRelativePath(req); if ((path.toUpperCase().startsWith("/WEB-INF")) || (path.toUpperCase().startsWith("/META-INF"))) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return false; } if (destinationPath.equals(path)) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return false; } // Parsing overwrite header boolean overwrite = true; String overwriteHeader = req.getHeader("Overwrite"); if (overwriteHeader != null) { if (overwriteHeader.equalsIgnoreCase("T")) { overwrite = true; } else { overwrite = false; } } // Overwriting the destination // Retrieve the resources DirContext resources = getResources(); if (resources == null) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return false; } boolean exists = true; try { resources.lookup(destinationPath); } catch (NamingException e) { exists = false; } if (overwrite) { // Delete destination resource, if it exists if (exists) { if (!deleteResource(destinationPath, req, resp)) { return false; } else { resp.setStatus(WebdavStatus.SC_NO_CONTENT); } } else { resp.setStatus(WebdavStatus.SC_CREATED); } } else { // If the destination exists, then it's a conflict if (exists) { resp.sendError(WebdavStatus.SC_PRECONDITION_FAILED); return false; } } // Copying source to destination Hashtable errorList = new Hashtable(); boolean result = copyResource(resources, errorList, path, destinationPath); if ((!result) || (!errorList.isEmpty())) { sendReport(req, resp, errorList); return false; } // Removing any lock-null resource which would be present at // the destination path lockNullResources.remove(destinationPath); return true; } /** * Copy a collection. * * @param resources Resources implementation to be used * @param errorList Hashtable containing the list of errors which occurred * during the copy operation * @param source Path of the resource to be copied * @param dest Destination path */ private boolean copyResource(DirContext resources, Hashtable errorList, String source, String dest) { if (debug > 1) System.out.println("Copy: " + source + " To: " + dest); Object object = null; try { object = resources.lookup(source); } catch (NamingException e) { } if (object instanceof DirContext) { try { resources.createSubcontext(dest); } catch (NamingException e) { errorList.put (dest, new Integer(WebdavStatus.SC_CONFLICT)); return false; } try { NamingEnumeration enum = resources.list(source); while (enum.hasMoreElements()) { NameClassPair ncPair = (NameClassPair) enum.nextElement(); String childDest = dest; if (!childDest.equals("/")) childDest += "/"; childDest += ncPair.getName(); String childSrc = source; if (!childSrc.equals("/")) childSrc += "/"; childSrc += ncPair.getName(); copyResource(resources, errorList, childSrc, childDest); } } catch (NamingException e) { errorList.put (dest, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR)); return false; } } else { if (object instanceof Resource) { try { resources.bind(dest, object); } catch (NamingException e) { errorList.put (source, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR)); return false; } } else { errorList.put (source, new Integer(WebdavStatus.SC_INTERNAL_SERVER_ERROR)); return false; } } return true; } /** * Delete a resource. * * @param req Servlet request * @param resp Servlet response * @return boolean true if the copy is successful */ private boolean deleteResource(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String path = getRelativePath(req); return deleteResource(path, req, resp); } /** * Delete a resource. * * @param path Path of the resource which is to be deleted * @param req Servlet request * @param resp Servlet response */ private boolean deleteResource(String path, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if ((path.toUpperCase().startsWith("/WEB-INF")) || (path.toUpperCase().startsWith("/META-INF"))) { resp.sendError(WebdavStatus.SC_FORBIDDEN); return false; } String ifHeader = req.getHeader("If"); if (ifHeader == null) ifHeader = ""; String lockTokenHeader = req.getHeader("Lock-Token"); if (lockTokenHeader == null) lockTokenHeader = ""; if (isLocked(path, ifHeader + lockTokenHeader)) { resp.sendError(WebdavStatus.SC_LOCKED); return false; } // Retrieve the resources DirContext resources = getResources(); if (resources == null) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return false; } boolean exists = true; Object object = null; try { object = resources.lookup(path); } catch (NamingException e) { exists = false; } if (!exists) { resp.sendError(WebdavStatus.SC_NOT_FOUND); return false; } boolean collection = (object instanceof DirContext); if (!collection) { try { resources.unbind(path); } catch (NamingException e) { resp.sendError(WebdavStatus.SC_INTERNAL_SERVER_ERROR); return false; } } else { Hashtable errorList = new Hashtable(); deleteCollection(req, resources, path, errorList); try { resources.unbind(path); } catch (NamingException e) { errorList.put(path, new Integer (WebdavStatus.SC_INTERNAL_SERVER_ERROR)); } if (!errorList.isEmpty()) { sendReport(req, resp, errorList); return false; } } resp.setStatus(WebdavStatus.SC_NO_CONTENT); return true; } /** * Deletes a collection. * * @param resources Resources implementation associated with the context * @param path Path to the collection to be deleted * @param errorList Contains the list of the errors which occurred */ private void deleteCollection(HttpServletRequest req, DirContext resources, String path, Hashtable errorList) { if (debug > 1) System.out.println("Delete:" + path); if ((path.toUpperCase().startsWith("/WEB-INF")) || (path.toUpperCase().startsWith("/META-INF"))) { errorList.put(path, new Integer(WebdavStatus.SC_FORBIDDEN)); return; } String ifHeader = req.getHeader("If"); if (ifHeader == null) ifHeader = ""; String lockTokenHeader = req.getHeader("Lock-Token"); if (lockTokenHeader == null) lockTokenHeader = ""; Enumeration enum = null; try { enum = resources.list(path); } catch (NamingException e) { errorList.put(path, new Integer (WebdavStatus.SC_INTERNAL_SERVER_ERROR)); return; } while (enum.hasMoreElements()) { NameClassPair ncPair = (NameClassPair) enum.nextElement(); String childName = path; if (!childName.equals("/")) childName += "/"; childName += ncPair.getName(); if (isLocked(childName, ifHeader + lockTokenHeader)) { errorList.put(childName, new Integer(WebdavStatus.SC_LOCKED)); } else { try { Object object = resources.lookup(childName); if (object instanceof DirContext) { deleteCollection(req, resources, childName, errorList); } try { resources.unbind(childName); } catch (NamingException e) { if (!(object instanceof DirContext)) { // If it's not a collection, then it's an unknown // error errorList.put (childName, new Integer (WebdavStatus.SC_INTERNAL_SERVER_ERROR)); } } } catch (NamingException e) { errorList.put (childName, new Integer (WebdavStatus.SC_INTERNAL_SERVER_ERROR)); } } } } /** * Send a multistatus element containing a complete error report to the * client. * * @param req Servlet request * @param resp Servlet response * @param errorList List of error to be displayed */ private void sendReport(HttpServletRequest req, HttpServletResponse resp, Hashtable errorList) throws ServletException, IOException { resp.setStatus(WebdavStatus.SC_MULTI_STATUS); String absoluteUri = req.getRequestURI(); String relativePath = getRelativePath(req); XMLWriter generatedXML = new XMLWriter(); generatedXML.writeXMLHeader(); generatedXML.writeElement(null, "multistatus" + generateNamespaceDeclarations(), XMLWriter.OPENING); Enumeration pathList = errorList.keys(); while (pathList.hasMoreElements()) { String errorPath = (String) pathList.nextElement(); int errorCode = ((Integer) errorList.get(errorPath)).intValue(); generatedXML.writeElement(null, "response", XMLWriter.OPENING); generatedXML.writeElement(null, "href", XMLWriter.OPENING); String toAppend = errorPath.substring(relativePath.length()); if (!toAppend.startsWith("/")) toAppend = "/" + toAppend; generatedXML.writeText(absoluteUri + toAppend); generatedXML.writeElement(null, "href", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML .writeText("HTTP/1.1 " + errorCode + " " + WebdavStatus.getStatusText(errorCode)); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "response", XMLWriter.CLOSING); } generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING); Writer writer = resp.getWriter(); writer.write(generatedXML.toString()); writer.close(); } /** * Propfind helper method. * * @param resources Resources object associated with this context * @param generatedXML XML response to the Propfind request * @param path Path of the current resource * @param type Propfind type * @param propertiesVector If the propfind type is find properties by * name, then this Vector contains those properties */ private void parseProperties(HttpServletRequest req, DirContext resources, XMLWriter generatedXML, String path, int type, Vector propertiesVector) { // Exclude any resource in the /WEB-INF and /META-INF subdirectories // (the "toUpperCase()" avoids problems on Windows systems) if (path.toUpperCase().startsWith("/WEB-INF") || path.toUpperCase().startsWith("/META-INF")) return; ResourceInfo resourceInfo = new ResourceInfo(path, resources); generatedXML.writeElement(null, "response", XMLWriter.OPENING); String status = new String("HTTP/1.1 " + WebdavStatus.SC_OK + " " + WebdavStatus.getStatusText (WebdavStatus.SC_OK)); // Generating href element generatedXML.writeElement(null, "href", XMLWriter.OPENING); String href = req.getContextPath(); if ((href.endsWith("/")) && (path.startsWith("/"))) href += path.substring(1); else href += path; if ((resourceInfo.collection) && (!href.endsWith("/"))) href += "/"; generatedXML.writeText(rewriteUrl(href)); generatedXML.writeElement(null, "href", XMLWriter.CLOSING); String resourceName = path; int lastSlash = path.lastIndexOf('/'); if (lastSlash != -1) resourceName = resourceName.substring(lastSlash + 1); switch (type) { case FIND_ALL_PROP : generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); generatedXML.writeProperty (null, "creationdate", getISOCreationDate(resourceInfo.creationDate)); generatedXML.writeElement(null, "displayname", XMLWriter.OPENING); generatedXML.writeData(resourceName); generatedXML.writeElement(null, "displayname", XMLWriter.CLOSING); generatedXML.writeProperty(null, "getcontentlanguage", Locale.getDefault().toString()); if (!resourceInfo.collection) { generatedXML.writeProperty (null, "getlastmodified", resourceInfo.httpDate); generatedXML.writeProperty (null, "getcontentlength", String.valueOf(resourceInfo.length)); generatedXML.writeProperty (null, "getcontenttype", getServletContext().getMimeType(resourceInfo.path)); generatedXML.writeProperty(null, "getetag", getETagValue(resourceInfo)); generatedXML.writeElement(null, "resourcetype", XMLWriter.NO_CONTENT); } else { generatedXML.writeElement(null, "resourcetype", XMLWriter.OPENING); generatedXML.writeElement(null, "collection", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "resourcetype", XMLWriter.CLOSING); } generatedXML.writeProperty(null, "source", ""); String supportedLocks = "<lockentry>" + "<lockscope><exclusive/></lockscope>" + "<locktype><write/></locktype>" + "</lockentry>" + "<lockentry>" + "<lockscope><shared/></lockscope>" + "<locktype><write/></locktype>" + "</lockentry>"; generatedXML.writeElement(null, "supportedlock", XMLWriter.OPENING); generatedXML.writeText(supportedLocks); generatedXML.writeElement(null, "supportedlock", XMLWriter.CLOSING); generateLockDiscovery(path, generatedXML); generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); break; case FIND_PROPERTY_NAMES : generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); generatedXML.writeElement(null, "creationdate", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "displayname", XMLWriter.NO_CONTENT); if (!resourceInfo.collection) { generatedXML.writeElement(null, "getcontentlanguage", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getcontentlength", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getcontenttype", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getetag", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getlastmodified", XMLWriter.NO_CONTENT); } generatedXML.writeElement(null, "resourcetype", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "source", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "lockdiscovery", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); break; case FIND_BY_PROPERTY : Vector propertiesNotFound = new Vector(); // Parse the list of properties generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); Enumeration properties = propertiesVector.elements(); while (properties.hasMoreElements()) { String property = (String) properties.nextElement(); if (property.equals("creationdate")) { generatedXML.writeProperty (null, "creationdate", getISOCreationDate(resourceInfo.creationDate)); } else if (property.equals("displayname")) { generatedXML.writeElement (null, "displayname", XMLWriter.OPENING); generatedXML.writeData(resourceName); generatedXML.writeElement (null, "displayname", XMLWriter.CLOSING); } else if (property.equals("getcontentlanguage")) { if (resourceInfo.collection) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty (null, "getcontentlanguage", Locale.getDefault().toString()); } } else if (property.equals("getcontentlength")) { if (resourceInfo.collection) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty (null, "getcontentlength", (String.valueOf(resourceInfo.length))); } } else if (property.equals("getcontenttype")) { if (resourceInfo.collection) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty (null, "getcontenttype", getServletContext().getMimeType (resourceInfo.path)); } } else if (property.equals("getetag")) { if (resourceInfo.collection) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty (null, "getetag", getETagValue(resourceInfo)); } } else if (property.equals("getlastmodified")) { if (resourceInfo.collection) { propertiesNotFound.addElement(property); } else { generatedXML.writeProperty (null, "getlastmodified", resourceInfo.httpDate); } } else if (property.equals("resourcetype")) { if (resourceInfo.collection) { generatedXML.writeElement(null, "resourcetype", XMLWriter.OPENING); generatedXML.writeElement(null, "collection", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "resourcetype", XMLWriter.CLOSING); } else { generatedXML.writeElement(null, "resourcetype", XMLWriter.NO_CONTENT); } } else if (property.equals("source")) { generatedXML.writeProperty(null, "source", ""); } else if (property.equals("supportedlock")) { supportedLocks = "<lockentry>" + "<lockscope><exclusive/></lockscope>" + "<locktype><write/></locktype>" + "</lockentry>" + "<lockentry>" + "<lockscope><shared/></lockscope>" + "<locktype><write/></locktype>" + "</lockentry>"; generatedXML.writeElement(null, "supportedlock", XMLWriter.OPENING); generatedXML.writeText(supportedLocks); generatedXML.writeElement(null, "supportedlock", XMLWriter.CLOSING); } else if (property.equals("lockdiscovery")) { if (!generateLockDiscovery(path, generatedXML)) propertiesNotFound.addElement(property); } else { propertiesNotFound.addElement(property); } } generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); Enumeration propertiesNotFoundList = propertiesNotFound.elements(); if (propertiesNotFoundList.hasMoreElements()) { status = new String("HTTP/1.1 " + WebdavStatus.SC_NOT_FOUND + " " + WebdavStatus.getStatusText (WebdavStatus.SC_NOT_FOUND)); generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); while (propertiesNotFoundList.hasMoreElements()) { generatedXML.writeElement (null, (String) propertiesNotFoundList.nextElement(), XMLWriter.NO_CONTENT); } generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); } break; } generatedXML.writeElement(null, "response", XMLWriter.CLOSING); } /** * Propfind helper method. Dispays the properties of a lock-null resource. * * @param resources Resources object associated with this context * @param generatedXML XML response to the Propfind request * @param path Path of the current resource * @param type Propfind type * @param propertiesVector If the propfind type is find properties by * name, then this Vector contains those properties */ private void parseLockNullProperties(HttpServletRequest req, XMLWriter generatedXML, String path, int type, Vector propertiesVector) { // Exclude any resource in the /WEB-INF and /META-INF subdirectories // (the "toUpperCase()" avoids problems on Windows systems) if (path.toUpperCase().startsWith("/WEB-INF") || path.toUpperCase().startsWith("/META-INF")) return; // Retrieving the lock associated with the lock-null resource LockInfo lock = (LockInfo) resourceLocks.get(path); if (lock == null) return; generatedXML.writeElement(null, "response", XMLWriter.OPENING); String status = new String("HTTP/1.1 " + WebdavStatus.SC_OK + " " + WebdavStatus.getStatusText (WebdavStatus.SC_OK)); // Generating href element generatedXML.writeElement(null, "href", XMLWriter.OPENING); String absoluteUri = req.getRequestURI(); String relativePath = getRelativePath(req); String toAppend = path.substring(relativePath.length()); if (!toAppend.startsWith("/")) toAppend = "/" + toAppend; generatedXML.writeText(rewriteUrl(normalize(absoluteUri + toAppend))); generatedXML.writeElement(null, "href", XMLWriter.CLOSING); String resourceName = path; int lastSlash = path.lastIndexOf('/'); if (lastSlash != -1) resourceName = resourceName.substring(lastSlash + 1); switch (type) { case FIND_ALL_PROP : generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); generatedXML.writeProperty (null, "creationdate", getISOCreationDate(lock.creationDate.getTime())); generatedXML.writeElement (null, "displayname", XMLWriter.OPENING); generatedXML.writeData(resourceName); generatedXML.writeElement (null, "displayname", XMLWriter.CLOSING); generatedXML.writeProperty(null, "getcontentlanguage", Locale.getDefault().toString()); generatedXML.writeProperty(null, "getlastmodified", formats[0].format(lock.creationDate)); generatedXML.writeProperty (null, "getcontentlength", String.valueOf(0)); generatedXML.writeProperty(null, "getcontenttype", ""); generatedXML.writeProperty(null, "getetag", ""); generatedXML.writeElement(null, "resourcetype", XMLWriter.OPENING); generatedXML.writeElement(null, "lock-null", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "resourcetype", XMLWriter.CLOSING); generatedXML.writeProperty(null, "source", ""); String supportedLocks = "<lockentry>" + "<lockscope><exclusive/></lockscope>" + "<locktype><write/></locktype>" + "</lockentry>" + "<lockentry>" + "<lockscope><shared/></lockscope>" + "<locktype><write/></locktype>" + "</lockentry>"; generatedXML.writeElement(null, "supportedlock", XMLWriter.OPENING); generatedXML.writeText(supportedLocks); generatedXML.writeElement(null, "supportedlock", XMLWriter.CLOSING); generateLockDiscovery(path, generatedXML); generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); break; case FIND_PROPERTY_NAMES : generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); generatedXML.writeElement(null, "creationdate", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "displayname", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getcontentlanguage", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getcontentlength", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getcontenttype", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getetag", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "getlastmodified", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "resourcetype", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "source", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "lockdiscovery", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); break; case FIND_BY_PROPERTY : Vector propertiesNotFound = new Vector(); // Parse the list of properties generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); Enumeration properties = propertiesVector.elements(); while (properties.hasMoreElements()) { String property = (String) properties.nextElement(); if (property.equals("creationdate")) { generatedXML.writeProperty (null, "creationdate", getISOCreationDate(lock.creationDate.getTime())); } else if (property.equals("displayname")) { generatedXML.writeElement (null, "displayname", XMLWriter.OPENING); generatedXML.writeData(resourceName); generatedXML.writeElement (null, "displayname", XMLWriter.CLOSING); } else if (property.equals("getcontentlanguage")) { generatedXML.writeProperty (null, "getcontentlanguage", Locale.getDefault().toString()); } else if (property.equals("getcontentlength")) { generatedXML.writeProperty (null, "getcontentlength", (String.valueOf(0))); } else if (property.equals("getcontenttype")) { generatedXML.writeProperty (null, "getcontenttype", ""); } else if (property.equals("getetag")) { generatedXML.writeProperty(null, "getetag", ""); } else if (property.equals("getlastmodified")) { generatedXML.writeProperty (null, "getlastmodified", formats[0].format(lock.creationDate)); } else if (property.equals("resourcetype")) { generatedXML.writeElement(null, "resourcetype", XMLWriter.OPENING); generatedXML.writeElement(null, "lock-null", XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "resourcetype", XMLWriter.CLOSING); } else if (property.equals("source")) { generatedXML.writeProperty(null, "source", ""); } else if (property.equals("supportedlock")) { supportedLocks = "<lockentry>" + "<lockscope><exclusive/></lockscope>" + "<locktype><write/></locktype>" + "</lockentry>" + "<lockentry>" + "<lockscope><shared/></lockscope>" + "<locktype><write/></locktype>" + "</lockentry>"; generatedXML.writeElement(null, "supportedlock", XMLWriter.OPENING); generatedXML.writeText(supportedLocks); generatedXML.writeElement(null, "supportedlock", XMLWriter.CLOSING); } else if (property.equals("lockdiscovery")) { if (!generateLockDiscovery(path, generatedXML)) propertiesNotFound.addElement(property); } else { propertiesNotFound.addElement(property); } } generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); Enumeration propertiesNotFoundList = propertiesNotFound.elements(); if (propertiesNotFoundList.hasMoreElements()) { status = new String("HTTP/1.1 " + WebdavStatus.SC_NOT_FOUND + " " + WebdavStatus.getStatusText (WebdavStatus.SC_NOT_FOUND)); generatedXML.writeElement(null, "propstat", XMLWriter.OPENING); generatedXML.writeElement(null, "prop", XMLWriter.OPENING); while (propertiesNotFoundList.hasMoreElements()) { generatedXML.writeElement (null, (String) propertiesNotFoundList.nextElement(), XMLWriter.NO_CONTENT); } generatedXML.writeElement(null, "prop", XMLWriter.CLOSING); generatedXML.writeElement(null, "status", XMLWriter.OPENING); generatedXML.writeText(status); generatedXML.writeElement(null, "status", XMLWriter.CLOSING); generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING); } break; } generatedXML.writeElement(null, "response", XMLWriter.CLOSING); } /** * Print the lock discovery information associated with a path. * * @param path Path * @param generatedXML XML data to which the locks info will be appended * @return true if at least one lock was displayed */ private boolean generateLockDiscovery (String path, XMLWriter generatedXML) { LockInfo resourceLock = (LockInfo) resourceLocks.get(path); Enumeration collectionLocksList = collectionLocks.elements(); boolean wroteStart = false; if (resourceLock != null) { wroteStart = true; generatedXML.writeElement(null, "lockdiscovery", XMLWriter.OPENING); resourceLock.toXML(generatedXML); } while (collectionLocksList.hasMoreElements()) { LockInfo currentLock = (LockInfo) collectionLocksList.nextElement(); if (path.startsWith(currentLock.path)) { if (!wroteStart) { wroteStart = true; generatedXML.writeElement(null, "lockdiscovery", XMLWriter.OPENING); } currentLock.toXML(generatedXML); } } if (wroteStart) { generatedXML.writeElement(null, "lockdiscovery", XMLWriter.CLOSING); } else { return false; } return true; } /** * Get creation date in ISO format. */ private String getISOCreationDate(long creationDate) { StringBuffer creationDateValue = new StringBuffer (creationDateFormat.format (new Date(creationDate))); /* int offset = Calendar.getInstance().getTimeZone().getRawOffset() / 3600000; // FIXME ? if (offset < 0) { creationDateValue.append("-"); offset = -offset; } else if (offset > 0) { creationDateValue.append("+"); } if (offset != 0) { if (offset < 10) creationDateValue.append("0"); creationDateValue.append(offset + ":00"); } else { creationDateValue.append("Z"); } */ return creationDateValue.toString(); } // -------------------------------------------------- LockInfo Inner Class /** * Holds a lock information. */ private class LockInfo { // -------------------------------------------------------- Constructor /** * Constructor. * * @param pathname Path name of the file */ public LockInfo() { } // ------------------------------------------------- Instance Variables String path = "/"; String type = "write"; String scope = "exclusive"; int depth = 0; String owner = ""; Vector tokens = new Vector(); long expiresAt = 0; Date creationDate = new Date(); // ----------------------------------------------------- Public Methods /** * Get a String representation of this lock token. */ public String toString() { String result = "Type:" + type + "\n"; result += "Scope:" + scope + "\n"; result += "Depth:" + depth + "\n"; result += "Owner:" + owner + "\n"; result += "Expiration:" + formats[0].format(new Date(expiresAt)) + "\n"; Enumeration tokensList = tokens.elements(); while (tokensList.hasMoreElements()) { result += "Token:" + tokensList.nextElement() + "\n"; } return result; } /** * Return true if the lock has expired. */ public boolean hasExpired() { return (System.currentTimeMillis() > expiresAt); } /** * Return true if the lock is exclusive. */ public boolean isExclusive() { return (scope.equals("exclusive")); } /** * Get an XML representation of this lock token. This method will * append an XML fragment to the given XML writer. */ public void toXML(XMLWriter generatedXML) { toXML(generatedXML, false); } /** * Get an XML representation of this lock token. This method will * append an XML fragment to the given XML writer. */ public void toXML(XMLWriter generatedXML, boolean showToken) { generatedXML.writeElement(null, "activelock", XMLWriter.OPENING); generatedXML.writeElement(null, "locktype", XMLWriter.OPENING); generatedXML.writeElement(null, type, XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "locktype", XMLWriter.CLOSING); generatedXML.writeElement(null, "lockscope", XMLWriter.OPENING); generatedXML.writeElement(null, scope, XMLWriter.NO_CONTENT); generatedXML.writeElement(null, "lockscope", XMLWriter.CLOSING); generatedXML.writeElement(null, "depth", XMLWriter.OPENING); if (depth == INFINITY) { generatedXML.writeText("Infinity"); } else { generatedXML.writeText("0"); } generatedXML.writeElement(null, "depth", XMLWriter.CLOSING); generatedXML.writeElement(null, "owner", XMLWriter.OPENING); generatedXML.writeText(owner); generatedXML.writeElement(null, "owner", XMLWriter.CLOSING); generatedXML.writeElement(null, "timeout", XMLWriter.OPENING); long timeout = (expiresAt - System.currentTimeMillis()) / 1000; generatedXML.writeText("Second-" + timeout); generatedXML.writeElement(null, "timeout", XMLWriter.CLOSING); generatedXML.writeElement(null, "locktoken", XMLWriter.OPENING); if (showToken) { Enumeration tokensList = tokens.elements(); while (tokensList.hasMoreElements()) { generatedXML.writeElement(null, "href", XMLWriter.OPENING); generatedXML.writeText("opaquelocktoken:" + tokensList.nextElement()); generatedXML.writeElement(null, "href", XMLWriter.CLOSING); } } else { generatedXML.writeElement(null, "href", XMLWriter.OPENING); generatedXML.writeText("opaquelocktoken:dummytoken"); generatedXML.writeElement(null, "href", XMLWriter.CLOSING); } generatedXML.writeElement(null, "locktoken", XMLWriter.CLOSING); generatedXML.writeElement(null, "activelock", XMLWriter.CLOSING); } } // --------------------------------------------------- Property Inner Class private class Property { public String name; public String value; public String namespace; public String namespaceAbbrev; public int status = WebdavStatus.SC_OK; } }; // -------------------------------------------------------- WebdavStatus Class /** * Wraps the HttpServletResponse class to abstract the * specific protocol used. To support other protocols * we would only need to modify this class and the * WebDavRetCode classes. * * @author Marc Eaddy * @version 1.0, 16 Nov 1997 */ class WebdavStatus { // ----------------------------------------------------- Instance Variables /** * This Hashtable contains the mapping of HTTP and WebDAV * status codes to descriptive text. This is a static * variable. */ private static Hashtable mapStatusCodes = new Hashtable(); // ------------------------------------------------------ HTTP Status Codes /** * Status code (200) indicating the request succeeded normally. */ public static final int SC_OK = HttpServletResponse.SC_OK; /** * Status code (201) indicating the request succeeded and created * a new resource on the server. */ public static final int SC_CREATED = HttpServletResponse.SC_CREATED; /** * Status code (202) indicating that a request was accepted for * processing, but was not completed. */ public static final int SC_ACCEPTED = HttpServletResponse.SC_ACCEPTED; /** * Status code (204) indicating that the request succeeded but that * there was no new information to return. */ public static final int SC_NO_CONTENT = HttpServletResponse.SC_NO_CONTENT; /** * Status code (301) indicating that the resource has permanently * moved to a new location, and that future references should use a * new URI with their requests. */ public static final int SC_MOVED_PERMANENTLY = HttpServletResponse.SC_MOVED_PERMANENTLY; /** * Status code (302) indicating that the resource has temporarily * moved to another location, but that future references should * still use the original URI to access the resource. */ public static final int SC_MOVED_TEMPORARILY = HttpServletResponse.SC_MOVED_TEMPORARILY; /** * Status code (304) indicating that a conditional GET operation * found that the resource was available and not modified. */ public static final int SC_NOT_MODIFIED = HttpServletResponse.SC_NOT_MODIFIED; /** * Status code (400) indicating the request sent by the client was * syntactically incorrect. */ public static final int SC_BAD_REQUEST = HttpServletResponse.SC_BAD_REQUEST; /** * Status code (401) indicating that the request requires HTTP * authentication. */ public static final int SC_UNAUTHORIZED = HttpServletResponse.SC_UNAUTHORIZED; /** * Status code (403) indicating the server understood the request * but refused to fulfill it. */ public static final int SC_FORBIDDEN = HttpServletResponse.SC_FORBIDDEN; /** * Status code (404) indicating that the requested resource is not * available. */ public static final int SC_NOT_FOUND = HttpServletResponse.SC_NOT_FOUND; /** * Status code (500) indicating an error inside the HTTP service * which prevented it from fulfilling the request. */ public static final int SC_INTERNAL_SERVER_ERROR = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; /** * Status code (501) indicating the HTTP service does not support * the functionality needed to fulfill the request. */ public static final int SC_NOT_IMPLEMENTED = HttpServletResponse.SC_NOT_IMPLEMENTED; /** * Status code (502) indicating that the HTTP server received an * invalid response from a server it consulted when acting as a * proxy or gateway. */ public static final int SC_BAD_GATEWAY = HttpServletResponse.SC_BAD_GATEWAY; /** * Status code (503) indicating that the HTTP service is * temporarily overloaded, and unable to handle the request. */ public static final int SC_SERVICE_UNAVAILABLE = HttpServletResponse.SC_SERVICE_UNAVAILABLE; /** * Status code (100) indicating the client may continue with * its request. This interim response is used to inform the * client that the initial part of the request has been * received and has not yet been rejected by the server. */ public static final int SC_CONTINUE = 100; /** * Status code (405) indicating the method specified is not * allowed for the resource. */ public static final int SC_METHOD_NOT_ALLOWED = 405; /** * Status code (409) indicating that the request could not be * completed due to a conflict with the current state of the * resource. */ public static final int SC_CONFLICT = 409; /** * Status code (412) indicating the precondition given in one * or more of the request-header fields evaluated to false * when it was tested on the server. */ public static final int SC_PRECONDITION_FAILED = 412; /** * Status code (413) indicating the server is refusing to * process a request because the request entity is larger * than the server is willing or able to process. */ public static final int SC_REQUEST_TOO_LONG = 413; /** * Status code (415) indicating the server is refusing to service * the request because the entity of the request is in a format * not supported by the requested resource for the requested * method. */ public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415; // -------------------------------------------- Extended WebDav status code /** * Status code (207) indicating that the response requires * providing status for multiple independent operations. */ public static final int SC_MULTI_STATUS = 207; // This one colides with HTTP 1.1 // "207 Parital Update OK" /** * Status code (418) indicating the entity body submitted with * the PATCH method was not understood by the resource. */ public static final int SC_UNPROCESSABLE_ENTITY = 418; // This one colides with HTTP 1.1 // "418 Reauthentication Required" /** * Status code (419) indicating that the resource does not have * sufficient space to record the state of the resource after the * execution of this method. */ public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419; // This one colides with HTTP 1.1 // "419 Proxy Reauthentication Required" /** * Status code (420) indicating the method was not executed on * a particular resource within its scope because some part of * the method's execution failed causing the entire method to be * aborted. */ public static final int SC_METHOD_FAILURE = 420; /** * Status code (423) indicating the destination resource of a * method is locked, and either the request did not contain a * valid Lock-Info header, or the Lock-Info header identifies * a lock held by another principal. */ public static final int SC_LOCKED = 423; // ------------------------------------------------------------ Initializer static { // HTTP 1.0 tatus Code addStatusCodeMap(SC_OK, "OK"); addStatusCodeMap(SC_CREATED, "Created"); addStatusCodeMap(SC_ACCEPTED, "Accepted"); addStatusCodeMap(SC_NO_CONTENT, "No Content"); addStatusCodeMap(SC_MOVED_PERMANENTLY, "Moved Permanently"); addStatusCodeMap(SC_MOVED_TEMPORARILY, "Moved Temporarily"); addStatusCodeMap(SC_NOT_MODIFIED, "Not Modified"); addStatusCodeMap(SC_BAD_REQUEST, "Bad Request"); addStatusCodeMap(SC_UNAUTHORIZED, "Unauthorized"); addStatusCodeMap(SC_FORBIDDEN, "Forbidden"); addStatusCodeMap(SC_NOT_FOUND, "Not Found"); addStatusCodeMap(SC_INTERNAL_SERVER_ERROR, "Internal Server Error"); addStatusCodeMap(SC_NOT_IMPLEMENTED, "Not Implemented"); addStatusCodeMap(SC_BAD_GATEWAY, "Bad Gateway"); addStatusCodeMap(SC_SERVICE_UNAVAILABLE, "Service Unavailable"); addStatusCodeMap(SC_CONTINUE, "Continue"); addStatusCodeMap(SC_METHOD_NOT_ALLOWED, "Method Not Allowed"); addStatusCodeMap(SC_CONFLICT, "Conflict"); addStatusCodeMap(SC_PRECONDITION_FAILED, "Precondition Failed"); addStatusCodeMap(SC_REQUEST_TOO_LONG, "Request Too Long"); addStatusCodeMap(SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type"); // WebDav Status Codes addStatusCodeMap(SC_MULTI_STATUS, "Multi-Status"); addStatusCodeMap(SC_UNPROCESSABLE_ENTITY, "Unprocessable Entity"); addStatusCodeMap(SC_INSUFFICIENT_SPACE_ON_RESOURCE, "Insufficient Space On Resource"); addStatusCodeMap(SC_METHOD_FAILURE, "Method Failure"); addStatusCodeMap(SC_LOCKED, "Locked"); } // --------------------------------------------------------- Public Methods /** * Returns the HTTP status text for the HTTP or WebDav status code * specified by looking it up in the static mapping. This is a * static function. * * @param nHttpStatusCode [IN] HTTP or WebDAV status code * @return A string with a short descriptive phrase for the * HTTP status code (e.g., "OK"). */ public static String getStatusText(int nHttpStatusCode) { Integer intKey = new Integer(nHttpStatusCode); if (!mapStatusCodes.containsKey(intKey)) { return ""; } else { return (String) mapStatusCodes.get(intKey); } } // -------------------------------------------------------- Private Methods /** * Adds a new status code -> status text mapping. This is a static * method because the mapping is a static variable. * * @param nKey [IN] HTTP or WebDAV status code * @param strVal [IN] HTTP status text */ private static void addStatusCodeMap(int nKey, String strVal) { mapStatusCodes.put(new Integer(nKey), strVal); } };
[ "wangyue.wy@taobao.com" ]
wangyue.wy@taobao.com
68a108721bef795eef775b77fdef3014445dbb2e
a01ffaf0095c7f4ef3346bc67bbd4f3c5ffceb14
/BehaverialPattern/src/main/java/epam/com/BehaverialPattern/IteratorMain.java
1bce3bfde76b1667bdd5524a4ca5003e96b1722d
[]
no_license
nikitha02/GaddamNikitha_Design_patterns
f277555c8496ad0be0c87e4877f22956bb457948
ec247c1b05a23dffb131d506c2a21948f938ab95
refs/heads/master
2021-03-05T01:57:50.670115
2020-03-09T16:35:03
2020-03-09T16:35:03
246,086,468
0
0
null
2020-10-13T20:13:03
2020-03-09T16:27:34
Java
UTF-8
Java
false
false
328
java
package epam.com.BehaverialPattern; public class IteratorMain { public static void main(String[] args) { // TODO Auto-generated method stub Students std = new Students(); for(Iterator itr = std.getIterator();itr.hasnext();){ String student = (String)itr.next(); System.out.println("Students:"+student); } } }
[ "Nikitha@NikithaReddy" ]
Nikitha@NikithaReddy
349b683931d8d5106bd082b56afcd165a21eeb1f
9ab1f0fed5dc75b5c34e92e89e01ac4d032b1c18
/src/test/java/ch/tdd/DummyTest.java
766f4b497dc346a2b0ec3fb4d0dadecb3a7befeb
[]
no_license
hfu-tdd/tdd-starter-gradle
77e7212615a45b4d1bc35f9771634feaa3a332c4
f17a87d69eec31e899f262f4625237010e7c446a
refs/heads/master
2021-01-19T22:13:47.064207
2017-04-19T17:44:16
2017-04-19T17:44:16
88,771,202
0
1
null
null
null
null
UTF-8
Java
false
false
202
java
package ch.tdd; import org.junit.Test; import static org.junit.Assert.assertTrue; public class DummyTest { @Test public void dummyTest() throws Exception { assertTrue(true); } }
[ "marius.reusch@googlemail.com" ]
marius.reusch@googlemail.com
6bc76d184452735498f3eb0fdd2c7c94803f47d7
d4600947345d60be335584a65ca58e5b995584f5
/PolljoyTestApp/src/com/polljoy/testapp/PJApplication.java
c54611e724a0776035bc851f067c28631b97afeb
[ "BSD-3-Clause" ]
permissive
dennismunene/PollJoy-android
59a6e50d4847cacfe54710b8b4608d9c3552f3ca
94950b3b17b741898ea389f00a9a58a316ab876a
refs/heads/master
2021-01-15T12:15:35.423429
2014-05-01T15:06:40
2014-05-01T15:06:40
null
0
0
null
null
null
null
UTF-8
Java
false
false
447
java
package com.polljoy.testapp; import com.polljoy.Polljoy; import android.app.Application; public class PJApplication extends Application { @Override public void onCreate() { super.onCreate(); Polljoy.setSandboxMode(true); // register your Polljoy session here. // check YOUR_APP_ID in Polljoy admin panel // ** please remember to add an app and assign to the polls you created. Polljoy.startSession(this, "YOUR_APP_ID"); } }
[ "jameszhao1116@gmail.com" ]
jameszhao1116@gmail.com
811cd9f223791643821b1cd533aa2a3aa757e53c
0008d71b9a38947b71193db121efa1155cbdf4e6
/src/main/java/com/usage/reentrant/tryLockDemo3/Client.java
054f00660a24375e76d42ab330c6918ef64626ba
[]
no_license
Harshal-Git/Concurrency
fc434b0cc32ffb85918f062258dba3ed4c9334d0
5f7e5878fd1a35f2a6dda229637996ed3d38c261
refs/heads/main
2023-06-25T07:26:45.738162
2021-07-28T11:16:00
2021-07-28T11:16:00
385,238,532
0
0
null
null
null
null
UTF-8
Java
false
false
982
java
/** * */ package com.usage.reentrant.tryLockDemo3; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.locks.ReentrantLock; /** * @author Harshal-Git * */ public class Client { private static final int MAX_THREAD = 3; /** * @param args */ public static void main(String[] args) { // prepare a common Reentrant thread ReentrantLock rLock = new ReentrantLock(); // prepare executor service batch ExecutorService batch = Executors.newFixedThreadPool(MAX_THREAD); // prepare runnable instances WorkerRunnable wr1 = new WorkerRunnable(rLock, "W1"); WorkerRunnable wr2 = new WorkerRunnable(rLock, "W2"); WorkerRunnable wr3 = new WorkerRunnable(rLock, "W3"); WorkerRunnable wr4 = new WorkerRunnable(rLock, "W4"); // submit instances to batch batch.execute(wr1); batch.execute(wr2); batch.execute(wr3); batch.execute(wr4); // shutdown service batch.shutdown(); } }
[ "47755408+Harshal-Git@users.noreply.github.com" ]
47755408+Harshal-Git@users.noreply.github.com
cfaceb6fd5bbad84e5d5153ee8f486839d2e5c31
0a3610b30829f4f458b7cd830d8da812c99e101b
/TD1-Xamarin/TD1_Xamarin.Android/obj/Debug/android/src/mono/MonoPackageManager.java
cbaaf9bde398598bc70f0dab76458462b02a050b
[]
no_license
remiDupuy/XamarinTD1
d2099fcb22972fd0807c920e31b3cc7a2456b10a
27556eb841c673bd7a60c2ed2e3d8b004370c6e6
refs/heads/master
2021-03-22T01:20:12.727522
2018-02-13T09:11:49
2018-02-13T09:11:49
121,361,552
0
0
null
null
null
null
UTF-8
Java
false
false
3,676
java
package mono; import java.io.*; import java.lang.String; import java.util.Locale; import java.util.HashSet; import java.util.zip.*; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.res.AssetManager; import android.util.Log; import mono.android.Runtime; public class MonoPackageManager { static Object lock = new Object (); static boolean initialized; static android.content.Context Context; public static void LoadApplication (Context context, ApplicationInfo runtimePackage, String[] apks) { synchronized (lock) { if (context instanceof android.app.Application) { Context = context; } if (!initialized) { android.content.IntentFilter timezoneChangedFilter = new android.content.IntentFilter ( android.content.Intent.ACTION_TIMEZONE_CHANGED ); context.registerReceiver (new mono.android.app.NotifyTimeZoneChanges (), timezoneChangedFilter); System.loadLibrary("monodroid"); Locale locale = Locale.getDefault (); String language = locale.getLanguage () + "-" + locale.getCountry (); String filesDir = context.getFilesDir ().getAbsolutePath (); String cacheDir = context.getCacheDir ().getAbsolutePath (); String dataDir = getNativeLibraryPath (context); ClassLoader loader = context.getClassLoader (); Runtime.init ( language, apks, getNativeLibraryPath (runtimePackage), new String[]{ filesDir, cacheDir, dataDir, }, loader, new java.io.File ( android.os.Environment.getExternalStorageDirectory (), "Android/data/" + context.getPackageName () + "/files/.__override__").getAbsolutePath (), MonoPackageManager_Resources.Assemblies, context.getPackageName ()); mono.android.app.ApplicationRegistration.registerApplications (); initialized = true; } } } public static void setContext (Context context) { // Ignore; vestigial } static String getNativeLibraryPath (Context context) { return getNativeLibraryPath (context.getApplicationInfo ()); } static String getNativeLibraryPath (ApplicationInfo ainfo) { if (android.os.Build.VERSION.SDK_INT >= 9) return ainfo.nativeLibraryDir; return ainfo.dataDir + "/lib"; } public static String[] getAssemblies () { return MonoPackageManager_Resources.Assemblies; } public static String[] getDependencies () { return MonoPackageManager_Resources.Dependencies; } public static String getApiPackageName () { return MonoPackageManager_Resources.ApiPackageName; } } class MonoPackageManager_Resources { public static final String[] Assemblies = new String[]{ /* We need to ensure that "TD1_Xamarin.Android.dll" comes first in this list. */ "TD1_Xamarin.Android.dll", "CommonServiceLocator.dll", "FormsViewGroup.dll", "GalaSoft.MvvmLight.dll", "GalaSoft.MvvmLight.Extras.dll", "GalaSoft.MvvmLight.Platform.dll", "Newtonsoft.Json.dll", "Xamarin.Android.Support.Animated.Vector.Drawable.dll", "Xamarin.Android.Support.Design.dll", "Xamarin.Android.Support.v4.dll", "Xamarin.Android.Support.v7.AppCompat.dll", "Xamarin.Android.Support.v7.CardView.dll", "Xamarin.Android.Support.v7.MediaRouter.dll", "Xamarin.Android.Support.v7.RecyclerView.dll", "Xamarin.Android.Support.Vector.Drawable.dll", "Xamarin.Forms.Core.dll", "Xamarin.Forms.Platform.Android.dll", "Xamarin.Forms.Platform.dll", "Xamarin.Forms.Xaml.dll", }; public static final String[] Dependencies = new String[]{ }; public static final String ApiPackageName = "Mono.Android.Platform.ApiLevel_23"; }
[ "remi.dup73@gmail.com" ]
remi.dup73@gmail.com
bac99203fee0b27076bc4155c03fffd557d26a02
e554df3b17fa36469ec71c9a798e59f59434de0a
/src/charactermaker/model/items/armor/Padded.java
ecbbf188c06eb8cce37d582cd14f9ebdd3932aed
[]
no_license
Ikegorgon/DnDCharacterMaker
8d6b779bd61b5473acfb0353dbf67f98643a0391
0005520a3447c7b5ae1ebff016e4bb1cd420b458
refs/heads/master
2020-03-16T03:39:56.088672
2018-06-27T17:02:46
2018-06-27T17:02:46
132,492,530
0
0
null
null
null
null
UTF-8
Java
false
false
217
java
package charactermaker.model.items.armor; public class Padded extends Armor{ public Padded() { super("Padded", "5 gp", " 11 + Dex modifier", "-", "Disadvantage", "8 lb.", "Light"); this.setDescription(""); } }
[ "31518729+Ikegorgon@users.noreply.github.com" ]
31518729+Ikegorgon@users.noreply.github.com
7306077b8e7be247ea6f32944b3f63212222d6de
083d72ab12898894f0efa87b73ad4b59d46fdda3
/trunk/source/Library-UltimateModel/src/de/uni_freiburg/informatik/ultimate/core/model/services/IResultService.java
7990ebe61fd3788c9c7e8a75859def6d5a00621f
[]
no_license
utopia-group/SmartPulseTool
19db821090c3a2d19bad6de690b5153bd55e8a92
92c920429d6946ff754c3d307943bcaeceba9a40
refs/heads/master
2023-06-09T04:10:52.900609
2021-06-06T18:30:15
2021-06-06T18:30:15
276,487,368
8
6
null
null
null
null
UTF-8
Java
false
false
2,902
java
/* * Copyright (C) 2014-2015 Daniel Dietsch (dietsch@informatik.uni-freiburg.de) * Copyright (C) 2015 University of Freiburg * * This file is part of the ULTIMATE Core. * * The ULTIMATE Core is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ULTIMATE Core is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with the ULTIMATE Core. If not, see <http://www.gnu.org/licenses/>. * * Additional permission under GNU GPL version 3 section 7: * If you modify the ULTIMATE Core, or any covered work, by linking * or combining it with Eclipse RCP (or a modified version of Eclipse RCP), * containing parts covered by the terms of the Eclipse Public License, the * licensors of the ULTIMATE Core grant you additional permission * to convey the resulting work. */ package de.uni_freiburg.informatik.ultimate.core.model.services; import java.util.List; import java.util.Map; import java.util.function.Function; import de.uni_freiburg.informatik.ultimate.core.model.results.IResult; /** * {@link IResultService} allows tools to report results. * * @author Daniel Dietsch (dietsch@informatik.uni-freiburg.de) */ public interface IResultService { /** * @return A map containing all results of a toolchain up to now. */ Map<String, List<IResult>> getResults(); /** * Report a result to the Ultimate result service. The result must not be {@code null} and must not contain * {@code null} values (i.e., at least {@link IResult#getShortDescription()} and * {@link IResult#getLongDescription()} must not be {@code null}). * * @param pluginId * The plugin ID of the tool which generated the result. * @param result * The result itself. */ void reportResult(String pluginId, IResult result); /** * Register a transformer function that is applied to <b>all</b> results during * {@link #reportResult(String, IResult)}. If the transformer returns null for a result, this result is dropped. * * If multiple transformers are registered, they are executed in their registration order. * * Currently, you cannot unregister transformers. * * @param name * the name of the transformer; useful for debugging * @param resultTransformer * the transformer function. */ void registerTransformer(final String name, final Function<IResult, IResult> resultTransformer); }
[ "jon@users-MacBook-Pro.local" ]
jon@users-MacBook-Pro.local
8d639994897aa792b38093e3374b25b30768aaa8
8974003e939fd82c45692bc0f0c0210fd4913af0
/src/main/java/com/qfedu/service/UserService.java
69635c76a9c9e067d7236a35cea90f097d98dbab
[]
no_license
pipifang/SSM
aab0be76a8a00c4881de64209d73de76ab01264c
7326321ea2a0aaf4adea5a1ffb16ce13c169badf
refs/heads/master
2020-04-13T09:55:25.241967
2019-01-04T06:30:10
2019-01-04T06:30:10
163,124,547
0
0
null
null
null
null
UTF-8
Java
false
false
402
java
package com.qfedu.service; import com.qfedu.comment.vo.Result; import com.qfedu.domain.User; public interface UserService { /** * 上传头像 * @param user * @return */ Result updateHeadImage(User user); /** * 修改用户信息 * @param user * @return */ Result updateUserInfo(User user); }
[ "1658119598@qq.com" ]
1658119598@qq.com
9d7ad4f91aca43be136ad5e73a83d286a0c6405a
2f2ebebe2dc7e48b68c54cc88b69061ade8a394d
/app/src/main/java/com/sayem/geeknot/ghdb/MedicalHistory/Fragment_medical4.java
0e597b5c4767dfe7da988e5d0b94c753c92cd981
[]
no_license
Sayem007/GHDB
dfad4f37910b97525772999c78717a0b94ec68d1
7bd80baef10277ff7298c461aaeab9d8f572f4cd
refs/heads/master
2021-09-01T04:12:46.247979
2017-12-24T17:40:38
2017-12-24T17:40:38
114,869,303
0
0
null
null
null
null
UTF-8
Java
false
false
740
java
package com.sayem.geeknot.ghdb.MedicalHistory; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.sayem.geeknot.ghdb.R; /** * Created by Sayem on 12/15/2017. */ public class Fragment_medical4 extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView=inflater.inflate(R.layout.fragment_medical4,container,false); return rootView; } @Override public String toString() { String title="VACCINATIONS"; return title; } }
[ "sayembubt@gmail.com" ]
sayembubt@gmail.com
e73f73a4aca24ab20b950306673679ff3bfd40c6
16ea69af51869d4a4b8e8e4e3ab3eeba8f691f1b
/src/main/resources/code/M_307_RangeSumQueryMutable.java
25e09077ec2e262a3f1d1050d9651127e73ddf11
[]
no_license
offerpie/LeetCodeSpider
e97f0b8b3278a27b0406e874ad93e14e367a92a2
3d6eb8244e2f03de49a168bcf94a57bd1c7bc7b9
refs/heads/master
2020-04-14T23:11:01.070872
2018-08-21T16:00:12
2018-08-21T16:00:12
164,192,792
1
0
null
2019-01-05T07:32:42
2019-01-05T07:32:42
null
UTF-8
Java
false
false
1,758
java
/** * [307] Range Sum Query - Mutable * * difficulty: Medium * * TestCase Example: ["NumArray","sumRange","update","sumRange"] [[[1,3,5]],[0,2],[1,2],[0,2]] * * https://leetcode-cn.com/problems/range-sum-query-mutable/ * * * Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. * * The update(i, val) function modifies nums by updating the element at index i to val. * * Example: * * * Given nums = [1, 3, 5] * * sumRange(0, 2) -> 9 * update(1, 2) * sumRange(0, 2) -> 8 * * * Note: * * * The array is only modifiable by the update function. * You may assume the number of calls to update and sumRange function is distributed evenly. * * * * * >>>>>>中文描述<<<<<< * * * [307] 区域和检索 - 数组可修改 * * * 给定一个整数数组 nums,求出数组从索引 i 到 j (i ≤ j) 范围内元素的总和,包含 i, j 两点。 * * update(i, val) 函数可以通过将下标为 i 的数值更新为 val,从而对数列进行修改。 * * 示例: * * Given nums = [1, 3, 5] * * sumRange(0, 2) -> 9 * update(1, 2) * sumRange(0, 2) -> 8 * * * 说明: * * * 数组仅可以在 update 函数下进行修改。 * 你可以假设 update 函数与 sumRange 函数的调用次数是均匀分布的。 * */ class NumArray { public NumArray(int[] nums) { } public void update(int i, int val) { } public int sumRange(int i, int j) { } } /** * Your NumArray object will be instantiated and called as such: * NumArray obj = new NumArray(nums); * obj.update(i,val); * int param_2 = obj.sumRange(i,j); */
[ "techflowing@gmail.com" ]
techflowing@gmail.com
986fcdf0df9102126eb39ffd8bc2761d1246e146
3072328d3f644d80432fbb3a1e8bab2a8f8339ef
/app/src/main/java/com/yupi/home/panikerapp/fragments/InviteFriendFragment.java
ce873f9586f69a677149da6835e0415595800146
[]
no_license
Corresol/Paniker
18e31151f0920359cee4abd6da274c95538b265b
5588fe11825c71274a23258c50aa923bee5c7be0
refs/heads/master
2021-04-30T04:43:00.208899
2018-02-14T17:55:30
2018-02-14T17:55:30
121,542,290
0
0
null
null
null
null
UTF-8
Java
false
false
1,991
java
package com.yupi.home.panikerapp.fragments; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import com.yupi.home.panikerapp.R; import java.util.ArrayList; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; /** * A simple {@link Fragment} subclass. */ public class InviteFriendFragment extends Fragment { @BindView(R.id.listView) ListView listView; ArrayList<String> integers; ArrayAdapter<String> adapter; @BindView(R.id.topic) TextView topic; public InviteFriendFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_invite_friend, container, false); ButterKnife.bind(this, view); integers = new ArrayList<>(); integers.add("John Doe"); integers.add("John Doe"); integers.add("John Doe"); integers.add("John Doe"); adapter = new ArrayAdapter<String>(getActivity(), R.layout.invite_friends_adapter_layout, R.id.name, integers); listView.setAdapter(adapter); topic.setText("Invite friends"); return view; } @OnClick({R.id.returnBack}) public void returnBack(View view){ switch (view.getId()){ case R.id.returnBack: FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.remove(InviteFriendFragment.this).commit(); break; } } }
[ "corresol@corresols-iMac.local" ]
corresol@corresols-iMac.local
b76d240d2abbdbcc4601868a117dd8c47366885f
dd2346f5994ab072aa61ebff9baafffe9b855b0c
/app/src/main/java/com/holike/crm/adapter/customer/CustomerRoundsAdapter.java
d7732511049e3f627e983eed07a41d67a9e08884
[]
no_license
stozen/HolikeCRM_V2
210573d8d27406629a373da08424d50dbc7d6710
752d00ef33f866e562d056ec88fe3e12695856fa
refs/heads/master
2020-07-19T20:53:47.228264
2019-08-28T09:52:25
2019-08-28T09:52:25
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,076
java
package com.holike.crm.adapter.customer; import android.content.Context; import android.text.TextUtils; import android.view.View; import com.holike.crm.R; import com.holike.crm.adapter.CustomerStatusListAdapter; import com.holike.crm.bean.CustomerStatusBean; import com.holike.crm.bean.MultiItem; import java.util.List; /** * Created by gallop on 2019/7/11. * Copyright holike possess 2019. * 待查房客户列表 */ public class CustomerRoundsAdapter extends CustomerStatusListAdapter { private String mTipsUploadDate, mTipsSource, mTipsDesigner, mTipsReservation, mTipsCountdown; public CustomerRoundsAdapter(Context context, List<MultiItem> mDatas) { super(context, mDatas); mTipsUploadDate = context.getString(R.string.followup_upload_scheme); mTipsSource = context.getString(R.string.customer_source_tips); mTipsDesigner = context.getString(R.string.followup_designer); mTipsReservation = context.getString(R.string.followup_reservation); mTipsCountdown = context.getString(R.string.customer_countdown_tips); } @Override public void setup(RecyclerHolder holder, CustomerStatusBean.InnerBean bean, int position) { holder.setText(R.id.tv_upload_date, obtain2(mTipsUploadDate, wrap(bean.uploadPlanDate))); //上传方案时间 holder.setText(R.id.tv_source, obtain(mTipsSource, bean.source, false)); //来源 holder.setText(R.id.tv_designer, obtain(mTipsDesigner, wrap(bean.designer), false)); //设计师 holder.setText(R.id.tv_reservation, obtain2(mTipsReservation, wrap(bean.measureAppConfirmTime))); //确图 if (TextUtils.isEmpty(bean.customerProtectTime)) { holder.setVisibility(R.id.tv_countdown, View.GONE); } else { holder.setText(R.id.tv_countdown, obtain2(mTipsCountdown, bean.customerProtectTime)); holder.setVisibility(R.id.tv_countdown, View.VISIBLE); } } @Override public int bindLayoutResId() { return R.layout.item_rv_customer_status_rounds_v2; } }
[ "i23xiaoyan@qq.com" ]
i23xiaoyan@qq.com
b17fae1a5f3e3d0ca081ab3227acf739f35060b6
7f1ca8a064a687cb8ec25d85e365ebda4ca1a103
/src/main/java/com/zeljic/posubtools/controllers/BootController.java
46f116129bbafe734985ccbb42ea4751b19f0558
[]
no_license
zeljic/POSubTools
ffcf92f4a9300eaba5446c239ecbb5872ec5e823
bb79c2aa9344cc6042ad52955dfa7bcc5cab0c9f
refs/heads/master
2020-04-11T04:26:47.522906
2015-05-05T16:39:06
2015-05-05T16:39:06
22,114,219
0
0
null
null
null
null
UTF-8
Java
false
false
909
java
package com.zeljic.posubtools.controllers; import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.geometry.Orientation; import javafx.scene.control.Button; import javafx.scene.control.SplitPane; import javafx.scene.control.TableView; import com.zeljic.posubtools.parser.Item; public class BootController implements Initializable { private URL url; private ResourceBundle bundle; @FXML private Button btnOpen, btnSave, btnReset, btnRun, btnLayout; @FXML private TableView<Item> tvSource, tvResult; @FXML private SplitPane spMain; @Override public void initialize(URL url, ResourceBundle bundle) { this.url = url; this.bundle = bundle; } @FXML private void btnLayoutOnAction() { spMain.setOrientation( Orientation.HORIZONTAL == spMain.getOrientation() ? Orientation.VERTICAL : Orientation.HORIZONTAL ); } }
[ "zeljic@gmail.com" ]
zeljic@gmail.com
7ede1d6faef8f2196f87227ba08d6ed3a3b18186
497fcb88c10c94fed1caa160ee110561c07b594c
/platform/standalone-server/src/main/java/com/yazino/model/document/SendGameMessageRequest.java
8d6ab7803767bdefdbabe90e2e01886fdeaefb91
[]
no_license
ShahakBH/jazzino-master
3f116a609c5648c00dfbe6ab89c6c3ce1903fc1a
2401394022106d2321873d15996953f2bbc2a326
refs/heads/master
2016-09-02T01:26:44.514049
2015-08-10T13:06:54
2015-08-10T13:06:54
40,482,590
0
1
null
null
null
null
UTF-8
Java
false
false
1,212
java
package com.yazino.model.document; import java.math.BigDecimal; import java.util.HashSet; import java.util.Set; public class SendGameMessageRequest { private String body; private String type; private String playerIds; private boolean tableMessage; public boolean isTableMessage() { return tableMessage; } public void setTableMessage(final boolean tableMessage) { this.tableMessage = tableMessage; } public String getType() { return type; } public void setType(final String type) { this.type = type; } public String getBody() { return body; } public void setBody(final String body) { this.body = body; } public String getPlayerIds() { return playerIds; } public void setPlayerIds(final String playerIds) { this.playerIds = playerIds; } public Set<BigDecimal> convertPlayerIds() { final String[] idsAsString = playerIds.split(","); final Set<BigDecimal> result = new HashSet<BigDecimal>(); for (String idAsString : idsAsString) { result.add(new BigDecimal(idAsString.trim())); } return result; } }
[ "shahak.ben-hamo@rbpkrltd.com" ]
shahak.ben-hamo@rbpkrltd.com
670184184721d109f6bca1b6c63dde1609b730cd
20eb62855cb3962c2d36fda4377dfd47d82eb777
/newEvaluatedBugs/Jsoup_42_buggy/mutated/179/TokeniserState.java
14fa0dc785c95e61f2be7c989248da7db804bf5c
[]
no_license
ozzydong/CapGen
356746618848065cce4e253e5d3c381baa85044a
0ba0321b6b1191443276021f1997833342f02515
refs/heads/master
2023-03-18T20:12:02.923428
2020-08-21T03:08:28
2020-08-21T03:08:28
null
0
0
null
null
null
null
UTF-8
Java
false
false
61,186
java
package org.jsoup.parser; /** * States and transition activations for the Tokeniser. */ enum TokeniserState { Data { // in data state, gather characters until a character reference or tag is found void read(Tokeniser t, CharacterReader r) { switch (r.current()) { case '&': t.advanceTransition(CharacterReferenceInData); break; case '<': t.advanceTransition(TagOpen); break; case nullChar: t.error(this); // NOT replacement character (oddly?) t.emit(r.consume()); break; case eof: t.emit(new Token.EOF()); break; default: String data = r.consumeToAny('&', '<', nullChar); t.emit(data); break; } } }, CharacterReferenceInData { // from & in data void read(Tokeniser t, CharacterReader r) { Character c = t.consumeCharacterReference(null, false); if (c == null) t.emit('&'); else t.emit(c); t.transition(Data); } }, Rcdata { /// handles data in title, textarea etc void read(Tokeniser t, CharacterReader r) { switch (r.current()) { case '&': t.advanceTransition(CharacterReferenceInRcdata); break; case '<': t.advanceTransition(RcdataLessthanSign); break; case nullChar: t.error(this); r.advance(); t.emit(replacementChar); break; case eof: t.emit(new Token.EOF()); break; default: String data = r.consumeToAny('&', '<', nullChar); t.emit(data); break; } } }, CharacterReferenceInRcdata { void read(Tokeniser t, CharacterReader r) { Character c = t.consumeCharacterReference(null, false); if (c == null) t.emit('&'); else t.emit(c); t.transition(Rcdata); } }, Rawtext { void read(Tokeniser t, CharacterReader r) { switch (r.current()) { case '<': t.advanceTransition(RawtextLessthanSign); break; case nullChar: t.error(this); r.advance(); t.emit(replacementChar); break; case eof: t.emit(new Token.EOF()); break; default: String data = r.consumeToAny('<', nullChar); t.emit(data); break; } } }, ScriptData { void read(Tokeniser t, CharacterReader r) { switch (r.current()) { case '<': t.advanceTransition(ScriptDataLessthanSign); break; case nullChar: t.error(this); r.advance(); t.emit(replacementChar); break; case eof: t.emit(new Token.EOF()); break; default: String data = r.consumeToAny('<', nullChar); t.emit(data); break; } } }, PLAINTEXT { void read(Tokeniser t, CharacterReader r) { switch (r.current()) { case nullChar: t.error(this); r.advance(); t.emit(replacementChar); break; case eof: t.emit(new Token.EOF()); break; default: String data = r.consumeTo(nullChar); t.emit(data); break; } } }, TagOpen { // from < in data void read(Tokeniser t, CharacterReader r) { switch (r.current()) { case '!': t.advanceTransition(MarkupDeclarationOpen); break; case '/': t.advanceTransition(EndTagOpen); break; case '?': t.advanceTransition(BogusComment); break; default: if (r.matchesLetter()) { t.createTagPending(true); t.transition(TagName); } else { t.error(this); t.emit('<'); // char that got us here t.transition(Data); } break; } } }, EndTagOpen { void read(Tokeniser t, CharacterReader r) { if (r.isEmpty()) { t.eofError(this); t.emit("</"); t.transition(Data); } else if (r.matchesLetter()) { t.createTagPending(false); t.transition(TagName); } else if (r.matches('>')) { t.error(this); t.advanceTransition(Data); } else { t.error(this); t.advanceTransition(BogusComment); } } }, TagName { // from < or </ in data, will have start or end tag pending void read(Tokeniser t, CharacterReader r) { // previous TagOpen state did NOT consume, will have a letter char in current String tagName = r.consumeToAny('\t', '\n', '\f', ' ', '/', '>', nullChar).toLowerCase(); t.tagPending.appendTagName(tagName); switch (r.consume()) { case '\t': case '\n': case '\f': case ' ': t.transition(BeforeAttributeName); break; case '/': t.transition(SelfClosingStartTag); break; case '>': t.emitTagPending(); t.transition(Data); break; case nullChar: // replacement t.tagPending.appendTagName(replacementStr); break; case eof: // should emit pending tag? t.eofError(this); t.transition(Data); // no default, as covered with above consumeToAny } } }, RcdataLessthanSign { // from < in rcdata void read(Tokeniser t, CharacterReader r) { if (r.matches('/')) { t.createTempBuffer(); t.advanceTransition(RCDATAEndTagOpen); } else if (r.matchesLetter() && !r.containsIgnoreCase("</" + t.appropriateEndTagName())) { // diverge from spec: got a start tag, but there's no appropriate end tag (</title>), so rather than // consuming to EOF; break out here t.tagPending = new Token.EndTag(t.appropriateEndTagName()); t.emitTagPending(); r.unconsume(); // undo "<" t.transition(Data); } else { t.emit("<"); t.transition(Rcdata); } } }, RCDATAEndTagOpen { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { t.createTagPending(false); t.tagPending.appendTagName(Character.toLowerCase(r.current())); t.dataBuffer.append(Character.toLowerCase(r.current())); t.advanceTransition(RCDATAEndTagName); } else { t.emit("</"); t.transition(Rcdata); } } }, RCDATAEndTagName { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { String name = r.consumeLetterSequence(); t.tagPending.appendTagName(name.toLowerCase()); t.dataBuffer.append(name); return; } char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': if (t.isAppropriateEndTagToken()) t.transition(BeforeAttributeName); else anythingElse(t, r); break; case '/': if (t.isAppropriateEndTagToken()) t.transition(SelfClosingStartTag); else anythingElse(t, r); break; case '>': if (t.isAppropriateEndTagToken()) { t.emitTagPending(); t.transition(Data); } else anythingElse(t, r); break; default: anythingElse(t, r); } } private void anythingElse(Tokeniser t, CharacterReader r) { t.emit("</" + t.dataBuffer.toString()); t.transition(Rcdata); } }, RawtextLessthanSign { void read(Tokeniser t, CharacterReader r) { if (r.matches('/')) { t.createTempBuffer(); t.advanceTransition(RawtextEndTagOpen); } else { t.emit('<'); t.transition(Rawtext); } } }, RawtextEndTagOpen { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { t.createTagPending(false); t.transition(RawtextEndTagName); } else { t.emit("</"); t.transition(Rawtext); } } }, RawtextEndTagName { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { String name = r.consumeLetterSequence(); t.tagPending.appendTagName(name.toLowerCase()); t.dataBuffer.append(name); return; } if (t.isAppropriateEndTagToken() && !r.isEmpty()) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': t.transition(BeforeAttributeName); break; case '/': t.transition(SelfClosingStartTag); break; case '>': t.emitTagPending(); t.transition(Data); break; default: t.dataBuffer.append(c); anythingElse(t, r); } } else anythingElse(t, r); } private void anythingElse(Tokeniser t, CharacterReader r) { t.emit("</" + t.dataBuffer.toString()); t.transition(Rawtext); } }, ScriptDataLessthanSign { void read(Tokeniser t, CharacterReader r) { switch (r.consume()) { case '/': t.createTempBuffer(); t.transition(ScriptDataEndTagOpen); break; case '!': t.emit("<!"); t.transition(ScriptDataEscapeStart); break; default: t.emit("<"); r.unconsume(); t.transition(ScriptData); } } }, ScriptDataEndTagOpen { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { t.createTagPending(false); t.transition(ScriptDataEndTagName); } else { t.emit("</"); t.transition(ScriptData); } } }, ScriptDataEndTagName { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { String name = r.consumeLetterSequence(); t.tagPending.appendTagName(name.toLowerCase()); t.dataBuffer.append(name); return; } if (t.isAppropriateEndTagToken() && !r.isEmpty()) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': t.transition(BeforeAttributeName); break; case '/': t.transition(SelfClosingStartTag); break; case '>': t.emitTagPending(); t.transition(Data); break; default: t.dataBuffer.append(c); anythingElse(t, r); } } else { anythingElse(t, r); } } private void anythingElse(Tokeniser t, CharacterReader r) { t.emit("</" + t.dataBuffer.toString()); t.transition(ScriptData); } }, ScriptDataEscapeStart { void read(Tokeniser t, CharacterReader r) { if (r.matches('-')) { t.emit('-'); t.advanceTransition(org.jsoup.parser.TokeniserState.RcdataLessthanSign); } else { t.transition(ScriptData); } } }, ScriptDataEscapeStartDash { void read(Tokeniser t, CharacterReader r) { if (r.matches('-')) { t.emit('-'); t.advanceTransition(ScriptDataEscapedDashDash); } else { t.transition(ScriptData); } } }, ScriptDataEscaped { void read(Tokeniser t, CharacterReader r) { if (r.isEmpty()) { t.eofError(this); t.transition(Data); return; } switch (r.current()) { case '-': t.emit('-'); t.advanceTransition(ScriptDataEscapedDash); break; case '<': t.advanceTransition(ScriptDataEscapedLessthanSign); break; case nullChar: t.error(this); r.advance(); t.emit(replacementChar); break; default: String data = r.consumeToAny('-', '<', nullChar); t.emit(data); } } }, ScriptDataEscapedDash { void read(Tokeniser t, CharacterReader r) { if (r.isEmpty()) { t.eofError(this); t.transition(Data); return; } char c = r.consume(); switch (c) { case '-': t.emit(c); t.transition(ScriptDataEscapedDashDash); break; case '<': t.transition(ScriptDataEscapedLessthanSign); break; case nullChar: t.error(this); t.emit(replacementChar); t.transition(ScriptDataEscaped); break; default: t.emit(c); t.transition(ScriptDataEscaped); } } }, ScriptDataEscapedDashDash { void read(Tokeniser t, CharacterReader r) { if (r.isEmpty()) { t.eofError(this); t.transition(Data); return; } char c = r.consume(); switch (c) { case '-': t.emit(c); break; case '<': t.transition(ScriptDataEscapedLessthanSign); break; case '>': t.emit(c); t.transition(ScriptData); break; case nullChar: t.error(this); t.emit(replacementChar); t.transition(ScriptDataEscaped); break; default: t.emit(c); t.transition(ScriptDataEscaped); } } }, ScriptDataEscapedLessthanSign { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { t.createTempBuffer(); t.dataBuffer.append(Character.toLowerCase(r.current())); t.emit("<" + r.current()); t.advanceTransition(ScriptDataDoubleEscapeStart); } else if (r.matches('/')) { t.createTempBuffer(); t.advanceTransition(ScriptDataEscapedEndTagOpen); } else { t.emit('<'); t.transition(ScriptDataEscaped); } } }, ScriptDataEscapedEndTagOpen { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { t.createTagPending(false); t.tagPending.appendTagName(Character.toLowerCase(r.current())); t.dataBuffer.append(r.current()); t.advanceTransition(ScriptDataEscapedEndTagName); } else { t.emit("</"); t.transition(ScriptDataEscaped); } } }, ScriptDataEscapedEndTagName { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { String name = r.consumeLetterSequence(); t.tagPending.appendTagName(name.toLowerCase()); t.dataBuffer.append(name); r.advance(); return; } if (t.isAppropriateEndTagToken() && !r.isEmpty()) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': t.transition(BeforeAttributeName); break; case '/': t.transition(SelfClosingStartTag); break; case '>': t.emitTagPending(); t.transition(Data); break; default: t.dataBuffer.append(c); anythingElse(t, r); break; } } else { anythingElse(t, r); } } private void anythingElse(Tokeniser t, CharacterReader r) { t.emit("</" + t.dataBuffer.toString()); t.transition(ScriptDataEscaped); } }, ScriptDataDoubleEscapeStart { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { String name = r.consumeLetterSequence(); t.dataBuffer.append(name.toLowerCase()); t.emit(name); return; } char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': case '/': case '>': if (t.dataBuffer.toString().equals("script")) t.transition(ScriptDataDoubleEscaped); else t.transition(ScriptDataEscaped); t.emit(c); break; default: r.unconsume(); t.transition(ScriptDataEscaped); } } }, ScriptDataDoubleEscaped { void read(Tokeniser t, CharacterReader r) { char c = r.current(); switch (c) { case '-': t.emit(c); t.advanceTransition(ScriptDataDoubleEscapedDash); break; case '<': t.emit(c); t.advanceTransition(ScriptDataDoubleEscapedLessthanSign); break; case nullChar: t.error(this); r.advance(); t.emit(replacementChar); break; case eof: t.eofError(this); t.transition(Data); break; default: String data = r.consumeToAny('-', '<', nullChar); t.emit(data); } } }, ScriptDataDoubleEscapedDash { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '-': t.emit(c); t.transition(ScriptDataDoubleEscapedDashDash); break; case '<': t.emit(c); t.transition(ScriptDataDoubleEscapedLessthanSign); break; case nullChar: t.error(this); t.emit(replacementChar); t.transition(ScriptDataDoubleEscaped); break; case eof: t.eofError(this); t.transition(Data); break; default: t.emit(c); t.transition(ScriptDataDoubleEscaped); } } }, ScriptDataDoubleEscapedDashDash { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '-': t.emit(c); break; case '<': t.emit(c); t.transition(ScriptDataDoubleEscapedLessthanSign); break; case '>': t.emit(c); t.transition(ScriptData); break; case nullChar: t.error(this); t.emit(replacementChar); t.transition(ScriptDataDoubleEscaped); break; case eof: t.eofError(this); t.transition(Data); break; default: t.emit(c); t.transition(ScriptDataDoubleEscaped); } } }, ScriptDataDoubleEscapedLessthanSign { void read(Tokeniser t, CharacterReader r) { if (r.matches('/')) { t.emit('/'); t.createTempBuffer(); t.advanceTransition(ScriptDataDoubleEscapeEnd); } else { t.transition(ScriptDataDoubleEscaped); } } }, ScriptDataDoubleEscapeEnd { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { String name = r.consumeLetterSequence(); t.dataBuffer.append(name.toLowerCase()); t.emit(name); return; } char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': case '/': case '>': if (t.dataBuffer.toString().equals("script")) t.transition(ScriptDataEscaped); else t.transition(ScriptDataDoubleEscaped); t.emit(c); break; default: r.unconsume(); t.transition(ScriptDataDoubleEscaped); } } }, BeforeAttributeName { // from tagname <xxx void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': break; // ignore whitespace case '/': t.transition(SelfClosingStartTag); break; case '>': t.emitTagPending(); t.transition(Data); break; case nullChar: t.error(this); t.tagPending.newAttribute(); r.unconsume(); t.transition(AttributeName); break; case eof: t.eofError(this); t.transition(Data); break; case '"': case '\'': case '<': case '=': t.error(this); t.tagPending.newAttribute(); t.tagPending.appendAttributeName(c); t.transition(AttributeName); break; default: // A-Z, anything else t.tagPending.newAttribute(); r.unconsume(); t.transition(AttributeName); } } }, AttributeName { // from before attribute name void read(Tokeniser t, CharacterReader r) { String name = r.consumeToAny('\t', '\n', '\f', ' ', '/', '=', '>', nullChar, '"', '\'', '<'); t.tagPending.appendAttributeName(name.toLowerCase()); char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': t.transition(AfterAttributeName); break; case '/': t.transition(SelfClosingStartTag); break; case '=': t.transition(BeforeAttributeValue); break; case '>': t.emitTagPending(); t.transition(Data); break; case nullChar: t.error(this); t.tagPending.appendAttributeName(replacementChar); break; case eof: t.eofError(this); t.transition(Data); break; case '"': case '\'': case '<': t.error(this); t.tagPending.appendAttributeName(c); // no default, as covered in consumeToAny } } }, AfterAttributeName { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': // ignore break; case '/': t.transition(SelfClosingStartTag); break; case '=': t.transition(BeforeAttributeValue); break; case '>': t.emitTagPending(); t.transition(Data); break; case nullChar: t.error(this); t.tagPending.appendAttributeName(replacementChar); t.transition(AttributeName); break; case eof: t.eofError(this); t.transition(Data); break; case '"': case '\'': case '<': t.error(this); t.tagPending.newAttribute(); t.tagPending.appendAttributeName(c); t.transition(AttributeName); break; default: // A-Z, anything else t.tagPending.newAttribute(); r.unconsume(); t.transition(AttributeName); } } }, BeforeAttributeValue { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': // ignore break; case '"': t.transition(AttributeValue_doubleQuoted); break; case '&': r.unconsume(); t.transition(AttributeValue_unquoted); break; case '\'': t.transition(AttributeValue_singleQuoted); break; case nullChar: t.error(this); t.tagPending.appendAttributeValue(replacementChar); t.transition(AttributeValue_unquoted); break; case eof: t.eofError(this); t.transition(Data); break; case '>': t.error(this); t.emitTagPending(); t.transition(Data); break; case '<': case '=': case '`': t.error(this); t.tagPending.appendAttributeValue(c); t.transition(AttributeValue_unquoted); break; default: r.unconsume(); t.transition(AttributeValue_unquoted); } } }, AttributeValue_doubleQuoted { void read(Tokeniser t, CharacterReader r) { String value = r.consumeToAny('"', '&', nullChar); if (value.length() > 0) t.tagPending.appendAttributeValue(value); char c = r.consume(); switch (c) { case '"': t.transition(AfterAttributeValue_quoted); break; case '&': Character ref = t.consumeCharacterReference('"', true); if (ref != null) t.tagPending.appendAttributeValue(ref); else t.tagPending.appendAttributeValue('&'); break; case nullChar: t.error(this); t.tagPending.appendAttributeValue(replacementChar); break; case eof: t.eofError(this); t.transition(Data); break; // no default, handled in consume to any above } } }, AttributeValue_singleQuoted { void read(Tokeniser t, CharacterReader r) { String value = r.consumeToAny('\'', '&', nullChar); if (value.length() > 0) t.tagPending.appendAttributeValue(value); char c = r.consume(); switch (c) { case '\'': t.transition(AfterAttributeValue_quoted); break; case '&': Character ref = t.consumeCharacterReference('\'', true); if (ref != null) t.tagPending.appendAttributeValue(ref); else t.tagPending.appendAttributeValue('&'); break; case nullChar: t.error(this); t.tagPending.appendAttributeValue(replacementChar); break; case eof: t.eofError(this); t.transition(Data); break; // no default, handled in consume to any above } } }, AttributeValue_unquoted { void read(Tokeniser t, CharacterReader r) { String value = r.consumeToAny('\t', '\n', '\f', ' ', '&', '>', nullChar, '"', '\'', '<', '=', '`'); if (value.length() > 0) t.tagPending.appendAttributeValue(value); char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': t.transition(BeforeAttributeName); break; case '&': Character ref = t.consumeCharacterReference('>', true); if (ref != null) t.tagPending.appendAttributeValue(ref); else t.tagPending.appendAttributeValue('&'); break; case '>': t.emitTagPending(); t.transition(Data); break; case nullChar: t.error(this); t.tagPending.appendAttributeValue(replacementChar); break; case eof: t.eofError(this); t.transition(Data); break; case '"': case '\'': case '<': case '=': case '`': t.error(this); t.tagPending.appendAttributeValue(c); break; // no default, handled in consume to any above } } }, // CharacterReferenceInAttributeValue state handled inline AfterAttributeValue_quoted { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': t.transition(BeforeAttributeName); break; case '/': t.transition(SelfClosingStartTag); break; case '>': t.emitTagPending(); t.transition(Data); break; case eof: t.eofError(this); t.transition(Data); break; default: t.error(this); r.unconsume(); t.transition(BeforeAttributeName); } } }, SelfClosingStartTag { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '>': t.tagPending.selfClosing = true; t.emitTagPending(); t.transition(Data); break; case eof: t.eofError(this); t.transition(Data); break; default: t.error(this); t.transition(BeforeAttributeName); } } }, BogusComment { void read(Tokeniser t, CharacterReader r) { // todo: handle bogus comment starting from eof. when does that trigger? // rewind to capture character that lead us here r.unconsume(); Token.Comment comment = new Token.Comment(); comment.data.append(r.consumeTo('>')); // todo: replace nullChar with replaceChar t.emit(comment); t.advanceTransition(Data); } }, MarkupDeclarationOpen { void read(Tokeniser t, CharacterReader r) { if (r.matchConsume("--")) { t.createCommentPending(); t.transition(CommentStart); } else if (r.matchConsumeIgnoreCase("DOCTYPE")) { t.transition(Doctype); } else if (r.matchConsume("[CDATA[")) { // todo: should actually check current namepspace, and only non-html allows cdata. until namespace // is implemented properly, keep handling as cdata //} else if (!t.currentNodeInHtmlNS() && r.matchConsume("[CDATA[")) { t.transition(CdataSection); } else { t.error(this); t.advanceTransition(BogusComment); // advance so this character gets in bogus comment data's rewind } } }, CommentStart { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '-': t.transition(CommentStartDash); break; case nullChar: t.error(this); t.commentPending.data.append(replacementChar); t.transition(Comment); break; case '>': t.error(this); t.emitCommentPending(); t.transition(Data); break; case eof: t.eofError(this); t.emitCommentPending(); t.transition(Data); break; default: t.commentPending.data.append(c); t.transition(Comment); } } }, CommentStartDash { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '-': t.transition(CommentStartDash); break; case nullChar: t.error(this); t.commentPending.data.append(replacementChar); t.transition(Comment); break; case '>': t.error(this); t.emitCommentPending(); t.transition(Data); break; case eof: t.eofError(this); t.emitCommentPending(); t.transition(Data); break; default: t.commentPending.data.append(c); t.transition(Comment); } } }, Comment { void read(Tokeniser t, CharacterReader r) { char c = r.current(); switch (c) { case '-': t.advanceTransition(CommentEndDash); break; case nullChar: t.error(this); r.advance(); t.commentPending.data.append(replacementChar); break; case eof: t.eofError(this); t.emitCommentPending(); t.transition(Data); break; default: t.commentPending.data.append(r.consumeToAny('-', nullChar)); } } }, CommentEndDash { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '-': t.transition(CommentEnd); break; case nullChar: t.error(this); t.commentPending.data.append('-').append(replacementChar); t.transition(Comment); break; case eof: t.eofError(this); t.emitCommentPending(); t.transition(Data); break; default: t.commentPending.data.append('-').append(c); t.transition(Comment); } } }, CommentEnd { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '>': t.emitCommentPending(); t.transition(Data); break; case nullChar: t.error(this); t.commentPending.data.append("--").append(replacementChar); t.transition(Comment); break; case '!': t.error(this); t.transition(CommentEndBang); break; case '-': t.error(this); t.commentPending.data.append('-'); break; case eof: t.eofError(this); t.emitCommentPending(); t.transition(Data); break; default: t.error(this); t.commentPending.data.append("--").append(c); t.transition(Comment); } } }, CommentEndBang { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '-': t.commentPending.data.append("--!"); t.transition(CommentEndDash); break; case '>': t.emitCommentPending(); t.transition(Data); break; case nullChar: t.error(this); t.commentPending.data.append("--!").append(replacementChar); t.transition(Comment); break; case eof: t.eofError(this); t.emitCommentPending(); t.transition(Data); break; default: t.commentPending.data.append("--!").append(c); t.transition(Comment); } } }, Doctype { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': t.transition(BeforeDoctypeName); break; case eof: t.eofError(this); t.createDoctypePending(); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.error(this); t.transition(BeforeDoctypeName); } } }, BeforeDoctypeName { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { t.createDoctypePending(); t.transition(DoctypeName); return; } char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': break; // ignore whitespace case nullChar: t.error(this); t.doctypePending.name.append(replacementChar); t.transition(DoctypeName); break; case eof: t.eofError(this); t.createDoctypePending(); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.createDoctypePending(); t.doctypePending.name.append(c); t.transition(DoctypeName); } } }, DoctypeName { void read(Tokeniser t, CharacterReader r) { if (r.matchesLetter()) { String name = r.consumeLetterSequence(); t.doctypePending.name.append(name.toLowerCase()); return; } char c = r.consume(); switch (c) { case '>': t.emitDoctypePending(); t.transition(Data); break; case '\t': case '\n': case '\f': case ' ': t.transition(AfterDoctypeName); break; case nullChar: t.error(this); t.doctypePending.name.append(replacementChar); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.doctypePending.name.append(c); } } }, AfterDoctypeName { void read(Tokeniser t, CharacterReader r) { if (r.isEmpty()) { t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); return; } if (r.matchesAny('\t', '\n', '\f', ' ')) r.advance(); // ignore whitespace else if (r.matches('>')) { t.emitDoctypePending(); t.advanceTransition(Data); } else if (r.matchConsumeIgnoreCase("PUBLIC")) { t.transition(AfterDoctypePublicKeyword); } else if (r.matchConsumeIgnoreCase("SYSTEM")) { t.transition(AfterDoctypeSystemKeyword); } else { t.error(this); t.doctypePending.forceQuirks = true; t.advanceTransition(BogusDoctype); } } }, AfterDoctypePublicKeyword { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': t.transition(BeforeDoctypePublicIdentifier); break; case '"': t.error(this); // set public id to empty string t.transition(DoctypePublicIdentifier_doubleQuoted); break; case '\'': t.error(this); // set public id to empty string t.transition(DoctypePublicIdentifier_singleQuoted); break; case '>': t.error(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.error(this); t.doctypePending.forceQuirks = true; t.transition(BogusDoctype); } } }, BeforeDoctypePublicIdentifier { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': break; case '"': // set public id to empty string t.transition(DoctypePublicIdentifier_doubleQuoted); break; case '\'': // set public id to empty string t.transition(DoctypePublicIdentifier_singleQuoted); break; case '>': t.error(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.error(this); t.doctypePending.forceQuirks = true; t.transition(BogusDoctype); } } }, DoctypePublicIdentifier_doubleQuoted { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '"': t.transition(AfterDoctypePublicIdentifier); break; case nullChar: t.error(this); t.doctypePending.publicIdentifier.append(replacementChar); break; case '>': t.error(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.doctypePending.publicIdentifier.append(c); } } }, DoctypePublicIdentifier_singleQuoted { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\'': t.transition(AfterDoctypePublicIdentifier); break; case nullChar: t.error(this); t.doctypePending.publicIdentifier.append(replacementChar); break; case '>': t.error(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.doctypePending.publicIdentifier.append(c); } } }, AfterDoctypePublicIdentifier { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': t.transition(BetweenDoctypePublicAndSystemIdentifiers); break; case '>': t.emitDoctypePending(); t.transition(Data); break; case '"': t.error(this); // system id empty t.transition(DoctypeSystemIdentifier_doubleQuoted); break; case '\'': t.error(this); // system id empty t.transition(DoctypeSystemIdentifier_singleQuoted); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.error(this); t.doctypePending.forceQuirks = true; t.transition(BogusDoctype); } } }, BetweenDoctypePublicAndSystemIdentifiers { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': break; case '>': t.emitDoctypePending(); t.transition(Data); break; case '"': t.error(this); // system id empty t.transition(DoctypeSystemIdentifier_doubleQuoted); break; case '\'': t.error(this); // system id empty t.transition(DoctypeSystemIdentifier_singleQuoted); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.error(this); t.doctypePending.forceQuirks = true; t.transition(BogusDoctype); } } }, AfterDoctypeSystemKeyword { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': t.transition(BeforeDoctypeSystemIdentifier); break; case '>': t.error(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; case '"': t.error(this); // system id empty t.transition(DoctypeSystemIdentifier_doubleQuoted); break; case '\'': t.error(this); // system id empty t.transition(DoctypeSystemIdentifier_singleQuoted); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.error(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); } } }, BeforeDoctypeSystemIdentifier { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': break; case '"': // set system id to empty string t.transition(DoctypeSystemIdentifier_doubleQuoted); break; case '\'': // set public id to empty string t.transition(DoctypeSystemIdentifier_singleQuoted); break; case '>': t.error(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.error(this); t.doctypePending.forceQuirks = true; t.transition(BogusDoctype); } } }, DoctypeSystemIdentifier_doubleQuoted { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '"': t.transition(AfterDoctypeSystemIdentifier); break; case nullChar: t.error(this); t.doctypePending.systemIdentifier.append(replacementChar); break; case '>': t.error(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.doctypePending.systemIdentifier.append(c); } } }, DoctypeSystemIdentifier_singleQuoted { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\'': t.transition(AfterDoctypeSystemIdentifier); break; case nullChar: t.error(this); t.doctypePending.systemIdentifier.append(replacementChar); break; case '>': t.error(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.doctypePending.systemIdentifier.append(c); } } }, AfterDoctypeSystemIdentifier { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '\t': case '\n': case '\f': case ' ': break; case '>': t.emitDoctypePending(); t.transition(Data); break; case eof: t.eofError(this); t.doctypePending.forceQuirks = true; t.emitDoctypePending(); t.transition(Data); break; default: t.error(this); t.transition(BogusDoctype); // NOT force quirks } } }, BogusDoctype { void read(Tokeniser t, CharacterReader r) { char c = r.consume(); switch (c) { case '>': t.emitDoctypePending(); t.transition(Data); break; case eof: t.emitDoctypePending(); t.transition(Data); break; default: // ignore char break; } } }, CdataSection { void read(Tokeniser t, CharacterReader r) { String data = r.consumeTo("]]>"); t.emit(data); r.matchConsume("]]>"); t.transition(Data); } }; abstract void read(Tokeniser t, CharacterReader r); private static final char nullChar = '\u0000'; private static final char replacementChar = Tokeniser.replacementChar; private static final String replacementStr = String.valueOf(Tokeniser.replacementChar); private static final char eof = CharacterReader.EOF; }
[ "justinwm@163.com" ]
justinwm@163.com
b59c11ef2e9f8fd7501defcffc57e086ccb45b10
664f86f7d051c6fd0588b50a1d97c5da3aba0d65
/Profiling/app/src/main/java/user/com/profiling/SampleAlarmReceiver.java
d2aca26b9bbf4a0c6e165ba75f4fc892421f0a9f
[]
no_license
sureshdraco/eyal
f42a823b5ccd0bc33cd65008d931d29fecc6e86c
ab3bc237db8cf69173b541f35212b504271567e2
refs/heads/master
2020-06-03T20:31:24.269061
2015-02-06T15:59:03
2015-02-06T15:59:03
29,441,534
0
0
null
null
null
null
UTF-8
Java
false
false
6,053
java
package user.com.profiling; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.support.v4.content.WakefulBroadcastReceiver; import java.util.Calendar; /** * When the alarm fires, this WakefulBroadcastReceiver receives the broadcast Intent * and then starts the IntentService {@code SampleSchedulingService} to do some work. */ public class SampleAlarmReceiver extends WakefulBroadcastReceiver { // The app's AlarmManager, which provides access to the system alarm services. private AlarmManager alarmMgr; // The pending intent that is triggered when the alarm fires. private PendingIntent alarmIntent; @Override public void onReceive(Context context, Intent intent) { // BEGIN_INCLUDE(alarm_onreceive) /* * If your receiver intent includes extras that need to be passed along to the * service, use setComponent() to indicate that the service should handle the * receiver's intent. For example: * * ComponentName comp = new ComponentName(context.getPackageName(), * MyService.class.getName()); * * // This intent passed in this call will include the wake lock extra as well as * // the receiver intent contents. * startWakefulService(context, (intent.setComponent(comp))); * * In this example, we simply create a new intent to deliver to the service. * This intent holds an extra identifying the wake lock. */ Intent service = new Intent(context, ProfilingSchedulingService.class); // Start the service, keeping the device awake while it is launching. startWakefulService(context, service); // END_INCLUDE(alarm_onreceive) } // BEGIN_INCLUDE(set_alarm) /** * Sets a repeating alarm that runs once a day at approximately 8:30 a.m. When the * alarm fires, the app broadcasts an Intent to this WakefulBroadcastReceiver. * @param context */ public void setAlarm(Context context) { alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, SampleAlarmReceiver.class); alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); // Set the alarm's trigger time to 8:30 a.m. calendar.set(Calendar.HOUR_OF_DAY, 8); calendar.set(Calendar.MINUTE, 30); /* * If you don't have precise time requirements, use an inexact repeating alarm * the minimize the drain on the device battery. * * The call below specifies the alarm type, the trigger time, the interval at * which the alarm is fired, and the alarm's associated PendingIntent. * It uses the alarm type RTC_WAKEUP ("Real Time Clock" wake up), which wakes up * the device and triggers the alarm according to the time of the device's clock. * * Alternatively, you can use the alarm type ELAPSED_REALTIME_WAKEUP to trigger * an alarm based on how much time has elapsed since the device was booted. This * is the preferred choice if your alarm is based on elapsed time--for example, if * you simply want your alarm to fire every 60 minutes. You only need to use * RTC_WAKEUP if you want your alarm to fire at a particular date/time. Remember * that clock-based time may not translate well to other locales, and that your * app's behavior could be affected by the user changing the device's time setting. * * Here are some examples of ELAPSED_REALTIME_WAKEUP: * * // Wake up the device to fire a one-time alarm in one minute. * alarmMgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, * SystemClock.elapsedRealtime() + * 60*1000, alarmIntent); * * // Wake up the device to fire the alarm in 30 minutes, and every 30 minutes * // after that. * alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, * AlarmManager.INTERVAL_HALF_HOUR, * AlarmManager.INTERVAL_HALF_HOUR, alarmIntent); */ // Set the alarm to fire at approximately 8:30 a.m., according to the device's // clock, and to repeat once a day. alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, alarmIntent); // Enable {@code SampleBootReceiver} to automatically restart the alarm when the // device is rebooted. ComponentName receiver = new ComponentName(context, AlarmBootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); } // END_INCLUDE(set_alarm) /** * Cancels the alarm. * @param context */ // BEGIN_INCLUDE(cancel_alarm) public void cancelAlarm(Context context) { // If the alarm has been set, cancel it. if (alarmMgr!= null) { alarmMgr.cancel(alarmIntent); } // Disable {@code SampleBootReceiver} so that it doesn't automatically restart the // alarm when the device is rebooted. ComponentName receiver = new ComponentName(context, AlarmBootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } // END_INCLUDE(cancel_alarm) }
[ "suresh.kumar@rebtel.com" ]
suresh.kumar@rebtel.com
eb7f3ac15916d1bf35e1f751b793663e6e013f6f
d05742de1759bae63b60a30ec3bd560c6da813aa
/spring_ioc_1/src/main/java/cn/figo/factory/StaticFactory.java
836d0a7ec33626858bf78c513e8c6dcd2f6889e1
[]
no_license
erouss/javaSSM
da72103a47b3dd2c43ec8fbb4bcfb5ec2bf4a9b1
7abb38d9e758a66ed454fe622b12a8a0053601ef
refs/heads/master
2023-03-04T19:30:33.013328
2020-03-20T16:06:49
2020-03-20T16:06:49
null
0
0
null
null
null
null
UTF-8
Java
false
false
394
java
package cn.figo.factory; import cn.figo.service.IAccountService; import cn.figo.service.impl.AccountServiceImpl; /** * 模拟一个工厂类(该类可能是存在于jar包中的,我们无法通过修改源码的方式来提供默认构造函数) */ public class StaticFactory { public static IAccountService getAccountService(){ return new AccountServiceImpl(); } }
[ "501385003@qq.com" ]
501385003@qq.com
d792d8542fe33bdfcf508991786237d3c25fc3e2
2351c9f127f2b8976062078030976f4628db8d30
/app/src/androidTest/java/com/matsu/claphands/ApplicationTest.java
a6212934932585328612b45fbc11c4608a7876ca
[]
no_license
panmatsu/ClapHands
31fb1b852deef3a8740b8c8083691175c9ce4332
e764cb27942122c90deb84a354faee46ad0262b6
refs/heads/master
2021-01-10T05:24:44.664809
2016-01-18T10:05:26
2016-01-18T10:05:26
49,868,350
0
0
null
null
null
null
UTF-8
Java
false
false
350
java
package com.matsu.claphands; import android.app.Application; import android.test.ApplicationTestCase; /** * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> */ public class ApplicationTest extends ApplicationTestCase<Application> { public ApplicationTest() { super(Application.class); } }
[ "5bji1214@mail.u-tokai.ac.jp" ]
5bji1214@mail.u-tokai.ac.jp
cc6b6c1cd38b47172367de53ec099132c0893dcf
8668f975325a6368161b14383200f1f07001a920
/umallT/src/uuu/model/RDBCustomerDAO.java
7a93664b229bae1936dfabe5752275581ad00e55
[]
no_license
lin761222/uMall
66d0801b5fc1cb0d84153d75843ae7328d336d06
2f9ba57bb1dac83e3f700352ea72ddb79da46672
refs/heads/master
2016-09-06T00:46:34.419268
2014-11-05T01:39:22
2014-11-05T01:39:22
null
0
0
null
null
null
null
UTF-8
Java
false
false
8,235
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package uuu.model; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.naming.Context; import javax.naming.InitialContext; import javax.sql.DataSource; import uuu.domain.BloodType; import uuu.domain.Customer; import uuu.domain.UMallException; /** * * @author Administrator */ public class RDBCustomerDAO implements DAOInterface<String, Customer> { private static final String DRIVER = "com.mysql.jdbc.Driver"; private static final String URL = "jdbc:mysql://localhost:3306/umall?useUnicode=true&characterEncoding=utf-8"; private static final String UID = "root"; private static final String PWD = "123456"; public Connection getConnection() throws UMallException { DataSource ds = null; Connection connection = null; Context ctx; try { ctx = new InitialContext(); if (ctx == null) { throw new RuntimeException("JNDI Context could not be found."); } ds = (DataSource) ctx.lookup("java:comp/env/jdbc/umall"); if (ds == null) { throw new RuntimeException("DataSource could not be found."); } connection = ds.getConnection(); System.out.print("取得Connection Pool:" + connection); } catch (Exception ex) { ex.printStackTrace(); // throw new UMallException(ex); try { Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection(URL, UID, PWD); } catch (Exception e) { throw new UMallException("無法建立資料庫連線!", e); } } System.out.println(connection); return connection; } private static final String INSERT_SQL = "INSERT INTO customers " + "(id, name, password, phone, gender, address, email, married, birth_date, blood_type) " + "VALUES (?,?,?,?,?,?,?,?,?,?)"; private static final String UPDATE_SQL = "UPDATE customers SET " + "name=?, password=?, phone=?, gender=? , address=?, email=?, married=?, birth_date=?, blood_type=? WHERE id=?"; private static final String DELETE_SQL = "DELETE FROM customers WHERE id=?"; private static final String SELECT_ALL = "SELECT id, name, password, phone, gender, address, email, married, birth_date, blood_type FROM customers"; private static final String SELECT_SQL = SELECT_ALL + " WHERE id=?"; @Override public void insert(Customer o) throws UMallException { //Class.forName(DRIVER); try (Connection con = getConnection(); PreparedStatement pstmt = con.prepareStatement(INSERT_SQL)) { pstmt.setString(1, o.getId()); pstmt.setString(2, o.getName()); pstmt.setString(3, o.getPassword()); pstmt.setString(4, o.getPhone()); pstmt.setString(5, String.valueOf(o.getGender())); pstmt.setString(6, o.getAddress()); pstmt.setString(7, o.getEmail()); pstmt.setBoolean(8, o.isMarried()); pstmt.setDate(9, new java.sql.Date(o.getBirthDate().getTime())); pstmt.setString(10, o.getBloodtype().name()); pstmt.executeUpdate(); } catch (SQLException e) { throw new UMallException("新增客戶資料失敗:" + o, e); } } @Override public void update(Customer o) throws UMallException { try (Connection con = getConnection(); PreparedStatement pstmt = con.prepareStatement(UPDATE_SQL)) { pstmt.setString(1, o.getName()); pstmt.setString(2, o.getPassword()); pstmt.setString(3, o.getPhone()); pstmt.setString(4, String.valueOf(o.getGender())); pstmt.setString(5, o.getAddress()); pstmt.setString(6, o.getEmail()); pstmt.setBoolean(7, o.isMarried()); pstmt.setDate(8, new java.sql.Date(o.getBirthDate().getTime())); pstmt.setString(9, o.getBloodtype().name()); pstmt.setString(10, o.getId()); pstmt.executeUpdate(); } catch (SQLException e) { throw new UMallException("修改客戶資料失敗:" + o, e); } } @Override public void delete(Customer o) throws UMallException { try (Connection con = getConnection(); PreparedStatement pstmt = con.prepareStatement(DELETE_SQL)) { pstmt.setString(1, o.getId()); pstmt.executeUpdate(); } catch (SQLException e) { throw new UMallException("刪除客戶資料失敗:" + o, e); } } @Override public Customer get(String key) throws UMallException { Customer c = null; try (Connection con = getConnection(); PreparedStatement pstmt = con.prepareStatement(SELECT_SQL)) { pstmt.setString(1, key); try (ResultSet rs = pstmt.executeQuery()) { while (rs.next()) { if (rs.getRow() > 1) { throw new UMallException("讀取客戶資料失敗, id:" + key); } c = new Customer(); c.setId(rs.getString("id")); c.setName(rs.getString("name")); c.setPassword(rs.getString("password")); c.setPhone(rs.getString("phone")); c.setGender(rs.getString("gender").charAt(0)); c.setAddress(rs.getString("address")); if (rs.getString("email") != null) { c.setEmail(rs.getString("email")); } c.setMarried(rs.getBoolean("married")); c.setBirthDate(rs.getDate("birth_date")); c.setBloodtype(BloodType.valueOf(rs .getString("blood_type"))); System.out.println("get Customer:" + c); } } catch (SQLException e) { throw new UMallException("讀取客戶資料失敗, id:" + key, e); } } catch (SQLException e) { throw new UMallException("查詢客戶資料失敗, id:" + key, e); } return c; } @Override public List<Customer> getAll() throws UMallException { List<Customer> list = new ArrayList<>(); try (Connection con = getConnection(); PreparedStatement pstmt = con.prepareStatement(SELECT_ALL); ResultSet rs = pstmt.executeQuery()) { while (rs.next()) { Customer c = new Customer(); c.setId(rs.getString("id")); c.setName(rs.getString("name")); c.setPassword(rs.getString("password")); c.setPhone(rs.getString("phone")); c.setGender(rs.getString("gender").charAt(0)); c.setAddress(rs.getString("address")); if (rs.getString("email") != null) { c.setEmail(rs.getString("email")); } c.setMarried(rs.getBoolean("married")); c.setBirthDate(rs.getDate("birth_date")); c.setBloodtype(BloodType.valueOf(rs.getString("blood_type"))); list.add(c); } } catch (SQLException e) { throw new UMallException("查詢全部客戶資料失敗!", e); } return list; } public static void main(String[] args) { try { RDBCustomerDAO dao = new RDBCustomerDAO(); System.out.println(dao.getAll()); } catch (UMallException ex) { Logger.getLogger(RDBCustomerDAO.class.getName()).log(Level.SEVERE, null, ex); } } }
[ "alex.chen1222@gmail.com" ]
alex.chen1222@gmail.com
9877ab2ba8120cb89d4de9c7ab81746e3cd06f16
971f932fc8558216bf58ceeb89ef1c41101c2a09
/lesports-bole/branches/focus/lesports-crawler/lesports-crawler-core/src/main/java/com/lesports/crawler/utils/Constants.java
ef6b783d3e850dc340f9bf228de308f584e779a4
[]
no_license
wang-shun/lesports
c80085652d6c5c7af9f7eeacde65cd3bdd066e56
40b3d588e400046b89803f8fbd8fb9176f7acaa6
refs/heads/master
2020-04-12T23:23:16.620900
2018-12-21T02:59:29
2018-12-21T02:59:29
null
0
0
null
null
null
null
UTF-8
Java
false
false
856
java
package com.lesports.crawler.utils; /** * aa. * * @author pangchuanxiao * @since 2015/11/20 */ public abstract class Constants { public static final String KEY_ATTACH_RESULT = "attach_result"; public static final String KEY_IS_DATA_NULL = "is_data_null"; public static final String KEY_IS_HANDLER_NULL = "is_handler_null"; public static final String KEY_URL = "url"; public static final String KEY_DATA = "data"; public static final int SCHEDULER_INIT_DELAY = 0 * 60;//TIME UNIT SECOND public static final int SCHEDULER_DELAY = 30 * 60;//TIME UNIT SECOND public static final int CONCURRENT_THREAD_PER_HOST = 5;//每台机器上worker并发数 public static final int SUSPEND_TASK_RETRY_COUNT = 3;//每台机器上worker并发数 public static final int SEED_LOAD_DELAY = 1800; // SECONDS }
[ "ryan@ryandeMacBook-Air.local" ]
ryan@ryandeMacBook-Air.local
0a00606fc9f11b098e74a62909663924f1b8dcec
7f38f132996df84bbd32788b63f801dac7c38b8b
/service-ribbon/src/main/java/com/zhy/springboot/HelloService.java
ed369e74bae7b0b470b98589af1e491997e04b21
[]
no_license
brockhong/springcloud
46b5f15f6a14e7cfb819533cde0d7c27babe3722
d258b2f12b963ceec82b13bf76c87a1bc8bd8974
refs/heads/master
2021-04-03T08:01:59.740679
2018-07-18T09:47:33
2018-07-18T09:47:33
125,182,149
0
0
null
null
null
null
UTF-8
Java
false
false
788
java
package com.zhy.springboot; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @Service public class HelloService { @Autowired RestTemplate restTemplate; @HystrixCommand(fallbackMethod = "hiError") public String hiService(String name) { return restTemplate.getForObject("http://SERVICE-HI/hi?name="+name,String.class); } //加入Hystrix public String hiError(String name) { return "hi,"+name+",sorry,error!"; } public String hiaService(String name) { return restTemplate.getForObject("http://SERVICE-HI/hia?name="+name,String.class); } }
[ "hongyuan_2@163.com" ]
hongyuan_2@163.com
28a3f1655839f40442ff1ca202137cedaf0ea535
5e542c0fb35ce0484bcec2c61e76d6e061facefc
/imoocstudemo/src/com/imooc/concurrent/socket_datagram/Client.java
75f25967eee0f5087367fb6cd90fd3a569738ee0
[]
no_license
ccgg369/JAVA
60e25e037e5ce2cfd60a6f7d382fc3007119967d
06b071772397828f493e7e998953d43ce39af4e2
refs/heads/master
2020-06-30T12:31:44.605623
2019-08-06T08:49:42
2019-08-06T08:49:42
200,826,287
2
0
null
2019-08-06T10:06:07
2019-08-06T10:06:06
null
UTF-8
Java
false
false
979
java
package com.imooc.concurrent.socket_datagram; import java.io.IOException; import java.net.*; /** * Created by Luowenlv on 2018/11/21,16:57 * 基于UDP的用户登陆——客户端 */ public class Client { public static void main(String[] args) throws IOException { InetAddress address = InetAddress.getByName("localhost"); int port = 8800; byte[] data = "用户名:tom;密码:1234".getBytes(); DatagramPacket packet = new DatagramPacket(data, data.length, address, port); DatagramSocket socket = new DatagramSocket(); socket.send(packet); //接受服务器端的响应信息 byte[] data2 = new byte[1024]; DatagramPacket packet2 = new DatagramPacket(data2, data2.length); socket.receive(packet2); String reply = new String(data2, 0, packet2.getLength()); System.out.println("我是客户端,服务器端说:" + reply); ; socket.close(); } }
[ "1271826981@qq.com" ]
1271826981@qq.com
344225add3e29025b2d715c2aa214f6ea4a38ae1
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/2/2_16546f6207be02d22a06450bf403ceb315bfd8ea/Lesson8_Granulation/2_16546f6207be02d22a06450bf403ceb315bfd8ea_Lesson8_Granulation_s.java
422cdcb6494885ee9a209779692898e1a53ab345
[]
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
1,747
java
import net.beadsproject.beads.core.AudioContext; import net.beadsproject.beads.data.SampleManager; import net.beadsproject.beads.ugens.Envelope; import net.beadsproject.beads.ugens.Gain; import net.beadsproject.beads.ugens.GranularSamplePlayer; import net.beadsproject.beads.ugens.SamplePlayer; public class Lesson8_Granulation { public static void main(String[] args) { AudioContext ac; ac = new AudioContext(); /* * In lesson 4 we played back samples. This example is almost the same * but uses GranularSamplePlayer instead of SamplePlayer. See some of * the controls below. */ String audioFile = "audio/1234.aif"; GranularSamplePlayer player = new GranularSamplePlayer(ac, SampleManager.sample(audioFile)); /* * Have some fun with the controls. */ // loop the sample at its end points player.setLoopType(SamplePlayer.LoopType.LOOP_ALTERNATING); player.getLoopStartUGen().setValue(0); player.getLoopEndUGen().setValue( (float)SampleManager.sample(audioFile).getLength()); // control the rate of grain firing Envelope grainIntervalEnvelope = new Envelope(ac, 100); grainIntervalEnvelope.addSegment(20, 10000); player.setGrainIntervalUgen(grainIntervalEnvelope); // control the playback rate Envelope rateEnvelope = new Envelope(ac, 1); rateEnvelope.addSegment(1, 5000); rateEnvelope.addSegment(0, 5000); rateEnvelope.addSegment(0, 2000); rateEnvelope.addSegment(-0.1f, 2000); player.setRate(rateEnvelope); // a bit of noise can be nice player.getRandomnessUGen().setValue(0.01f); /* * And as before... */ Gain g = new Gain(ac, 2, 0.2f); g.addInput(player); ac.out.addInput(g); ac.start(); } }
[ "yuzhongxing88@gmail.com" ]
yuzhongxing88@gmail.com
8216bd611cc86d5f84194dd3e65eba544816dbcc
805b2a791ec842e5afdd33bb47ac677b67741f78
/Mage.Sets/src/mage/sets/returntoravnica/BloodCrypt.java
6074b5e4fee1ad9a99acf5f40c079e91b823cb99
[]
no_license
klayhamn/mage
0d2d3e33f909b4052b0dfa58ce857fbe2fad680a
5444b2a53beca160db2dfdda0fad50e03a7f5b12
refs/heads/master
2021-01-12T19:19:48.247505
2015-08-04T20:25:16
2015-08-04T20:25:16
39,703,242
2
0
null
2015-07-25T21:17:43
2015-07-25T21:17:42
null
UTF-8
Java
false
false
2,126
java
/* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ package mage.sets.returntoravnica; import java.util.UUID; /** * * @author magenoxx_at_gmail.com */ public class BloodCrypt extends mage.sets.dissension.BloodCrypt { public BloodCrypt(UUID ownerId) { super(ownerId); this.cardNumber = 238; this.expansionSetCode = "RTR"; } public BloodCrypt(final BloodCrypt card) { super(card); } @Override public BloodCrypt copy() { return new BloodCrypt(this); } }
[ "magenoxx@gmail" ]
magenoxx@gmail
d3cf069260eb4c07d7242515c852e014033ff8ea
37565116bf677f94fd7abe20584f303d46aed68e
/Topup_18-06-2015_1/src/main/java/com/masary/controlers/ChangePoints/LoyaltyPointsConfirmation.java
93d23777a8d3e3525b70ecf6daa5e4a3d332b70f
[]
no_license
Sobhy-M/test-jira
70b6390b95182b7c70fbca510b032ca853d2c508
f38554d674e4eaf6c38e4493278a63d41504f155
refs/heads/master
2022-12-20T12:22:32.110190
2019-07-07T16:39:34
2019-07-07T16:39:34
195,658,623
0
0
null
2022-12-16T08:16:01
2019-07-07T14:07:16
Java
UTF-8
Java
false
false
3,141
java
package com.masary.controlers.ChangePoints; import java.io.IOException; import java.util.List; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.masary.common.CONFIG; import com.masary.controlers.CashatMasary.CashatMasaryProperties; import com.masary.database.manager.MasaryManager; import com.masary.integration.dto.ChangePointsDTO; import com.masary.integration.dto.TedataDenominationRepresentation; /** * Servlet implementation class LoyaltyPointsConfirmation */ public class LoyaltyPointsConfirmation extends HttpServlet { private static final long serialVersionUID = 1L; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); String nextPage = ""; HttpSession session = request.getSession(); try { if (!isLogin(session)) { nextPage = CONFIG.PAGE_LOGIN; session.setAttribute(CONFIG.LOGIN_IP, request.getRemoteAddr()); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/" + nextPage); dispatcher.forward(request, response); return; } ChangePointsDTO loyaltyPointsRepresentation = (ChangePointsDTO) request.getSession() .getAttribute("loyaltyPointsRepresentation"); loyaltyPointsRepresentation.getWalletPoints(); loyaltyPointsRepresentation.getPoints(); long choosenAmount = Long.parseLong(request.getParameter("points")); if (!(checkAmountInPointsList(choosenAmount, loyaltyPointsRepresentation.getPoints()) && checkAmountValidation(choosenAmount, loyaltyPointsRepresentation))) { session.setAttribute("ErrorMessage","يرجي العلم بانه بان هذا العدد من النقاط اكبر من النقاط المتاحة"); nextPage = CONFIG.PAGE_ERRPR; } else { String selectedPoints = request.getParameter("points"); request.setAttribute("selectedPoints", Integer.valueOf(selectedPoints)); nextPage = CONFIG.LoyaltyPoints_Confirmation_Page; } } catch (Exception ex) { MasaryManager.logger.info("ErrorMessage " + ex.getMessage()); session.setAttribute("ErrorMessage", ex.getMessage()); nextPage = CONFIG.PAGE_ERRPR; } finally { RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/" + nextPage); dispatcher.forward(request, response); } } private boolean checkAmountValidation(long choosenAmount, ChangePointsDTO changePointsDTO) { if (!checkAmountInPointsList(choosenAmount, changePointsDTO.getPoints())) { return false; } if (choosenAmount > changePointsDTO.getWalletPoints()) { return false; } return true; } private boolean checkAmountInPointsList(long choosenAmount, List<Long> points) { for (Long i : points) { if (i == choosenAmount) return true; } return false; } private boolean isLogin(HttpSession session) { return session.getAttribute(CONFIG.PARAM_PIN) != null; } }
[ "Mostafa.Sobhy@MASARY.LOCAL" ]
Mostafa.Sobhy@MASARY.LOCAL
50573ea37ede93a3af65d992139b9e456a58094c
89fecd0985f8018b3568ce471968f71603d0df39
/src/main/java/com/myfinancial/model/service/impl/AuthServiceImpl.java
83bc522932597bdf5bf5674b7fe938f7c2eec5cf
[]
no_license
rafabart/myfinancialV2
540b079b66ae740c32ab07e2ffd2f418dc33e092
a480e9ca258da64755b3fb667308f586f27fae8c
refs/heads/master
2021-02-04T03:35:25.655861
2020-07-03T12:09:42
2020-07-03T12:09:42
243,611,418
0
0
null
null
null
null
UTF-8
Java
false
false
2,272
java
package com.myfinancial.model.service.impl; import com.myfinancial.model.domain.entity.Customer; import com.myfinancial.model.domain.request.NewPasswordRequest; import com.myfinancial.model.exception.EmailSenderException; import com.myfinancial.model.exception.ObjectNotFoundException; import com.myfinancial.model.exception.PasswordMatchException; import com.myfinancial.model.repository.CustomerRepository; import com.myfinancial.model.service.AuthService; import com.myfinancial.model.service.CustomerService; import com.myfinancial.model.service.EmailService; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service public class AuthServiceImpl implements AuthService { @Autowired private BCryptPasswordEncoder bCryptPasswordEncoder; @Autowired private CustomerRepository customerRepository; @Autowired private CustomerService customerService; @Autowired private EmailService emailService; @Transactional public void sendNewPassword(final String email) { Customer customer = customerRepository.findByEmail(email).orElseThrow(() -> new ObjectNotFoundException("Email")); String newPass = RandomStringUtils.randomAlphanumeric(10); customer.setPassword(bCryptPasswordEncoder.encode(newPass)); customerRepository.save(customer); try { emailService.sendNewPasswordEmail(customer, newPass); } catch (Exception e) { throw new EmailSenderException("Não foi possível enviar o email, não foi criada a nova senha!"); } } @Transactional public void changePassword(final NewPasswordRequest newPasswordRequest) { if (!newPasswordRequest.getConfirmPassword().equals(newPasswordRequest.getPassword())) { throw new PasswordMatchException(); } Customer customer = customerService.getAuthenticatedUser(); customer.setPassword(bCryptPasswordEncoder.encode(newPasswordRequest.getPassword())); customerRepository.save(customer); } }
[ "rafamola@gmail.com" ]
rafamola@gmail.com
5415abd73053bc72e9cbee23c13bcdac3590b8d8
06a029a1908698c6d4025431fe4d9e459dc9fb38
/web-application/servlet-web/src/main/java/com/example/springbootdemo/servletweb/exception/handler/RawHttpStatusExceptionHandler.java
261d3301d074b303f05228fc102465b2ee36f9cd
[ "MIT" ]
permissive
neillee95/spring-boot-demo
e60b1e2de209145d2a2ac164dc58d0fadd8b172a
7321eb9e54e44c89e9f2e32c66791d485c3686ae
refs/heads/main
2023-07-25T22:51:55.875287
2021-09-09T02:08:23
2021-09-09T02:08:23
385,786,449
1
0
null
null
null
null
UTF-8
Java
false
false
1,653
java
package com.example.springbootdemo.servletweb.exception.handler; import com.example.springbootdemo.servletweb.exception.ObjectNotFoundException; import com.example.springbootdemo.servletweb.exception.RequestParamsException; import com.example.springbootdemo.servletweb.util.BindingUtil; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestControllerAdvice; @ConditionalOnMissingBean(CustomResponseExceptionHandler.class) @ControllerAdvice @RestControllerAdvice @ResponseBody public class RawHttpStatusExceptionHandler implements GlobalExceptionHandler { @ExceptionHandler @Override public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { String errorMessage = BindingUtil.errorMessage(e.getBindingResult()); return ResponseEntity.badRequest().body(errorMessage); } @ExceptionHandler @Override public Object handleObjectNotFoundException(ObjectNotFoundException e) { return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage()); } @ExceptionHandler @Override public Object handleRequestParamsException(RequestParamsException e) { return ResponseEntity.badRequest().body(e.getMessage()); } }
[ "crossthebackstreet@gmail.com" ]
crossthebackstreet@gmail.com
fd85124ccdfb40332cbf3422c425a03324da06da
63a9c24defb4bffc7ce97f42222f5bfbb671a87a
/shop/src/net/shopxx/security/CurrentCartHandlerInterceptor.java
7cb6df17fa791e396cc25ddd7cd85ab9ac40c646
[]
no_license
zhanglize-paomo/shop
438437b26c79b8137a9b22edf242a5df49fa5c2e
d5728b263fa3cabf917e7a37bc1ca6986c68b019
refs/heads/master
2022-12-20T22:40:57.549683
2019-12-18T09:04:11
2019-12-18T09:04:11
228,772,639
0
1
null
2022-12-16T11:10:26
2019-12-18T06:24:10
FreeMarker
UTF-8
Java
false
false
1,869
java
/* * Copyright 2005-2017 shopxx.net. All rights reserved. * Support: http://www.shopxx.net * License: http://www.shopxx.net/license */ package net.shopxx.security; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import net.shopxx.service.CartService; /** * Security - 当前购物车拦截器 * * @author SHOP++ Team * @version 5.0 */ public class CurrentCartHandlerInterceptor extends HandlerInterceptorAdapter { /** * 默认"当前购物车"属性名称 */ public static final String DEFAULT_CURRENT_CART_ATTRIBUTE_NAME = "currentCart"; /** * "当前购物车"属性名称 */ private String currentCartAttributeName = DEFAULT_CURRENT_CART_ATTRIBUTE_NAME; @Inject private CartService cartService; /** * 请求后处理 * * @param request * HttpServletRequest * @param response * HttpServletResponse * @param handler * 处理器 * @param modelAndView * 数据视图 */ @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { request.setAttribute(getCurrentCartAttributeName(), cartService.getCurrent()); } /** * 获取"当前购物车"属性名称 * * @return "当前购物车"属性名称 */ public String getCurrentCartAttributeName() { return currentCartAttributeName; } /** * 设置"当前购物车"属性名称 * * @param currentCartAttributeName * "当前购物车"属性名称 */ public void setCurrentCartAttributeName(String currentCartAttributeName) { this.currentCartAttributeName = currentCartAttributeName; } }
[ "Z18434395962@163.com" ]
Z18434395962@163.com
91fc36f062120941debf63c3578c6c131806cb89
25e2d23c753811adc0a60240e0b8bad2a36cb272
/src/main/java/com/impavidly/util/backup/tasks/Mysql.java
3fe8362a3d7ee7108e2d4c3ac2bce8b10b2095d2
[]
no_license
skywebro/jbackup
828a20dc561b8cc7efd774c76cf40c7d83887412
2880afbd77a52a1fcd864fa2921da472aa0c9ac3
refs/heads/master
2020-12-04T03:23:21.530888
2015-09-09T15:12:05
2015-09-09T15:12:05
41,626,960
0
0
null
null
null
null
UTF-8
Java
false
false
248
java
package com.impavidly.util.backup.tasks; import org.apache.commons.csv.CSVRecord; public class Mysql extends Base { @Override public void run() { System.out.println(this.getClassName().toUpperCase() + (CSVRecord)context); } }
[ "andi@skyweb.ro" ]
andi@skyweb.ro
d6711f99166445593294f29d6736ed34eff584c1
524e7564b42fd1624fbbeec20b9962a8853b7f0e
/sso-security/src/main/java/com/ray/des/controller/DesController.java
12a5cc409008d899e2cad13f5139f8af481500ff
[]
no_license
Strivema/sso
0c3fc213260654d408ec40f1489cbaf5aab4598a
12bb19bea4b48062fb3f00df34894f4e20514b32
refs/heads/master
2022-12-22T01:35:37.493181
2019-07-17T06:30:22
2019-07-17T06:30:22
197,328,866
0
0
null
2022-12-16T00:39:14
2019-07-17T06:29:20
Java
UTF-8
Java
false
false
1,082
java
package com.ray.des.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.ray.des.utils.DesResponse; import com.ray.service.DesService; @Controller public class DesController { @Autowired private DesService desService; /** * 加密逻辑为: name+password 使用key作为密匙源,加密得到securityMessage * @param key 密匙源 * @param securityMessage 加密后的签名 * @param name 用户名 * @param password 密码 * @return */ @RequestMapping("/testDes") @ResponseBody public DesResponse testDes(@RequestParam("key") String key, @RequestParam("message") String securityMessage , @RequestParam("name") String name, @RequestParam("password") String password){ DesResponse resp = this.desService.testDes(key, securityMessage, name, password); return resp; } }
[ "ray.ma@chinaentropy.com" ]
ray.ma@chinaentropy.com
16e61735fa6457388b2e85be2e23e3a375772eb9
49fe4921780b44d2f2116207445b3f8e06d8f742
/server/src/main/java/cn/edu/nju/travel/config/swagger.java
a54e5ba71ab8aa78fd0eb12bd1cb78e83f871387
[]
no_license
JiayiWu/TravelWebsites
f391cd4cd30a9d54d95f33dd5b0edaf025838f95
63beb0dffa8f8d68f32ecbafdb1e40fd629b8336
refs/heads/master
2020-04-16T09:36:17.727485
2019-04-14T03:03:40
2019-04-14T03:03:40
165,470,128
4
0
null
2019-02-02T03:56:10
2019-01-13T05:39:44
Java
UTF-8
Java
false
false
1,644
java
package cn.edu.nju.travel.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; import springfox.documentation.service.Contact; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; /** * Created by Jiayiwu on 19/1/13. * Mail:wujiayi@lgdreamer.com * Change everywhere */ @Configuration @EnableSwagger2 public class swagger { //swagger2的配置文件,这里可以配置swagger2的一些基本的内容,比如扫描的包等等 @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() //为当前包路径 .apis(RequestHandlerSelectors.basePackage("cn.edu.nju.travel")) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() //页面标题 .title("大学生协同出游项目API") //创建人 .contact(new Contact("StevenWu", "http://www.fivedreamer.com", "")) //版本号 .version("1.0") //描述 .description("API 描述") .build(); } }
[ "wjy@superid.cn" ]
wjy@superid.cn
5c79dd354e74e785bcb92ad8c8ec48399586b2fe
d304af62b37177d706599ba5f19dcc7c7acfa7f9
/app/src/main/java/ip/signature/com/signatureapps/global/GlobalMaps.java
91e97dbf200ddd47cace3a7f2c0f52267c0066c6
[]
no_license
akbarattijani/android_monitoring
f6b665dfcabe9db05ddfad7e97fd8b6b779cba74
7f5cc0d7168b889b0b1825e0e46137bd4c18a4ea
refs/heads/master
2020-05-18T16:22:30.278325
2020-01-21T03:45:16
2020-01-21T03:45:16
184,523,821
0
0
null
null
null
null
UTF-8
Java
false
false
394
java
package ip.signature.com.signatureapps.global; import ip.signature.com.signatureapps.fragment.MenuFragment; public class GlobalMaps { private static MenuFragment menuFragment; public static MenuFragment getMenuFragment() { return menuFragment; } public static void setMenuFragment(MenuFragment menuFragment) { GlobalMaps.menuFragment = menuFragment; } }
[ "e.printing9090@gmail.com" ]
e.printing9090@gmail.com
dbd0bbeaa0d02c72cbb97adbfb69f9d8d7fe9d79
53f5a941261609775dc3eedf0cb487956b734ab0
/com.samsung.app.watchmanager/sources/androidx/core/widget/n.java
e89147deb54243fec2763322e0c10dbf4bb1fdf2
[]
no_license
ThePBone/BudsProAnalysis
4a3ede6ba6611cc65598d346b5a81ea9c33265c0
5b04abcae98d1ec8d35335d587b628890383bb44
refs/heads/master
2023-02-18T14:24:57.731752
2021-01-17T12:44:58
2021-01-17T12:44:58
322,783,234
16
1
null
null
null
null
UTF-8
Java
false
false
268
java
package androidx.core.widget; import android.content.res.ColorStateList; import android.graphics.PorterDuff; public interface n { void setSupportButtonTintList(ColorStateList colorStateList); void setSupportButtonTintMode(PorterDuff.Mode mode); }
[ "thebone.main@gmail.com" ]
thebone.main@gmail.com